react-native-terra-ui 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +1 -1
- package/lib/module/components/avatar/Avatar.js +20 -20
- package/lib/module/components/avatar/Avatar.js.map +1 -1
- package/lib/module/components/button/Button.js +11 -11
- package/lib/module/components/button/Button.js.map +1 -1
- package/lib/module/components/chip/Chip.js +32 -32
- package/lib/module/components/chip/Chip.js.map +1 -1
- package/lib/module/components/empty-state/EmptyState.js +3 -3
- package/lib/module/components/empty-state/EmptyState.js.map +1 -1
- package/lib/module/components/header/variants/LargeTitleHeader/index.js +30 -32
- package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -1
- package/lib/module/components/header/variants/TitleHeader/index.js +26 -18
- package/lib/module/components/header/variants/TitleHeader/index.js.map +1 -1
- package/lib/module/components/icon/Icon.js +3 -3
- package/lib/module/components/page-indicator/hooks/use-page-indicator-colors.js +2 -2
- package/lib/module/components/screen/Screen.js +63 -34
- package/lib/module/components/screen/Screen.js.map +1 -1
- package/lib/module/components/screen/ScreenContext.js +28 -9
- package/lib/module/components/screen/ScreenContext.js.map +1 -1
- package/lib/module/components/screen/ScreenFlatList.js +4 -162
- package/lib/module/components/screen/ScreenFlatList.js.map +1 -1
- package/lib/module/components/screen/ScreenList.js +81 -97
- package/lib/module/components/screen/ScreenList.js.map +1 -1
- package/lib/module/components/screen/ScreenScrollView.js +64 -115
- package/lib/module/components/screen/ScreenScrollView.js.map +1 -1
- package/lib/module/components/screen/hooks/use-screen-ref.js +18 -0
- package/lib/module/components/screen/hooks/use-screen-ref.js.map +1 -0
- package/lib/module/components/screen/hooks/use-screen-scroll-handler.js +19 -0
- package/lib/module/components/screen/hooks/use-screen-scroll-handler.js.map +1 -0
- package/lib/module/components/screen/index.js.map +1 -1
- package/lib/module/components/screen/parts/ScreenFrame.js +47 -0
- package/lib/module/components/screen/parts/ScreenFrame.js.map +1 -0
- package/lib/module/components/screen/parts/ScreenHeaderAppearance.js +43 -0
- package/lib/module/components/screen/parts/ScreenHeaderAppearance.js.map +1 -0
- package/lib/module/components/screen/parts/ScreenPlaceholder.js +11 -13
- package/lib/module/components/screen/parts/ScreenPlaceholder.js.map +1 -1
- package/lib/module/components/screen/parts/ScreenSafeArea.android.js +27 -0
- package/lib/module/components/screen/parts/ScreenSafeArea.android.js.map +1 -0
- package/lib/module/components/screen/parts/ScreenSafeArea.js +26 -0
- package/lib/module/components/screen/parts/ScreenSafeArea.js.map +1 -0
- package/lib/module/components/screen/utils.js +18 -9
- package/lib/module/components/screen/utils.js.map +1 -1
- package/lib/module/components/spinner/Spinner.js +2 -2
- package/lib/module/components/text/Text.js +1 -1
- package/lib/module/components/toast/Toast.js +13 -13
- package/lib/module/components/toast/Toast.js.map +1 -1
- package/lib/module/components/toolbar/Toolbar.js +2 -2
- package/lib/module/context/ThemeProvider.js +22 -39
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/context/index.js +1 -1
- package/lib/module/context/index.js.map +1 -1
- package/lib/module/theme/breakpoints.js +1 -1
- package/lib/module/theme/define-config.js +21 -0
- package/lib/module/theme/define-config.js.map +1 -0
- package/lib/module/theme/diagnostics.js +13 -0
- package/lib/module/theme/diagnostics.js.map +1 -0
- package/lib/module/theme/errors.js +15 -0
- package/lib/module/theme/errors.js.map +1 -0
- package/lib/module/theme/index.js +7 -1
- package/lib/module/theme/index.js.map +1 -1
- package/lib/module/theme/legacy-tokens.js +119 -0
- package/lib/module/theme/legacy-tokens.js.map +1 -0
- package/lib/module/theme/registry.js +122 -130
- package/lib/module/theme/registry.js.map +1 -1
- package/lib/module/theme/resolve-config.js +346 -0
- package/lib/module/theme/resolve-config.js.map +1 -0
- package/lib/module/theme/runtime.js +57 -12
- package/lib/module/theme/runtime.js.map +1 -1
- package/lib/module/theme/screen-margin.js +6 -14
- package/lib/module/theme/screen-margin.js.map +1 -1
- package/lib/module/theme/screen-padding.js +17 -0
- package/lib/module/theme/screen-padding.js.map +1 -0
- package/lib/module/theme/selection-store.js +75 -0
- package/lib/module/theme/selection-store.js.map +1 -0
- package/lib/module/theme/theme.js +81 -36
- package/lib/module/theme/theme.js.map +1 -1
- package/lib/module/theme/tokens/canonical-color-keys.js +102 -0
- package/lib/module/theme/tokens/canonical-color-keys.js.map +1 -0
- package/lib/module/theme/tokens/dark.js +72 -88
- package/lib/module/theme/tokens/dark.js.map +1 -1
- package/lib/module/theme/tokens/light.js +69 -83
- package/lib/module/theme/tokens/light.js.map +1 -1
- package/lib/module/theme/tokens/primitives.js +14 -14
- package/lib/module/theme/tokens/primitives.js.map +1 -1
- package/lib/module/theme/tokens/validate.js +238 -0
- package/lib/module/theme/tokens/validate.js.map +1 -0
- package/lib/module/theme/unistyles-adapter.js +77 -0
- package/lib/module/theme/unistyles-adapter.js.map +1 -0
- package/lib/module/utils/accent-generator.js +476 -0
- package/lib/module/utils/accent-generator.js.map +1 -0
- package/lib/module/utils/accent-utils.js +52 -35
- package/lib/module/utils/accent-utils.js.map +1 -1
- package/lib/module/utils/color-utils.js +224 -7
- package/lib/module/utils/color-utils.js.map +1 -1
- package/lib/module/utils/deep-merge.js +1 -1
- package/lib/module/utils/deep-merge.js.map +1 -1
- package/lib/module/utils/resolve-theme-color.js +2 -2
- package/lib/typescript/src/components/chip/types.d.ts +1 -1
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts +1 -1
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts.map +1 -1
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts +6 -5
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts +11 -5
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/icon/Icon.d.ts +2 -2
- package/lib/typescript/src/components/screen/Screen.d.ts +45 -16
- package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenContext.d.ts +42 -26
- package/lib/typescript/src/components/screen/ScreenContext.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +5 -46
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenList.d.ts +62 -50
- package/lib/typescript/src/components/screen/ScreenList.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts +18 -58
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/hooks/use-screen-ref.d.ts +5 -0
- package/lib/typescript/src/components/screen/hooks/use-screen-ref.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/hooks/use-screen-scroll-handler.d.ts +53 -0
- package/lib/typescript/src/components/screen/hooks/use-screen-scroll-handler.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/index.d.ts +2 -2
- package/lib/typescript/src/components/screen/index.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/parts/ScreenFrame.d.ts +6 -0
- package/lib/typescript/src/components/screen/parts/ScreenFrame.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/parts/ScreenHeaderAppearance.d.ts +21 -0
- package/lib/typescript/src/components/screen/parts/ScreenHeaderAppearance.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts +6 -8
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/parts/ScreenSafeArea.android.d.ts +7 -0
- package/lib/typescript/src/components/screen/parts/ScreenSafeArea.android.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/parts/ScreenSafeArea.d.ts +6 -0
- package/lib/typescript/src/components/screen/parts/ScreenSafeArea.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/types.d.ts +27 -32
- package/lib/typescript/src/components/screen/types.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/utils.d.ts +9 -8
- package/lib/typescript/src/components/screen/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/text/Text.d.ts +1 -1
- package/lib/typescript/src/components/text/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/toolbar/Toolbar.d.ts +2 -2
- package/lib/typescript/src/context/ThemeProvider.d.ts +29 -12
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/context/index.d.ts +1 -1
- package/lib/typescript/src/context/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/breakpoints.d.ts +1 -1
- package/lib/typescript/src/theme/define-config.d.ts +23 -0
- package/lib/typescript/src/theme/define-config.d.ts.map +1 -0
- package/lib/typescript/src/theme/diagnostics.d.ts +4 -0
- package/lib/typescript/src/theme/diagnostics.d.ts.map +1 -0
- package/lib/typescript/src/theme/errors.d.ts +10 -0
- package/lib/typescript/src/theme/errors.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +10 -2
- package/lib/typescript/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/legacy-tokens.d.ts +187 -0
- package/lib/typescript/src/theme/legacy-tokens.d.ts.map +1 -0
- package/lib/typescript/src/theme/registry.d.ts +12 -17
- package/lib/typescript/src/theme/registry.d.ts.map +1 -1
- package/lib/typescript/src/theme/resolve-config.d.ts +99 -0
- package/lib/typescript/src/theme/resolve-config.d.ts.map +1 -0
- package/lib/typescript/src/theme/runtime.d.ts +25 -4
- package/lib/typescript/src/theme/runtime.d.ts.map +1 -1
- package/lib/typescript/src/theme/screen-margin.d.ts +6 -14
- package/lib/typescript/src/theme/screen-margin.d.ts.map +1 -1
- package/lib/typescript/src/theme/screen-padding.d.ts +15 -0
- package/lib/typescript/src/theme/screen-padding.d.ts.map +1 -0
- package/lib/typescript/src/theme/selection-store.d.ts +41 -0
- package/lib/typescript/src/theme/selection-store.d.ts.map +1 -0
- package/lib/typescript/src/theme/theme.d.ts +54 -1
- package/lib/typescript/src/theme/theme.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/canonical-color-keys.d.ts +95 -0
- package/lib/typescript/src/theme/tokens/canonical-color-keys.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens/dark.d.ts +56 -63
- package/lib/typescript/src/theme/tokens/dark.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/light.d.ts +56 -71
- package/lib/typescript/src/theme/tokens/light.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/primitives.d.ts +11 -10
- package/lib/typescript/src/theme/tokens/primitives.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/validate.d.ts +34 -0
- package/lib/typescript/src/theme/tokens/validate.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +166 -86
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/lib/typescript/src/theme/unistyles-adapter.d.ts +33 -0
- package/lib/typescript/src/theme/unistyles-adapter.d.ts.map +1 -0
- package/lib/typescript/src/utils/accent-generator.d.ts +103 -0
- package/lib/typescript/src/utils/accent-generator.d.ts.map +1 -0
- package/lib/typescript/src/utils/accent-utils.d.ts +15 -2
- package/lib/typescript/src/utils/accent-utils.d.ts.map +1 -1
- package/lib/typescript/src/utils/color-utils.d.ts +59 -2
- package/lib/typescript/src/utils/color-utils.d.ts.map +1 -1
- package/lib/typescript/src/utils/deep-merge.d.ts +1 -0
- package/lib/typescript/src/utils/deep-merge.d.ts.map +1 -1
- package/lib/typescript/src/utils/resolve-theme-color.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/avatar/Avatar.tsx +20 -20
- package/src/components/button/Button.tsx +11 -11
- package/src/components/chip/Chip.tsx +32 -32
- package/src/components/chip/types.ts +1 -1
- package/src/components/empty-state/EmptyState.tsx +4 -4
- package/src/components/header/variants/LargeTitleHeader/index.tsx +31 -30
- package/src/components/header/variants/TitleHeader/index.tsx +33 -22
- package/src/components/icon/Icon.tsx +4 -4
- package/src/components/page-indicator/hooks/use-page-indicator-colors.ts +2 -2
- package/src/components/screen/Screen.tsx +89 -43
- package/src/components/screen/ScreenContext.tsx +48 -28
- package/src/components/screen/ScreenFlatList.tsx +5 -191
- package/src/components/screen/ScreenList.tsx +197 -175
- package/src/components/screen/ScreenScrollView.tsx +92 -167
- package/src/components/screen/hooks/use-screen-ref.ts +24 -0
- package/src/components/screen/hooks/use-screen-scroll-handler.ts +31 -0
- package/src/components/screen/index.ts +8 -2
- package/src/components/screen/parts/ScreenFrame.tsx +49 -0
- package/src/components/screen/parts/ScreenHeaderAppearance.tsx +52 -0
- package/src/components/screen/parts/ScreenPlaceholder.tsx +16 -16
- package/src/components/screen/parts/ScreenSafeArea.android.tsx +22 -0
- package/src/components/screen/parts/ScreenSafeArea.tsx +20 -0
- package/src/components/screen/types.ts +29 -32
- package/src/components/screen/utils.ts +24 -11
- package/src/components/spinner/Spinner.tsx +2 -2
- package/src/components/text/Text.tsx +2 -2
- package/src/components/toast/Toast.tsx +13 -13
- package/src/components/toolbar/Toolbar.tsx +4 -4
- package/src/context/ThemeProvider.tsx +47 -51
- package/src/context/index.ts +1 -1
- package/src/theme/breakpoints.ts +1 -1
- package/src/theme/define-config.ts +27 -0
- package/src/theme/diagnostics.ts +11 -0
- package/src/theme/errors.ts +14 -0
- package/src/theme/index.ts +40 -1
- package/src/theme/legacy-tokens.ts +227 -0
- package/src/theme/registry.ts +119 -137
- package/src/theme/resolve-config.ts +406 -0
- package/src/theme/runtime.ts +52 -14
- package/src/theme/screen-margin.ts +6 -25
- package/src/theme/screen-padding.ts +26 -0
- package/src/theme/selection-store.ts +76 -0
- package/src/theme/theme.ts +104 -39
- package/src/theme/tokens/canonical-color-keys.ts +107 -0
- package/src/theme/tokens/dark.ts +91 -98
- package/src/theme/tokens/light.ts +88 -93
- package/src/theme/tokens/primitives.ts +14 -14
- package/src/theme/tokens/validate.ts +271 -0
- package/src/theme/types.ts +184 -95
- package/src/theme/unistyles-adapter.ts +75 -0
- package/src/utils/accent-generator.ts +530 -0
- package/src/utils/accent-utils.ts +66 -39
- package/src/utils/color-utils.ts +225 -8
- package/src/utils/deep-merge.ts +1 -1
- package/src/utils/resolve-theme-color.ts +2 -2
- package/lib/module/components/screen/parts/BottomSafeArea.js +0 -62
- package/lib/module/components/screen/parts/BottomSafeArea.js.map +0 -1
- package/lib/typescript/src/components/screen/parts/BottomSafeArea.d.ts +0 -30
- package/lib/typescript/src/components/screen/parts/BottomSafeArea.d.ts.map +0 -1
- package/src/components/screen/parts/BottomSafeArea.tsx +0 -59
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, deterministic accent generation from a single seed color.
|
|
3
|
+
*
|
|
4
|
+
* Consumed by the resolver (`theme/resolve-config.ts`) for startup, runtime
|
|
5
|
+
* accent changes and `createTerraThemes`, and by the `normalizeAccent`
|
|
6
|
+
* compatibility wrapper. Must not import the registry, provider, Unistyles,
|
|
7
|
+
* or renderers — only `#theme/types` and the colour maths in `./color-utils`.
|
|
8
|
+
*
|
|
9
|
+
* ## Algorithm
|
|
10
|
+
*
|
|
11
|
+
* Every role is derived in OKLCH (Björn Ottosson's OKLab, in-house
|
|
12
|
+
* implementation in `./color-utils`): the seed's hue is kept for every role,
|
|
13
|
+
* chroma is capped per role and reduced further by sRGB gamut mapping, and
|
|
14
|
+
* perceptual lightness is *solved* per role against the scheme's actual
|
|
15
|
+
* ordinary surfaces so that WCAG 2.x targets are met (4.5:1 for text and
|
|
16
|
+
* solid/soft labels, 3:1 for the accent border). Contrast is evaluated with
|
|
17
|
+
* sRGB alpha compositing over each of the four surfaces and, for solid
|
|
18
|
+
* controls, additionally with the pressed opacity applied to the whole control.
|
|
19
|
+
*
|
|
20
|
+
* - `accent.solid.bg` keeps the seed exactly when black or white text reads on
|
|
21
|
+
* it at both opacities; otherwise the fill is moved the smallest lightness
|
|
22
|
+
* distance (ties prefer darker in light, lighter in dark) until a readable
|
|
23
|
+
* label exists — so the fill MAY differ from the seed. Pin `accent.solid.bg`
|
|
24
|
+
* through overrides for an exact fill.
|
|
25
|
+
* - `accent.solid.fg` is a tinted near-black or near-white (pure black/white
|
|
26
|
+
* when the tint would not reach 4.5:1) picked by contrast, not brightness.
|
|
27
|
+
* - Hover/pressed fills darken in light and lighten in dark (mirroring the
|
|
28
|
+
* built-in tokens); the direction flips only where following the scheme
|
|
29
|
+
* would break the label contrast or leave the lightness range.
|
|
30
|
+
* - `accent.soft.bg` is a light tint in light / dark tint in dark, placed
|
|
31
|
+
* relative to the surfaces; `accent.soft.fg` is solved on all three soft
|
|
32
|
+
* states. `accent.text` (and `text.link`, the existing shorthand) is solved
|
|
33
|
+
* on every surface; `accent.border` is solved to 3:1 on every surface.
|
|
34
|
+
* - Disabled fills are desaturated and low-contrast-but-visible, in the
|
|
35
|
+
* spirit of the default `slate.200`/`slate.700`-like tokens.
|
|
36
|
+
*
|
|
37
|
+
* Unsatisfiable pairs (e.g. one very light and one very dark surface) are
|
|
38
|
+
* reported as `unsatisfied` diagnostics with the best deterministic colour
|
|
39
|
+
* kept; unparseable surfaces are excluded from solving and reported as
|
|
40
|
+
* `unsupported`. Nothing ever falls back to white silently.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
import type { CanonicalThemeColor, Scheme } from "../theme/types";
|
|
44
|
+
/** Every canonical role a seed generates. `text.link` is kept for the existing shorthand behaviour. */
|
|
45
|
+
export type GeneratedAccentRole = "accent.text" | "accent.border" | "accent.solid.bg" | "accent.solid.bg.hover" | "accent.solid.bg.pressed" | "accent.solid.bg.disabled" | "accent.solid.fg" | "accent.soft.bg" | "accent.soft.bg.hover" | "accent.soft.bg.pressed" | "accent.soft.bg.disabled" | "accent.soft.fg" | "text.link";
|
|
46
|
+
export declare const GENERATED_ACCENT_ROLES: readonly GeneratedAccentRole[];
|
|
47
|
+
export type AccentSurfaceRole = "surface.canvas" | "surface.default" | "surface.raised" | "surface.sunken";
|
|
48
|
+
/** The four ordinary surfaces every accent pair is evaluated over, in a fixed order. */
|
|
49
|
+
export declare const ACCENT_SURFACE_ROLES: readonly AccentSurfaceRole[];
|
|
50
|
+
/**
|
|
51
|
+
* The resolved scheme context a generator needs: the scheme's actual ordinary
|
|
52
|
+
* surfaces (after defaults, shared and scheme patches) and the opacity that
|
|
53
|
+
* components apply to a whole pressed control.
|
|
54
|
+
*/
|
|
55
|
+
export interface AccentGenerationContext {
|
|
56
|
+
scheme: Scheme;
|
|
57
|
+
surfaces: Record<AccentSurfaceRole, string>;
|
|
58
|
+
pressedOpacity: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `unsatisfied` — the pair was evaluated and fell below `required`.
|
|
62
|
+
* `unsupported` — a colour could not be evaluated (non-sRGB/opaque format);
|
|
63
|
+
* `ratio` is `null` and no accessibility claim is made.
|
|
64
|
+
*/
|
|
65
|
+
export type ContrastDiagnosticKind = "unsatisfied" | "unsupported";
|
|
66
|
+
export interface ContrastDiagnostic {
|
|
67
|
+
kind: ContrastDiagnosticKind;
|
|
68
|
+
/** Foreground role checked, e.g. `accent.solid.fg` or `accent.text`. */
|
|
69
|
+
role: string;
|
|
70
|
+
/** Background role the foreground sits on, e.g. `accent.solid.bg` or `surface.canvas`. */
|
|
71
|
+
background: string;
|
|
72
|
+
/** Ordinary surface the pair was composited over. */
|
|
73
|
+
surface: AccentSurfaceRole;
|
|
74
|
+
/** Opacity applied to the whole control for this check (1 when none). */
|
|
75
|
+
opacity: number;
|
|
76
|
+
ratio: number | null;
|
|
77
|
+
required: number;
|
|
78
|
+
message: string;
|
|
79
|
+
}
|
|
80
|
+
export interface AccentGenerationResult {
|
|
81
|
+
colors: Record<GeneratedAccentRole, string>;
|
|
82
|
+
/** Pairs the generator could not satisfy or evaluate in the supported domain. */
|
|
83
|
+
diagnostics: ContrastDiagnostic[];
|
|
84
|
+
}
|
|
85
|
+
/** Whether `value` is an opaque six-digit sRGB hex seed (`#rrggbb`, case-insensitive). */
|
|
86
|
+
export declare function isSupportedAccentSeed(value: unknown): value is string;
|
|
87
|
+
/** WCAG 2.x minimum for normal text and solid/soft labels. */
|
|
88
|
+
export declare const ACCENT_TEXT_CONTRAST = 4.5;
|
|
89
|
+
/** WCAG 2.x minimum for a meaningful accent boundary on an ordinary surface. */
|
|
90
|
+
export declare const ACCENT_BORDER_CONTRAST = 3;
|
|
91
|
+
/**
|
|
92
|
+
* Generates every {@link GeneratedAccentRole} for `seed` in the given scheme
|
|
93
|
+
* context. Pure and deterministic: same inputs → same output. Callers must
|
|
94
|
+
* validate the seed with {@link isSupportedAccentSeed} first.
|
|
95
|
+
*/
|
|
96
|
+
export declare function generateAccentColors(seed: string, context: AccentGenerationContext): AccentGenerationResult;
|
|
97
|
+
/**
|
|
98
|
+
* Evaluates the final accent roles (after explicit overrides) against their
|
|
99
|
+
* intended backgrounds in the supported domain and returns the failing or
|
|
100
|
+
* unevaluable pairs. Never repairs a colour.
|
|
101
|
+
*/
|
|
102
|
+
export declare function checkAccentContrast(colors: Pick<CanonicalThemeColor, GeneratedAccentRole>, context: AccentGenerationContext): ContrastDiagnostic[];
|
|
103
|
+
//# sourceMappingURL=accent-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accent-generator.d.ts","sourceRoot":"","sources":["../../../../src/utils/accent-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAYhE,uGAAuG;AACvG,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,eAAe,GACf,iBAAiB,GACjB,uBAAuB,GACvB,yBAAyB,GACzB,0BAA0B,GAC1B,iBAAiB,GACjB,gBAAgB,GAChB,sBAAsB,GACtB,wBAAwB,GACxB,yBAAyB,GACzB,gBAAgB,GAChB,WAAW,CAAC;AAEhB,eAAO,MAAM,sBAAsB,EAAE,SAAS,mBAAmB,EAchE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAE3G,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,EAAE,SAAS,iBAAiB,EAK5D,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG,aAAa,CAAC;AAEnE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC5C,iFAAiF;IACjF,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAErE;AAID,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,IAAI,CAAC;AA8JxC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAiI3G;AA+BD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,EACtD,OAAO,EAAE,uBAAuB,GAC/B,kBAAkB,EAAE,CAqDtB"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import type { Accent, NormalizedAccent } from "../theme/types";
|
|
2
|
-
|
|
1
|
+
import type { Accent, NormalizedAccent, Scheme } from "../theme/types";
|
|
2
|
+
import { type AccentGenerationContext } from "./accent-generator.js";
|
|
3
|
+
/**
|
|
4
|
+
* The generation context of a built-in default theme: its four ordinary
|
|
5
|
+
* surfaces and pressed opacity. Used by the {@link normalizeAccent}
|
|
6
|
+
* compatibility wrapper, which has no access to shared/scheme patches.
|
|
7
|
+
*/
|
|
8
|
+
export declare function defaultAccentContext(scheme: Scheme): AccentGenerationContext;
|
|
9
|
+
/**
|
|
10
|
+
* Compatibility wrapper: normalizes any accent input into per-scheme
|
|
11
|
+
* partial-theme overrides. Strings and `{ seed, overrides }` are generated
|
|
12
|
+
* against the DEFAULT themes' surfaces and pressed opacity (the resolver
|
|
13
|
+
* pipeline uses the actual resolved surfaces instead); full theme patches
|
|
14
|
+
* pass through unchanged. Pure and independent of the registry.
|
|
15
|
+
*/
|
|
3
16
|
export declare function normalizeAccent(accent: Accent): NormalizedAccent;
|
|
4
17
|
//# sourceMappingURL=accent-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accent-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/accent-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accent-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/accent-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,MAAM,EAEN,gBAAgB,EAChB,MAAM,EAGP,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,uBAAuB,EAG7B,MAAM,uBAAoB,CAAC;AAG5B;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CAK5E;AAkCD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAKhE"}
|
|
@@ -1,4 +1,61 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Colour helpers shared by the accent generator, the contrast diagnostics and
|
|
3
|
+
* the public `shade` / `withAlpha` / `readableOn` utilities.
|
|
4
|
+
*
|
|
5
|
+
* Everything here is pure sRGB maths with no runtime dependency:
|
|
6
|
+
* - parsing of `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`,
|
|
7
|
+
* - WCAG 2.x relative luminance / contrast with sRGB alpha compositing,
|
|
8
|
+
* - OKLab / OKLCH conversions (Björn Ottosson's published matrices) with
|
|
9
|
+
* sRGB gamut mapping by chroma reduction at constant lightness and hue.
|
|
10
|
+
*/
|
|
11
|
+
export interface RGB {
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
}
|
|
16
|
+
/** A parsed sRGB colour with 0-255 channels and a 0-1 alpha. */
|
|
17
|
+
export interface RGBA extends RGB {
|
|
18
|
+
a: number;
|
|
19
|
+
}
|
|
20
|
+
/** OKLCH coordinates: L in [0, 1], C ≥ 0, h in degrees [0, 360). */
|
|
21
|
+
export interface OKLCH {
|
|
22
|
+
l: number;
|
|
23
|
+
c: number;
|
|
24
|
+
h: number;
|
|
25
|
+
}
|
|
26
|
+
/** Formats 0-255 channels as a lowercase `#rrggbb` string (channels are rounded and clamped). */
|
|
27
|
+
export declare function rgbToHex(rgb: RGB): string;
|
|
28
|
+
/**
|
|
29
|
+
* Parses an sRGB colour string. Accepts `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
|
|
30
|
+
* (case-insensitive) and `rgb(r, g, b)` / `rgba(r, g, b, a)` with integer or
|
|
31
|
+
* percentage channels. Returns `null` for anything else (named colours,
|
|
32
|
+
* `transparent`, hsl(), gradients, platform dynamic colours, ...).
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseColor(value: unknown): RGBA | null;
|
|
35
|
+
/** Source-over compositing of `front` at `alpha` onto an opaque `back`, in gamma-encoded sRGB. */
|
|
36
|
+
export declare function compositeOver(front: RGB, back: RGB, alpha: number): RGB;
|
|
37
|
+
/** WCAG 2.x relative luminance of an opaque sRGB colour (0-255 channels). */
|
|
38
|
+
export declare function relativeLuminance(rgb: RGB): number;
|
|
39
|
+
/** WCAG 2.x contrast ratio between two opaque sRGB colours (≥ 1). */
|
|
40
|
+
export declare function contrastRatio(a: RGB, b: RGB): number;
|
|
41
|
+
/**
|
|
42
|
+
* Contrast of a foreground on a background, both composited over an opaque
|
|
43
|
+
* `surface`, with `opacity` applied to the whole control afterwards (the way a
|
|
44
|
+
* pressed Button or Toast action fades as one unit). Matches the reference
|
|
45
|
+
* calculation in `theme/__tests__/color-contrast.test.ts`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function compositedContrast(fg: RGBA, bg: RGBA, surface: RGB, opacity?: number): number;
|
|
48
|
+
/** Converts 0-255 sRGB channels to OKLCH. Achromatic input yields `c ≈ 0` and `h = 0`. */
|
|
49
|
+
export declare function rgbToOklch(rgb: RGB): OKLCH;
|
|
50
|
+
/**
|
|
51
|
+
* Converts OKLCH to 0-255 sRGB channels. Colours outside the sRGB gamut are
|
|
52
|
+
* mapped by reducing chroma at constant lightness and hue (binary search)
|
|
53
|
+
* until they fit, so the requested lightness — what the contrast targets
|
|
54
|
+
* depend on — is preserved as closely as the gamut allows.
|
|
55
|
+
*/
|
|
56
|
+
export declare function oklchToRgb(color: OKLCH): RGB;
|
|
57
|
+
/** `oklchToRgb` followed by `rgbToHex`. */
|
|
58
|
+
export declare function oklchToHex(color: OKLCH): string;
|
|
2
59
|
/**
|
|
3
60
|
* Shifts a hex color toward black (negative `amount`) or white (positive),
|
|
4
61
|
* by a fraction in [-1, 1]. Returns the input unchanged if not a 6-digit hex.
|
|
@@ -6,6 +63,6 @@
|
|
|
6
63
|
export declare function shade(hex: string, amount: number): string;
|
|
7
64
|
/** Returns an `rgba(...)` string for a hex color at the given alpha. */
|
|
8
65
|
export declare function withAlpha(hex: string, alpha: number): string;
|
|
9
|
-
/** Picks
|
|
66
|
+
/** Picks the higher-contrast black/white foreground for an opaque 6-digit hex. */
|
|
10
67
|
export declare function readableOn(hex: string): string;
|
|
11
68
|
//# sourceMappingURL=color-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/color-utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../../../src/utils/color-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,gEAAgE;AAChE,MAAM,WAAW,IAAK,SAAQ,GAAG;IAC/B,CAAC,EAAE,MAAM,CAAC;CACX;AAED,oEAAoE;AACpE,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAeD,iGAAiG;AACjG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAEzC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CA8CtD;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAOvE;AAYD,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAIlD;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAIpD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,SAAI,GAAG,MAAM,CAOxF;AA6BD,0FAA0F;AAC1F,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,KAAK,CAU1C;AAYD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAqB5C;AAED,2CAA2C;AAC3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAE/C;AAID;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends object ? {
|
|
3
3
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
4
4
|
} : T;
|
|
5
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
5
6
|
/**
|
|
6
7
|
* Deep-merges `override` onto `base`, returning a new object.
|
|
7
8
|
* Plain objects merge recursively; all other values (and arrays) replace.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-merge.d.ts","sourceRoot":"","sources":["../../../../src/utils/deep-merge.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"deep-merge.d.ts","sourceRoot":"","sources":["../../../../src/utils/deep-merge.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAC;AAER,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAI3B,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAiBlE"}
|
|
@@ -4,8 +4,8 @@ import type { ColorToken, TerraTheme } from "../theme/types";
|
|
|
4
4
|
* Raw literals pass through unchanged.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* resolveThemeColor('text.
|
|
8
|
-
* resolveThemeColor('
|
|
7
|
+
* resolveThemeColor('text.primary', theme) // → '#020618'
|
|
8
|
+
* resolveThemeColor('accent.solid.bg', theme) // → '#009966'
|
|
9
9
|
* resolveThemeColor('#ff0000', theme) // → '#ff0000'
|
|
10
10
|
*/
|
|
11
11
|
export declare function resolveThemeColor(token: ColorToken | undefined, theme: TerraTheme): string | undefined;
|
package/package.json
CHANGED
|
@@ -149,80 +149,80 @@ const styles = StyleSheet.create((theme) => {
|
|
|
149
149
|
color: "secondary",
|
|
150
150
|
variant: "solid",
|
|
151
151
|
styles: {
|
|
152
|
-
backgroundColor: c["
|
|
153
|
-
color: c["
|
|
152
|
+
backgroundColor: c["neutral.solid.bg"],
|
|
153
|
+
color: c["neutral.solid.fg"],
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
157
|
color: "secondary",
|
|
158
158
|
variant: "soft",
|
|
159
159
|
styles: {
|
|
160
|
-
backgroundColor: c["
|
|
161
|
-
color: c["
|
|
160
|
+
backgroundColor: c["neutral.soft.bg"],
|
|
161
|
+
color: c["neutral.soft.fg"],
|
|
162
162
|
},
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
color: "primary",
|
|
166
166
|
variant: "solid",
|
|
167
167
|
styles: {
|
|
168
|
-
backgroundColor: c["
|
|
169
|
-
color: c["
|
|
168
|
+
backgroundColor: c["accent.solid.bg"],
|
|
169
|
+
color: c["accent.solid.fg"],
|
|
170
170
|
},
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
color: "primary",
|
|
174
174
|
variant: "soft",
|
|
175
175
|
styles: {
|
|
176
|
-
backgroundColor: c["
|
|
177
|
-
color: c["
|
|
176
|
+
backgroundColor: c["accent.soft.bg"],
|
|
177
|
+
color: c["accent.soft.fg"],
|
|
178
178
|
},
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
color: "success",
|
|
182
182
|
variant: "solid",
|
|
183
183
|
styles: {
|
|
184
|
-
backgroundColor: c["
|
|
185
|
-
color: c["
|
|
184
|
+
backgroundColor: c["success.solid.bg"],
|
|
185
|
+
color: c["success.solid.fg"],
|
|
186
186
|
},
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
color: "success",
|
|
190
190
|
variant: "soft",
|
|
191
191
|
styles: {
|
|
192
|
-
backgroundColor: c["
|
|
193
|
-
color: c["
|
|
192
|
+
backgroundColor: c["success.soft.bg"],
|
|
193
|
+
color: c["success.soft.fg"],
|
|
194
194
|
},
|
|
195
195
|
},
|
|
196
196
|
{
|
|
197
197
|
color: "warning",
|
|
198
198
|
variant: "solid",
|
|
199
199
|
styles: {
|
|
200
|
-
backgroundColor: c["
|
|
201
|
-
color: c["
|
|
200
|
+
backgroundColor: c["warning.solid.bg"],
|
|
201
|
+
color: c["warning.solid.fg"],
|
|
202
202
|
},
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
205
|
color: "warning",
|
|
206
206
|
variant: "soft",
|
|
207
207
|
styles: {
|
|
208
|
-
backgroundColor: c["
|
|
209
|
-
color: c["
|
|
208
|
+
backgroundColor: c["warning.soft.bg"],
|
|
209
|
+
color: c["warning.soft.fg"],
|
|
210
210
|
},
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
213
|
color: "danger",
|
|
214
214
|
variant: "solid",
|
|
215
215
|
styles: {
|
|
216
|
-
backgroundColor: c["
|
|
217
|
-
color: c["
|
|
216
|
+
backgroundColor: c["danger.solid.bg"],
|
|
217
|
+
color: c["danger.solid.fg"],
|
|
218
218
|
},
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
color: "danger",
|
|
222
222
|
variant: "soft",
|
|
223
223
|
styles: {
|
|
224
|
-
backgroundColor: c["
|
|
225
|
-
color: c["
|
|
224
|
+
backgroundColor: c["danger.soft.bg"],
|
|
225
|
+
color: c["danger.soft.fg"],
|
|
226
226
|
},
|
|
227
227
|
},
|
|
228
228
|
],
|
|
@@ -70,38 +70,38 @@ function getColors(variant: ButtonVariant, theme: TerraTheme): ButtonColors {
|
|
|
70
70
|
switch (variant) {
|
|
71
71
|
case "primary":
|
|
72
72
|
return {
|
|
73
|
-
bg: get("
|
|
74
|
-
border: get("
|
|
73
|
+
bg: get("accent.solid.bg"),
|
|
74
|
+
border: get("accent.solid.bg"),
|
|
75
75
|
borderWidth: 0,
|
|
76
|
-
fg: get("
|
|
76
|
+
fg: get("accent.solid.fg"),
|
|
77
77
|
};
|
|
78
78
|
case "secondary":
|
|
79
79
|
return {
|
|
80
|
-
bg: get("
|
|
81
|
-
border: get("
|
|
80
|
+
bg: get("neutral.solid.bg"),
|
|
81
|
+
border: get("neutral.solid.bg"),
|
|
82
82
|
borderWidth: 0,
|
|
83
|
-
fg: get("
|
|
83
|
+
fg: get("neutral.solid.fg"),
|
|
84
84
|
};
|
|
85
85
|
case "outline":
|
|
86
86
|
return {
|
|
87
87
|
bg: "transparent",
|
|
88
88
|
border: get("border.default"),
|
|
89
89
|
borderWidth: 1,
|
|
90
|
-
fg: get("text.
|
|
90
|
+
fg: get("text.primary"),
|
|
91
91
|
};
|
|
92
92
|
case "ghost":
|
|
93
93
|
return {
|
|
94
94
|
bg: "transparent",
|
|
95
95
|
border: "transparent",
|
|
96
96
|
borderWidth: 0,
|
|
97
|
-
fg: get("text.
|
|
97
|
+
fg: get("text.primary"),
|
|
98
98
|
};
|
|
99
99
|
case "danger":
|
|
100
100
|
return {
|
|
101
|
-
bg: get("
|
|
102
|
-
border: get("
|
|
101
|
+
bg: get("danger.solid.bg"),
|
|
102
|
+
border: get("danger.solid.bg"),
|
|
103
103
|
borderWidth: 0,
|
|
104
|
-
fg: get("
|
|
104
|
+
fg: get("danger.solid.fg"),
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -31,7 +31,7 @@ interface ChipContextValue {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const ChipContext = createContext<ChipContextValue>({
|
|
34
|
-
color: "text.
|
|
34
|
+
color: "text.primary",
|
|
35
35
|
size: "md",
|
|
36
36
|
});
|
|
37
37
|
|
|
@@ -66,29 +66,29 @@ function paintedVariant(variant: ChipVariant): ChipPaintedVariant {
|
|
|
66
66
|
/** Foreground token per (scheme, variant) — mirrors the spec's token table. */
|
|
67
67
|
const FG_TOKEN: Record<ChipScheme, Record<ChipPaintedVariant, ColorToken>> = {
|
|
68
68
|
primary: {
|
|
69
|
-
solid: "
|
|
70
|
-
soft: "
|
|
71
|
-
outline: "text
|
|
69
|
+
solid: "accent.solid.fg",
|
|
70
|
+
soft: "accent.soft.fg",
|
|
71
|
+
outline: "accent.text",
|
|
72
72
|
},
|
|
73
73
|
secondary: {
|
|
74
|
-
solid: "
|
|
75
|
-
soft: "
|
|
76
|
-
outline: "text.
|
|
74
|
+
solid: "neutral.solid.fg",
|
|
75
|
+
soft: "neutral.soft.fg",
|
|
76
|
+
outline: "text.primary",
|
|
77
77
|
},
|
|
78
78
|
success: {
|
|
79
|
-
solid: "
|
|
80
|
-
soft: "
|
|
81
|
-
outline: "
|
|
79
|
+
solid: "success.solid.fg",
|
|
80
|
+
soft: "success.soft.fg",
|
|
81
|
+
outline: "success.soft.fg",
|
|
82
82
|
},
|
|
83
83
|
warning: {
|
|
84
|
-
solid: "
|
|
85
|
-
soft: "
|
|
86
|
-
outline: "
|
|
84
|
+
solid: "warning.solid.fg",
|
|
85
|
+
soft: "warning.soft.fg",
|
|
86
|
+
outline: "warning.soft.fg",
|
|
87
87
|
},
|
|
88
88
|
danger: {
|
|
89
|
-
solid: "
|
|
90
|
-
soft: "
|
|
91
|
-
outline: "
|
|
89
|
+
solid: "danger.solid.fg",
|
|
90
|
+
soft: "danger.soft.fg",
|
|
91
|
+
outline: "danger.soft.fg",
|
|
92
92
|
},
|
|
93
93
|
};
|
|
94
94
|
|
|
@@ -222,7 +222,7 @@ type ChipComponent = typeof ChipRoot & {
|
|
|
222
222
|
// change that computes a value equal to that stale record emits no update at
|
|
223
223
|
// all, and the node keeps whatever the theme switch painted. That is reachable
|
|
224
224
|
// whenever one colour fills two roles across themes — an accent equal to
|
|
225
|
-
// another theme's `
|
|
225
|
+
// another theme's `neutral.soft.bg`, say — and it shows up as a
|
|
226
226
|
// deselected chip still wearing the selected background.
|
|
227
227
|
//
|
|
228
228
|
// Re-rendering on a theme switch commits the new value there and then, so no
|
|
@@ -327,7 +327,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
327
327
|
color: "primary",
|
|
328
328
|
variant: "solid",
|
|
329
329
|
styles: {
|
|
330
|
-
backgroundColor: c["
|
|
330
|
+
backgroundColor: c["accent.solid.bg"],
|
|
331
331
|
borderWidth: 0,
|
|
332
332
|
},
|
|
333
333
|
},
|
|
@@ -335,7 +335,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
335
335
|
color: "primary",
|
|
336
336
|
variant: "soft",
|
|
337
337
|
styles: {
|
|
338
|
-
backgroundColor: c["
|
|
338
|
+
backgroundColor: c["accent.soft.bg"],
|
|
339
339
|
borderWidth: 0,
|
|
340
340
|
},
|
|
341
341
|
},
|
|
@@ -344,7 +344,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
344
344
|
variant: "outline",
|
|
345
345
|
styles: {
|
|
346
346
|
backgroundColor: "transparent",
|
|
347
|
-
borderColor: c["
|
|
347
|
+
borderColor: c["accent.soft.bg"],
|
|
348
348
|
borderWidth: 1,
|
|
349
349
|
},
|
|
350
350
|
},
|
|
@@ -352,7 +352,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
352
352
|
color: "secondary",
|
|
353
353
|
variant: "solid",
|
|
354
354
|
styles: {
|
|
355
|
-
backgroundColor: c["
|
|
355
|
+
backgroundColor: c["neutral.solid.bg"],
|
|
356
356
|
borderWidth: 0,
|
|
357
357
|
},
|
|
358
358
|
},
|
|
@@ -360,7 +360,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
360
360
|
color: "secondary",
|
|
361
361
|
variant: "soft",
|
|
362
362
|
styles: {
|
|
363
|
-
backgroundColor: c["
|
|
363
|
+
backgroundColor: c["neutral.soft.bg"],
|
|
364
364
|
borderWidth: 0,
|
|
365
365
|
},
|
|
366
366
|
},
|
|
@@ -369,7 +369,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
369
369
|
variant: "outline",
|
|
370
370
|
styles: {
|
|
371
371
|
backgroundColor: "transparent",
|
|
372
|
-
borderColor: c["
|
|
372
|
+
borderColor: c["neutral.soft.bg"],
|
|
373
373
|
borderWidth: 1,
|
|
374
374
|
},
|
|
375
375
|
},
|
|
@@ -377,7 +377,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
377
377
|
color: "success",
|
|
378
378
|
variant: "solid",
|
|
379
379
|
styles: {
|
|
380
|
-
backgroundColor: c["
|
|
380
|
+
backgroundColor: c["success.solid.bg"],
|
|
381
381
|
borderWidth: 0,
|
|
382
382
|
},
|
|
383
383
|
},
|
|
@@ -385,7 +385,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
385
385
|
color: "success",
|
|
386
386
|
variant: "soft",
|
|
387
387
|
styles: {
|
|
388
|
-
backgroundColor: c["
|
|
388
|
+
backgroundColor: c["success.soft.bg"],
|
|
389
389
|
borderWidth: 0,
|
|
390
390
|
},
|
|
391
391
|
},
|
|
@@ -394,7 +394,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
394
394
|
variant: "outline",
|
|
395
395
|
styles: {
|
|
396
396
|
backgroundColor: "transparent",
|
|
397
|
-
borderColor: c["
|
|
397
|
+
borderColor: c["success.soft.bg"],
|
|
398
398
|
borderWidth: 1,
|
|
399
399
|
},
|
|
400
400
|
},
|
|
@@ -402,7 +402,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
402
402
|
color: "warning",
|
|
403
403
|
variant: "solid",
|
|
404
404
|
styles: {
|
|
405
|
-
backgroundColor: c["
|
|
405
|
+
backgroundColor: c["warning.solid.bg"],
|
|
406
406
|
borderWidth: 0,
|
|
407
407
|
},
|
|
408
408
|
},
|
|
@@ -410,7 +410,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
410
410
|
color: "warning",
|
|
411
411
|
variant: "soft",
|
|
412
412
|
styles: {
|
|
413
|
-
backgroundColor: c["
|
|
413
|
+
backgroundColor: c["warning.soft.bg"],
|
|
414
414
|
borderWidth: 0,
|
|
415
415
|
},
|
|
416
416
|
},
|
|
@@ -419,7 +419,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
419
419
|
variant: "outline",
|
|
420
420
|
styles: {
|
|
421
421
|
backgroundColor: "transparent",
|
|
422
|
-
borderColor: c["
|
|
422
|
+
borderColor: c["warning.soft.bg"],
|
|
423
423
|
borderWidth: 1,
|
|
424
424
|
},
|
|
425
425
|
},
|
|
@@ -427,7 +427,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
427
427
|
color: "danger",
|
|
428
428
|
variant: "solid",
|
|
429
429
|
styles: {
|
|
430
|
-
backgroundColor: c["
|
|
430
|
+
backgroundColor: c["danger.solid.bg"],
|
|
431
431
|
borderWidth: 0,
|
|
432
432
|
},
|
|
433
433
|
},
|
|
@@ -435,7 +435,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
435
435
|
color: "danger",
|
|
436
436
|
variant: "soft",
|
|
437
437
|
styles: {
|
|
438
|
-
backgroundColor: c["
|
|
438
|
+
backgroundColor: c["danger.soft.bg"],
|
|
439
439
|
borderWidth: 0,
|
|
440
440
|
},
|
|
441
441
|
},
|
|
@@ -444,7 +444,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
444
444
|
variant: "outline",
|
|
445
445
|
styles: {
|
|
446
446
|
backgroundColor: "transparent",
|
|
447
|
-
borderColor: c["
|
|
447
|
+
borderColor: c["danger.soft.bg"],
|
|
448
448
|
borderWidth: 1,
|
|
449
449
|
},
|
|
450
450
|
},
|
|
@@ -3,7 +3,7 @@ export type ChipVariant = "solid" | "soft" | "outline" | "ghost";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Semantic color scheme, or a raw CSS color literal (`#fff`, `rgb(...)`, `hsl(...)`).
|
|
6
|
-
* Has no effect when `variant="ghost"` — ghost always renders `text.
|
|
6
|
+
* Has no effect when `variant="ghost"` — ghost always renders `text.primary`.
|
|
7
7
|
*/
|
|
8
8
|
export type ChipColor =
|
|
9
9
|
| "primary"
|
|
@@ -11,7 +11,7 @@ import type { EmptyStateSize } from "./types";
|
|
|
11
11
|
export interface EmptyStateProps extends Omit<ViewProps, "children"> {
|
|
12
12
|
/** Icon rendered in the circular badge above the title. */
|
|
13
13
|
icon?: TerraIconName;
|
|
14
|
-
/** Icon tint. Defaults to `text.
|
|
14
|
+
/** Icon tint. Defaults to `text.tertiary`. */
|
|
15
15
|
iconColor?: ColorToken;
|
|
16
16
|
/**
|
|
17
17
|
* Replaces the icon badge entirely — an illustration, `Image`, or any custom
|
|
@@ -75,7 +75,7 @@ function renderSlot(node: ReactNode, wrap: (value: ReactNode) => ReactNode): Rea
|
|
|
75
75
|
export const EmptyState = forwardRef<ComponentRef<typeof View>, EmptyStateProps>(function EmptyState(
|
|
76
76
|
{
|
|
77
77
|
icon,
|
|
78
|
-
iconColor = "text.
|
|
78
|
+
iconColor = "text.primary",
|
|
79
79
|
media,
|
|
80
80
|
title,
|
|
81
81
|
description,
|
|
@@ -107,7 +107,7 @@ export const EmptyState = forwardRef<ComponentRef<typeof View>, EmptyStateProps>
|
|
|
107
107
|
</Text>
|
|
108
108
|
))}
|
|
109
109
|
{renderSlot(description, (value) => (
|
|
110
|
-
<Text variant={typography.description} color="text.
|
|
110
|
+
<Text variant={typography.description} color="text.tertiary" align="center">
|
|
111
111
|
{value}
|
|
112
112
|
</Text>
|
|
113
113
|
))}
|
|
@@ -160,7 +160,7 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
160
160
|
iconBadge: {
|
|
161
161
|
alignItems: "center",
|
|
162
162
|
justifyContent: "center",
|
|
163
|
-
backgroundColor: theme.color["
|
|
163
|
+
backgroundColor: theme.color["accent.soft.bg"],
|
|
164
164
|
borderRadius: theme.radius.full,
|
|
165
165
|
variants: {
|
|
166
166
|
size: {
|