@propellerads/tokens 0.0.1 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +63 -8
  2. package/common.css +62 -33
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -193,6 +193,29 @@ over something else rather than replacing it:
193
193
  colour + amount, for baking into a colour with `color-mix()` instead of laying on
194
194
  a second layer. They are not colours, so `color: var(--over-bg-mix)` does nothing.
195
195
 
196
+ ## Spacing and corners
197
+
198
+ Both scales are the 4 px grid. `--space-4` is one step — `Basic` in the design
199
+ file — and every other name is that step multiplied: `--space-8` is 2X,
200
+ `--space-80` is 20X. Corners run on the same grid and stop at `--radius-40`.
201
+
202
+ ```css
203
+ .card {
204
+ padding: var(--space-16); /* 4X */
205
+ gap: var(--space-8); /* 2X */
206
+ border-radius: var(--radius-8);
207
+ }
208
+ ```
209
+
210
+ The token name carries the pixel value rather than the multiplier, so a value
211
+ read off the design file is looked up without arithmetic, and the same name
212
+ cannot come to mean a different number later.
213
+
214
+ Two names are on the list without being steps of the grid: `--space-0` is a
215
+ reset, and `--space-1` is for hairlines and rules. A component may still use its
216
+ own padding internally for optical alignment — the scale governs the space
217
+ between things, not the inside of a control.
218
+
196
219
  ## Dark theme
197
220
 
198
221
  `common.css` switches on the operating system setting, and on `data-theme`:
@@ -210,17 +233,49 @@ once per switch, because a media query and a plain selector cannot share a rule
210
233
 
211
234
  ## Sizes
212
235
 
213
- A type size is named desktop-mobile: `--font-size-28-20` is 28px, and 20px below
214
- the mobile breakpoint, which `common.css` applies on its own. Equal halves are the
215
- common case. The scale is in pixels, not `em` or `rem`, so a root font size cannot
216
- move it behind the page's back.
236
+ Type is named by role, not by size — H4, Text and Paragraph are all 14px and
237
+ differ in weight and leading. A role is one token, for the `font` shorthand, and
238
+ the whole style lands in one declaration:
239
+
240
+ ```css
241
+ .card__title {
242
+ font: var(--font-h3);
243
+ }
244
+ ```
245
+
246
+ There is no separate size, leading or weight token: the numbers only mean
247
+ anything together, and a role you can take apart is a role that gets assembled
248
+ wrong. The family is the one part that stays a variable, because it is the
249
+ brand's.
250
+
251
+ `font` is a shorthand, so it also resets `font-style`, `font-variant` and
252
+ `font-stretch`. That is what you want on a heading and a trap inside one: set the
253
+ italic *after* the shorthand, never before.
254
+
255
+ | Role | Weight | Size | Line height |
256
+ |---|---|---|---|
257
+ | `--font-hero-max` | 700 | 100px | `normal` |
258
+ | `--font-hero-basic` | 700 | 52px | `normal` |
259
+ | `--font-h1` | 700 | 28px, 20px below the mobile breakpoint | `normal` |
260
+ | `--font-h2` | 700 | 20px, 18px below the mobile breakpoint | `normal` |
261
+ | `--font-h3` | 700 | 16px | `normal` |
262
+ | `--font-h4` | 700 | 14px | `normal` |
263
+ | `--font-text` | 400 | 14px | `normal` |
264
+ | `--font-paragraph` | 400 | 14px | 20px |
265
+ | `--font-description` | 400 | 12px | 16px |
266
+ | `--font-hints` | 400 | 10px | `normal` |
267
+
268
+ `normal` is what the design file calls Auto. Sizes are in pixels, not `em` or
269
+ `rem`, so a root font size cannot move them behind the page's back, and
270
+ `common.css` applies the two mobile steps on its own — a role is one value, so
271
+ the media query repeats the whole declaration rather than a size inside it.
217
272
 
218
273
  | Group | Tokens |
219
274
  |--------------|--------------------------------------------------------------------------------------------|
220
- | Font size | `--font-size-100-100`, `-52-52`, `-28-20`, `-20-20`, `-20-18`, `-16-16`, `-14-14`, `-12-12`, `-10-10` |
221
- | Line height | `--line-height-20-20`, `--line-height-16-16` |
222
- | Font weight | `--font-weight-title` (700), `--font-weight-basic` (400) |
223
- | Space | `--space-0`, `-1`, `-2`, `-4`, `-8`, `-12`, `-16`, `-24`, `-32`, `-40`, `-80` — the number is the pixel value |
275
+ | Type role | `--font-hero-max`, `-hero-basic`, `--font-h1`…`-h4`, `--font-text`, `-paragraph`, `-description`, `-hints` |
276
+ | Font family | `--font-family` — the brand's, and the only part of a role that is a variable |
277
+ | Space | `--space-0`, `-1`, `-2`, `-4`, `-8`, `-12`, `-16`, `-20`, `-24`, `-32`, `-40`, `-80` — the number is the pixel value |
278
+ | Corner | `--radius-2`, `-4`, `-8`, `-16`, `-24`, `-32`, `-40` — the number is the pixel value |
224
279
  | Shadow | `--shadow-little`, `--shadow-middle`, `--shadow-big` |
225
280
  | Breakpoint | `--breakpoint-mobile` (481px), `--breakpoint-tablet` (769px), `--breakpoint-desktop` (1025px) |
226
281
 
package/common.css CHANGED
@@ -49,36 +49,63 @@
49
49
  --over-bg-mix: hsl(0 0% 100%) 90%;
50
50
 
51
51
  /* Typography --------------------------------------------------------------
52
- A size is named desktop-mobile: --font-size-28-20 is 28px, and 20px below the
53
- mobile breakpoint. The two halves being equal is the common case. */
54
- --font-weight-title: 700;
55
- --font-weight-basic: 400;
56
-
57
- --font-size-100-100: 100px;
58
- --font-size-52-52: 52px;
59
- --font-size-28-20: 28px;
60
- --font-size-20-20: 20px;
61
- --font-size-20-18: 20px;
62
- --font-size-16-16: 16px;
63
- --font-size-14-14: 14px;
64
- --font-size-12-12: 12px;
65
- --font-size-10-10: 10px;
66
-
67
- --line-height-20-20: 20px;
68
- --line-height-16-16: 16px;
69
-
70
- /* Spacing */
71
- --space-0: 0px;
72
- --space-1: 1px;
73
- --space-2: 2px;
74
- --space-4: 4px;
75
- --space-8: 8px;
76
- --space-12: 12px;
77
- --space-16: 16px;
78
- --space-24: 24px;
79
- --space-32: 32px;
80
- --space-40: 40px;
81
- --space-80: 80px;
52
+ Ten roles, named for the job rather than the size, because three of them are
53
+ the same size: H4, Text and Paragraph are all 14px and differ in weight and
54
+ leading. There is no separate size, leading or weight token — a role is one
55
+ declaration, and the numbers only mean anything together:
56
+
57
+ .card__title { font: var(--font-h3); }
58
+
59
+ The value is the `font` shorthand, so it also resets font-style, font-variant
60
+ and font-stretch to their initial values. That is what you want on a heading
61
+ and a trap inside one: set the italic after the shorthand, never before.
62
+
63
+ `normal` is what the design file calls Auto. Sizes are in pixels, not em or
64
+ rem, so a root font size cannot move them behind the page's back, and the
65
+ family is the one part that stays a variable, because it is the brand's. */
66
+
67
+ /* Headlines */
68
+ --font-hero-max: 700 100px / normal var(--font-family);
69
+ --font-hero-basic: 700 52px / normal var(--font-family);
70
+ --font-h1: 700 28px / normal var(--font-family); /* 20px below the mobile breakpoint */
71
+ --font-h2: 700 20px / normal var(--font-family); /* 18px below the mobile breakpoint */
72
+ --font-h3: 700 16px / normal var(--font-family);
73
+ --font-h4: 700 14px / normal var(--font-family);
74
+
75
+ /* Basic */
76
+ --font-text: 400 14px / normal var(--font-family);
77
+ --font-paragraph: 400 14px / 20px var(--font-family);
78
+ --font-description: 400 12px / 16px var(--font-family);
79
+ --font-hints: 400 10px / normal var(--font-family);
80
+
81
+ /* Spacing ----------------------------------------------------------------
82
+ The 4 px grid. Basic is one step, and a name is its own pixel value, so the
83
+ multiplier designers speak in is the name over four: --space-16 is 4X. Two
84
+ of these are not steps of the grid, and say so. A component may still use
85
+ its own padding inside itself, for optical alignment. */
86
+ --space-0: 0px; /* Not a step: a reset */
87
+ --space-1: 1px; /* Off the grid: hairlines and rules, not spacing */
88
+ --space-2: 2px; /* 0.5X */
89
+ --space-4: 4px; /* Basic — one step of the grid */
90
+ --space-8: 8px; /* 2X */
91
+ --space-12: 12px; /* 3X */
92
+ --space-16: 16px; /* 4X */
93
+ --space-20: 20px; /* 5X */
94
+ --space-24: 24px; /* 6X */
95
+ --space-32: 32px; /* 8X */
96
+ --space-40: 40px; /* 10X — the design scale skips it, jumping 8X to 20X */
97
+ --space-80: 80px; /* 20X — the largest step */
98
+
99
+ /* Corners ----------------------------------------------------------------
100
+ The same grid, read the same way, on a sparser scale: above Basic every step
101
+ is an even multiple. */
102
+ --radius-2: 2px; /* 0.5X */
103
+ --radius-4: 4px; /* Basic */
104
+ --radius-8: 8px; /* 2X */
105
+ --radius-16: 16px; /* 4X */
106
+ --radius-24: 24px; /* 6X */
107
+ --radius-32: 32px; /* 8X */
108
+ --radius-40: 40px; /* 10X */
82
109
 
83
110
  /* Breakpoints -------------------------------------------------------------
84
111
  Readable from JavaScript; a media query cannot use var(), so the queries in
@@ -148,11 +175,13 @@
148
175
  }
149
176
 
150
177
  /* Below the mobile breakpoint ---------------------------------------------
151
- Only the sizes whose desktop and mobile halves differ appear here. */
178
+ Only the roles whose size changes appear here; the rest hold at one size. A
179
+ role is one value, so the whole declaration is repeated rather than a size
180
+ inside it — which is also the only place to look to see what changes. */
152
181
 
153
182
  @media (max-width: 480px) {
154
183
  :root {
155
- --font-size-28-20: 20px;
156
- --font-size-20-18: 18px;
184
+ --font-h1: 700 20px / normal var(--font-family);
185
+ --font-h2: 700 18px / normal var(--font-family);
157
186
  }
158
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propellerads/tokens",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "exports": {
5
5
  "./common.css": "./common.css",
6
6
  "./propellerads.css": "./propellerads.css",