From d822430d6a8c08169b2c654a754a5c88e1790c26 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Thu, 8 Jun 2023 17:20:34 +0800 Subject: [PATCH] feat: toggle chain set theme-color --- chains/mainnet/evmos.json | 1 + chains/mainnet/osmosis.json | 1 + src/stores/useBlockchain.ts | 8 ++++++-- src/stores/useDashboard.ts | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/chains/mainnet/evmos.json b/chains/mainnet/evmos.json index 737ecf52..40c814ba 100644 --- a/chains/mainnet/evmos.json +++ b/chains/mainnet/evmos.json @@ -8,6 +8,7 @@ "min_tx_fee": "5000000000000000", "addr_prefix": "evmos", "logo": "/logos/evmos.png", + // "theme_color": "159 94% 51%", "keplr_features": ["ibc-transfer", "ibc-go", "eth-address-gen", "eth-key-sign"], "assets": [{ "base": "aevmos", diff --git a/chains/mainnet/osmosis.json b/chains/mainnet/osmosis.json index 7a86bf52..9adc8c60 100644 --- a/chains/mainnet/osmosis.json +++ b/chains/mainnet/osmosis.json @@ -9,6 +9,7 @@ "min_tx_fee": "800", "addr_prefix": "osmo", "logo": "/logos/osmosis.jpg", + // "theme_color": "99 40% 21%", "assets": [{ "base": "uosmo", "symbol": "OSMO", diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 9841a9ba..c3fa1534 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -35,7 +35,6 @@ export const useBlockchain = defineStore('blockchain', { }, getters: { current(): ChainConfig | undefined { - console.log(this.dashboard.chains[this.chainName], 'jljfkj') return this.dashboard.chains[this.chainName]; }, logo(): string { @@ -58,16 +57,21 @@ export const useBlockchain = defineStore('blockchain', { }, computedChainMenu() { let currNavItem: VerticalNavItems = []; - const router = useRouter(); const routes = router?.getRoutes() || []; if (this.current && routes) { + if (this.current?.themeColor) { + document.body.style.setProperty('--p', `${this.current?.themeColor}`); + }else { + document.body.style.setProperty('--p', '237.65 100% 70%'); + } currNavItem = [ { title: this.current?.prettyName || this.chainName || '', icon: { image: this.current.logo, size: '22' }, i18n: false, badgeContent: this.isConsumerChain ? 'Consumer' : undefined, + themeColor: this.current?.themeColor, badgeClass: 'bg-error', children: routes .filter((x) => x.meta.i18n) // defined menu name diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index 269acc5e..c9246c44 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -166,6 +166,7 @@ export function fromLocal(lc: LocalConfig): ChainConfig { conf.logo = lc.logo; conf.keplrFeatures = lc.keplr_features; conf.keplrPriceStep = lc.keplr_price_step; + conf.themeColor = lc.theme_color; return conf; }