@cdx-ui/styles 0.0.1-beta.8 → 0.0.1-beta.80
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/README.md +116 -20
- package/css/theme.css +201 -85
- package/css/vanilla.css +124 -54
- package/lib/commonjs/applyThemeOverride.js +154 -0
- package/lib/commonjs/applyThemeOverride.js.map +1 -0
- package/lib/commonjs/index.js +82 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/palette.js +262 -0
- package/lib/commonjs/palette.js.map +1 -0
- package/lib/commonjs/theming.js +255 -0
- package/lib/commonjs/theming.js.map +1 -0
- package/lib/commonjs/types.js +75 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useCdxFonts.js +7 -231
- package/lib/commonjs/useCdxFonts.js.map +1 -1
- package/lib/commonjs/useForgeFonts.js +237 -0
- package/lib/commonjs/useForgeFonts.js.map +1 -0
- package/lib/module/applyThemeOverride.js +149 -0
- package/lib/module/applyThemeOverride.js.map +1 -0
- package/lib/module/index.js +11 -20
- package/lib/module/index.js.map +1 -1
- package/lib/module/palette.js +257 -0
- package/lib/module/palette.js.map +1 -0
- package/lib/module/theming.js +239 -0
- package/lib/module/theming.js.map +1 -0
- package/lib/module/types.js +71 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useCdxFonts.js +2 -220
- package/lib/module/useCdxFonts.js.map +1 -1
- package/lib/module/useForgeFonts.js +223 -0
- package/lib/module/useForgeFonts.js.map +1 -0
- package/lib/runtime/prestige-vs-default.json +1 -0
- package/lib/runtime/pulse-vs-default.json +1 -0
- package/lib/runtime/token-to-css-var.json +672 -0
- package/lib/typescript/applyThemeOverride.d.ts +26 -0
- package/lib/typescript/applyThemeOverride.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -57
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/palette.d.ts +60 -0
- package/lib/typescript/palette.d.ts.map +1 -0
- package/lib/typescript/theming.d.ts +40 -0
- package/lib/typescript/theming.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +90 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/useCdxFonts.d.ts +2 -11
- package/lib/typescript/useCdxFonts.d.ts.map +1 -1
- package/lib/typescript/useForgeFonts.d.ts +12 -0
- package/lib/typescript/useForgeFonts.d.ts.map +1 -0
- package/package.json +27 -8
- package/runtime/prestige-vs-default.json +1 -0
- package/runtime/pulse-vs-default.json +1 -0
- package/runtime/token-to-css-var.json +672 -0
- package/src/__tests__/applyThemeOverride.test.ts +552 -0
- package/src/__tests__/generateColorScale.test.ts +296 -0
- package/src/__tests__/theming.test.ts +647 -0
- package/src/applyThemeOverride.ts +139 -0
- package/src/index.ts +36 -60
- package/src/palette.ts +307 -0
- package/src/theming.ts +268 -0
- package/src/types.ts +112 -0
- package/src/useCdxFonts.ts +2 -230
- package/src/useForgeFonts.ts +230 -0
- package/tokens/presets/.manifest.json +3 -3
- package/tokens/presets/poise.json +319 -39
- package/tokens/presets/prestige.json +1 -1
- package/tokens/presets/pulse.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Platform, Preset, ThemeOverride } from './types';
|
|
2
|
+
import { type RuntimeMap } from './theming';
|
|
3
|
+
/** The build-time default preset. Apps ship with Poise baked into CSS. */
|
|
4
|
+
export declare const DEFAULT_PRESET: Preset;
|
|
5
|
+
export type ApplyThemeOverrideResult = {
|
|
6
|
+
applied: true;
|
|
7
|
+
light: Record<string, string>;
|
|
8
|
+
dark: Record<string, string>;
|
|
9
|
+
} | {
|
|
10
|
+
applied: false;
|
|
11
|
+
reason: 'unsupported_schema_version' | 'no_theme_changes';
|
|
12
|
+
};
|
|
13
|
+
export interface ApplyThemeOverrideOptions {
|
|
14
|
+
runtimeMap?: RuntimeMap;
|
|
15
|
+
runtimePlatform?: Platform;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Apply a `ThemeOverride` end-to-end: schema version gate, preset patch
|
|
19
|
+
* selection, palette generation, and `Uniwind.updateCSSVariables` calls.
|
|
20
|
+
*
|
|
21
|
+
* Encapsulates the full runtime theme application sequence so consuming
|
|
22
|
+
* apps don't need to orchestrate lower-level utilities or import Uniwind
|
|
23
|
+
* directly.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyThemeOverride(override: ThemeOverride, options?: ApplyThemeOverrideOptions): ApplyThemeOverrideResult;
|
|
26
|
+
//# sourceMappingURL=applyThemeOverride.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyThemeOverride.d.ts","sourceRoot":"","sources":["../../src/applyThemeOverride.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AAC3E,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAMnB,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,MAAgB,CAAC;AAgC9C,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9E;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,4BAA4B,GAAG,kBAAkB,CAAA;CAAE,CAAC;AAMlF,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAMD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CA6D1B"}
|
|
@@ -1,59 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
[key: string]: TokenValue | TokenGroup;
|
|
10
|
-
}
|
|
11
|
-
/** Theme metadata stored under `$extensions.com.candescent.theme`. */
|
|
12
|
-
export interface ThemeMetadata {
|
|
13
|
-
name: string;
|
|
14
|
-
preset: string;
|
|
15
|
-
schemaVersion: string;
|
|
16
|
-
}
|
|
17
|
-
/** Override metadata stored under `$extensions.com.candescent.themeOverride`. */
|
|
18
|
-
export interface ThemeOverrideMetadata {
|
|
19
|
-
basePreset: string;
|
|
20
|
-
fiId: string;
|
|
21
|
-
fiName: string;
|
|
22
|
-
schemaVersion: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A complete CDX UI theme object (DTCG-compatible).
|
|
26
|
-
*
|
|
27
|
-
* Presets (Poise, Prestige, Pulse) are full theme objects. At runtime the
|
|
28
|
-
* build-time default preset is augmented by FI overrides via
|
|
29
|
-
* `applyThemeOverrides`.
|
|
30
|
-
*/
|
|
31
|
-
export type ThemeObject = TokenGroup & {
|
|
32
|
-
$extensions: {
|
|
33
|
-
'com.candescent.theme': ThemeMetadata;
|
|
34
|
-
[key: string]: unknown;
|
|
35
|
-
};
|
|
36
|
-
modes: {
|
|
37
|
-
light: TokenGroup;
|
|
38
|
-
dark: TokenGroup;
|
|
39
|
-
};
|
|
40
|
-
platform: {
|
|
41
|
-
web: TokenGroup;
|
|
42
|
-
ios: TokenGroup;
|
|
43
|
-
android: TokenGroup;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* A theme override — a strict subset of the theme object schema containing
|
|
48
|
-
* only the token paths that differ from the base preset.
|
|
49
|
-
*/
|
|
50
|
-
export type ThemeOverride = TokenGroup & {
|
|
51
|
-
$extensions?: {
|
|
52
|
-
'com.candescent.themeOverride'?: ThemeOverrideMetadata;
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export type Mode = 'light' | 'dark';
|
|
57
|
-
export type Platform = 'web' | 'ios' | 'android';
|
|
1
|
+
export { OVERRIDE_SCHEMA_VERSION, SUPPORTED_OVERRIDE_SCHEMA_VERSIONS, INPUT_TOKEN_MAP, presetFonts, } from './types';
|
|
2
|
+
export type { TokenValue, TokenGroup, Preset, ThemeMetadata, ThemeOverrideMetadata, ThemeObject, ThemeOverride, Mode, Platform, } from './types';
|
|
3
|
+
export { generateColorScale, generatePalettesFromInputs, deriveBaseColorKey } from './palette';
|
|
4
|
+
export type { PaletteCategory, PaletteScale, PaletteStep, PaletteTokenMap } from './palette';
|
|
5
|
+
export { isSchemaVersionSupported, presetPatchToUniwindMaps, themeOverrideToUniwindMaps, applyThemeOverride, DEFAULT_PRESET, } from './theming';
|
|
6
|
+
export type { CssVariableMaps, RuntimeMap } from './theming';
|
|
7
|
+
export type { ApplyThemeOverrideOptions, ApplyThemeOverrideResult } from './applyThemeOverride';
|
|
8
|
+
export { useForgeFonts } from './useForgeFonts';
|
|
58
9
|
export { useCdxFonts } from './useCdxFonts';
|
|
59
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,uBAAuB,EACvB,kCAAkC,EAClC,eAAe,EACf,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,UAAU,EACV,UAAU,EACV,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,IAAI,EACJ,QAAQ,GACT,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/F,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAM7F,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC7D,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMhG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Palette step keys produced by `generateColorScale`. */
|
|
2
|
+
export type PaletteStep = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950' | 'input';
|
|
3
|
+
/** Token category that supports palette generation. */
|
|
4
|
+
export type PaletteCategory = 'brand' | 'accent' | 'base';
|
|
5
|
+
/** Map of palette step → resolved hex color. */
|
|
6
|
+
export type PaletteScale = Record<PaletteStep, string>;
|
|
7
|
+
/** Map of token dot-path → resolved hex color (e.g. `color.brand.500` → `#548cdc`). */
|
|
8
|
+
export type PaletteTokenMap = Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Generate an 11-step contrast-based color scale from a single hex color.
|
|
11
|
+
*
|
|
12
|
+
* Uses `@adobe/leonardo-contrast-colors` internally. The generation algorithm
|
|
13
|
+
* is wrapped behind this function so the underlying library is swappable
|
|
14
|
+
* without changing the public API.
|
|
15
|
+
*
|
|
16
|
+
* @param hex - A valid hex color string (`#RGB` or `#RRGGBB`).
|
|
17
|
+
* @param category - The token namespace (`'brand'` or `'accent'`).
|
|
18
|
+
* @returns A `PaletteTokenMap` keyed by token dot-paths
|
|
19
|
+
* (e.g. `"color.brand.50"` through `"color.brand.950"` plus `"color.brand.input"`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateColorScale(hex: string, category: PaletteCategory): PaletteTokenMap;
|
|
22
|
+
/**
|
|
23
|
+
* Derive the base palette color key from a brand color.
|
|
24
|
+
*
|
|
25
|
+
* The base scale shares the brand's hue and lightness but is nearly neutral:
|
|
26
|
+
* the brand color is converted to HSL and its saturation is lowered to
|
|
27
|
+
* {@link BASE_SATURATION} (5%). The resulting hex is the color key fed to
|
|
28
|
+
* {@link generateColorScale} for the `base` category.
|
|
29
|
+
*
|
|
30
|
+
* @param brandHex - A valid hex color string (`#RGB` or `#RRGGBB`).
|
|
31
|
+
* @returns The normalised hex color key for the base scale.
|
|
32
|
+
*/
|
|
33
|
+
export declare function deriveBaseColorKey(brandHex: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Generate palettes for all colour inputs in a theme override `inputs` object.
|
|
36
|
+
*
|
|
37
|
+
* Iterates over known colour-input keys that map to a `color.*` token
|
|
38
|
+
* namespace. For each matching key present in `inputs`, runs
|
|
39
|
+
* `generateColorScale` and merges the results into a single flat map of
|
|
40
|
+
* token dot-paths to hex values — ready for the S5 override application
|
|
41
|
+
* merge step.
|
|
42
|
+
*
|
|
43
|
+
* Non-colour inputs (e.g. `displayFont`) are silently skipped.
|
|
44
|
+
*
|
|
45
|
+
* @param inputs - The `inputs` object from a `ThemeOverride`.
|
|
46
|
+
* @returns A merged `Record<string, string>` of all generated token
|
|
47
|
+
* dot-paths to hex values.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const inputs = { brandPrimary: '#0052cc', accentPrimary: '#FF8C42', displayFont: 'Poppins' };
|
|
52
|
+
* const result = generatePalettesFromInputs(inputs);
|
|
53
|
+
* // {
|
|
54
|
+
* // "color.brand.50": "#...", …, "color.brand.input": "#0052cc",
|
|
55
|
+
* // "color.accent.50": "#...", …, "color.accent.input": "#ff8c42"
|
|
56
|
+
* // }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function generatePalettesFromInputs(inputs: Record<string, string | number>): PaletteTokenMap;
|
|
60
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/palette.ts"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GACnB,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,OAAO,CAAC;AAEZ,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE1D,gDAAgD;AAChD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAEvD,uFAAuF;AACvF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AA8ErD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,eAAe,CAgD1F;AAkED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACtC,eAAe,CAcjB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Platform, type ThemeOverride, type TokenGroup } from './types';
|
|
2
|
+
export { applyThemeOverride, DEFAULT_PRESET } from './applyThemeOverride';
|
|
3
|
+
export type { ApplyThemeOverrideOptions, ApplyThemeOverrideResult } from './applyThemeOverride';
|
|
4
|
+
/** Per-mode CSS variable maps ready for `Uniwind.updateCSSVariables`. */
|
|
5
|
+
export interface CssVariableMaps {
|
|
6
|
+
light: Record<string, string>;
|
|
7
|
+
dark: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/** Runtime map: token dot-paths → CSS custom property names. */
|
|
10
|
+
export type RuntimeMap = Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Check whether a `ThemeOverride`'s schema version is supported by the current
|
|
13
|
+
* build of `@cdx-ui/styles`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSchemaVersionSupported(override: ThemeOverride): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a nested DTCG preset patch (sparse, `$type`/`$value` leaves) into
|
|
18
|
+
* per-mode CSS variable maps suitable for `Uniwind.updateCSSVariables`.
|
|
19
|
+
*
|
|
20
|
+
* @param patch - A sparse DTCG token object (preset patch).
|
|
21
|
+
* @param runtimeMap - The generated token-to-CSS-var mapping.
|
|
22
|
+
* @param runtimePlatform - Current platform (`'web' | 'ios' | 'android'`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function presetPatchToUniwindMaps(patch: TokenGroup, runtimeMap: RuntimeMap, runtimePlatform: Platform): CssVariableMaps;
|
|
25
|
+
/**
|
|
26
|
+
* Convert a hybrid FI override (`ThemeOverride`) into per-mode CSS variable
|
|
27
|
+
* maps suitable for `Uniwind.updateCSSVariables`.
|
|
28
|
+
*
|
|
29
|
+
* Processing:
|
|
30
|
+
* 1. Generate palettes from color `inputs` (via S4).
|
|
31
|
+
* 2. Map font inputs to token paths.
|
|
32
|
+
* 3. For each mode, merge palette + fonts + explicit `overrides.{mode}` entries.
|
|
33
|
+
* 4. Map all token dot-paths to CSS variable names via runtime map.
|
|
34
|
+
*
|
|
35
|
+
* @param override - A `ThemeOverride` object.
|
|
36
|
+
* @param runtimeMap - The generated token-to-CSS-var mapping.
|
|
37
|
+
* @param runtimePlatform - Current platform (`'web' | 'ios' | 'android'`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function themeOverrideToUniwindMaps(override: ThemeOverride, runtimeMap: RuntimeMap): CssVariableMaps;
|
|
40
|
+
//# sourceMappingURL=theming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theming.d.ts","sourceRoot":"","sources":["../../src/theming.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,UAAU,EAEhB,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMhG,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAMhD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAGzE;AAgFD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,QAAQ,GACxB,eAAe,CAIjB;AA+CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,UAAU,GAErB,eAAe,CAgEjB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** A DTCG token leaf node. */
|
|
2
|
+
export interface TokenValue {
|
|
3
|
+
$type: string;
|
|
4
|
+
$value: string | number;
|
|
5
|
+
$extensions?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
/** Recursive token group — every non-leaf node in a theme object. */
|
|
8
|
+
export interface TokenGroup {
|
|
9
|
+
[key: string]: TokenValue | TokenGroup;
|
|
10
|
+
}
|
|
11
|
+
/** The three built-in Forge UI theme presets. */
|
|
12
|
+
export type Preset = 'poise' | 'prestige' | 'pulse';
|
|
13
|
+
/** Theme metadata stored under `$extensions.com.forge.ui.theme`. */
|
|
14
|
+
export interface ThemeMetadata {
|
|
15
|
+
name: string;
|
|
16
|
+
preset: Preset;
|
|
17
|
+
schemaVersion: string;
|
|
18
|
+
}
|
|
19
|
+
/** Override metadata stored under `$extensions.com.forge.ui.themeOverride`. */
|
|
20
|
+
export interface ThemeOverrideMetadata {
|
|
21
|
+
basePreset: Preset;
|
|
22
|
+
schemaVersion: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A complete Forge UI theme object (DTCG-compatible).
|
|
26
|
+
*
|
|
27
|
+
* Presets (Poise, Prestige, Pulse) are full theme objects. At runtime the
|
|
28
|
+
* build-time default preset is augmented by FI overrides via
|
|
29
|
+
* `applyThemeOverrides`.
|
|
30
|
+
*/
|
|
31
|
+
export type ThemeObject = TokenGroup & {
|
|
32
|
+
$extensions: {
|
|
33
|
+
'com.forge.ui.theme': ThemeMetadata;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
modes: {
|
|
37
|
+
light: TokenGroup;
|
|
38
|
+
dark: TokenGroup;
|
|
39
|
+
};
|
|
40
|
+
platform: {
|
|
41
|
+
web: TokenGroup;
|
|
42
|
+
ios: TokenGroup;
|
|
43
|
+
android: TokenGroup;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A theme override using the hybrid input + semantic structure.
|
|
48
|
+
*
|
|
49
|
+
* - `inputs` — flat map of abstract FI-selected brand values (e.g.
|
|
50
|
+
* `brandPrimary`, `displayFont`). Palette generation expands these into
|
|
51
|
+
* full token scales at runtime.
|
|
52
|
+
* - `overrides` — per-mode flat maps of token dot-paths to resolved values
|
|
53
|
+
* for direct semantic token overrides beyond what inputs generate.
|
|
54
|
+
* - `$extensions` — required metadata including base preset and schema version.
|
|
55
|
+
*/
|
|
56
|
+
export interface ThemeOverride {
|
|
57
|
+
$extensions: {
|
|
58
|
+
'com.forge.ui.themeOverride': ThemeOverrideMetadata;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
inputs?: Record<string, string | number>;
|
|
62
|
+
overrides?: Partial<Record<Mode, Record<string, string | number>>>;
|
|
63
|
+
}
|
|
64
|
+
export type Mode = 'light' | 'dark';
|
|
65
|
+
export type Platform = 'web' | 'ios' | 'android';
|
|
66
|
+
/** Current override schema version. Consuming apps gate compatibility on this. */
|
|
67
|
+
export declare const OVERRIDE_SCHEMA_VERSION: "1.0.0";
|
|
68
|
+
/**
|
|
69
|
+
* Schema versions that consuming apps accept. Includes the current version and
|
|
70
|
+
* may include the immediately prior version during transition windows.
|
|
71
|
+
* @see docs/internal/token-architecture/16-override-structure.md § 4
|
|
72
|
+
*/
|
|
73
|
+
export declare const SUPPORTED_OVERRIDE_SCHEMA_VERSIONS: readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Schema-level mapping from known input keys to the token path pattern each
|
|
76
|
+
* affects. Used by override application (S5) to route inputs to the correct
|
|
77
|
+
* palette/token namespace. Distinct from the full runtime map (S3).
|
|
78
|
+
*/
|
|
79
|
+
export declare const INPUT_TOKEN_MAP: {
|
|
80
|
+
readonly brandPrimary: "color.brand";
|
|
81
|
+
readonly accentPrimary: "color.accent";
|
|
82
|
+
readonly basePrimary: "color.base";
|
|
83
|
+
readonly displayFont: "font.display";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Allowed display font families per preset, consumed by the theme editor for
|
|
87
|
+
* font selection and by consuming apps for validation.
|
|
88
|
+
*/
|
|
89
|
+
export declare const presetFonts: Record<Preset, readonly string[]>;
|
|
90
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAIA,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;CACxC;AAED,iDAAiD;AACjD,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAEpD,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,WAAW,EAAE;QACX,oBAAoB,EAAE,aAAa,CAAC;QACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,KAAK,EAAE;QACL,KAAK,EAAE,UAAU,CAAC;QAClB,IAAI,EAAE,UAAU,CAAC;KAClB,CAAC;IACF,QAAQ,EAAE;QACR,GAAG,EAAE,UAAU,CAAC;QAChB,GAAG,EAAE,UAAU,CAAC;QAChB,OAAO,EAAE,UAAU,CAAC;KACrB,CAAC;CACH,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE;QACX,4BAA4B,EAAE,qBAAqB,CAAC;QACpD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;CACpE;AAED,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC;AACpC,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;AAMjD,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,EAAG,OAAgB,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,SAAS,MAAM,EAAuB,CAAC;AAExF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;CAKe,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAIhD,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
* variants, plus web platform fonts (Inter, IBM Plex Mono) on web.
|
|
4
|
-
*
|
|
5
|
-
* This is a pure font loader with no preset or FI config awareness. Font
|
|
6
|
-
* selection is handled by the CSS variable layer via theme tokens.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useCdxFonts(): {
|
|
9
|
-
loaded: boolean;
|
|
10
|
-
error: Error | null;
|
|
11
|
-
};
|
|
1
|
+
/** @deprecated Use `useForgeFonts` instead. Will be removed in a future major release. */
|
|
2
|
+
export { useForgeFonts as useCdxFonts } from './useForgeFonts';
|
|
12
3
|
//# sourceMappingURL=useCdxFonts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCdxFonts.d.ts","sourceRoot":"","sources":["../../src/useCdxFonts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCdxFonts.d.ts","sourceRoot":"","sources":["../../src/useCdxFonts.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,EAAE,aAAa,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads all Forge UI fonts — 9 display fonts (3 per preset) with weight/italic
|
|
3
|
+
* variants, plus web platform fonts (Inter, IBM Plex Mono) on web.
|
|
4
|
+
*
|
|
5
|
+
* This is a pure font loader with no preset or FI config awareness. Font
|
|
6
|
+
* selection is handled by the CSS variable layer via theme tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useForgeFonts(): {
|
|
9
|
+
loaded: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useForgeFonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForgeFonts.d.ts","sourceRoot":"","sources":["../../src/useForgeFonts.ts"],"names":[],"mappings":"AAuNA;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAOxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/styles",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.80",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -19,13 +19,24 @@
|
|
|
19
19
|
"./vanilla.css": "./css/vanilla.css",
|
|
20
20
|
"./presets/poise.json": "./tokens/presets/poise.json",
|
|
21
21
|
"./presets/prestige.json": "./tokens/presets/prestige.json",
|
|
22
|
-
"./presets/pulse.json": "./tokens/presets/pulse.json"
|
|
22
|
+
"./presets/pulse.json": "./tokens/presets/pulse.json",
|
|
23
|
+
"./theming": {
|
|
24
|
+
"react-native": "./src/theming.ts",
|
|
25
|
+
"types": "./lib/typescript/theming.d.ts",
|
|
26
|
+
"import": "./lib/module/theming.js",
|
|
27
|
+
"require": "./lib/commonjs/theming.js",
|
|
28
|
+
"default": "./lib/module/theming.js"
|
|
29
|
+
},
|
|
30
|
+
"./runtime/token-to-css-var.json": "./runtime/token-to-css-var.json",
|
|
31
|
+
"./runtime/prestige-vs-default.json": "./runtime/prestige-vs-default.json",
|
|
32
|
+
"./runtime/pulse-vs-default.json": "./runtime/pulse-vs-default.json"
|
|
23
33
|
},
|
|
24
34
|
"files": [
|
|
25
35
|
"lib",
|
|
26
36
|
"src",
|
|
27
37
|
"css",
|
|
28
|
-
"tokens"
|
|
38
|
+
"tokens",
|
|
39
|
+
"runtime"
|
|
29
40
|
],
|
|
30
41
|
"react-native-builder-bob": {
|
|
31
42
|
"source": "src",
|
|
@@ -42,6 +53,7 @@
|
|
|
42
53
|
]
|
|
43
54
|
},
|
|
44
55
|
"dependencies": {
|
|
56
|
+
"@adobe/leonardo-contrast-colors": "1.1.0",
|
|
45
57
|
"@expo-google-fonts/bitter": "0.4.1",
|
|
46
58
|
"@expo-google-fonts/cormorant": "0.4.2",
|
|
47
59
|
"@expo-google-fonts/crimson-pro": "0.4.2",
|
|
@@ -53,12 +65,13 @@
|
|
|
53
65
|
"@expo-google-fonts/manrope": "0.4.2",
|
|
54
66
|
"@expo-google-fonts/outfit": "0.4.3",
|
|
55
67
|
"@expo-google-fonts/public-sans": "0.4.2",
|
|
56
|
-
"@cdx-ui/utils": "0.0.1-beta.
|
|
68
|
+
"@cdx-ui/utils": "0.0.1-beta.80"
|
|
57
69
|
},
|
|
58
70
|
"peerDependencies": {
|
|
71
|
+
"expo-font": ">=13.0.0",
|
|
59
72
|
"react": "^18.2.0 || ^19.0.0",
|
|
60
73
|
"react-native": ">=0.76.0",
|
|
61
|
-
"
|
|
74
|
+
"uniwind": ">=1.0.0"
|
|
62
75
|
},
|
|
63
76
|
"peerDependenciesMeta": {
|
|
64
77
|
"react-native": {
|
|
@@ -66,15 +79,20 @@
|
|
|
66
79
|
},
|
|
67
80
|
"expo-font": {
|
|
68
81
|
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"uniwind": {
|
|
84
|
+
"optional": true
|
|
69
85
|
}
|
|
70
86
|
},
|
|
71
87
|
"devDependencies": {
|
|
88
|
+
"@types/jest": "^29.5.14",
|
|
72
89
|
"@types/react": "*",
|
|
73
90
|
"expo-font": "*",
|
|
74
91
|
"react": "*",
|
|
75
92
|
"react-native": "*",
|
|
76
93
|
"react-native-builder-bob": "^0.40.17",
|
|
77
94
|
"style-dictionary": "^4.4.0",
|
|
95
|
+
"ts-jest": "29.4.11",
|
|
78
96
|
"typescript": "~5.9.2"
|
|
79
97
|
},
|
|
80
98
|
"nx": {
|
|
@@ -90,10 +108,11 @@
|
|
|
90
108
|
"access": "public"
|
|
91
109
|
},
|
|
92
110
|
"scripts": {
|
|
93
|
-
"build": "bob build",
|
|
94
|
-
"lint": "eslint src/",
|
|
111
|
+
"build": "bob build && cp -r runtime lib/runtime",
|
|
112
|
+
"lint": "eslint src/ --ignore-pattern '**/__tests__/**'",
|
|
95
113
|
"tokens:fetch": "node scripts/figma-fetch-variables.mjs",
|
|
96
114
|
"tokens:build": "node scripts/build-tokens.mjs",
|
|
97
|
-
"fonts:validate": "node scripts/validate-font-tokens.mjs"
|
|
115
|
+
"fonts:validate": "node scripts/validate-font-tokens.mjs",
|
|
116
|
+
"test": "jest --config jest.config.js"
|
|
98
117
|
}
|
|
99
118
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|