@lit-material/tokens 0.0.2 → 1.0.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 +73 -0
- package/dist/sbom.cdx.json +65 -0
- package/figma/tokens.dark.json +602 -0
- package/figma/tokens.light.json +602 -0
- package/package.json +9 -5
- package/src/css/typography.css +256 -0
package/README.md
CHANGED
|
@@ -23,6 +23,79 @@ Dark mode follows `prefers-color-scheme` automatically (via CSS `light-dark()`).
|
|
|
23
23
|
a scheme regardless of OS preference, set `color-scheme="light"` or `color-scheme="dark"`
|
|
24
24
|
on `<html>` or any ancestor element.
|
|
25
25
|
|
|
26
|
+
## Typography (opt-in)
|
|
27
|
+
|
|
28
|
+
`css/typography.css` styles plain HTML on the M3 type scale. It's not part of `index.css`.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<link rel="stylesheet" href="node_modules/@lit-material/tokens/css/typography.css" />
|
|
32
|
+
|
|
33
|
+
<h2 class="md-typescale-title-large">A level-2 heading at title size</h2>
|
|
34
|
+
<article class="lit-material-content">…Markdown output…</article>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- `.md-typescale-<role>-<size>`: one M3 text style (`display`, `headline`, `title`, `body`,
|
|
38
|
+
`label` × `large`, `medium`, `small`), so a heading's level and its size are separate.
|
|
39
|
+
- `.lit-material-content`: headings, paragraphs, lists, definition lists, quotes, code, rules and
|
|
40
|
+
links inside it get M3 styles and spacing.
|
|
41
|
+
|
|
42
|
+
Values come from the `--md-sys-typescale-*` tokens, with M3's baseline for roles the tokens don't
|
|
43
|
+
define. Classes don't reach into a shadow root: in a Lit component, add the sheet to its styles
|
|
44
|
+
(`import typography from "@lit-material/tokens/css/typography.css?inline"` with Vite, then
|
|
45
|
+
`unsafeCSS(typography)`).
|
|
46
|
+
|
|
47
|
+
## Figma
|
|
48
|
+
|
|
49
|
+
`figma/tokens.light.json` and `figma/tokens.dark.json` hold the same tokens as the CSS, in the
|
|
50
|
+
[W3C Design Tokens Community Group](https://www.designtokens.org/) (DTCG) format: nested groups
|
|
51
|
+
(`md.sys.color.primary` for `--md-sys-color-primary`) of `$type` / `$value` tokens. They're generated
|
|
52
|
+
from `src/css` by `node tools/figma-tokens.mjs` (CI fails when they're stale), and published with the
|
|
53
|
+
package (`@lit-material/tokens/figma/tokens.light.json`), or download them from the repository.
|
|
54
|
+
|
|
55
|
+
**One file per mode.** The colors written `light-dark(light, dark)` in CSS are split: the light value
|
|
56
|
+
goes in `tokens.light.json`, the dark one in `tokens.dark.json`. Every other token is identical in both.
|
|
57
|
+
This is the shape both importers want: Figma's Variables import creates one mode per file it's given
|
|
58
|
+
(and only for tokens present, with the same type, in every file), and Tokens Studio treats each file as
|
|
59
|
+
a token set you can switch between with a theme. A single file with per-mode `$extensions` would need
|
|
60
|
+
a plugin-specific convention neither reads.
|
|
61
|
+
|
|
62
|
+
### Figma Variables (native import)
|
|
63
|
+
|
|
64
|
+
1. In a Figma Design file, open the **Local variables** panel and choose **Import**.
|
|
65
|
+
2. Select both files. Figma creates a collection with a **light** and a **dark** mode (rename them if
|
|
66
|
+
the names come from the files), one variable per token, grouped `md/sys/color/…`, `md/sys/shape/…`.
|
|
67
|
+
3. To update later, right-click a mode and choose **Import mode** with the matching file.
|
|
68
|
+
|
|
69
|
+
Variables hold colors, numbers, strings and lengths. The composite tokens (shadows, easing curves,
|
|
70
|
+
typography styles) have no variable type, so Figma's importer leaves them out: use Tokens Studio for
|
|
71
|
+
those, or build the effect and text styles from the variables by hand.
|
|
72
|
+
|
|
73
|
+
### Tokens Studio for Figma
|
|
74
|
+
|
|
75
|
+
1. Open the plugin, choose a sync provider (**Local document**, or a Git provider pointed at this
|
|
76
|
+
package's `figma/` folder) and set the token format to **W3C DTCG** in the settings.
|
|
77
|
+
2. Create two sets, `light` and `dark`, and paste or load each file into its set.
|
|
78
|
+
3. Under **Themes**, make a `Light` theme with the `light` set enabled and a `Dark` theme with `dark`.
|
|
79
|
+
4. **Export to Figma** → **Variables** (both themes become modes of one collection) and **Styles**:
|
|
80
|
+
elevation levels become effect styles and each `md.sys.typescale.<role>.style` a text style.
|
|
81
|
+
(Themes are a Tokens Studio Pro feature; on the free plan, apply one set at a time.)
|
|
82
|
+
|
|
83
|
+
### What's included
|
|
84
|
+
|
|
85
|
+
| Group | `$type` | Notes |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `md.sys.color.*` | `color` | M3 baseline scheme, hex (`#rrggbb`). |
|
|
88
|
+
| `md.sys.shape.corner.*` | `dimension` | px. |
|
|
89
|
+
| `md.sys.typescale.<role>.*` | `fontFamily`, `fontWeight`, `dimension` | `font`, `weight`, `size`, `line-height`, `tracking`. rem values are converted to px at 16px; the CSS value is kept in `$extensions["dev.lit-material"].css`, as is the full font stack (`$value` is its first family). |
|
|
90
|
+
| `md.sys.typescale.<role>.style` | `typography` | Aliases to the five tokens above; no CSS property of its own. |
|
|
91
|
+
| `md.sys.elevation.level0`–`5` | `shadow` | Layers with `#rrggbbaa` colors; `level0` (`none`) is an empty list. |
|
|
92
|
+
| `md.sys.state.*` | `number` | State-layer and disabled opacities. |
|
|
93
|
+
| `md.sys.motion.easing.*`, `.duration.*` | `cubicBezier`, `duration` | |
|
|
94
|
+
|
|
95
|
+
A token whose CSS value is `var(--md-sys-…)` becomes a DTCG alias (`{md.sys.…}`). Only the tokens the
|
|
96
|
+
CSS declares are exported: the type scale is the subset the components use (the other roles exist only as
|
|
97
|
+
fallbacks in `typography.css`). These are tokens only: there are no component symbols or a Figma kit yet.
|
|
98
|
+
|
|
26
99
|
## License
|
|
27
100
|
|
|
28
101
|
MIT
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json",
|
|
3
|
+
"bomFormat": "CycloneDX",
|
|
4
|
+
"specVersion": "1.7",
|
|
5
|
+
"serialNumber": "urn:uuid:9d849b7a-3825-4719-b6b5-68c9007d0abb",
|
|
6
|
+
"version": 1,
|
|
7
|
+
"metadata": {
|
|
8
|
+
"timestamp": "2026-11-04T17:55:36.891Z",
|
|
9
|
+
"lifecycles": [
|
|
10
|
+
{
|
|
11
|
+
"phase": "pre-build"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"tools": {
|
|
15
|
+
"components": [
|
|
16
|
+
{
|
|
17
|
+
"type": "application",
|
|
18
|
+
"name": "pnpm",
|
|
19
|
+
"version": "11.10.0"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"component": {
|
|
24
|
+
"type": "library",
|
|
25
|
+
"name": "tokens",
|
|
26
|
+
"version": "1.0.0",
|
|
27
|
+
"purl": "pkg:npm/%40lit-material/tokens@1.0.0",
|
|
28
|
+
"bom-ref": "pkg:npm/%40lit-material/tokens@1.0.0",
|
|
29
|
+
"group": "@lit-material",
|
|
30
|
+
"authors": [
|
|
31
|
+
{
|
|
32
|
+
"name": "bohdaq"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"licenses": [
|
|
36
|
+
{
|
|
37
|
+
"license": {
|
|
38
|
+
"id": "MIT"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"description": "Material Design 3 design tokens (color, type, shape, elevation, motion) for lit-material components.",
|
|
43
|
+
"externalReferences": [
|
|
44
|
+
{
|
|
45
|
+
"type": "vcs",
|
|
46
|
+
"url": "git+ssh://git@github.com/bohdaq/lit-material.git"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "issue-tracker",
|
|
50
|
+
"url": "https://github.com/bohdaq/lit-material/issues"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"supplier": {
|
|
55
|
+
"name": "lit-material"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"components": [],
|
|
59
|
+
"dependencies": [
|
|
60
|
+
{
|
|
61
|
+
"ref": "pkg:npm/%40lit-material/tokens@1.0.0",
|
|
62
|
+
"dependsOn": []
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|