Skip to content

Commit

Permalink
feat(theme-provider): apply the changed design token structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sungik-choi committed Nov 30, 2023
1 parent f2faf6b commit fca0204
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/bezier-react/src/providers/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,30 @@ import { createContext } from '~/src/utils/react'
type Tokens = typeof tokens
type GlobalTokens = Tokens['global']
type SemanticTokens = Omit<Tokens, 'global'>
type FlattedTokens = GlobalTokens & SemanticTokens[keyof SemanticTokens]

type ThemedTokenSet = {
global: GlobalTokens
semantic: SemanticTokens[keyof SemanticTokens]
}

// TODO: Change theme name constant to import from bezier-tokens
export type ThemeName = 'light' | 'dark'

interface TokenContextValue {
themeName: ThemeName
tokens: FlattedTokens
tokens: ThemedTokenSet
}

const [TokenContextProvider, useTokenContext] = createContext<TokenContextValue | null>(null, 'TokenProvider')

Check warning on line 28 in packages/bezier-react/src/providers/ThemeProvider.tsx

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/providers/ThemeProvider.tsx#L28

Added line #L28 was not covered by tests

const tokenSet: Record<ThemeName, FlattedTokens> = Object.freeze({
const tokenSet: Record<ThemeName, ThemedTokenSet> = Object.freeze({

Check warning on line 30 in packages/bezier-react/src/providers/ThemeProvider.tsx

View check run for this annotation

Codecov / codecov/patch

packages/bezier-react/src/providers/ThemeProvider.tsx#L30

Added line #L30 was not covered by tests
light: {
...tokens.global,
...tokens.lightTheme,
global: tokens.global,
semantic: tokens.lightTheme,
},
dark: {
...tokens.global,
...tokens.darkTheme,
global: tokens.global,
semantic: tokens.darkTheme,
},
})

Expand Down

0 comments on commit fca0204

Please sign in to comment.