@guardian/stand 0.0.7 → 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 +217 -23
  2. package/dist/fonts/OpenSans.css +327 -0
  3. package/dist/index.cjs +8 -0
  4. package/dist/index.js +4 -0
  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 +2 -10
  30. package/dist/styleD/utils/semantic/typography.js +2 -10
  31. package/dist/types/index.d.ts +8 -0
  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 +1 -8
  45. package/package.json +12 -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,20 +140,22 @@ 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
150
  const stringStyle = css`
120
- color: ${semanticColors.text.primary}; /* JS/TS usage */
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
  `;
125
156
 
126
157
  const objectStyle = {
127
- color: semanticColors.text.primary /* JS/TS usage */,
158
+ color: semanticColors.text.default /* JS/TS usage */,
128
159
  backgroundColor:
129
160
  'var(--semantic-colors-bg-default-on-light)' /* CSS usage */,
130
161
  };
@@ -136,6 +167,8 @@ For a full list of CSS Semantic Color tokens see [`semantic/colors.css`](./src/s
136
167
 
137
168
  #### Typography
138
169
 
170
+ _Status: WIP_
171
+
139
172
  ```ts
140
173
  import { css } from '@emotion/react';
141
174
  import {
@@ -148,18 +181,33 @@ import '@guardian/stand/semantic/typography.css'; // CSS usage
148
181
 
149
182
  /* JS/TS usage */
150
183
  const stringStyleJS = css`
184
+ // other styles e.g.
185
+ color: ${semanticColors.text.default};
186
+
187
+ /* (recommended) emotion string style usage helper function*/
151
188
  ${convertTypographyToEmotionStringStyle(
152
189
  semanticTypography['body-compact-md'],
153
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};
154
197
  `;
155
198
  const objectStyleJS = {
156
199
  // other styles e.g.
157
- color: semanticColors.text.primary,
200
+ color: semanticColors.text.default,
158
201
 
159
- // typography styles
202
+ // (recommended) emotion object style usage helper function
160
203
  ...convertTypographyToEmotionObjectStyle(
161
204
  semanticTypography['body-compact-sm'],
162
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}`,
163
211
  };
164
212
 
165
213
  /* CSS usage */
@@ -171,12 +219,9 @@ const stringStyleCSS = css`
171
219
  var(--semantic-typography-body-compact-sm-font-width);
172
220
  `;
173
221
  const objectStyleCSS = {
174
- fontFamily: 'var(--semantic-typography-body-compact-sm-font-family)',
175
- fontWeight: 'var(--semantic-typography-body-compact-sm-font-weight)',
176
- fontSize: 'var(--semantic-typography-body-compact-sm-font-size)',
177
- lineHeight: 'var(--semantic-typography-body-compact-sm-line-height)',
222
+ font: 'var(--semantic-typography-body-compact-sm-font)',
178
223
  letterSpacing: 'var(--semantic-typography-body-compact-sm-letter-spacing)',
179
- fontVariationSettings: `'wdth' var(--semantic-typography-body-compact-sm-font-variation-settings)`,
224
+ fontVariationSettings: `'wdth' var(--semantic-typography-body-compact-sm-font-width)`,
180
225
  };
181
226
  ```
182
227
 
@@ -184,10 +229,42 @@ For a list of available typography styles see the [Storybook Semantic Typography
184
229
 
185
230
  For a full list of CSS Semantic Typography tokens see [`semantic/typography.css`](./src/styleD/build/css/semantic/typography.css).
186
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
+
187
262
  ### Base / Primitives
188
263
 
189
264
  #### Colors
190
265
 
266
+ _Status: WIP_
267
+
191
268
  ```ts
192
269
  import { css } from '@emotion/react';
193
270
  import { baseColors } from '@guardian/stand'; // JS/TS usage
@@ -210,6 +287,8 @@ For a full list of CSS Base/Primitives Color tokens see [`base/colors.css`](./sr
210
287
 
211
288
  #### Typography
212
289
 
290
+ _Status: WIP_
291
+
213
292
  ```ts
214
293
  import { css } from '@emotion/react';
215
294
  import { baseTypography } from '@guardian/stand'; // JS/TS usage
@@ -218,41 +297,41 @@ import '@guardian/stand/base/typography.css'; // CSS usage
218
297
  /* JS/TS usage */
219
298
  const stringStyleJS = css`
220
299
  font-family: ${baseTypography.family['Open Sans']};
221
- font-size: ${baseTypography.size['14-px']};
300
+ font-size: ${baseTypography.size['14-rem']};
222
301
  font-weight: ${baseTypography.weight['Open Sans'].normal};
223
302
  font-variation-settings: 'wdth' ${baseTypography.width['Open Sans']};
224
303
  style: ${baseTypography.style.normal};
225
304
  line-height: ${baseTypography.lineHeight.normal};
226
- letter-spacing: ${baseTypography.letterSpacing['default-px']};
305
+ letter-spacing: ${baseTypography.letterSpacing['default-rem']};
227
306
  `;
228
307
  const objectStyleJS = {
229
308
  fontFamily: baseTypography.family['Open Sans'],
230
- fontSize: baseTypography.size['14-px'],
309
+ fontSize: baseTypography.size['14-rem'],
231
310
  fontWeight: baseTypography.weight['Open Sans'].normal,
232
311
  fontVariationSettings: `'wdth' ${baseTypography.width['Open Sans']}`,
233
312
  fontStyle: baseTypography.style.normal,
234
313
  lineHeight: baseTypography.lineHeight.normal,
235
- letterSpacing: baseTypography.letterSpacing['default-px'],
314
+ letterSpacing: baseTypography.letterSpacing['default-rem'],
236
315
  };
237
316
 
238
317
  /* CSS usage */
239
318
  const stringStyleCSS = css`
240
319
  font-family: var(--base-typography-family-open-sans);
241
- font-size: var(--base-typography-size-14-px);
320
+ font-size: var(--base-typography-size-14-rem);
242
321
  font-weight: var(--base-typography-weight-open-sans-normal);
243
322
  font-variation-settings: 'wdth' var(--base-typography-width-open-sans);
244
323
  font-style: var(--base-typography-style-normal);
245
324
  line-height: var(--base-typography-line-height-normal);
246
- letter-spacing: var(--base-typography-letter-spacing-default-px);
325
+ letter-spacing: var(--base-typography-letter-spacing-default-rem);
247
326
  `;
248
327
  const objectStyleCSS = {
249
328
  fontFamily: 'var(--base-typography-family-open-sans)',
250
- fontSize: 'var(--base-typography-size-14-px)',
329
+ fontSize: 'var(--base-typography-size-14-rem)',
251
330
  fontWeight: 'var(--base-typography-weight-open-sans-normal)',
252
331
  fontVariationSettings: `'wdth' var(--base-typography-width-open-sans)`,
253
332
  fontStyle: 'var(--base-typography-style-normal)',
254
333
  lineHeight: 'var(--base-typography-line-height-normal)',
255
- letterSpacing: 'var(--base-typography-letter-spacing-default-px)',
334
+ letterSpacing: 'var(--base-typography-letter-spacing-default-rem)',
256
335
  };
257
336
  ```
258
337
 
@@ -260,6 +339,121 @@ For a list of the available base/primitives typography tokens see the [Storybook
260
339
 
261
340
  For a full list of CSS Base/Primitives Typography tokens see [`base/typography.css`](./src/styleD/build/css/base/typography.css).
262
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
+
263
457
  ## Components
264
458
 
265
459
  ### `Byline`