@ikas/bp-storefront 1.4.0-beta.87 → 1.4.0-beta.88
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.
|
@@ -76,6 +76,15 @@ export type KeyframeToken = {
|
|
|
76
76
|
styles?: StyleEntry[];
|
|
77
77
|
}[];
|
|
78
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* A color SLOT — one entry of the top-level `getThemeColorSchemes().schemes` list. It is a
|
|
81
|
+
* label only (`id` + display `name`); the actual colors for the slot live in each palette's
|
|
82
|
+
* `colorsByScheme[id]`.
|
|
83
|
+
*/
|
|
84
|
+
export type ColorSchemeSlot = {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
};
|
|
79
88
|
/**
|
|
80
89
|
* A color palette (one entry of `getThemeColorSchemes().values`). Its colors live in
|
|
81
90
|
* `colorsByScheme` — the top-level `schemes` list holds only slot id→name labels.
|
|
@@ -104,13 +113,40 @@ export type ThemeGlobals = {
|
|
|
104
113
|
breakpoints: BreakpointToken[];
|
|
105
114
|
keyframes: KeyframeToken[];
|
|
106
115
|
colorSchemes: {
|
|
107
|
-
schemes:
|
|
108
|
-
id: string;
|
|
109
|
-
name: string;
|
|
110
|
-
}[];
|
|
116
|
+
schemes: ColorSchemeSlot[];
|
|
111
117
|
values: ColorSchemeToken[];
|
|
112
118
|
};
|
|
113
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Runtime-facing token views returned by the `@ikas/bp-storefront` getters
|
|
122
|
+
* (`getThemeColors` / `getThemeTypography` / ...). They intentionally OMIT `name`: at runtime
|
|
123
|
+
* a token must be identified by its STABLE `id` (color → `cssVar` / `var(--<id>)`, typography
|
|
124
|
+
* & keyframe → `className`/`ref` `_<id>`, color-scheme slot → a `colorsByScheme` key), NEVER by
|
|
125
|
+
* its human name. Names are non-unique (two design assets can ship the same name) and renaming
|
|
126
|
+
* them must not break references, so reading `.name` at render is an anti-pattern — hiding it
|
|
127
|
+
* from the return type turns that into a compile error.
|
|
128
|
+
*
|
|
129
|
+
* The full types above (with `name`) are still produced in the serialized {@link ThemeGlobals}
|
|
130
|
+
* payload and surfaced by the CLI/MCP `list-theme-globals` AUTHORING read, so the agent/editor
|
|
131
|
+
* can still discover and reuse existing tokens by name. `name` is hidden ONLY from the runtime
|
|
132
|
+
* getter return types.
|
|
133
|
+
*/
|
|
134
|
+
export type RuntimeDesignToken = Omit<DesignToken, "name">;
|
|
135
|
+
export type RuntimeTypographyToken = Omit<TypographyToken, "name">;
|
|
136
|
+
export type RuntimeBreakpointToken = Omit<BreakpointToken, "name">;
|
|
137
|
+
export type RuntimeKeyframeToken = Omit<KeyframeToken, "name">;
|
|
138
|
+
export type RuntimeColorSchemeToken = Omit<ColorSchemeToken, "name">;
|
|
139
|
+
export type RuntimeColorSchemeSlot = Omit<ColorSchemeSlot, "name">;
|
|
140
|
+
/**
|
|
141
|
+
* Runtime view of {@link ThemeGlobals.colorSchemes} (returned by `getThemeColorSchemes`). The
|
|
142
|
+
* slot list carries only `{ id }`: slot display LABELS (the slot `name`) are authoring-only —
|
|
143
|
+
* read them via the CLI/MCP `list-theme-globals` or the editor, not at runtime. Render a palette
|
|
144
|
+
* by iterating each value's `colorsByScheme`, keyed by slot id.
|
|
145
|
+
*/
|
|
146
|
+
export type RuntimeThemeColorSchemes = {
|
|
147
|
+
schemes: RuntimeColorSchemeSlot[];
|
|
148
|
+
values: RuntimeColorSchemeToken[];
|
|
149
|
+
};
|
|
114
150
|
export declare const EMPTY_THEME_GLOBALS: ThemeGlobals;
|
|
115
151
|
type StyleValueLike = {
|
|
116
152
|
value?: any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RuntimeBreakpointToken, RuntimeDesignToken, RuntimeKeyframeToken, RuntimeThemeColorSchemes, RuntimeTypographyToken, ThemeSetting } from "../../storefront-config/src";
|
|
2
2
|
/**
|
|
3
3
|
* Register the live global-variable object (`_g_`) so `getThemeSetting`/`getThemeSettings`
|
|
4
4
|
* return actual runtime values (constants, computed getters, and in-editor edits) instead
|
|
@@ -19,37 +19,30 @@ export declare function getThemeSetting(name: string): ThemeSetting | undefined;
|
|
|
19
19
|
/** Convenience: the resolved value of a global variable, or `undefined` if not found. */
|
|
20
20
|
export declare function getThemeSettingValue(name: string): any;
|
|
21
21
|
/** Theme color tokens. Each carries a resolved value and a `var(--id)` CSS reference. */
|
|
22
|
-
export declare function getThemeColors():
|
|
22
|
+
export declare function getThemeColors(): RuntimeDesignToken[];
|
|
23
23
|
/** Theme typography tokens (text styles). Apply `className` or read `resolved` CSS values. */
|
|
24
|
-
export declare function getThemeTypography():
|
|
25
|
-
/** Theme responsive breakpoints (`{ id,
|
|
26
|
-
export declare function getThemeBreakpoints():
|
|
24
|
+
export declare function getThemeTypography(): RuntimeTypographyToken[];
|
|
25
|
+
/** Theme responsive breakpoints (`{ id, width }`). */
|
|
26
|
+
export declare function getThemeBreakpoints(): RuntimeBreakpointToken[];
|
|
27
27
|
/** Theme keyframe/transition animations. Use `ref` as the CSS animation name. */
|
|
28
|
-
export declare function getThemeKeyframes():
|
|
28
|
+
export declare function getThemeKeyframes(): RuntimeKeyframeToken[];
|
|
29
29
|
/**
|
|
30
30
|
* Theme color schemes (palettes). Returns two PARALLEL lists with different jobs:
|
|
31
|
-
* - `schemes`: the color SLOTS as `{ id
|
|
32
|
-
*
|
|
31
|
+
* - `schemes`: the color SLOTS as `{ id }` only — no colors and no display label live here at
|
|
32
|
+
* runtime. A slot's human name is authoring-only (read it via the CLI/MCP `list-theme-globals`
|
|
33
|
+
* or the editor); at runtime identify a slot solely by its `id`.
|
|
33
34
|
* - `values`: the actual palettes. A palette's colors live in its `colorsByScheme`
|
|
34
35
|
* map, keyed by slot id → `{ resolved, cssVar }`.
|
|
35
36
|
*
|
|
36
37
|
* To render swatches, iterate `values[].colorsByScheme` (the source of truth for
|
|
37
|
-
* colors), NOT the top-level `schemes` array — `schemes` carries
|
|
38
|
-
* iterating it renders empty
|
|
39
|
-
* slot-id key:
|
|
38
|
+
* colors), NOT the top-level `schemes` array — `schemes` carries slot ids only, so
|
|
39
|
+
* iterating it renders empty:
|
|
40
40
|
*
|
|
41
|
-
* const {
|
|
42
|
-
* const slotName = (id: string) => schemes.find(s => s.id === id)?.name ?? id;
|
|
41
|
+
* const { values } = getThemeColorSchemes();
|
|
43
42
|
* values.forEach(palette =>
|
|
44
43
|
* Object.entries(palette.colorsByScheme).forEach(([slotId, { resolved, cssVar }]) => {
|
|
45
|
-
* //
|
|
44
|
+
* // slotId → stable slot key, cssVar → live var() ref (prefer this), resolved → hex snapshot
|
|
46
45
|
* })
|
|
47
46
|
* );
|
|
48
47
|
*/
|
|
49
|
-
export declare function getThemeColorSchemes():
|
|
50
|
-
schemes: {
|
|
51
|
-
id: string;
|
|
52
|
-
name: string;
|
|
53
|
-
}[];
|
|
54
|
-
values: ColorSchemeToken[];
|
|
55
|
-
};
|
|
48
|
+
export declare function getThemeColorSchemes(): RuntimeThemeColorSchemes;
|