Skip to content

Commit

Permalink
fix: Fix colorMode does not follow the parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Nov 28, 2024
1 parent dc0fcac commit bcf65ef
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .release/.changeset/itchy-flies-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bnb-chain/canonical-bridge-widget": patch
---

Fix colorMode does not follow the parameter
1 change: 1 addition & 0 deletions .release/.changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"gorgeous-maps-fly",
"grumpy-squids-collect",
"honest-lies-cheer",
"itchy-flies-fail",
"late-swans-sparkle",
"lovely-maps-study",
"quick-pots-tease",
Expand Down
6 changes: 6 additions & 0 deletions packages/canonical-bridge-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @bnb-chain/canonical-bridge-widget

## 0.5.4-alpha.4

### Patch Changes

- Fix colorMode does not follow the parameter

## 0.5.4-alpha.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/canonical-bridge-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bnb-chain/canonical-bridge-widget",
"version": "0.5.4-alpha.3",
"version": "0.5.4-alpha.4",
"description": "canonical bridge widget",
"author": "bnb-chain",
"private": false,
Expand Down
18 changes: 10 additions & 8 deletions packages/canonical-bridge-widget/src/CanonicalBridgeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext, useMemo } from 'react';
import { ColorMode, IntlProvider } from '@bnb-chain/space';
import { ColorMode, IntlProvider, theme } from '@bnb-chain/space';

import { ChainType, IChainConfig, ITransferConfig } from '@/modules/aggregator/types';
import { StoreProvider } from '@/modules/store/StoreProvider';
import { ThemeProvider, ThemeProviderProps } from '@/core/theme/ThemeProvider';
import { ThemeProvider } from '@/core/theme/ThemeProvider';
import { AggregatorProvider } from '@/modules/aggregator/components/AggregatorProvider';
import { TokenBalancesProvider } from '@/modules/aggregator/components/TokenBalancesProvider';
import { TokenPricesProvider } from '@/modules/aggregator/components/TokenPricesProvider';
Expand All @@ -17,7 +17,12 @@ export interface ICanonicalBridgeConfig {

appearance: {
colorMode?: ColorMode;
theme?: ThemeProviderProps['themeConfig'];
theme?: {
dark?: any;
light?: any;
fontFamily?: string;
breakpoints?: Partial<typeof theme.breakpoints>;
};
locale?: string;
messages?: Record<string, string>;
bridgeTitle?: string;
Expand Down Expand Up @@ -75,7 +80,7 @@ export function CanonicalBridgeProvider(props: CanonicalBridgeProviderProps) {

appearance: {
bridgeTitle: 'BNB Chain Cross-Chain Bridge',
mode: 'dark',
colorMode: 'dark',
locale: 'en',
messages: locales.en,
...config.appearance,
Expand All @@ -100,10 +105,7 @@ export function CanonicalBridgeProvider(props: CanonicalBridgeProviderProps) {
<StoreProvider>
<IntlProvider locale={value.appearance.locale!} messages={value.appearance.messages}>
<AggregatorProvider transferConfig={transferConfig} chains={chains}>
<ThemeProvider
themeConfig={value.appearance.theme}
colorMode={value.appearance.colorMode}
>
<ThemeProvider>
<TronAccountProvider>
<TokenBalancesProvider />
<TokenPricesProvider />
Expand Down
29 changes: 12 additions & 17 deletions packages/canonical-bridge-widget/src/core/theme/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChakraProvider, theme, createLocalStorageManager, ColorMode } from '@bnb-chain/space';
import { ChakraProvider, ColorMode, theme } from '@bnb-chain/space';
import { useMemo } from 'react';
import { merge } from 'lodash';

Expand All @@ -8,24 +8,13 @@ import { walletStyles } from '@/core/theme/walletStyles';
import { useBridgeConfig } from '@/CanonicalBridgeProvider';

export interface ThemeProviderProps {
colorMode?: ColorMode;
children: React.ReactNode;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
themeConfig?: {
dark?: any;
light?: any;
fontFamily?: string;
breakpoints?: Partial<typeof theme.breakpoints>;
};
}

export const ThemeProvider = ({
children,
colorMode = 'dark',
themeConfig,
}: ThemeProviderProps) => {
const { appName: APP_NAME } = useBridgeConfig();
const colorModeManager = createLocalStorageManager(`${APP_NAME}-color-mode`);
export const ThemeProvider = ({ children }: ThemeProviderProps) => {
const { appearance } = useBridgeConfig();
const { theme: themeConfig, colorMode } = appearance;

const customTheme = useMemo(() => {
return {
...theme,
Expand Down Expand Up @@ -57,7 +46,13 @@ export const ThemeProvider = ({

return (
<ChakraProvider
colorModeManager={colorModeManager}
colorModeManager={{
type: 'localStorage',
get() {
return colorMode;
},
set() {},
}}
theme={customTheme}
toastOptions={{
defaultOptions: {
Expand Down

0 comments on commit bcf65ef

Please sign in to comment.