@teacss/preset-standard 0.4.4 → 0.4.5

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 CHANGED
@@ -238,6 +238,32 @@ specialized controls such as file, range, and color inputs have no profile:
238
238
  their native rendering is not a shared shape, so compose the declarations the
239
239
  design actually needs.
240
240
 
241
+ ## Theme Variants
242
+
243
+ Named theme variants live in `theme.themes` (applications declare them with
244
+ `@custom theme <name> {}` / `@custom theme <name> dark {}` in the CSS entry;
245
+ the preset default is an empty record). The theme preflight emits each variant
246
+ after the base `:root` and mode blocks as a zero-specificity
247
+ `:where(.theme-<name>){…}` variable-override block, and each of its
248
+ non-default modes last as
249
+ `:where(<mode> .theme-<name>,.theme-<name>:is(<mode>),.theme-<name> <mode>){…}`
250
+ with the configured mode selector — mode-above, same-element, and mode-below
251
+ arrangements all covered. Toggling the single `theme-<name>` class re-skins a
252
+ subtree with no regeneration; custom-property inheritance resolves nested
253
+ scopes, and `preflight: "on-demand"` filters variant entries like mode
254
+ entries.
255
+
256
+ The bare `theme-<name>` class is a dynamic rule that matches declared variants
257
+ only and emits one internal indicator declaration, `--T-theme: <name>`, so
258
+ the token stays matched and devtools show the active variant; the override CSS
259
+ itself comes from the preflight. Activate themes with the literal class in
260
+ markup — `@apply theme-<name>` (and compile-class strings) inline only that
261
+ indicator declaration, never the variant's variables. In the preset-aware merger, bare kebab
262
+ `theme-*` classes form one opaque merge family like the reset profiles: a
263
+ later theme class replaces an earlier one and never conflicts with ordinary
264
+ property utilities. `@teacss/config` enforces the variant contract — a
265
+ variant may only override values the base theme declares.
266
+
241
267
  This is a TeaCSS-specific subset inspired by the
242
268
  [Radix Themes 3.3.0 Reset](https://github.com/radix-ui/themes/blob/3.3.0/packages/radix-ui-themes/src/components/reset.css),
243
269
  adapted to named atomic profiles and TeaCSS merge semantics rather than copied
package/dist/index.d.ts CHANGED
@@ -110,11 +110,30 @@ interface Theme {
110
110
  }>;
111
111
  /** The mode whose palette is `theme.colors` (need not appear in `modes`). @default "light" */
112
112
  defaultMode?: string;
113
+ /**
114
+ * Named theme variants (`@custom theme <name>`): subtree-scoped variable
115
+ * overrides emitted under `:where(.theme-<name>)` after the base and mode
116
+ * blocks. The bare `theme-<name>` class activates one. A variant may only
117
+ * override values the base theme declares — `@teacss/config` enforces that
118
+ * contract for entry-declared variants.
119
+ */
120
+ themes?: Record<string, ThemeVariant>;
113
121
  /** Root selector(s) used when emitting preflight CSS custom properties */
114
122
  preflightRoot?: Arrayable<string>;
115
123
  /** Additional CSS custom properties merged after the default theme-derived preflight variables */
116
124
  preflightBase?: Record<string, string | number>;
117
125
  }
126
+ /**
127
+ * One named theme variant: the scalar scales plus color-only mode overrides
128
+ * (entry-authored variants carry only `dark`). Structural records, mode
129
+ * bookkeeping, and preflight options stay top-level-theme-only.
130
+ */
131
+ interface ThemeVariant extends Omit<Theme, "animation" | "modes" | "defaultMode" | "themes" | "preflightRoot" | "preflightBase"> {
132
+ modes?: Record<string, {
133
+ colors?: ColorPalette;
134
+ semanticColors?: SemanticColors;
135
+ }>;
136
+ }
118
137
  type CustomRule = Rule<Theme>;
119
138
  type CustomShortcut = StaticShortcut | DynamicShortcut<Theme>;
120
139
  /** Ancestor selectors for the class-triggered `dark` / `light` modes. @default `.dark` / `.light` */