@cssints/css-grammar 0.2.0 → 0.3.1
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 +88 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,22 +31,27 @@ way, each beside `cssints` (`npm install --save-dev @cssints/fluid`); the list i
|
|
|
31
31
|
import cssints, { cssTarget, targets } from "cssints/vite";
|
|
32
32
|
|
|
33
33
|
export default {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
plugins: [cssints()],
|
|
35
|
+
css: { transformer: "lightningcss", lightningcss: { targets } },
|
|
36
|
+
build: { cssMinify: "lightningcss", cssTarget },
|
|
37
37
|
};
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
// the entry, once
|
|
42
42
|
import "virtual:cssints.css";
|
|
43
|
+
import { reset } from "@cssints/reset" with { type: "cssints" };
|
|
44
|
+
|
|
45
|
+
reset();
|
|
43
46
|
```
|
|
44
47
|
|
|
48
|
+
`reset()` is the recommended start: [`@cssints/reset`](packages/reset/README.md) is a small modern reset in a layer below every style, so any style of yours beats it. A project without the call has none, as in any app.
|
|
49
|
+
|
|
45
50
|
`targets` and `cssTarget` come from the browserslist query of the support warnings: the `BROWSERSLIST` variable, else the standard config (`"browserslist"` in `package.json` or `.browserslistrc`, with the `BROWSERSLIST_ENV`, `NODE_ENV` or `production` section), else `defaults`. The exports are computed when `vite.config.ts` is imported, before Vite's root is known, so they look the config up from `process.cwd()` and upward; the support warnings look it up from Vite's `root` (2026-10-09, cssints-p3d2). They are the same when Vite runs from the app's directory; with `vite <dir>` from elsewhere, give `targets` and `cssTarget` the app's config yourself. Vite's CSS minify reads `cssTarget`, not `targets`: without it the minifier merges the declarations of a `firstThatWorks` into the last one. Add `"types": ["vite/client"]` to `tsconfig.json` for the `virtual:` import.
|
|
46
51
|
|
|
47
52
|
### Frameworks
|
|
48
53
|
|
|
49
|
-
Any framework that builds JSX through a Vite plugin works; the engine evaluates your modules itself, so it does not care what the plugin makes of JSX, nor in which order the plugins are listed. `apps/
|
|
54
|
+
Any framework that builds JSX through a Vite plugin works; the engine evaluates your modules itself, so it does not care what the plugin makes of JSX, nor in which order the plugins are listed. `apps/csssky` is the Solid 2 app (`solid-js` and `@solidjs/web` 2.0.0-rc.13, `@solidjs/vite-plugin` 3.0.0-next.47):
|
|
50
55
|
|
|
51
56
|
```ts skip
|
|
52
57
|
// vite.config.ts
|
|
@@ -54,50 +59,89 @@ import solid from "@solidjs/vite-plugin";
|
|
|
54
59
|
import cssints, { cssTarget, targets } from "cssints/vite";
|
|
55
60
|
|
|
56
61
|
export default {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
plugins: [cssints(), solid()],
|
|
63
|
+
css: { transformer: "lightningcss", lightningcss: { targets } },
|
|
64
|
+
build: { cssMinify: "lightningcss", cssTarget },
|
|
60
65
|
};
|
|
61
66
|
```
|
|
62
67
|
|
|
63
68
|
`tsconfig.json` is Solid's: `"jsx": "preserve"`, `"jsxImportSource": "@solidjs/web"`, `"types": ["vite/client"]`. Solid's `class` takes a string, an object or an array, so `cn` is not needed for the join: `class={[card, on() && p(4)]}` and `class={badge({ tone: tone() })}` work as in React. A site's arguments are still build-time values, so a signal goes in the condition or in a `cv` variant, not in `p(n())`. Under `vite dev` an edit of a component replaces it and resets its state below it (Solid's refresh); an edit of a style changes the class strings and the sheet with no reload.
|
|
64
69
|
|
|
65
70
|
```tsx
|
|
66
|
-
import {
|
|
71
|
+
import { reset } from "@cssints/reset" with { type: "cssints" };
|
|
72
|
+
import {
|
|
73
|
+
bg,
|
|
74
|
+
color,
|
|
75
|
+
cn,
|
|
76
|
+
cv,
|
|
77
|
+
flex,
|
|
78
|
+
hover,
|
|
79
|
+
media,
|
|
80
|
+
p,
|
|
81
|
+
style,
|
|
82
|
+
token,
|
|
83
|
+
} from "cssints" with { type: "cssints" };
|
|
84
|
+
|
|
85
|
+
reset();
|
|
67
86
|
|
|
68
87
|
const md = media("(width >= 40rem)");
|
|
69
88
|
const accent = token.color("#2563eb", "accent");
|
|
70
89
|
|
|
71
90
|
const button = cv({
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
base: cn(p(2), color("white"), bg(accent), hover(bg("#1d4ed8"))),
|
|
92
|
+
variants: { wide: { true: md(p(4)) } },
|
|
74
93
|
});
|
|
75
94
|
|
|
76
95
|
export const Row = ({ wide, on }: { wide?: boolean; on?: boolean }) => (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
<div
|
|
97
|
+
className={cn(flex().alignItems("center").gap(2), on && p(1))}
|
|
98
|
+
style={style(token.set(accent, "#dc2626"))}
|
|
99
|
+
>
|
|
100
|
+
<button className={button({ wide })}>Save</button>
|
|
101
|
+
</div>
|
|
80
102
|
);
|
|
81
103
|
```
|
|
82
104
|
|
|
83
|
-
`with { type: "cssints" }` marks what runs at build time. The plugin replaces each call with a class string, so the browser gets `__cx([], "_1s47490 _1ob5z5m _g2iyum", on && "_lqk467")` and `button` is a call of the runtime with `{ base: "_1t8gqy5 ...", ... }`, so it never sees `flex()`. `virtual:cssints.css` is one sheet with every rule once, sorted by layer, then condition, then shorthand before longhand, then class name:
|
|
105
|
+
`with { type: "cssints" }` marks what runs at build time. The plugin replaces each call with a class string, so the browser gets `__cx([], "_1s47490 _1ob5z5m _g2iyum", on && "_lqk467")` and `button` is a call of the runtime with `{ base: "_1t8gqy5 ...", ... }`, so it never sees `flex()`. `virtual:cssints.css` is one sheet with every rule once, sorted by layer, then condition, then shorthand before longhand, then class name (the `@layer reset { ... }` block of `reset()` comes first and is left out here):
|
|
84
106
|
|
|
85
107
|
```css
|
|
86
108
|
@layer _.k, _.a, _.b, _.c, _.d, _.e;
|
|
87
|
-
@property --accent{
|
|
109
|
+
@property --accent {
|
|
110
|
+
syntax: "<color>";
|
|
111
|
+
inherits: true;
|
|
112
|
+
initial-value: #2563eb;
|
|
113
|
+
}
|
|
88
114
|
@layer _.a {
|
|
89
|
-
._1t8gqy5{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
115
|
+
._1t8gqy5 {
|
|
116
|
+
padding: 0.5rem;
|
|
117
|
+
}
|
|
118
|
+
._lqk467 {
|
|
119
|
+
padding: 0.25rem;
|
|
120
|
+
}
|
|
121
|
+
._g2iyum {
|
|
122
|
+
gap: 0.5rem;
|
|
123
|
+
}
|
|
124
|
+
._17xzvrh {
|
|
125
|
+
background-color: var(--accent);
|
|
126
|
+
}
|
|
127
|
+
._1binn6n {
|
|
128
|
+
color: white;
|
|
129
|
+
}
|
|
130
|
+
._1ob5z5m {
|
|
131
|
+
align-items: center;
|
|
132
|
+
}
|
|
133
|
+
._1s47490 {
|
|
134
|
+
display: flex;
|
|
135
|
+
}
|
|
96
136
|
}
|
|
97
137
|
@layer _.b {
|
|
98
|
-
._1tsjws2:hover{
|
|
138
|
+
._1tsjws2:hover {
|
|
139
|
+
background-color: #1d4ed8;
|
|
140
|
+
}
|
|
99
141
|
@media (width >= 40rem) {
|
|
100
|
-
._tdcza3{
|
|
142
|
+
._tdcza3 {
|
|
143
|
+
padding: 1rem;
|
|
144
|
+
}
|
|
101
145
|
}
|
|
102
146
|
}
|
|
103
147
|
```
|
|
@@ -131,15 +175,15 @@ and Cursor. The skills use it when it is configured and work without it.
|
|
|
131
175
|
|
|
132
176
|
## Layout
|
|
133
177
|
|
|
134
|
-
| Path
|
|
135
|
-
|
|
136
|
-
| `packages/cssints`
|
|
137
|
-
| `packages/css-grammar`
|
|
138
|
-
| `packages/icons`
|
|
139
|
-
| `packages/mise-en-mode`
|
|
140
|
-
| `apps/demo`
|
|
141
|
-
| `apps/docs`
|
|
142
|
-
| `docs/research`, `docs/archive` | Comparisons with other libraries; outdated plans
|
|
178
|
+
| Path | What |
|
|
179
|
+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
| `packages/cssints` | Vite plugin (`cssints/vite`) on the Vite Module Runner, and the `cssints` library |
|
|
181
|
+
| `packages/css-grammar` | Type-level recognizer and its runtime twin over mdn-data grammars, Typed OM values, browser support and prose rules |
|
|
182
|
+
| `packages/icons` | `@cssints/icons`: icons from iconify JSON collections or SVG folders, a mask style with no runtime |
|
|
183
|
+
| `packages/mise-en-mode` | `@cssints/mise-en-mode`: looks as themes in the layers app < author < viewer, on `data-mode` scopes, checked against the tokens and by `check.contrast` |
|
|
184
|
+
| `apps/demo` | React demo of every 0.1 feature |
|
|
185
|
+
| `apps/docs` | The documentation site: this file and `docs/API.md` as pages, with search and type hovers (`cd apps/docs && bun run dev`) |
|
|
186
|
+
| `docs/research`, `docs/archive` | Comparisons with other libraries; outdated plans |
|
|
143
187
|
|
|
144
188
|
## Development
|
|
145
189
|
|
|
@@ -161,16 +205,16 @@ cssints is MIT. It stands on other people's work; this is what we took, from who
|
|
|
161
205
|
|
|
162
206
|
### Data and code that ships
|
|
163
207
|
|
|
164
|
-
| Where
|
|
165
|
-
|
|
166
|
-
| [@cssints/tokens](packages/tokens/README.md)
|
|
167
|
-
| [@cssints/css-grammar](packages/css-grammar/THIRD_PARTY_NOTICES.md) | the CSS syntax strings (`src/mdn.ts`, `keywords.ts`, `functions.ts`), also in the types of `cssints` | [mdn-data](https://github.com/mdn/data); the numeric ranges it omits from [@webref/css](https://github.com/w3c/webref)
|
|
168
|
-
| @cssints/css-grammar
|
|
169
|
-
| [@cssints/fonts](packages/fonts/README.md)
|
|
170
|
-
| [@cssints/icons](packages/icons/README.md)
|
|
171
|
-
| `tools/ai-automation/vendor`
|
|
172
|
-
| [apps/
|
|
173
|
-
| apps/demo
|
|
208
|
+
| Where | What | From | License |
|
|
209
|
+
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
|
|
210
|
+
| [@cssints/tokens](packages/tokens/README.md) | the Open Props, Radix Colors, Flexoki and Reasonable Colors sets | [Open Props](https://github.com/argyleink/open-props) (Adam Argyle), [Radix Colors](https://github.com/radix-ui/colors), [Flexoki](https://github.com/kepano/flexoki) (Steph Ango), [Reasonable Colors](https://github.com/matthewhowell/reasonable-colors) (Matthew Howell) | MIT, notices in its README |
|
|
211
|
+
| [@cssints/css-grammar](packages/css-grammar/THIRD_PARTY_NOTICES.md) | the CSS syntax strings (`src/mdn.ts`, `keywords.ts`, `functions.ts`), also in the types of `cssints` | [mdn-data](https://github.com/mdn/data); the numeric ranges it omits from [@webref/css](https://github.com/w3c/webref) | CC0-1.0; MIT (W3C) |
|
|
212
|
+
| @cssints/css-grammar | browser support warnings, read from the package (not copied) | [@mdn/browser-compat-data](https://github.com/mdn/browser-compat-data) | CC0-1.0 |
|
|
213
|
+
| [@cssints/fonts](packages/fonts/README.md) | the latin character weights and the metrics of Arial, Times New Roman and Courier New | [Capsize](https://github.com/seek-oss/capsize) (SEEK) | MIT, notice in its README |
|
|
214
|
+
| [@cssints/icons](packages/icons/README.md) | nothing: the collections are your dependency | [Iconify](https://iconify.design) `@iconify-json/*` | each collection's own |
|
|
215
|
+
| `tools/ai-automation/vendor` | lint rules, not published | [dmmulroy/anti-slop](https://github.com/dmmulroy/anti-slop) (Dillon Mulroy) | MIT, `LICENSE` and `UPSTREAM.md` |
|
|
216
|
+
| [apps/csssky](apps/csssky/NOTICE.md) | layout and token values; Inter; Phosphor icons | Mu and `@bsky.app/alf` (Bluesky Social PBC), [Inter](https://github.com/rsms/inter), [Phosphor](https://phosphoricons.com) | MIT; OFL-1.1; MIT |
|
|
217
|
+
| apps/demo | Material Design Icons (`@iconify-json/mdi`) | Pictogrammers | Apache-2.0 |
|
|
174
218
|
|
|
175
219
|
### Ideas and designs
|
|
176
220
|
|
|
@@ -178,7 +222,7 @@ No code is copied from these; each package README says which part follows which.
|
|
|
178
222
|
|
|
179
223
|
- **Plugin packages.** [Every Layout](https://every-layout.dev) and [smolcss](https://smolcss.dev) (layout), [nytimes/text-balancer](https://github.com/nytimes/text-balancer) and [react-wrap-balancer](https://github.com/shuding/react-wrap-balancer) (balance), [fluid-tailwind](https://github.com/barvian/fluid-tailwind) (fluid), [postcss-easing-gradients](https://github.com/larsenwork/postcss-easing-gradients) (gradient), [tailwindcss-motion](https://github.com/romboHQ/tailwindcss-motion) and [tailwindcss-animate](https://github.com/jamiebuilds/tailwindcss-animate) (motion), [the supersonic plugin](https://github.com/the-illarionov/the-supersonic-plugin-for-scroll-based-animation) and [lax.js](https://github.com/alexfoxy/lax.js) (reveal), [sync-skeleton](https://github.com/crutchcorn/sync-skeleton) (skeleton), [bramus/sticky-observer](https://github.com/bramus/sticky-observer) (stuck), [unpic-placeholder](https://github.com/ascorbic/unpic-placeholder) and [ThumbHash](https://github.com/evanw/thumbhash) (placeholder), [nutelch](https://github.com/meodai/nutelch) and [Leonardo](https://github.com/adobe/leonardo) (ramp), the resets of Josh Comeau, Jake Lazaroff, Vale and Andy Bell (reset), [Mise en Mode](https://standard.mode.place) and its Mode Contract (mise-en-mode), [brendonovich/vite-plugin-opencode](https://github.com/Brendonovich/vite-plugin-opencode) (the prompt box of devtools).
|
|
180
224
|
- **The engine.** The comparisons in [docs/research](docs/research) record what we took from [StyleX](https://stylexjs.com), [vanilla-extract](https://vanilla-extract.style), [Tailwind CSS](https://tailwindcss.com), [Tokenami](https://tokenami.com), [SugarCube](https://sugarcube.sh) and the [React Spectrum](https://react-spectrum.adobe.com) style macros; the first spark was [Haz's post](https://bsky.app/profile/haz.dev/post/3mebm2mx6jk27) on a CSS framework in TypeScript. Tokens follow the [Design Tokens Community Group](https://www.designtokens.org) format.
|
|
181
|
-
- **apps/
|
|
225
|
+
- **apps/csssky** follows the look of Mu and the hue slider of Witchsky.
|
|
182
226
|
|
|
183
227
|
### Built on
|
|
184
228
|
|