@sereno-ds/tokens 0.30.1 → 0.31.0
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 +20 -1
- package/dist/breakpoints.d.ts +17 -0
- package/dist/breakpoints.js +10 -0
- package/dist/breakpoints.js.map +1 -0
- package/package.json +17 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sereno-ds/tokens
|
|
2
2
|
|
|
3
|
-
The token layer of the Sereno Design System — CSS custom properties (colors, typography, spacing, radii, elevation, motion) with light and `[data-theme="dark"]` values.
|
|
3
|
+
The token layer of the Sereno Design System — CSS custom properties (colors, typography, spacing, radii, elevation, motion) with light and `[data-theme="dark"]` values. CSS-first: the one JS export ([Breakpoints](#breakpoints), below) exists only for values a CSS custom property can't serve on its own.
|
|
4
4
|
|
|
5
5
|
Required by [`@sereno-ds/ui`](https://www.npmjs.com/package/@sereno-ds/ui); usable on its own if you want the Sereno scales without the components.
|
|
6
6
|
|
|
@@ -25,6 +25,25 @@ import '@sereno-ds/tokens/colors.css';
|
|
|
25
25
|
import '@sereno-ds/tokens/spacing.css';
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Breakpoints
|
|
29
|
+
|
|
30
|
+
`spacing.css` defines the canonical breakpoints as `--bp-sm` / `--bp-md` / `--bp-lg` / `--bp-xl`, but a CSS `@media` query can't read a custom property — anything that has to write one (a Tailwind `@theme`, a `matchMedia` call) needs the literal pixel number. Import it instead of retyping it by hand:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { breakpoints } from '@sereno-ds/tokens/breakpoints';
|
|
34
|
+
// { sm: 560, md: 768, lg: 1024, xl: 1280 }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
A build-time check keeps this in sync with `spacing.css` — the two can never silently drift apart.
|
|
38
|
+
|
|
39
|
+
CSS still can't import a JS value, so a tool like Tailwind v4's `@theme` (which compiles breakpoints straight into `@media` rules) still needs the literal number written in its own config — this export just gives you something to read that number *from* instead of hand-copying it, and something a consumer-side test can assert against so a future change to `--bp-*` doesn't drift silently:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// e.g. a small check in the consuming app's own test suite
|
|
43
|
+
import { breakpoints } from '@sereno-ds/tokens/breakpoints';
|
|
44
|
+
expect(TAILWIND_THEME.breakpointSm).toBe(`${breakpoints.sm}px`);
|
|
45
|
+
```
|
|
46
|
+
|
|
28
47
|
## Dark mode
|
|
29
48
|
|
|
30
49
|
`colors.css` and `elevation.css` carry `[data-theme="dark"]` overrides. Set `data-theme="dark"` (or `"light"`) on `<html>` — `@sereno-ds/ui`'s `ThemeProvider` does this, or wire your own.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pixel breakpoints — mirrors `--bp-sm` / `--bp-md` / `--bp-lg` / `--bp-xl` in
|
|
3
|
+
* `spacing.css`. A CSS `@media` query can't read a custom property, so
|
|
4
|
+
* anything that has to write one (a Tailwind `@theme`, a `matchMedia` call, a
|
|
5
|
+
* React Native `useWindowDimensions` check) needs the literal number — import
|
|
6
|
+
* this instead of retyping it by hand. Kept in sync with `spacing.css` by
|
|
7
|
+
* `scripts/check-breakpoints.mjs`, which fails the build if they disagree.
|
|
8
|
+
*/
|
|
9
|
+
declare const breakpoints: {
|
|
10
|
+
readonly sm: 560;
|
|
11
|
+
readonly md: 768;
|
|
12
|
+
readonly lg: 1024;
|
|
13
|
+
readonly xl: 1280;
|
|
14
|
+
};
|
|
15
|
+
type Breakpoint = keyof typeof breakpoints;
|
|
16
|
+
|
|
17
|
+
export { type Breakpoint, breakpoints };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/breakpoints.ts"],"sourcesContent":["/**\n * Pixel breakpoints — mirrors `--bp-sm` / `--bp-md` / `--bp-lg` / `--bp-xl` in\n * `spacing.css`. A CSS `@media` query can't read a custom property, so\n * anything that has to write one (a Tailwind `@theme`, a `matchMedia` call, a\n * React Native `useWindowDimensions` check) needs the literal number — import\n * this instead of retyping it by hand. Kept in sync with `spacing.css` by\n * `scripts/check-breakpoints.mjs`, which fails the build if they disagree.\n */\nexport const breakpoints = {\n sm: 560,\n md: 768,\n lg: 1024,\n xl: 1280,\n} as const;\n\nexport type Breakpoint = keyof typeof breakpoints;\n"],"mappings":"AAQO,MAAM,cAAc;AAAA,EACzB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sereno-ds/tokens",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Sereno Design System — the token layer (CSS custom properties, light × dark).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sereno",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://github.com/GabrielGomesBarbosa/sereno-ds/tree/main/packages/tokens#readme",
|
|
13
13
|
"bugs": "https://github.com/GabrielGomesBarbosa/sereno-ds/issues",
|
|
14
|
+
"type": "module",
|
|
14
15
|
"keywords": [
|
|
15
16
|
"design-tokens",
|
|
16
17
|
"css-variables",
|
|
@@ -30,13 +31,28 @@
|
|
|
30
31
|
"./elevation.css": "./elevation.css",
|
|
31
32
|
"./motion.css": "./motion.css",
|
|
32
33
|
"./base.css": "./base.css",
|
|
34
|
+
"./breakpoints": {
|
|
35
|
+
"types": "./dist/breakpoints.d.ts",
|
|
36
|
+
"import": "./dist/breakpoints.js"
|
|
37
|
+
},
|
|
33
38
|
"./package.json": "./package.json"
|
|
34
39
|
},
|
|
35
40
|
"files": [
|
|
36
41
|
"*.css",
|
|
42
|
+
"dist",
|
|
37
43
|
"README.md",
|
|
38
44
|
"LICENSE"
|
|
39
45
|
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "node scripts/check-breakpoints.mjs && tsup",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"prepack": "npm run build"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"tsup": "^8.5.1",
|
|
54
|
+
"typescript": "^5"
|
|
55
|
+
},
|
|
40
56
|
"publishConfig": {
|
|
41
57
|
"access": "public",
|
|
42
58
|
"provenance": true
|