@teacss/preset-standard 0.6.0 → 0.6.2
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 +91 -54
- package/dist/index.d.ts +4 -7
- package/dist/index.js +9 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -35,14 +35,32 @@ separate. `multiplerKeywords` remains a deprecated alias for
|
|
|
35
35
|
## Application shortcuts
|
|
36
36
|
|
|
37
37
|
```css
|
|
38
|
-
@shortcut
|
|
39
|
-
@shortcut truncate "overflow:hidden text-overflow:ellipsis white-space:nowrap";
|
|
38
|
+
@shortcut stack-row "d:flex flex-direction:row align-items:center";
|
|
39
|
+
@shortcut text-truncate "overflow:hidden text-overflow:ellipsis white-space:nowrap";
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Declarations may live in the CSS entry, imported CSS, or CSS matched by
|
|
43
43
|
`@source`. Conditions remain valid on use, and the last declaration of a name
|
|
44
44
|
wins. Programmatic shortcuts use Core's generic `UserConfig` types.
|
|
45
45
|
|
|
46
|
+
## Paired sizing and logical dividers
|
|
47
|
+
|
|
48
|
+
For text-flow sizing, `size:4x`, `min-size:4x`, and `max-size:4x` set both
|
|
49
|
+
inline and block sizes. For fixed geometry, use `dimensions:4x`,
|
|
50
|
+
`min-dimensions:4x`, and `max-dimensions:4x` for width and height. These are
|
|
51
|
+
ordinary Standard declarations. Values must be accepted by both underlying
|
|
52
|
+
single-axis rules. Variables, arbitrary values, and suffix conditions work as
|
|
53
|
+
they do on those rules. `size:screen` emits `100vi` and `100vb`;
|
|
54
|
+
`dimensions:screen` emits `100vw` and `100vh`.
|
|
55
|
+
|
|
56
|
+
`divide-inline-width:` and `divide-block-width:` draw on logical inline-end
|
|
57
|
+
and block-end edges. `divide-x-width:` and `divide-y-width:` keep physical
|
|
58
|
+
right and bottom edges. `divide-color:` and `divide-style:` supply common
|
|
59
|
+
settings. `divide-inline-color/style:` and `divide-block-color/style:` override
|
|
60
|
+
only the named logical axis. Color and style alone do not draw a divider; each
|
|
61
|
+
axis needs its own width. To change axes at a breakpoint, set the old width to
|
|
62
|
+
`0` and the new width explicitly.
|
|
63
|
+
|
|
46
64
|
## Preflight and themes
|
|
47
65
|
|
|
48
66
|
Preflight emits low-specificity reset rules and theme variables. Set
|
|
@@ -90,26 +108,14 @@ for Safari/VoiceOver. The reset adds no brand palette or global motion policy.
|
|
|
90
108
|
Element-local `reset-*` shortcuts belong to the optional Official preset;
|
|
91
109
|
Standard does not register those classes.
|
|
92
110
|
|
|
93
|
-
###
|
|
111
|
+
### Global role palettes and color scheme
|
|
94
112
|
|
|
95
|
-
|
|
113
|
+
Standard has seven 12-step roles: primary → gray, neutral → sage, focused →
|
|
114
|
+
neutral, success → jade, warning → amber, failure → red, and general → blue.
|
|
115
|
+
Use numbered roles directly, such as `bg-color:primary-200 text-color:primary-950`.
|
|
116
|
+
Official adds structure without background/hover/foreground color aliases.
|
|
96
117
|
|
|
97
|
-
|
|
98
|
-
focused → neutral, success → jade, warning → amber, failure → red, general → blue. Use
|
|
99
|
-
`bg-color:primary-200 text-color:primary-950` directly. Neither Standard nor
|
|
100
|
-
Official adds background/hover/foreground aliases; role steps already describe
|
|
101
|
-
those uses. Keep palette selection in central configuration.
|
|
102
|
-
|
|
103
|
-
The role order is primary, neutral, then the states: focused, success, warning,
|
|
104
|
-
failure, general. Focused follows the resolved neutral scale at each step when
|
|
105
|
-
no focused selection applies, including when `@focused` is omitted. Declaring
|
|
106
|
-
`@focused` only enables choices; it does not change this fallback. A configured
|
|
107
|
-
`data-css-focused` selection overrides it. Empty, unknown or undeclared selections
|
|
108
|
-
return to the region’s neutral palette; `theme.rolePalettes.focused: []` clears
|
|
109
|
-
independent choices. Application `@custom` overrides still take precedence in
|
|
110
|
-
the base mapping.
|
|
111
|
-
|
|
112
|
-
Declare selectable physical palettes in the CSS entry:
|
|
118
|
+
The CSS entry registers the selectable built-in physical palettes:
|
|
113
119
|
|
|
114
120
|
```css
|
|
115
121
|
@presets "standard,official";
|
|
@@ -123,43 +129,70 @@ Declare selectable physical palettes in the CSS entry:
|
|
|
123
129
|
@teacss;
|
|
124
130
|
```
|
|
125
131
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
Repeated/imported lists union and sort. They enable choices without changing
|
|
133
|
+
defaults; removing every list for a role clears its choices. Only Standard's
|
|
134
|
+
original built-in physical palette names are candidates. Overrides through
|
|
135
|
+
`@custom` or `theme.colors` keep that identity; custom names remain available to
|
|
136
|
+
ordinary color utilities but cannot become role candidates. Enabled palettes
|
|
137
|
+
need all 12 effective steps and no direct/transitive role references, including
|
|
138
|
+
mode overrides, `preflightBase`, and variable fallbacks. Candidate registration
|
|
139
|
+
has no public Theme field; programmatic consumers load the CSS entry with
|
|
140
|
+
`resolveEntryConfig()`.
|
|
132
141
|
|
|
133
142
|
```html
|
|
134
|
-
<html data-css-primary="
|
|
135
|
-
<body>
|
|
136
|
-
<section data-css-primary="red" data-css-mode="light">
|
|
137
|
-
<p>Red / sage / light</p>
|
|
138
|
-
<article data-css-neutral="slate">Gray / slate / dark</article>
|
|
139
|
-
</section>
|
|
140
|
-
</body>
|
|
143
|
+
<html data-css-primary="blue" data-css-neutral="slate" data-css-scheme="dark">
|
|
144
|
+
<body><p class="text-color:primary-900">Global blue / slate / dark</p></body>
|
|
141
145
|
</html>
|
|
142
146
|
```
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
root
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
Only html role attributes, `data-css-scheme` and configured mode aliases select
|
|
149
|
+
colors. Descendants inherit; the same markers on descendants have no effect.
|
|
150
|
+
Missing, empty, unknown or undeclared role values use configured defaults.
|
|
151
|
+
Focused defaults to final global neutral while preserving explicit default
|
|
152
|
+
step overrides. Valid root focused selection chooses an independent palette.
|
|
153
|
+
Changing root attributes switches registered candidates without regenerating CSS.
|
|
154
|
+
|
|
155
|
+
`@dark` / `@light` inspect html for every final target, including pseudo-elements.
|
|
156
|
+
Without a valid explicit mode, neither condition activates, even when `defaultMode` is
|
|
157
|
+
dark; `defaultMode` names the base table. OS conditions remain independent media
|
|
158
|
+
queries. `modeSelectors: { dark: ".night", light: ".day" }` adds optional aliases
|
|
159
|
+
on html. Canonical `data-css-scheme` wins even when empty/invalid; conflicting
|
|
160
|
+
aliases select neither mode. Aliases are never implicit. Mode names preserve
|
|
161
|
+
case, spaces and punctuation; empty names, NUL and unpaired surrogates are invalid.
|
|
162
|
+
|
|
163
|
+
Theme output uses zero-specificity ordinary html selectors: base variables once,
|
|
164
|
+
mode differences, then independent role mappings. Each role/candidate mapping is
|
|
165
|
+
emitted once, without multiplying it by modes or other roles. `preflightRoot`
|
|
166
|
+
adds explicit re-declaration targets that always use html selections; it does not
|
|
167
|
+
enable local colors. On-demand preflight retains the consumed dependency closure
|
|
168
|
+
through all registered candidates and effective modes. With preflight disabled,
|
|
169
|
+
root mode conditions still work but the application supplies variables.
|
|
159
170
|
|
|
160
171
|
Global `@custom` sets scales and colors; `@custom dark` changes colors only.
|
|
161
|
-
Whole-theme variants are unsupported.
|
|
162
|
-
|
|
172
|
+
Whole-theme variants and role scheme blocks are unsupported. Color selection
|
|
173
|
+
never resets inherited spacing or changes radius/shadow geometry.
|
|
174
|
+
|
|
175
|
+
### Spacing scaling
|
|
176
|
+
|
|
177
|
+
The default chain is `--scaling → --spacing → default 1x…9x`:
|
|
178
|
+
|
|
179
|
+
```css
|
|
180
|
+
--spacing: calc(0.25rem * var(--scaling, 1));
|
|
181
|
+
--spacing-1x: var(--spacing);
|
|
182
|
+
--spacing-5x: calc(var(--spacing) * 6);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Set the existing variable utility on html, such as `$scaling:0.5@sm`, to halve
|
|
186
|
+
numeric and default named spacing at the configured `sm` breakpoint (768px by
|
|
187
|
+
default). Named multipliers remain `1,2,3,4,6,8,10,12,16`. Only the base formula
|
|
188
|
+
reads scaling; no extra multiplier or default `--scaling` declaration is emitted.
|
|
189
|
+
|
|
190
|
+
A root override of `--spacing` replaces the base formula and also changes default
|
|
191
|
+
named steps. Explicit named overrides remain final values; reference `--spacing`
|
|
192
|
+
to make a custom step follow the chain. Fixed lengths and unrelated scales are
|
|
193
|
+
unchanged. Variables resolve where declared, so a descendant-only scaling change
|
|
194
|
+
does not recompute inherited root spacing. Existing `preflightRoot` follows normal
|
|
195
|
+
CSS re-declaration semantics. No density configuration or additional rule is needed.
|
|
163
196
|
|
|
164
197
|
### Relationship markers
|
|
165
198
|
|
|
@@ -181,7 +214,7 @@ Names are case-sensitive. Group remains descendant matching, peer uses `~`.
|
|
|
181
214
|
`@lang-<tag>` compares the complete root `html:root[lang]` value, ignoring ASCII
|
|
182
215
|
case without trimming. Here `@lang-zh` matches and `@lang-en` does not.
|
|
183
216
|
`zh`, `zh-CN`, and `zh-Hans` are independent: `@lang-zh` does not match a root
|
|
184
|
-
value of `zh-CN`. Local `lang
|
|
217
|
+
value of `zh-CN`. Local `lang` and descendant color markers do not override the root
|
|
185
218
|
language.
|
|
186
219
|
Root elements, descendants, targets, and pseudo-elements share this condition.
|
|
187
220
|
|
|
@@ -235,7 +268,7 @@ explicit display and overflow can override `line-clamp`'s corresponding declarat
|
|
|
235
268
|
## Value and composition boundaries
|
|
236
269
|
|
|
237
270
|
- Logical border width/style pairs accept two arbitrary components, such as
|
|
238
|
-
`border-
|
|
271
|
+
`border-inline-width:[1px_2px]`; physical x/y and single-edge forms accept one.
|
|
239
272
|
- `[…]` keeps structurally valid arbitrary CSS, including
|
|
240
273
|
`animation-name:[var(--name)]`. It does not guarantee browser support.
|
|
241
274
|
- Custom-variable values and `font-palette` use the shared structural checks;
|
|
@@ -247,7 +280,11 @@ explicit display and overflow can override `line-clamp`'s corresponding declarat
|
|
|
247
280
|
`shadow:$shadow-card` reads a complete raw variable without recoloring;
|
|
248
281
|
`box-shadow:[…]` replaces the whole composed surface.
|
|
249
282
|
- Named animations quote their decoded CSS names to avoid shorthand keyword
|
|
250
|
-
ambiguity. Numeric zero iteration counts remain zero.
|
|
283
|
+
ambiguity. Numeric zero iteration counts remain zero. `animation:spin` rotates
|
|
284
|
+
at `1s linear infinite`; `animation:spinner` fades a spinner leaf from opacity
|
|
285
|
+
`1` to `.25` at `800ms linear infinite`. Duration, timing, and iteration
|
|
286
|
+
utilities override these defaults. Gate decorative motion with `@motion-safe`
|
|
287
|
+
or stop it with `animation:none@motion-reduce`.
|
|
251
288
|
- Bare background/mask sizes cannot be negative.
|
|
252
289
|
- Border-spacing axis variables do not inherit into nested tables.
|
|
253
290
|
- Gradient properties are registered on demand, retaining shared fallbacks
|
|
@@ -260,7 +297,7 @@ exactly `on`, with ordinary importance and suffix conditions:
|
|
|
260
297
|
|
|
261
298
|
```txt
|
|
262
299
|
mask-g-linear:on mask-g-radial:on mask-g-conic:on
|
|
263
|
-
space-x-reverse:on space-y-reverse:on space-
|
|
300
|
+
space-x-reverse:on space-y-reverse:on space-inline-reverse:on space-block-reverse:on
|
|
264
301
|
```
|
|
265
302
|
|
|
266
303
|
Use `divide-x-width:1` / `divide-y-width:1` for 1px child dividers. The former
|
package/dist/index.d.ts
CHANGED
|
@@ -64,7 +64,6 @@ declare function transformerCompileClass(options?: CompileClassOptions): SourceC
|
|
|
64
64
|
type ColorPalette = Record<string, Record<string, string>>;
|
|
65
65
|
/** Semantic color roles emitted as `--color-<role>` variables. */
|
|
66
66
|
type SemanticColors = Record<string, string | number>;
|
|
67
|
-
type ColorRole = "primary" | "neutral" | "focused" | "success" | "warning" | "failure" | "general";
|
|
68
67
|
interface ThemeAnimation {
|
|
69
68
|
keyframes?: Record<string, string>;
|
|
70
69
|
durations?: Record<string, string>;
|
|
@@ -77,8 +76,6 @@ interface Theme {
|
|
|
77
76
|
colors?: ColorPalette;
|
|
78
77
|
/** Application semantic colors. Presets supply an empty namespace. */
|
|
79
78
|
semanticColors?: SemanticColors;
|
|
80
|
-
/** Physical palettes available through each data-css-<role> attribute. Lists replace per role. */
|
|
81
|
-
rolePalettes?: Partial<Record<ColorRole, readonly string[]>>;
|
|
82
79
|
breakpoint?: Record<string, string>;
|
|
83
80
|
container?: Record<string, string>;
|
|
84
81
|
spacing?: Record<string, string>;
|
|
@@ -103,7 +100,7 @@ interface Theme {
|
|
|
103
100
|
/**
|
|
104
101
|
* Non-default mode color overrides. `theme.colors` and
|
|
105
102
|
* `theme.semanticColors` are the default mode; each entry here (e.g. `dark`)
|
|
106
|
-
* contributes to the complete mapping for its `data-css-
|
|
103
|
+
* contributes to the complete mapping for its `data-css-scheme` on html (or a
|
|
107
104
|
* configured `dark`/`light` alias). Only declare values that differ. OS
|
|
108
105
|
* preference uses `@os-dark` / `@os-light`.
|
|
109
106
|
*/
|
|
@@ -113,19 +110,19 @@ interface Theme {
|
|
|
113
110
|
}>;
|
|
114
111
|
/** The mode whose palette is `theme.colors` (need not appear in `modes`). @default "light" */
|
|
115
112
|
defaultMode?: string;
|
|
116
|
-
/** Additional declaration points
|
|
113
|
+
/** Additional declaration points that re-declare the complete theme selected on html. */
|
|
117
114
|
preflightRoot?: Arrayable<string>;
|
|
118
115
|
/** Additional CSS custom properties merged after the default theme-derived preflight variables */
|
|
119
116
|
preflightBase?: Record<string, string | number>;
|
|
120
117
|
}
|
|
121
118
|
type CustomRule = Rule<Theme>;
|
|
122
|
-
/** Optional
|
|
119
|
+
/** Optional html selector aliases for `dark` / `light`; canonical `data-css-scheme` takes precedence. */
|
|
123
120
|
interface ModeSelectors {
|
|
124
121
|
dark?: string;
|
|
125
122
|
light?: string;
|
|
126
123
|
}
|
|
127
124
|
interface PresetStandardOptions extends PresetOptions {
|
|
128
|
-
/** Add `dark` / `light`
|
|
125
|
+
/** Add `dark` / `light` html aliases, e.g. `{ dark: ".night" }`; no aliases are enabled by default. */
|
|
129
126
|
modeSelectors?: ModeSelectors;
|
|
130
127
|
/**
|
|
131
128
|
* Container sizes for the `@container-*` conditions, merged over the default
|