@justeattakeaway/pie-css 1.1.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 +1 -1
- package/docs/design-tokens-cookbook.md +1 -1
- package/docs/typography-utility-classes.md +43 -100
- package/package.json +1 -1
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/
|
|
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
|
|
|
@@ -86,7 +86,7 @@ A spacing token (`--dt-spacing-e`) is applied to padding, providing internal spa
|
|
|
86
86
|
## Typography
|
|
87
87
|
|
|
88
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/
|
|
89
|
+
Documentation and examples can be found in Storybook [here](https://webc.pie.design/?path=/docs/introduction-typography-utility-classes--docs).
|
|
90
90
|
|
|
91
91
|
## Radius
|
|
92
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
|
-
|
|
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
|
-
- [
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
|
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/
|
|
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
|
-
##
|
|
214
|
+
## The `font-theme` mixin
|
|
244
215
|
|
|
245
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
224
|
+
```scss
|
|
225
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|
|
276
226
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
232
|
+
Alternatively, you can import the mixin directly, without importing the other SCSS utilities:
|
|
294
233
|
|
|
295
|
-
|
|
234
|
+
```scss
|
|
235
|
+
@use '@justeattakeaway/pie-css/scss/mixins/font-theme' as *;
|
|
296
236
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
|
|
242
|
+
## Usage Examples
|
|
243
|
+
|
|
244
|
+
### Basic Usage
|
|
305
245
|
|
|
306
|
-
|
|
246
|
+
Simply add the utility class to your HTML element:
|
|
307
247
|
|
|
308
248
|
```html
|
|
309
|
-
|
|
310
|
-
<
|
|
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.1.
|
|
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",
|