The Cosmos Components can be used in vanilla HTML.
I particularly wanted these Cosmos Components to be usable in vanilla HTML, without any bundler
or frontend framework whatsoever. I find this is great for prototyping and simple projects.
Note that not all browsers support separate import maps, so for the time being you will need to
always inline it in your HTML.
setup.js
Copy
import { CosmosElements } from '@kiruse/cosmos-components';import { reconnectSigners } from '@kiruse/cosmos-components/utils.js';import { Apophis, Cosmos } from '@apophis-sdk/cosmos';import { CosmWasm, DefaultCosmWasmMiddlewares } from '@apophis-sdk/cosmwasm';Apophis.use(...DefaultCosmWasmMiddlewares);CosmosElements.register();// in a `type="module"` script you can `await` on top level scopeexport const networks = Promise.all([ Cosmos.getNetworkFromRegistry('neutron'), Cosmos.getNetworkFromRegistry('neutrontestnet'),]);networks.then(networks => reconnectSigners(networks));
index.js
Copy
import { modals } from '@kiruse/cosmos-components';import { networks } from './setup.js';document.getElementById('connect-wallet').addEventListener('click', async () => { modals.showWalletModal(await networks);});
My personal favorite for writing HTML is Pug, although it requires some
additional build steps to get the final HTML. The above snippet can be written in Pug as: