|
| 1 | +import { type tokens } from '@channel.io/bezier-tokens/alpha' |
| 2 | + |
| 3 | +import { |
| 4 | + type ExtractKeys, |
| 5 | + type RemovePrefix, |
| 6 | + type StartsWithPrefix, |
| 7 | +} from './utils' |
| 8 | + |
| 9 | +// TODO: Change theme name constant to import from bezier-tokens |
| 10 | +export type ThemeName = 'light' | 'dark' |
| 11 | + |
| 12 | +export type GlobalToken = typeof tokens.global |
| 13 | +export type ThemeToken = typeof tokens.lightTheme | typeof tokens.darkTheme |
| 14 | + |
| 15 | +// NOTE: (@ed) Do not remove alpha- prefix to match CSS variable names |
| 16 | +export type FlattenGlobalToken = ExtractKeys<GlobalToken[keyof GlobalToken]> |
| 17 | +export type FlattenThemeToken = ExtractKeys<ThemeToken[keyof ThemeToken]> |
| 18 | +export type FlattenAllToken = FlattenGlobalToken | FlattenThemeToken |
| 19 | + |
| 20 | +export type GlobalColor = RemovePrefix< |
| 21 | + 'alpha-color', |
| 22 | + keyof GlobalToken['color'] |
| 23 | +> |
| 24 | + |
| 25 | +/** |
| 26 | + * Functional & Semantic color tokens |
| 27 | + */ |
| 28 | +export type ThemeColor = RemovePrefix<'alpha-color', keyof ThemeToken['color']> |
| 29 | + |
| 30 | +export type BackgroundFunctionalColor = StartsWithPrefix<'bg', ThemeColor> |
| 31 | +export type ForegroundFunctionalColor = StartsWithPrefix<'fg', ThemeColor> |
| 32 | +export type SurfaceFunctionalColor = StartsWithPrefix<'surface', ThemeColor> |
| 33 | +export type ShadowFunctionalColor = StartsWithPrefix<'shadow', ThemeColor> |
| 34 | +export type DimFunctionalColor = StartsWithPrefix<'dim', ThemeColor> |
| 35 | + |
| 36 | +export type FunctionalColor = |
| 37 | + | BackgroundFunctionalColor |
| 38 | + | ForegroundFunctionalColor |
| 39 | + | SurfaceFunctionalColor |
| 40 | + | ShadowFunctionalColor |
| 41 | + | DimFunctionalColor |
| 42 | + |
| 43 | +export type SemanticColor = StartsWithPrefix< |
| 44 | + 'primary' | 'critical' | 'warning' | 'accent' | 'success', |
| 45 | + ThemeColor |
| 46 | +> |
| 47 | + |
| 48 | +export type Color = GlobalColor | FunctionalColor | SemanticColor |
| 49 | + |
| 50 | +export type Radius = RemovePrefix<'alpha-radius', keyof GlobalToken['radius']> |
| 51 | +export type Opacity = RemovePrefix< |
| 52 | + 'alpha-opacity', |
| 53 | + keyof GlobalToken['opacity'] |
| 54 | +> |
| 55 | +export type Font = RemovePrefix<'alpha-font', keyof GlobalToken['font']> |
| 56 | +export type Typography = RemovePrefix< |
| 57 | + 'alpha-typography', |
| 58 | + keyof GlobalToken['typography'] |
| 59 | +> |
| 60 | +export type GlobalGradient = RemovePrefix< |
| 61 | + 'alpha-gradient', |
| 62 | + keyof GlobalToken['gradient'] |
| 63 | +> |
| 64 | + |
| 65 | +export type Shadow = RemovePrefix<'alpha-shadow', keyof ThemeToken['shadow']> |
| 66 | +export type FunctionalGradient = RemovePrefix< |
| 67 | + 'alpha-gradient', |
| 68 | + keyof ThemeToken['gradient'] |
| 69 | +> |
0 commit comments