|
1 | 1 | import { CAPTokens } from './types'; |
2 | 2 |
|
3 | | -export const capTokens: Record<keyof CAPTokens, string> = { |
4 | | - borderRadius2XLarge: 'var(--borderRadius2XLarge)', |
5 | | - borderRadius3XLarge: 'var(--borderRadius3XLarge)', |
6 | | - borderRadius4XLarge: 'var(--borderRadius4XLarge)', |
7 | | - colorNeutralStroke4: 'var(--colorNeutralStroke4)', |
8 | | - colorNeutralStroke4Hover: 'var(--colorNeutralStroke4Hover)', |
9 | | - colorNeutralStroke4Pressed: 'var(--colorNeutralStroke4Pressed)', |
10 | | - colorNeutralStroke4Selected: 'var(--colorNeutralStroke4Selected)', |
11 | | - colorNeutralForeground5: 'var(--colorNeutralForeground5)', |
12 | | - colorNeutralForeground5Hover: 'var(--colorNeutralForeground5Hover)', |
13 | | - colorNeutralForeground5Pressed: 'var(--colorNeutralForeground5Pressed)', |
| 3 | +/** |
| 4 | + * Default values for the CAP-specific design tokens (the ones Fluent v9 doesn't |
| 5 | + * ship yet). These defaults are baked into the CAP style hooks (see `capTokens`) |
| 6 | + * as CSS-variable fallbacks, so consumers don't have to set them by default. |
| 7 | + * |
| 8 | + * Override a value by defining the matching theme token on your `FluentProvider` |
| 9 | + * theme — that emits the CSS variable, which takes precedence over the fallback. |
| 10 | + * To override several at once, spread these onto your base theme: |
| 11 | + * |
| 12 | + * ```tsx |
| 13 | + * const capTheme = { ...webLightTheme, ...CAP_THEME_TOKENS }; |
| 14 | + * ``` |
| 15 | + */ |
| 16 | +export const CAP_THEME_TOKENS: Record<keyof CAPTokens, string> = { |
| 17 | + borderRadius2XLarge: '12px', |
| 18 | + borderRadius3XLarge: '16px', |
| 19 | + borderRadius4XLarge: '24px', |
| 20 | + colorNeutralStroke4: '#ebebeb', |
| 21 | + colorNeutralStroke4Hover: '#e0e0e0', |
| 22 | + colorNeutralStroke4Pressed: '#d6d6d6', |
| 23 | + colorNeutralStroke4Selected: '#ebebeb', |
| 24 | + colorNeutralForeground5: '#616161', |
| 25 | + colorNeutralForeground5Hover: '#242424', |
| 26 | + colorNeutralForeground5Pressed: '#242424', |
14 | 27 | }; |
| 28 | + |
| 29 | +/** |
| 30 | + * The CAP tokens as CSS-variable references for use inside style hooks. Each one |
| 31 | + * carries its {@link CAP_THEME_TOKENS} default as a fallback, so the hooks work |
| 32 | + * even when the consumer hasn't defined the token on their theme; defining it |
| 33 | + * (e.g. via `CAP_THEME_TOKENS`) overrides the fallback. |
| 34 | + */ |
| 35 | +export const capTokens: Record<keyof CAPTokens, string> = Object.fromEntries( |
| 36 | + (Object.keys(CAP_THEME_TOKENS) as (keyof CAPTokens)[]).map((key) => [ |
| 37 | + key, |
| 38 | + `var(--${key}, ${CAP_THEME_TOKENS[key]})`, |
| 39 | + ]) |
| 40 | +) as Record<keyof CAPTokens, string>; |
0 commit comments