@justeattakeaway/pie-css 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -219,7 +219,7 @@ To use the typography utilities, import the typography CSS file:
219
219
  import '@justeattakeaway/pie-css/dist/helpers/typography.css';
220
220
  ```
221
221
 
222
- For complete documentation on all available typography utility classes, including usage examples and best practices, see the [Typography Utilities documentation in Storybook](/docs/additional-libraries-pie-css-typography-utility-classes--docs).
222
+ For complete documentation on all available typography utility classes, including usage examples and best practices, see the [Typography Utilities documentation in Storybook](/docs/introduction-typography-utility-classes--docs).
223
223
 
224
224
  ---
225
225
 
@@ -20,10 +20,6 @@ All of our design tokens can be added to your project by following our [CSS setu
20
20
  - [Stack items with spacing token](#stack-items-with-spacing-token)
21
21
  - [Add padding using spacing alias](#add-padding-using-spacing-alias)
22
22
  - [Typography](#typography)
23
- - [Font size](#font-size)
24
- - [Body text](#body-text)
25
- - [Heading example](#heading-example)
26
- - [Line height](#line-height)
27
23
  - [Radius](#radius)
28
24
  - [Rounded card](#rounded-card)
29
25
  - [Motion](#motion)
@@ -89,50 +85,8 @@ A spacing token (`--dt-spacing-e`) is applied to padding, providing internal spa
89
85
 
90
86
  ## Typography
91
87
 
92
- **Note:** Whenever you set a `font-size`, you must also set a compatible `line-height` rule to ensure the font looks correct.
93
-
94
- ### Font size
95
- Our font-size tokens only store the raw number, not a `px` unit. Therefore, you must multiply the token by `1px` to create a `px` value that CSS will understand.
96
-
97
- ```css
98
- .font-size-example {
99
- font-size: calc(var(--dt-font-body-l-size) * 1px);
100
- }
101
- ```
102
-
103
- ### Body text
104
- Font tokens define the typography for body content, including font family, size, weight, and line height. Each token maps to a specific design choice in the type scale, and using them ensures that text remains visually consistent and readable, even as underlying type styles evolve in the system.
105
-
106
- ```css
107
- .body-text {
108
- font-family: var(--dt-font-body-l-family);
109
- font-size: calc(var(--dt-font-body-l-size) * 1px);
110
- font-weight: var(--dt-font-body-l-weight);
111
- line-height: calc(var(--dt-font-body-l-line-height) * 1px);
112
- }
113
- ```
114
-
115
- ### Heading example
116
- Typography tokens are again used here, but with heading-specific values - including a `--wide` variant for font size and line height. This demonstrates how token modifiers allow flexibility (e.g. tighter vs wider spacing) without diverging from the core type system.
117
-
118
- ```css
119
- .heading-m {
120
- font-family: var(--dt-font-heading-m-family);
121
- font-size: calc(var(--dt-font-heading-m-size--wide) * 1px);
122
- font-weight: var(--dt-font-heading-m-weight);
123
- line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);
124
- }
125
- ```
126
-
127
- ### Line height
128
-
129
- Line height tokens only contain the raw number, not a `px` unit. Therefore they must be multipled by `1px` to create a `px` value CSS will understand.
130
-
131
- ```css
132
- .applied-lineheight {
133
- line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);
134
- }
135
- ```
88
+ For typography, we recommend using the utility classes provided by `pie-css` instead of directly applying font tokens. These classes ensure consistent application of our type scale and responsive adjustments across all components.
89
+ Documentation and examples can be found in Storybook [here](https://webc.pie.design/?path=/docs/introduction-typography-utility-classes--docs).
136
90
 
137
91
  ## Radius
138
92
 
@@ -2,26 +2,25 @@
2
2
 
3
3
  [Source Code](https://github.com/justeattakeaway/pie/tree/main/packages/tools/pie-css) | [NPM Package](https://www.npmjs.com/package/@justeattakeaway/pie-css)
4
4
 
5
- The PIE CSS Typography Utilities provide a comprehensive set of utility classes for applying consistent typography styles across your application. These classes are built on top of PIE design tokens and ensure your typography follows the design system's guidelines automatically.
5
+ `@justeattakeaway/pie-css` provide a comprehensive set of utility classes for applying consistent typography styles across your application. These classes are built on top of the PIE design tokens and ensure your typography follows the design system's guidelines automatically. The utility classes handle the responsive behaviour automatically, so you don't need to write additional media queries.
6
+
7
+ > Note: The utility classes do **not** apply colours to your text. This should be handled in your own CSS.
6
8
 
7
9
  ## Table of Contents
8
10
 
9
11
  - [Why?](#why)
10
12
  - [Installation](#installation)
11
- - [Importing](#importing)
12
- - [JavaScript/Framework Import (via bundler)](#javascriptframework-import-via-bundler)
13
- - [SCSS/Sass Import](#scsssass-import)
14
13
  - [Which Class Should I Use?](#which-class-should-i-use)
15
14
  - [If You Have Designs](#if-you-have-designs)
16
15
  - [If You Don't Have Designs](#if-you-dont-have-designs)
17
16
  - [Available Classes](#available-classes)
18
- - [Typography Spacing Utility](#typography-spacing-utility)
19
- - [the `font-theme` mixin](#the-font-theme-mixin)
17
+ - [SCSS Mixin](#the-font-theme-mixin)
20
18
  - [Usage Examples](#usage-examples)
21
19
  - [What Each Utility Class Applies](#what-each-utility-class-applies)
22
20
  - [Troubleshooting](#troubleshooting)
23
21
  - [Utilities Not Working](#utilities-not-working)
24
22
  - [Font Not Displaying](#font-not-displaying)
23
+ - [No Colours Appearing](#no-colours-appearing)
25
24
 
26
25
  ## Why?
27
26
 
@@ -44,18 +43,18 @@ yarn add @justeattakeaway/pie-css
44
43
  npm install @justeattakeaway/pie-css
45
44
  ```
46
45
 
47
- ## Importing
46
+ ### Importing
48
47
 
49
48
  To use the typography utility classes, you need to import the typography CSS file. The import method depends on your project setup:
50
49
 
51
- ### JavaScript/Framework Import (via bundler)
50
+ #### JavaScript/Framework Import (via bundler)
52
51
 
53
52
  ```javascript
54
53
  // Import the typography utilities
55
54
  import '@justeattakeaway/pie-css/dist/helpers/typography.css';
56
55
  ```
57
56
 
58
- ### SCSS/Sass Import
57
+ #### SCSS/Sass Import
59
58
 
60
59
  ```scss
61
60
  @use '@justeattakeaway/pie-css/dist/helpers/typography.css';
@@ -88,35 +87,15 @@ If you don't have access to designs, you have two options:
88
87
 
89
88
  ## Available Classes
90
89
 
91
- The typography utilities are organized into several categories. This documentation is automatically generated from the CSS source file.
92
-
93
- ### the `font-theme` mixin
94
-
95
- In addition to the typography utility classes, the `font-theme` mixin can also be used directly to apply the styles to your SCSS.
96
-
97
- **N.b. We recommend only using this when using the classes isn't possible – and only if you are serving your CSS gzipped, to ensure that this code is properly optimised when served to your users.**
98
-
99
- Using the `font-theme` mixin will apply the corresponding typography styles to the element selected. It takes a typography token name as an argument.
100
-
101
- To use the mixin as part of the full set of PIE SCSS Utilities, you can import the mixin as follows:
90
+ The typography utilities are organised into several categories. This documentation is automatically generated from the CSS source file.
102
91
 
103
- ```scss
104
- @use '@justeattakeaway/pie-css/scss' as p;
105
-
106
- .my-element {
107
- @include p.font-theme('font-heading-l');
108
- }
109
- ```
110
-
111
- Alternatively, you can import the mixin directly, without importing the other SCSS utilities:
92
+ ### Typography Spacing Utility
112
93
 
113
- ```scss
114
- @use '@justeattakeaway/pie-css/scss/mixins/font-theme' as *;
94
+ Use `.u-typographySpacing` alongside a typography utility class on the same element to apply paragraph spacing for typography tokens that define a `paragraph` token.
115
95
 
116
- .my-element {
117
- @include font-theme('font-heading-l');
118
- }
119
- ```
96
+ | Class | Use Case |
97
+ | --- | --- |
98
+ | `.u-typographySpacing` | Opt-in paragraph spacing for typography classes that support paragraph tokens |
120
99
 
121
100
  ### Headings
122
101
 
@@ -155,7 +134,7 @@ Subheadings are used for secondary headings and section titles.
155
134
 
156
135
  ### Interactive Text
157
136
 
158
- Interactive text utilities are optimized for buttons, links, and other interactive elements.
137
+ Interactive text utilities are optimised for buttons, links, and other interactive elements.
159
138
 
160
139
  | Class | Use Case |
161
140
  | --- | --- |
@@ -163,14 +142,6 @@ Interactive text utilities are optimized for buttons, links, and other interacti
163
142
  | `.u-font-interactive-s` | Small interactive text |
164
143
  | `.u-font-interactive-xs` | Extra small interactive text |
165
144
 
166
- ### Typography Spacing Utility
167
-
168
- Use `.u-typographySpacing` alongside a typography utility class on the same element to apply paragraph spacing for typography tokens that define a `paragraph` token.
169
-
170
- | Class | Use Case |
171
- | --- | --- |
172
- | `.u-typographySpacing` | Opt-in paragraph spacing for typography classes that support paragraph tokens |
173
-
174
145
  ### Body Text
175
146
 
176
147
  Body text utilities are for paragraphs and general content.
@@ -191,7 +162,7 @@ Body link utilities combine body text styling with link-specific properties like
191
162
 
192
163
  ### Body Strong
193
164
 
194
- Body strong utilities are for bold/emphasized body text.
165
+ Body strong utilities are for bold/emphasised body text.
195
166
 
196
167
  | Class | Use Case |
197
168
  | --- | --- |
@@ -240,78 +211,46 @@ Caption strong link utilities combine bold caption styling with link properties.
240
211
  | --- | --- |
241
212
  | `.u-font-caption-strong-link` | caption bold/strong link |
242
213
 
243
- ## Usage Examples
214
+ ## The `font-theme` mixin
244
215
 
245
- ### Basic Usage
216
+ In addition to the typography utility classes, the `font-theme` mixin can also be used directly to apply the styles to your SCSS.
246
217
 
247
- Simply add the utility class to your HTML element:
218
+ **N.b. We recommend only using this when using the classes isn't possible – and only if you are serving your CSS gzipped, to ensure that this code is properly optimised when served to your users.**
248
219
 
249
- ```html
250
- <h1 class="u-font-heading-xl">Page Title</h1>
251
- <p class="u-font-body-l">This is a paragraph of body text.</p>
252
- <p class="u-font-body-l u-typographySpacing">This is body text with opt-in paragraph spacing.</p>
253
- ```
220
+ Using the `font-theme` mixin will apply the corresponding typography styles to the element selected. It takes a typography token name as an argument.
254
221
 
255
- ### React Example
256
-
257
- ```jsx
258
- function MyComponent() {
259
- return (
260
- <div>
261
- <h1 className="u-font-heading-xl">Welcome</h1>
262
- <h2 className="u-font-heading-m">Section Title</h2>
263
- <p className="u-font-body-l">
264
- This is a paragraph using the body large utility class.
265
- </p>
266
- <p className="u-font-body-l u-typographySpacing">
267
- This paragraph uses the same typography class with opt-in spacing.
268
- </p>
269
- <a href="#" className="u-font-body-l-link">Learn more</a>
270
- </div>
271
- );
272
- }
273
- ```
222
+ To use the mixin as part of the full set of PIE SCSS Utilities, you can import the mixin as follows:
274
223
 
275
- ### Vue Example
224
+ ```scss
225
+ @use '@justeattakeaway/pie-css/scss' as p;
276
226
 
277
- ```html
278
- <template>
279
- <div>
280
- <h1 class="u-font-heading-xl">Welcome</h1>
281
- <h2 class="u-font-heading-m">Section Title</h2>
282
- <p class="u-font-body-l">
283
- This is a paragraph using the body large utility class.
284
- </p>
285
- <p class="u-font-body-l u-typographySpacing">
286
- This paragraph uses the same typography class with opt-in spacing.
287
- </p>
288
- <a href="#" class="u-font-body-l-link">Learn more</a>
289
- </div>
290
- </template>
227
+ .my-element {
228
+ @include p.font-theme('font-heading-l');
229
+ }
291
230
  ```
292
231
 
293
- ### Combining with Other Classes
232
+ Alternatively, you can import the mixin directly, without importing the other SCSS utilities:
294
233
 
295
- You can combine typography utilities with other CSS classes:
234
+ ```scss
235
+ @use '@justeattakeaway/pie-css/scss/mixins/font-theme' as *;
296
236
 
297
- ```html
298
- <div class="card">
299
- <h2 class="u-font-heading-m card-title">Card Title</h2>
300
- <p class="u-font-body-s card-description">Card description text.</p>
301
- </div>
237
+ .my-element {
238
+ @include font-theme('font-heading-l');
239
+ }
302
240
  ```
303
241
 
304
- ### Responsive Behavior
242
+ ## Usage Examples
243
+
244
+ ### Basic Usage
305
245
 
306
- Heading and subheading utilities automatically adjust at the 768px breakpoint:
246
+ Simply add the utility class to your HTML element:
307
247
 
308
248
  ```html
309
- <!-- This heading will be smaller on mobile and larger on desktop -->
310
- <h1 class="u-font-heading-xl">Responsive Heading</h1>
249
+ <h1 class="u-font-heading-xl">Page Title</h1>
250
+ <p class="u-font-body-l">This is a paragraph of body text.</p>
251
+ <p class="u-font-body-l u-typographySpacing">This is body text with opt-in paragraph spacing.</p>
311
252
  ```
312
253
 
313
- The utility classes handle the responsive behavior automatically, so you don't need to write additional media queries.
314
-
315
254
  ## What Each Utility Class Applies
316
255
 
317
256
  Each typography utility class applies a complete set of typography properties:
@@ -343,3 +282,7 @@ If fonts aren't displaying correctly:
343
282
  1. Ensure you've set up the JETSansDigital font as described in the [Typography setup guide](https://webc.pie.design/?path=/docs/introduction-typography--docs)
344
283
  2. Check that font files are loading correctly
345
284
  3. Verify font-face declarations are correct
285
+
286
+ ### No Colours Appearing
287
+
288
+ These utility classes do not apply any colours to your text. This must be handled in your own CSS.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-css",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "A styling library that provides both a shared collection of ready to use CSS styles to be used across JET web front-ends, and SCSS-based style helpers for our PIE Web Component library.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,7 +53,7 @@
53
53
  "include-media": "2.0.0",
54
54
  "postcss": "8.4.32",
55
55
  "postcss-import": "15.1.0",
56
- "w3c-css-validator": "1.3.2"
56
+ "w3c-css-validator": "1.4.1"
57
57
  },
58
58
  "volta": {
59
59
  "extends": "../../../package.json"