@grafctory/skin 0.0.0-stage → 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.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +469 -2
  3. package/dist/index.core.d.ts +201 -0
  4. package/dist/index.core.d.ts.map +1 -0
  5. package/dist/index.core.js +17 -0
  6. package/dist/index.core.js.map +1 -0
  7. package/dist/index.css +126 -0
  8. package/dist/index.d.ts +432 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +184 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/markup/alerts.css +83 -0
  13. package/dist/markup/blocks.css +255 -0
  14. package/dist/markup/forms.css +551 -0
  15. package/dist/markup/headings.css +131 -0
  16. package/dist/markup/highlights.css +38 -0
  17. package/dist/markup/inlines.css +183 -0
  18. package/dist/markup/lists.css +206 -0
  19. package/dist/markup/reset.css +38 -0
  20. package/dist/markup/tables.css +78 -0
  21. package/dist/presets/inter.css +194 -0
  22. package/dist/presets/roboto.css +198 -0
  23. package/dist/tokens/borders.css +151 -0
  24. package/dist/tokens/borders.d.ts +57 -0
  25. package/dist/tokens/borders.d.ts.map +1 -0
  26. package/dist/tokens/borders.js +72 -0
  27. package/dist/tokens/borders.js.map +1 -0
  28. package/dist/tokens/colors.css +515 -0
  29. package/dist/tokens/colors.d.ts +171 -0
  30. package/dist/tokens/colors.d.ts.map +1 -0
  31. package/dist/tokens/colors.js +186 -0
  32. package/dist/tokens/colors.js.map +1 -0
  33. package/dist/tokens/elevations.css +110 -0
  34. package/dist/tokens/elevations.d.ts +54 -0
  35. package/dist/tokens/elevations.d.ts.map +1 -0
  36. package/dist/tokens/elevations.js +69 -0
  37. package/dist/tokens/elevations.js.map +1 -0
  38. package/dist/tokens/layers.css +57 -0
  39. package/dist/tokens/layers.d.ts +34 -0
  40. package/dist/tokens/layers.d.ts.map +1 -0
  41. package/dist/tokens/layers.js +49 -0
  42. package/dist/tokens/layers.js.map +1 -0
  43. package/dist/tokens/motions.css +91 -0
  44. package/dist/tokens/motions.d.ts +40 -0
  45. package/dist/tokens/motions.d.ts.map +1 -0
  46. package/dist/tokens/motions.js +55 -0
  47. package/dist/tokens/motions.js.map +1 -0
  48. package/dist/tokens/opacities.css +41 -0
  49. package/dist/tokens/opacities.d.ts +32 -0
  50. package/dist/tokens/opacities.d.ts.map +1 -0
  51. package/dist/tokens/opacities.js +47 -0
  52. package/dist/tokens/opacities.js.map +1 -0
  53. package/dist/tokens/palettes.css +546 -0
  54. package/dist/tokens/palettes.d.ts +140 -0
  55. package/dist/tokens/palettes.d.ts.map +1 -0
  56. package/dist/tokens/palettes.js +155 -0
  57. package/dist/tokens/palettes.js.map +1 -0
  58. package/dist/tokens/scalings.css +81 -0
  59. package/dist/tokens/scalings.d.ts +31 -0
  60. package/dist/tokens/scalings.d.ts.map +1 -0
  61. package/dist/tokens/scalings.js +46 -0
  62. package/dist/tokens/scalings.js.map +1 -0
  63. package/dist/tokens/spacings.css +78 -0
  64. package/dist/tokens/spacings.d.ts +34 -0
  65. package/dist/tokens/spacings.d.ts.map +1 -0
  66. package/dist/tokens/spacings.js +49 -0
  67. package/dist/tokens/spacings.js.map +1 -0
  68. package/dist/tokens/typography.css +156 -0
  69. package/dist/tokens/typography.d.ts +77 -0
  70. package/dist/tokens/typography.d.ts.map +1 -0
  71. package/dist/tokens/typography.js +92 -0
  72. package/dist/tokens/typography.js.map +1 -0
  73. package/dist/tokens/viewports.css +101 -0
  74. package/dist/tokens/viewports.d.ts +75 -0
  75. package/dist/tokens/viewports.d.ts.map +1 -0
  76. package/dist/tokens/viewports.js +90 -0
  77. package/dist/tokens/viewports.js.map +1 -0
  78. package/package.json +87 -4
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Typography tokens.
3
+ *
4
+ * Names the faces, sizes, weights and casing text is set in, the leading and tracking it is spaced on and the measure
5
+ * prose keeps to. An app overrides them to retype a whole interface, from running text to titles, labels and leads.
6
+ *
7
+ * @remarks
8
+ *
9
+ * **Faces** — `fontFamily` carries the body face, `fontFamilyHeading` the one a title is set in and `fontFamilyMono`
10
+ * the one a code span or a figure aligns on. Each defaults to a platform face, which costs no download, and a preset
11
+ * sets all three in faces it bundles, as `presets/roboto.css` does with the Roboto faces of the Metreeca brand.
12
+ *
13
+ * Until a face loads, text is set in the next face of its stack. Every preset shipped here follows each face with a
14
+ * platform face scaled to its metrics, so labels, buttons and columns sized to their content keep their width when the
15
+ * face arrives. An app supplying a face of its own loads it and restates a generic stack after it, led by a fallback
16
+ * face scaled the same way through the `size-adjust` and metric override descriptors of its `@font-face` rules.
17
+ *
18
+ * A mono face runs wider than the text face it is paired with. Every preset shipped here scales its mono face to match
19
+ * its text face, so anything set in `fontFamilyMono` matches the text around it with no size of its own. An app
20
+ * supplying a mono face scales it the same way, through the `size-adjust` descriptor of its `@font-face` rules, so it
21
+ * stays matched wherever a component sets it. The platform faces vary by system and are left unscaled.
22
+ *
23
+ * **Sizes** — `fontSize` follows the reader's setting and grows on wider windows, while `fontSizeSmall` and
24
+ * `fontSizeLarge` follow whatever they sit in, keeping their ratio inside a subtree sized apart.
25
+ *
26
+ * The page sets the base size on `body` and leaves the root at the reader's setting, so `fontSize` resolves to the same
27
+ * length at every depth and a `rem` always means the reader's setting. A measure meant to follow the base text size is
28
+ * therefore stated in `em` or through a token, never in `rem`, which ignores the window and any app override.
29
+ *
30
+ * **Headings** — `fontSizeHeading` sizes every heading level, so an app resizing it resizes all headings together. The
31
+ * first two levels stand above it, the next two take it as it stands and the last two drop to the small size. Weight,
32
+ * colour and spacing carry the rest of the hierarchy, which keeps a deep outline readable in a column.
33
+ *
34
+ * `letterSpacingHeading` ships neutral and lets the brand face decide, so an app supplying a condensed or a wide face
35
+ * corrects the heading tracking through this token alone, without restating the rule for every heading level.
36
+ *
37
+ * **Display and labels** — `lineHeightDisplay` is the tight leading of display type, such as the heading of an
38
+ * `hgroup` or a figure set large. `letterSpacingCaps` spaces out a label set in small capitals, which would otherwise
39
+ * look crowded, as the eyebrow of a heading group and the top-level entries of a `nav` outline are.
40
+ *
41
+ * **Casing** — `textTransformHeading` sets the casing of every heading, as written by default, and `textTransformCaps`
42
+ * that of every label in capitals, so a call site restating either on a subtree recases every title or label inside.
43
+ * Neither token is derived from the other, and a label leaving capitals usually drops its extra tracking as well, so
44
+ * an app turning `textTransformCaps` to `none` restates `letterSpacingCaps` as `normal` in the same rule.
45
+ *
46
+ * **Measure** — `inlineSizeProse` caps a run of prose at a comfortable reading measure. It is stated in characters of
47
+ * the element it caps, so a heading group capped as a whole holds fewer characters per line in its larger lead.
48
+ *
49
+ * **Weights** — `fontWeight` is text at rest and `fontWeightStrong` anything marked out from it, from a link or a term
50
+ * to a heading, a label, a tab or a table header, so emphasis reads the same wherever it occurs in the interface.
51
+ *
52
+ * @module typography
53
+ */
54
+ /**
55
+ * The custom property behind every typography token.
56
+ *
57
+ * Narrowed to literals, so the design system contract can name the tokens and the custom properties they resolve to.
58
+ */
59
+ export declare const typography: {
60
+ readonly fontFamily: "--skin--font-family";
61
+ readonly fontFamilyHeading: "--skin--font-family-heading";
62
+ readonly fontFamilyMono: "--skin--font-family-mono";
63
+ readonly fontSize: "--skin--font-size";
64
+ readonly fontSizeSmall: "--skin--font-size-small";
65
+ readonly fontSizeLarge: "--skin--font-size-large";
66
+ readonly fontSizeHeading: "--skin--font-size-heading";
67
+ readonly lineHeight: "--skin--line-height";
68
+ readonly lineHeightDisplay: "--skin--line-height-display";
69
+ readonly letterSpacingHeading: "--skin--letter-spacing-heading";
70
+ readonly letterSpacingCaps: "--skin--letter-spacing-caps";
71
+ readonly textTransformHeading: "--skin--text-transform-heading";
72
+ readonly textTransformCaps: "--skin--text-transform-caps";
73
+ readonly inlineSizeProse: "--skin--inline-size-prose";
74
+ readonly fontWeight: "--skin--font-weight";
75
+ readonly fontWeightStrong: "--skin--font-weight-strong";
76
+ };
77
+ //# sourceMappingURL=typography.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../src/tokens/typography.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH;;;;GAIG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;CAuBb,CAAC"}
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright © 2023-2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Typography tokens.
18
+ *
19
+ * Names the faces, sizes, weights and casing text is set in, the leading and tracking it is spaced on and the measure
20
+ * prose keeps to. An app overrides them to retype a whole interface, from running text to titles, labels and leads.
21
+ *
22
+ * @remarks
23
+ *
24
+ * **Faces** — `fontFamily` carries the body face, `fontFamilyHeading` the one a title is set in and `fontFamilyMono`
25
+ * the one a code span or a figure aligns on. Each defaults to a platform face, which costs no download, and a preset
26
+ * sets all three in faces it bundles, as `presets/roboto.css` does with the Roboto faces of the Metreeca brand.
27
+ *
28
+ * Until a face loads, text is set in the next face of its stack. Every preset shipped here follows each face with a
29
+ * platform face scaled to its metrics, so labels, buttons and columns sized to their content keep their width when the
30
+ * face arrives. An app supplying a face of its own loads it and restates a generic stack after it, led by a fallback
31
+ * face scaled the same way through the `size-adjust` and metric override descriptors of its `@font-face` rules.
32
+ *
33
+ * A mono face runs wider than the text face it is paired with. Every preset shipped here scales its mono face to match
34
+ * its text face, so anything set in `fontFamilyMono` matches the text around it with no size of its own. An app
35
+ * supplying a mono face scales it the same way, through the `size-adjust` descriptor of its `@font-face` rules, so it
36
+ * stays matched wherever a component sets it. The platform faces vary by system and are left unscaled.
37
+ *
38
+ * **Sizes** — `fontSize` follows the reader's setting and grows on wider windows, while `fontSizeSmall` and
39
+ * `fontSizeLarge` follow whatever they sit in, keeping their ratio inside a subtree sized apart.
40
+ *
41
+ * The page sets the base size on `body` and leaves the root at the reader's setting, so `fontSize` resolves to the same
42
+ * length at every depth and a `rem` always means the reader's setting. A measure meant to follow the base text size is
43
+ * therefore stated in `em` or through a token, never in `rem`, which ignores the window and any app override.
44
+ *
45
+ * **Headings** — `fontSizeHeading` sizes every heading level, so an app resizing it resizes all headings together. The
46
+ * first two levels stand above it, the next two take it as it stands and the last two drop to the small size. Weight,
47
+ * colour and spacing carry the rest of the hierarchy, which keeps a deep outline readable in a column.
48
+ *
49
+ * `letterSpacingHeading` ships neutral and lets the brand face decide, so an app supplying a condensed or a wide face
50
+ * corrects the heading tracking through this token alone, without restating the rule for every heading level.
51
+ *
52
+ * **Display and labels** — `lineHeightDisplay` is the tight leading of display type, such as the heading of an
53
+ * `hgroup` or a figure set large. `letterSpacingCaps` spaces out a label set in small capitals, which would otherwise
54
+ * look crowded, as the eyebrow of a heading group and the top-level entries of a `nav` outline are.
55
+ *
56
+ * **Casing** — `textTransformHeading` sets the casing of every heading, as written by default, and `textTransformCaps`
57
+ * that of every label in capitals, so a call site restating either on a subtree recases every title or label inside.
58
+ * Neither token is derived from the other, and a label leaving capitals usually drops its extra tracking as well, so
59
+ * an app turning `textTransformCaps` to `none` restates `letterSpacingCaps` as `normal` in the same rule.
60
+ *
61
+ * **Measure** — `inlineSizeProse` caps a run of prose at a comfortable reading measure. It is stated in characters of
62
+ * the element it caps, so a heading group capped as a whole holds fewer characters per line in its larger lead.
63
+ *
64
+ * **Weights** — `fontWeight` is text at rest and `fontWeightStrong` anything marked out from it, from a link or a term
65
+ * to a heading, a label, a tab or a table header, so emphasis reads the same wherever it occurs in the interface.
66
+ *
67
+ * @module typography
68
+ */
69
+ /**
70
+ * The custom property behind every typography token.
71
+ *
72
+ * Narrowed to literals, so the design system contract can name the tokens and the custom properties they resolve to.
73
+ */
74
+ export const typography = {
75
+ fontFamily: "--skin--font-family",
76
+ fontFamilyHeading: "--skin--font-family-heading",
77
+ fontFamilyMono: "--skin--font-family-mono",
78
+ fontSize: "--skin--font-size",
79
+ fontSizeSmall: "--skin--font-size-small",
80
+ fontSizeLarge: "--skin--font-size-large",
81
+ fontSizeHeading: "--skin--font-size-heading",
82
+ lineHeight: "--skin--line-height",
83
+ lineHeightDisplay: "--skin--line-height-display",
84
+ letterSpacingHeading: "--skin--letter-spacing-heading",
85
+ letterSpacingCaps: "--skin--letter-spacing-caps",
86
+ textTransformHeading: "--skin--text-transform-heading",
87
+ textTransformCaps: "--skin--text-transform-caps",
88
+ inlineSizeProse: "--skin--inline-size-prose",
89
+ fontWeight: "--skin--font-weight",
90
+ fontWeightStrong: "--skin--font-weight-strong"
91
+ };
92
+ //# sourceMappingURL=typography.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typography.js","sourceRoot":"","sources":["../../src/tokens/typography.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IAEzB,UAAU,EAAE,qBAAqB;IACjC,iBAAiB,EAAE,6BAA6B;IAChD,cAAc,EAAE,0BAA0B;IAE1C,QAAQ,EAAE,mBAAmB;IAC7B,aAAa,EAAE,yBAAyB;IACxC,aAAa,EAAE,yBAAyB;IACxC,eAAe,EAAE,2BAA2B;IAE5C,UAAU,EAAE,qBAAqB;IACjC,iBAAiB,EAAE,6BAA6B;IAChD,oBAAoB,EAAE,gCAAgC;IACtD,iBAAiB,EAAE,6BAA6B;IAChD,oBAAoB,EAAE,gCAAgC;IACtD,iBAAiB,EAAE,6BAA6B;IAEhD,eAAe,EAAE,2BAA2B;IAE5C,UAAU,EAAE,qBAAqB;IACjC,gBAAgB,EAAE,4BAA4B;CAErC,CAAC"}
@@ -0,0 +1,101 @@
1
+ /*
2
+ * Copyright © 2023-2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * Which breakpoints the viewport has passed. A media feature cannot read a custom property, so a breakpoint cannot be
19
+ * a width token: these carry the answer instead of the question, and a rule branches on a breakpoint by name through
20
+ * a style query rather than repeating its width.
21
+ *
22
+ * The widths below are the only place the design system states them at all, one each for a phone held upright, a
23
+ * tablet or a split window, a laptop and a desktop. A rule elsewhere reads the switch for the breakpoint it cares
24
+ * about, never the width behind it, so the threshold can move without touching that rule.
25
+ */
26
+
27
+ @property --skin--viewport-small {
28
+ syntax: "*";
29
+ inherits: true;
30
+ initial-value: off;
31
+ }
32
+
33
+ @property --skin--viewport-medium {
34
+ syntax: "*";
35
+ inherits: true;
36
+ initial-value: off;
37
+ }
38
+
39
+ @property --skin--viewport-large {
40
+ syntax: "*";
41
+ inherits: true;
42
+ initial-value: off;
43
+ }
44
+
45
+ @property --skin--viewport-xlarge {
46
+ syntax: "*";
47
+ inherits: true;
48
+ initial-value: off;
49
+ }
50
+
51
+ /*
52
+ * Every query is a floor, so a wider viewport leaves the narrower switches on and a rule reads them as a ladder rather
53
+ * than as a band. Each is assigned on the root element and inherits, so every element sits inside a container that a
54
+ * style query can match, and no rule anywhere has to declare a container of its own to branch on a breakpoint.
55
+ *
56
+ * The widths are stated in rem because each one asks whether the content fits, not how big the glass is, and content
57
+ * is measured in text: a comfortable line runs 65 to 75 characters, which is a multiple of the font size rather than
58
+ * of physical pixels. A reader who raises the browser default to 24px needs about half as much width again for the
59
+ * same words, so the layout that fitted at 768 pixels no longer does. A px query cannot see that and hands them the
60
+ * wide layout with the text crammed into it, while a rem query moves them down the ladder to the simpler one, which
61
+ * is what raising the font size asked for.
62
+ *
63
+ * Inside a media query rem resolves against the browser's initial font size, never against the root font size the
64
+ * page sets, so neither --skin--font-size nor an app overriding it moves these thresholds: only the reader's own
65
+ * browser setting does, which is the one input that should. Browser zoom scales the CSS pixel and so moves a px
66
+ * query and a rem query alike, and is not a case either unit handles better.
67
+ *
68
+ * A device-bound question, such as whether this is a touch phone, takes other units and features: none below asks one.
69
+ */
70
+
71
+ @media (min-width: 30rem) {
72
+
73
+ :root {
74
+ --skin--viewport-small: on;
75
+ }
76
+
77
+ }
78
+
79
+ @media (min-width: 48rem) {
80
+
81
+ :root {
82
+ --skin--viewport-medium: on;
83
+ }
84
+
85
+ }
86
+
87
+ @media (min-width: 64rem) {
88
+
89
+ :root {
90
+ --skin--viewport-large: on;
91
+ }
92
+
93
+ }
94
+
95
+ @media (min-width: 90rem) {
96
+
97
+ :root {
98
+ --skin--viewport-xlarge: on;
99
+ }
100
+
101
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Viewport tokens.
3
+ *
4
+ * Tells which breakpoints the viewport has passed, so a stylesheet branches on one by name, CSS offering no other way.
5
+ *
6
+ * @remarks
7
+ *
8
+ * **Why these exist** — a media feature cannot read a custom property, so `@media (min-width: var(--x))` never
9
+ * matches and a breakpoint cannot be a width token. Each of these carries the *answer* instead of the question: the
10
+ * stylesheet states the width once, in its own media query, and hands the result on as a token any rule can read.
11
+ *
12
+ * **The breakpoints** — four widths, each naming the layout from it upwards, stated in the companion stylesheet alone:
13
+ *
14
+ * | Token | From | What it answers |
15
+ * |------------------|---------|------------------------------------------------------|
16
+ * | `viewportSmall` | `30rem` | a phone held upright, the one-column floor |
17
+ * | `viewportMedium` | `48rem` | a tablet or a split window, fitting a second column |
18
+ * | `viewportLarge` | `64rem` | a laptop, where navigation becomes a rail |
19
+ * | `viewportXlarge` | `90rem` | a desktop, where the measure is capped not stretched |
20
+ *
21
+ * **Floors, not bands** — every width is a lower bound, so a wide viewport leaves the narrower switches on and a rule
22
+ * reads them as a ladder. A rule needing a band states the wider switch as `off` alongside the narrower one as `on`,
23
+ * rather than reaching for a `max-width` query, where two rules can both match at the boundary or neither can.
24
+ *
25
+ * **Why `rem`** — each width asks whether the content fits, not how big the glass is, and content is measured in
26
+ * text: a comfortable line runs 65 to 75 characters, which is a multiple of the font size rather than of physical
27
+ * pixels. A reader who raises the browser default to 24px needs about half as much width again for the same words,
28
+ * so the layout that fitted at 768 pixels no longer does; a `px` query cannot see that and hands them the wide
29
+ * layout with the text crammed into it, while these move them down the ladder to the simpler one.
30
+ *
31
+ * A `rem` is the reader's own browser setting wherever it is read: the page takes {@link typography `fontSize`} on
32
+ * `body` and leaves the root alone, so a width a rule states in `rem` measures exactly what these thresholds measure.
33
+ * Neither `fontSize` nor an app overriding it moves them: only the reader's own browser setting does. Browser zoom
34
+ * scales the CSS pixel and so moves a `px` query and a `rem` query alike, and is not a case either unit handles better.
35
+ *
36
+ * **How a rule reads one** — through a style query, which matches on the value a custom property holds on an
37
+ * enclosing element. The tokens are assigned on the root element and inherit, so every element is inside a matching
38
+ * container and no rule declares a container of its own:
39
+ *
40
+ * ```css
41
+ * @container style(--skin--viewport-medium: on) {
42
+ * app-screen {
43
+ * grid-template-columns: 1fr 2fr;
44
+ * }
45
+ * }
46
+ * ```
47
+ *
48
+ * **Both branches** — each token defaults to `off` and turns `on` from its width up, so a rule matches either value.
49
+ *
50
+ * **Reusable, not retunable** — the width stays in the stylesheet's own media query, so overriding one of these
51
+ * tokens forces the switch without moving the threshold. What they remove is the width repeated across every component,
52
+ * not the need to revise it in one place. An app wanting thresholds of its own writes its own media queries.
53
+ *
54
+ * **Outside the cascade** — code needing the same answer reads the token as it reads any other, through
55
+ * `getComputedStyle`, which is a point-in-time read; a component that has to react to a threshold being crossed
56
+ * watches the element rather than polling.
57
+ *
58
+ * **Container queries first** — a widget changing shape because of the space it was given states a `@container` size
59
+ * query against its own inline size and reads none of these. They answer the page-level questions a container query
60
+ * cannot: how many columns a screen offers, whether navigation is a rail or a drawer.
61
+ *
62
+ * @module viewports
63
+ */
64
+ /**
65
+ * The custom property behind every viewport token.
66
+ *
67
+ * Narrowed to literals, so the design system contract can name the tokens and the custom properties they resolve to.
68
+ */
69
+ export declare const viewports: {
70
+ readonly viewportSmall: "--skin--viewport-small";
71
+ readonly viewportMedium: "--skin--viewport-medium";
72
+ readonly viewportLarge: "--skin--viewport-large";
73
+ readonly viewportXlarge: "--skin--viewport-xlarge";
74
+ };
75
+ //# sourceMappingURL=viewports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewports.d.ts","sourceRoot":"","sources":["../../src/tokens/viewports.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAGH;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;CAOZ,CAAC"}
@@ -0,0 +1,90 @@
1
+ /*
2
+ * Copyright © 2023-2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Viewport tokens.
18
+ *
19
+ * Tells which breakpoints the viewport has passed, so a stylesheet branches on one by name, CSS offering no other way.
20
+ *
21
+ * @remarks
22
+ *
23
+ * **Why these exist** — a media feature cannot read a custom property, so `@media (min-width: var(--x))` never
24
+ * matches and a breakpoint cannot be a width token. Each of these carries the *answer* instead of the question: the
25
+ * stylesheet states the width once, in its own media query, and hands the result on as a token any rule can read.
26
+ *
27
+ * **The breakpoints** — four widths, each naming the layout from it upwards, stated in the companion stylesheet alone:
28
+ *
29
+ * | Token | From | What it answers |
30
+ * |------------------|---------|------------------------------------------------------|
31
+ * | `viewportSmall` | `30rem` | a phone held upright, the one-column floor |
32
+ * | `viewportMedium` | `48rem` | a tablet or a split window, fitting a second column |
33
+ * | `viewportLarge` | `64rem` | a laptop, where navigation becomes a rail |
34
+ * | `viewportXlarge` | `90rem` | a desktop, where the measure is capped not stretched |
35
+ *
36
+ * **Floors, not bands** — every width is a lower bound, so a wide viewport leaves the narrower switches on and a rule
37
+ * reads them as a ladder. A rule needing a band states the wider switch as `off` alongside the narrower one as `on`,
38
+ * rather than reaching for a `max-width` query, where two rules can both match at the boundary or neither can.
39
+ *
40
+ * **Why `rem`** — each width asks whether the content fits, not how big the glass is, and content is measured in
41
+ * text: a comfortable line runs 65 to 75 characters, which is a multiple of the font size rather than of physical
42
+ * pixels. A reader who raises the browser default to 24px needs about half as much width again for the same words,
43
+ * so the layout that fitted at 768 pixels no longer does; a `px` query cannot see that and hands them the wide
44
+ * layout with the text crammed into it, while these move them down the ladder to the simpler one.
45
+ *
46
+ * A `rem` is the reader's own browser setting wherever it is read: the page takes {@link typography `fontSize`} on
47
+ * `body` and leaves the root alone, so a width a rule states in `rem` measures exactly what these thresholds measure.
48
+ * Neither `fontSize` nor an app overriding it moves them: only the reader's own browser setting does. Browser zoom
49
+ * scales the CSS pixel and so moves a `px` query and a `rem` query alike, and is not a case either unit handles better.
50
+ *
51
+ * **How a rule reads one** — through a style query, which matches on the value a custom property holds on an
52
+ * enclosing element. The tokens are assigned on the root element and inherit, so every element is inside a matching
53
+ * container and no rule declares a container of its own:
54
+ *
55
+ * ```css
56
+ * @container style(--skin--viewport-medium: on) {
57
+ * app-screen {
58
+ * grid-template-columns: 1fr 2fr;
59
+ * }
60
+ * }
61
+ * ```
62
+ *
63
+ * **Both branches** — each token defaults to `off` and turns `on` from its width up, so a rule matches either value.
64
+ *
65
+ * **Reusable, not retunable** — the width stays in the stylesheet's own media query, so overriding one of these
66
+ * tokens forces the switch without moving the threshold. What they remove is the width repeated across every component,
67
+ * not the need to revise it in one place. An app wanting thresholds of its own writes its own media queries.
68
+ *
69
+ * **Outside the cascade** — code needing the same answer reads the token as it reads any other, through
70
+ * `getComputedStyle`, which is a point-in-time read; a component that has to react to a threshold being crossed
71
+ * watches the element rather than polling.
72
+ *
73
+ * **Container queries first** — a widget changing shape because of the space it was given states a `@container` size
74
+ * query against its own inline size and reads none of these. They answer the page-level questions a container query
75
+ * cannot: how many columns a screen offers, whether navigation is a rail or a drawer.
76
+ *
77
+ * @module viewports
78
+ */
79
+ /**
80
+ * The custom property behind every viewport token.
81
+ *
82
+ * Narrowed to literals, so the design system contract can name the tokens and the custom properties they resolve to.
83
+ */
84
+ export const viewports = {
85
+ viewportSmall: "--skin--viewport-small",
86
+ viewportMedium: "--skin--viewport-medium",
87
+ viewportLarge: "--skin--viewport-large",
88
+ viewportXlarge: "--skin--viewport-xlarge"
89
+ };
90
+ //# sourceMappingURL=viewports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewports.js","sourceRoot":"","sources":["../../src/tokens/viewports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IAExB,aAAa,EAAE,wBAAwB;IACvC,cAAc,EAAE,yBAAyB;IACzC,aAAa,EAAE,wBAAwB;IACvC,cAAc,EAAE,yBAAyB;CAEhC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,89 @@
1
1
  {
2
2
  "name": "@grafctory/skin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.1",
4
+ "description": "Essential design tokens and styles.",
5
+ "keywords": [
6
+ "typescript",
7
+ "css",
8
+ "design-system",
9
+ "tokens",
10
+ "ui"
11
+ ],
12
+ "homepage": "https://grafctory.github.io/skin/",
13
+ "bugs": {
14
+ "url": "https://github.com/grafctory/skin/issues",
15
+ "email": "info@metreeca.com"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "author": {
19
+ "name": "Metreeca",
20
+ "email": "info@metreeca.com",
21
+ "url": "https://www.metreeca.com/"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/grafctory/skin.git"
26
+ },
27
+ "type": "module",
28
+ "sideEffects": [
29
+ "*.css"
30
+ ],
31
+ "exports": {
32
+ ".": {
33
+ "@grafctory/source": "./src/index.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./index.css": {
37
+ "@grafctory/source": "./src/index.css",
38
+ "default": "./dist/index.css"
39
+ },
40
+ "./presets/inter.css": {
41
+ "@grafctory/source": "./src/presets/inter.css",
42
+ "default": "./dist/presets/inter.css"
43
+ },
44
+ "./presets/roboto.css": {
45
+ "@grafctory/source": "./src/presets/roboto.css",
46
+ "default": "./dist/presets/roboto.css"
47
+ }
48
+ },
49
+ "files": [
50
+ "README.md",
51
+ "LICENSE",
52
+ "dist"
53
+ ],
54
+ "engines": {
55
+ "node": ">=22.22.0"
56
+ },
57
+ "scripts": {
58
+ "clean": "ush rm dist docs node_modules",
59
+ "prime": "npm ci",
60
+ "setup": "npm ci && ush ln",
61
+ "build": "ush rm dist docs && tsc -p tsconfig.build.json && ush cp dist 'src/**/*.css' && npx typedoc && npx vite build lab",
62
+ "check": "npx vitest --typecheck run",
63
+ "proof": "ush up npx typedoc --watch + ush ws --open docs",
64
+ "watch": "npx vite lab --open"
65
+ },
66
+ "dependencies": {
67
+ "@fontsource-variable/geist-mono": "^5.3.0",
68
+ "@fontsource-variable/inter": "^5.3.0",
69
+ "@fontsource-variable/inter-tight": "^5.3.0",
70
+ "@fontsource-variable/roboto": "^5.3.0",
71
+ "@fontsource-variable/roboto-condensed": "^5.3.0",
72
+ "@fontsource-variable/roboto-mono": "^5.3.0"
73
+ },
74
+ "devDependencies": {
75
+ "@csstools/color-helpers": "^6.1.2",
76
+ "@csstools/css-color-parser": "^4.2.7",
77
+ "@csstools/css-parser-algorithms": "^4.0.2",
78
+ "@csstools/css-tokenizer": "^4.0.2",
79
+ "@grafctory/rack": "^0.8.0",
80
+ "@types/node": "^22.20.4",
81
+ "typedoc": "^0.28.20",
82
+ "typescript": "^6.0.3",
83
+ "vite": "^8.3.6",
84
+ "vitest": "^5.0.5"
85
+ },
86
+ "allowScripts": {
87
+ "fsevents": true
88
+ }
89
+ }