@guardian/stand 0.0.6 → 0.0.8

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 (45) hide show
  1. package/README.md +272 -27
  2. package/dist/fonts/OpenSans.css +327 -0
  3. package/dist/index.cjs +10 -1
  4. package/dist/index.js +5 -1
  5. package/dist/styleD/build/css/css/base/colors.css +3 -3
  6. package/dist/styleD/build/css/css/base/radius.css +12 -0
  7. package/dist/styleD/build/css/css/base/sizing.css +22 -0
  8. package/dist/styleD/build/css/css/base/spacing.css +36 -0
  9. package/dist/styleD/build/css/css/base/typography.css +16 -1
  10. package/dist/styleD/build/css/css/semantic/colors.css +10 -8
  11. package/dist/styleD/build/css/css/semantic/sizing.css +14 -0
  12. package/dist/styleD/build/css/css/semantic/typography.css +83 -76
  13. package/dist/styleD/build/typescript/base/colors.cjs +3 -3
  14. package/dist/styleD/build/typescript/base/colors.js +3 -3
  15. package/dist/styleD/build/typescript/base/radius.cjs +12 -0
  16. package/dist/styleD/build/typescript/base/radius.js +10 -0
  17. package/dist/styleD/build/typescript/base/sizing.cjs +22 -0
  18. package/dist/styleD/build/typescript/base/sizing.js +20 -0
  19. package/dist/styleD/build/typescript/base/spacing.cjs +36 -0
  20. package/dist/styleD/build/typescript/base/spacing.js +34 -0
  21. package/dist/styleD/build/typescript/base/typography.cjs +20 -5
  22. package/dist/styleD/build/typescript/base/typography.js +20 -5
  23. package/dist/styleD/build/typescript/semantic/colors.cjs +14 -12
  24. package/dist/styleD/build/typescript/semantic/colors.js +14 -12
  25. package/dist/styleD/build/typescript/semantic/sizing.cjs +20 -0
  26. package/dist/styleD/build/typescript/semantic/sizing.js +18 -0
  27. package/dist/styleD/build/typescript/semantic/typography.cjs +76 -342
  28. package/dist/styleD/build/typescript/semantic/typography.js +76 -342
  29. package/dist/styleD/utils/semantic/typography.cjs +11 -7
  30. package/dist/styleD/utils/semantic/typography.js +10 -7
  31. package/dist/types/index.d.ts +9 -1
  32. package/dist/types/styleD/build/typescript/base/colors.d.ts +3 -3
  33. package/dist/types/styleD/build/typescript/base/radius.d.ts +12 -0
  34. package/dist/types/styleD/build/typescript/base/sizing.d.ts +22 -0
  35. package/dist/types/styleD/build/typescript/base/spacing.d.ts +36 -0
  36. package/dist/types/styleD/build/typescript/base/typography.d.ts +18 -3
  37. package/dist/types/styleD/build/typescript/semantic/colors.d.ts +11 -9
  38. package/dist/types/styleD/build/typescript/semantic/sizing.d.ts +20 -0
  39. package/dist/types/styleD/build/typescript/semantic/typography.d.ts +38 -304
  40. package/dist/types/styleD/stories/base/Radius.d.ts +1 -0
  41. package/dist/types/styleD/stories/base/Sizing.d.ts +1 -0
  42. package/dist/types/styleD/stories/base/Spacing.d.ts +1 -0
  43. package/dist/types/styleD/stories/semantic/Sizing.d.ts +1 -0
  44. package/dist/types/styleD/utils/semantic/typography.d.ts +4 -10
  45. package/package.json +13 -7
package/README.md CHANGED
@@ -34,11 +34,40 @@ Most applications should only need to load the `Open Sans` and `Guardian Headlin
34
34
 
35
35
  You only need to load Guardian Text Egyptian if you're planning to use it in your project, in most cases you only need this when working on Guardian editorial content on an editorial tool, i.e. when using `article-body-*` semantic tokens.
36
36
 
37
- #### Open Sans
37
+ ##### Open Sans
38
38
 
39
- We're currently looking at how to best self host this font under a Guardian specific domain, before we release `@guardian/stand` design system for wider usage.
39
+ ##### Guardian Hosted (Recommended)
40
40
 
41
- For now, the Open Sans variable font can be loaded via Google Fonts:
41
+ We are self hosting this font under a Guardian specific domain, so you can load the Open Sans variable font CSS file from our CDN:
42
+
43
+ Via CSS `@import`:
44
+
45
+ ```css
46
+ @import url('https://assets.guim.co.uk/fonts/open-sans/OpenSans.css');
47
+ ```
48
+
49
+ Via HTML `<link>`:
50
+
51
+ ```html
52
+ <link
53
+ rel="stylesheet"
54
+ href="https://assets.guim.co.uk/fonts/open-sans/OpenSans.css"
55
+ />
56
+ ```
57
+
58
+ We also publish the same `OpenSans.css` file in the `@guardian/stand` package if you prefer to import it from there and you're using a bundler that supports CSS imports:
59
+
60
+ ```ts
61
+ import '@guardian/stand/fonts/OpenSans.css';
62
+ ```
63
+
64
+ All options use the font files hosted on the Guardian CDN at `https://assets.guim.co.uk/fonts/open-sans/woff2/`.
65
+
66
+ You can also create your own CSS `@font-face` declarations, using the same format as in the `OpenSans.css` file, and/or self host the font files yourself if needed.
67
+
68
+ ##### via Google Fonts
69
+
70
+ The Open Sans variable font can also be loaded via Google Fonts, but we recommend using the Guardian hosted version to avoid loading from a third party domain:
42
71
 
43
72
  1. Visit [Google Fonts - Open Sans](https://fonts.google.com/specimen/Open+Sans)
44
73
  2. Click "Get Font" -> "Get embed code"
@@ -47,13 +76,13 @@ For now, the Open Sans variable font can be loaded via Google Fonts:
47
76
  5. Copy the relevant `<link>` tag or `@import` code snippet into your project
48
77
  - You don't need to include the CSS class, as the design system will handle applying the correct font-family via CSS variables or JS/TS tokens.
49
78
 
50
- ### Guardian Fonts
79
+ #### Guardian Fonts
51
80
 
52
81
  Make sure to visit [guardian/fonts](https://github.com/guardian/fonts) repo for the latest information on how to self-host these fonts.
53
82
 
54
83
  In general, we always want to use the `full-not-hinted` versions of the fonts where possible.
55
84
 
56
- #### Guardian Headline
85
+ ##### Guardian Headline
57
86
 
58
87
  We only use the bold weight (700) of Guardian Headline in the design system.
59
88
 
@@ -68,7 +97,7 @@ We only use the bold weight (700) of Guardian Headline in the design system.
68
97
  }
69
98
  ```
70
99
 
71
- #### Guardian Text Egyptian
100
+ ##### Guardian Text Egyptian
72
101
 
73
102
  We want the regular/normal weight (400), the bold weight (700), and the italic version of each weight for Guardian Text Egyptian in the design system.
74
103
 
@@ -111,104 +140,320 @@ We want the regular/normal weight (400), the bold weight (700), and the italic v
111
140
 
112
141
  #### Colors
113
142
 
143
+ _Status: WIP_
144
+
114
145
  ```ts
115
146
  import { css } from '@emotion/react';
116
147
  import { semanticColors } from '@guardian/stand'; // JS/TS usage
117
148
  import '@guardian/stand/semantic/colors.css'; // CSS usage
118
149
 
119
- const style = css`
120
- color: ${semanticColors.text.primary}; /* JS/TS usage */
150
+ const stringStyle = css`
151
+ color: ${semanticColors.text.default}; /* JS/TS usage */
121
152
  background-color: var(
122
153
  --semantic-colors-bg-default-on-light
123
154
  ); /* CSS usage */
124
155
  `;
156
+
157
+ const objectStyle = {
158
+ color: semanticColors.text.default /* JS/TS usage */,
159
+ backgroundColor:
160
+ 'var(--semantic-colors-bg-default-on-light)' /* CSS usage */,
161
+ };
125
162
  ```
126
163
 
127
- For a list of available semantic color styles see the [Storybook Semantic Colors](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-color-palette--docs) section.
164
+ For a list of available semantic color styles see the [Storybook Semantic Colors](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-color-palette--docs) section.
128
165
 
129
166
  For a full list of CSS Semantic Color tokens see [`semantic/colors.css`](./src/styleD/build/css/semantic/colors.css).
130
167
 
131
168
  #### Typography
132
169
 
170
+ _Status: WIP_
171
+
133
172
  ```ts
134
173
  import { css } from '@emotion/react';
135
174
  import {
175
+ semanticColors,
136
176
  semanticTypography,
137
- convertTypographyToEmotion, // helper function to convert from typography token object to emotion CSS
177
+ convertTypographyToEmotionObjectStyle, // helper function to convert from typography token object to emotion CSS object style
178
+ convertTypographyToEmotionStringStyle, // helper function to convert from typography token object to emotion CSS string style
138
179
  } from '@guardian/stand'; // JS/TS usage
139
180
  import '@guardian/stand/semantic/typography.css'; // CSS usage
140
181
 
141
- const styleJS = css`
142
- /* JS/TS usage */
143
- ${convertTypographyToEmotion(semanticTypography['body-compact-md'])}
182
+ /* JS/TS usage */
183
+ const stringStyleJS = css`
184
+ // other styles e.g.
185
+ color: ${semanticColors.text.default};
186
+
187
+ /* (recommended) emotion string style usage helper function*/
188
+ ${convertTypographyToEmotionStringStyle(
189
+ semanticTypography['body-compact-md'],
190
+ )}
191
+
192
+ /* or direct usage without helper function */
193
+ font: ${semanticTypography['body-compact-md'].font};
194
+ letter-spacing: ${semanticTypography['body-compact-md'].letterSpacing};
195
+ font-variation-settings: 'wdth'
196
+ ${semanticTypography['body-compact-md'].fontWidth};
144
197
  `;
198
+ const objectStyleJS = {
199
+ // other styles e.g.
200
+ color: semanticColors.text.default,
201
+
202
+ // (recommended) emotion object style usage helper function
203
+ ...convertTypographyToEmotionObjectStyle(
204
+ semanticTypography['body-compact-sm'],
205
+ ),
206
+
207
+ // or direct usage without helper function
208
+ font: semanticTypography['body-compact-sm'].font,
209
+ letterSpacing: semanticTypography['body-compact-sm'].letterSpacing,
210
+ fontVariationSettings: `'wdth' ${semanticTypography['body-compact-sm'].fontWidth}`,
211
+ };
145
212
 
146
- const styleCSS = css`
213
+ /* CSS usage */
214
+ const stringStyleCSS = css`
147
215
  /* CSS usage */
148
216
  font: var(--semantic-typography-body-compact-sm-font);
149
217
  letter-spacing: var(--semantic-typography-body-compact-sm-letter-spacing);
150
218
  font-variation-settings: 'wdth'
151
219
  var(--semantic-typography-body-compact-sm-font-width);
152
220
  `;
221
+ const objectStyleCSS = {
222
+ font: 'var(--semantic-typography-body-compact-sm-font)',
223
+ letterSpacing: 'var(--semantic-typography-body-compact-sm-letter-spacing)',
224
+ fontVariationSettings: `'wdth' var(--semantic-typography-body-compact-sm-font-width)`,
225
+ };
153
226
  ```
154
227
 
155
- For a list of available typography styles see the [Storybook Semantic Typography](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-typography--docs) section.
228
+ For a list of available typography styles see the [Storybook Semantic Typography](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-typography--docs) section.
156
229
 
157
230
  For a full list of CSS Semantic Typography tokens see [`semantic/typography.css`](./src/styleD/build/css/semantic/typography.css).
158
231
 
232
+ #### Sizing
233
+
234
+ _Status: WIP_
235
+
236
+ ```ts
237
+ import { css } from '@emotion/react';
238
+ import { semanticSizing } from '@guardian/stand'; // JS/TS usage
239
+ import '@guardian/stand/semantic/sizing.css'; // CSS usage
240
+
241
+ const stringStyle = css`
242
+ height: ${semanticSizing.height.md}; /* JS/TS usage */
243
+ border-width: var(--semantic-sizing-border-md); /* CSS usage */
244
+ `;
245
+
246
+ const objectStyle = {
247
+ height: semanticSizing.height.md /* JS/TS usage */,
248
+ borderWidth: 'var(--semantic-sizing-border-md)' /* CSS usage */,
249
+ };
250
+
251
+ // Icon sizing example
252
+ const iconStyle = css`
253
+ width: ${semanticSizing.icon.lg};
254
+ height: ${semanticSizing.icon.lg};
255
+ `;
256
+ ```
257
+
258
+ For a list of available semantic sizing styles see the [Storybook Semantic Sizing](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-semantic-sizing--docs) section.
259
+
260
+ For a full list of CSS Semantic Sizing tokens see [`semantic/sizing.css`](./src/styleD/build/css/semantic/sizing.css).
261
+
159
262
  ### Base / Primitives
160
263
 
161
264
  #### Colors
162
265
 
266
+ _Status: WIP_
267
+
163
268
  ```ts
164
269
  import { css } from '@emotion/react';
165
270
  import { baseColors } from '@guardian/stand'; // JS/TS usage
166
271
  import '@guardian/stand/base/colors.css'; // CSS usage
167
272
 
168
- const style = css`
273
+ const stringStyle = css`
169
274
  color: ${baseColors.neutral['900']}; /* JS/TS usage */
170
275
  background-color: var(--base-colors-blue-500); /* CSS usage */
171
276
  `;
277
+
278
+ const objectStyle = {
279
+ color: baseColors.neutral['900'] /* JS/TS usage */,
280
+ backgroundColor: 'var(--base-colors-blue-500)' /* CSS usage */,
281
+ };
172
282
  ```
173
283
 
174
- For a list of the available base/primitives color styles see the [Storybook Base Colors](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-base-color-palette--docs) section.
284
+ For a list of the available base/primitives color styles see the [Storybook Base Colors](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-color-palette--docs) section.
175
285
 
176
286
  For a full list of CSS Base/Primitives Color tokens see [`base/colors.css`](./src/styleD/build/css/base/colors.css).
177
287
 
178
288
  #### Typography
179
289
 
290
+ _Status: WIP_
291
+
180
292
  ```ts
181
293
  import { css } from '@emotion/react';
182
294
  import { baseTypography } from '@guardian/stand'; // JS/TS usage
183
295
  import '@guardian/stand/base/typography.css'; // CSS usage
184
296
 
185
- const styleJs = css`
186
- /* JS/TS usage */
297
+ /* JS/TS usage */
298
+ const stringStyleJS = css`
187
299
  font-family: ${baseTypography.family['Open Sans']};
188
- font-size: ${baseTypography.size['14-px']};
300
+ font-size: ${baseTypography.size['14-rem']};
189
301
  font-weight: ${baseTypography.weight['Open Sans'].normal};
190
302
  font-variation-settings: 'wdth' ${baseTypography.width['Open Sans']};
191
- font-style: ${baseTypography.style.normal};
303
+ style: ${baseTypography.style.normal};
192
304
  line-height: ${baseTypography.lineHeight.normal};
193
- letter-spacing: ${baseTypography.letterSpacing['default-px']};
305
+ letter-spacing: ${baseTypography.letterSpacing['default-rem']};
194
306
  `;
307
+ const objectStyleJS = {
308
+ fontFamily: baseTypography.family['Open Sans'],
309
+ fontSize: baseTypography.size['14-rem'],
310
+ fontWeight: baseTypography.weight['Open Sans'].normal,
311
+ fontVariationSettings: `'wdth' ${baseTypography.width['Open Sans']}`,
312
+ fontStyle: baseTypography.style.normal,
313
+ lineHeight: baseTypography.lineHeight.normal,
314
+ letterSpacing: baseTypography.letterSpacing['default-rem'],
315
+ };
195
316
 
196
- const styleCss = css`
197
- /* CSS usage */
317
+ /* CSS usage */
318
+ const stringStyleCSS = css`
198
319
  font-family: var(--base-typography-family-open-sans);
199
- font-size: var(--base-typography-size-14-px);
320
+ font-size: var(--base-typography-size-14-rem);
200
321
  font-weight: var(--base-typography-weight-open-sans-normal);
201
322
  font-variation-settings: 'wdth' var(--base-typography-width-open-sans);
202
323
  font-style: var(--base-typography-style-normal);
203
324
  line-height: var(--base-typography-line-height-normal);
204
- letter-spacing: var(--base-typography-letter-spacing-default-px);
325
+ letter-spacing: var(--base-typography-letter-spacing-default-rem);
205
326
  `;
327
+ const objectStyleCSS = {
328
+ fontFamily: 'var(--base-typography-family-open-sans)',
329
+ fontSize: 'var(--base-typography-size-14-rem)',
330
+ fontWeight: 'var(--base-typography-weight-open-sans-normal)',
331
+ fontVariationSettings: `'wdth' var(--base-typography-width-open-sans)`,
332
+ fontStyle: 'var(--base-typography-style-normal)',
333
+ lineHeight: 'var(--base-typography-line-height-normal)',
334
+ letterSpacing: 'var(--base-typography-letter-spacing-default-rem)',
335
+ };
206
336
  ```
207
337
 
208
- For a list of the available base/primitives typography tokens see the [Storybook Base Typography](https://68c12e3ed577cb56abfd31bf-ktzjjbdtby.chromatic.com/?path=/docs/stand-editorial-design-system-base-typography--docs) section.
338
+ For a list of the available base/primitives typography tokens see the [Storybook Base Typography](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-typography--docs) section.
209
339
 
210
340
  For a full list of CSS Base/Primitives Typography tokens see [`base/typography.css`](./src/styleD/build/css/base/typography.css).
211
341
 
342
+ #### Spacing
343
+
344
+ _Status: WIP_
345
+
346
+ The `rem` tokens should be used in most cases to ensure scalability across different root font sizes.
347
+ `px` tokens are available for cases where a fixed pixel value is required.
348
+
349
+ ```ts
350
+ import { css } from '@emotion/react';
351
+ import { baseSpacing } from '@guardian/stand'; // JS/TS usage
352
+ import '@guardian/stand/base/spacing.css'; // CSS usage
353
+
354
+ /* JS/TS usage */
355
+ const stringStyleJS = css`
356
+ padding: ${baseSpacing['16-rem']};
357
+ margin-bottom: ${baseSpacing['24-rem']};
358
+ gap: ${baseSpacing['8-rem']};
359
+ `;
360
+ const objectStyleJS = {
361
+ padding: baseSpacing['16-rem'],
362
+ marginBottom: baseSpacing['24-rem'],
363
+ gap: baseSpacing['8-rem'],
364
+ };
365
+
366
+ /* CSS usage */
367
+ const stringStyleCSS = css`
368
+ padding: var(--base-spacing-16-rem);
369
+ margin-bottom: var(--base-spacing-24-rem);
370
+ gap: var(--base-spacing-8-rem);
371
+ `;
372
+ const objectStyleCSS = {
373
+ padding: 'var(--base-spacing-16-rem)',
374
+ marginBottom: 'var(--base-spacing-24-rem)',
375
+ gap: 'var(--base-spacing-8-rem)',
376
+ };
377
+ ```
378
+
379
+ For a list of the available base/primitives spacing tokens see the [Storybook Base Spacing](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-spacing--docs) section.
380
+
381
+ For a full list of CSS Base/Primitives Spacing tokens see [`base/spacing.css`](./src/styleD/build/css/base/spacing.css).
382
+
383
+ #### Sizing
384
+
385
+ _Status: WIP_
386
+
387
+ The `rem` tokens should be used in most cases to ensure scalability across different root font sizes.
388
+ `px` tokens are available for cases where a fixed pixel value is required.
389
+
390
+ ```ts
391
+ import { css } from '@emotion/react';
392
+ import { baseSizing } from '@guardian/stand'; // JS/TS usage
393
+ import '@guardian/stand/base/sizing.css'; // CSS usage
394
+
395
+ /* JS/TS usage */
396
+ const stringStyleJS = css`
397
+ width: ${baseSizing['size-48-rem']};
398
+ height: ${baseSizing['size-24-rem']};
399
+ min-width: ${baseSizing['size-24-rem']};
400
+ `;
401
+ const objectStyleJS = {
402
+ width: baseSizing['size-48-rem'],
403
+ height: baseSizing['size-24-rem'],
404
+ minWidth: baseSizing['size-24-rem'],
405
+ };
406
+
407
+ /* CSS usage */
408
+ const stringStyleCSS = css`
409
+ width: var(--base-sizing-size-48-rem);
410
+ height: var(--base-sizing-size-24-rem);
411
+ min-width: var(--base-sizing-size-24-rem);
412
+ `;
413
+ const objectStyleCSS = {
414
+ width: 'var(--base-sizing-size-48-rem)',
415
+ height: 'var(--base-sizing-size-24-rem)',
416
+ minWidth: 'var(--base-sizing-size-24-rem)',
417
+ };
418
+ ```
419
+
420
+ For a list of the available base/primitives sizing tokens see the [Storybook Base Sizing](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-sizing--docs) section.
421
+
422
+ For a full list of CSS Base/Primitives Sizing tokens see [`base/sizing.css`](./src/styleD/build/css/base/sizing.css).
423
+
424
+ #### Radius
425
+
426
+ _Status: WIP_
427
+
428
+ The `rem` tokens should be used in most cases to ensure scalability across different root font sizes.
429
+ `px` tokens are available for cases where a fixed pixel value is required.
430
+
431
+ ```ts
432
+ import { css } from '@emotion/react';
433
+ import { baseRadius } from '@guardian/stand'; // JS/TS usage
434
+ import '@guardian/stand/base/radius.css'; // CSS usage
435
+
436
+ /* JS/TS usage */
437
+ const stringStyleJS = css`
438
+ border-radius: ${baseRadius['corner-4-rem']};
439
+ `;
440
+ const objectStyleJS = {
441
+ borderRadius: baseRadius['corner-4-rem'],
442
+ };
443
+
444
+ /* CSS usage */
445
+ const stringStyleCSS = css`
446
+ border-radius: var(--base-radius-corner-4-rem);
447
+ `;
448
+ const objectStyleCSS = {
449
+ borderRadius: 'var(--base-radius-corner-4-rem)',
450
+ };
451
+ ```
452
+
453
+ For a list of the available base/primitives radius tokens see the [Storybook Base Radius](https://68c12e3ed577cb56abfd31bf-kggeezequd.chromatic.com/?path=/docs/stand-editorial-design-system-base-radius--docs) section.
454
+
455
+ For a full list of CSS Base/Primitives Radius tokens see [`base/radius.css`](./src/styleD/build/css/base/radius.css).
456
+
212
457
  ## Components
213
458
 
214
459
  ### `Byline`