@justeattakeaway/pie-css 0.28.0 → 0.29.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.
|
@@ -306,6 +306,16 @@
|
|
|
306
306
|
line-height: calc(var(--dt-font-caption-strong-line-height) * 1px);
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
+
.u-font-caption-strong-italic {
|
|
310
|
+
font-family: var(--dt-font-caption-strong-italic-family);
|
|
311
|
+
font-weight: var(--dt-font-caption-strong-italic-weight);
|
|
312
|
+
margin-block-end: calc(var(--dt-font-caption-strong-italic-paragraph) * 1px);
|
|
313
|
+
font-style: var(--dt-font-caption-strong-italic-font-style);
|
|
314
|
+
font-variation-settings: "slnt" -20;
|
|
315
|
+
font-size: calc(var(--dt-font-caption-strong-italic-size) * 1px);
|
|
316
|
+
line-height: calc(var(--dt-font-caption-strong-italic-line-height) * 1px);
|
|
317
|
+
}
|
|
318
|
+
|
|
309
319
|
.u-font-caption-strong-link {
|
|
310
320
|
font-family: var(--dt-font-caption-strong-link-family);
|
|
311
321
|
font-weight: var(--dt-font-caption-strong-link-weight);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# PIE CSS Radio Component Styles
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
Style native HTML `<input type="radio">` elements with PIE design system styling.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Why?](#why)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Importing](#importing)
|
|
12
|
+
- [Basic Usage](#basic-usage)
|
|
13
|
+
- [Available Classes](#available-classes)
|
|
14
|
+
- [Visual States](#visual-states)
|
|
15
|
+
- [Accessibility](#accessibility)
|
|
16
|
+
|
|
17
|
+
## Why?
|
|
18
|
+
|
|
19
|
+
The PIE CSS Radio Component Styles are designed to provide the PIE visual styling to native HTML radio inputs. This is needed when
|
|
20
|
+
your designs use radio buttons in more complex ways than simple lists of options. For example complex radio button-based card components.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
The radio component styles are included as part of the `@justeattakeaway/pie-css` package:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Using Yarn
|
|
28
|
+
yarn add @justeattakeaway/pie-css
|
|
29
|
+
|
|
30
|
+
# Using NPM
|
|
31
|
+
npm install @justeattakeaway/pie-css
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Importing
|
|
35
|
+
|
|
36
|
+
### CSS Import (JavaScript/Framework)
|
|
37
|
+
|
|
38
|
+
Import the pre-compiled CSS file in your JavaScript/TypeScript application:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import '@justeattakeaway/pie-css/dist/components/radio.css';
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**React Example:**
|
|
45
|
+
|
|
46
|
+
```jsx
|
|
47
|
+
import '@justeattakeaway/pie-css/dist/components/radio.css';
|
|
48
|
+
|
|
49
|
+
function MyForm() {
|
|
50
|
+
return (
|
|
51
|
+
<label>
|
|
52
|
+
<input type="radio" className="c-radio" name="option" value="1" />
|
|
53
|
+
Option 1
|
|
54
|
+
</label>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Vue Example:**
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<script setup>
|
|
63
|
+
import '@justeattakeaway/pie-css/dist/components/radio.css';
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<label>
|
|
68
|
+
<input type="radio" class="c-radio" name="option" value="1" />
|
|
69
|
+
Option 1
|
|
70
|
+
</label>
|
|
71
|
+
</template>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Basic Usage
|
|
75
|
+
|
|
76
|
+
Apply the `c-radio` class to a native radio input:
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<!-- Basic radio -->
|
|
80
|
+
<input type="radio" class="c-radio" name="option" value="1">
|
|
81
|
+
|
|
82
|
+
<!-- With label -->
|
|
83
|
+
<label>
|
|
84
|
+
<input type="radio" class="c-radio" name="option" value="2" checked>
|
|
85
|
+
Option 2
|
|
86
|
+
</label>
|
|
87
|
+
|
|
88
|
+
<!-- Error state -->
|
|
89
|
+
<input type="radio" class="c-radio c-radio--error" name="option" value="3">
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Available Classes
|
|
93
|
+
|
|
94
|
+
| Class | Description |
|
|
95
|
+
|-------|-------------|
|
|
96
|
+
| `.c-radio` | Base radio input styling with all default states |
|
|
97
|
+
| `.c-radio--error` | Error state styling |
|
|
98
|
+
|
|
99
|
+
**Note:** All other visual states (`:checked`, `:disabled`, `:hover`, `:active`, `:focus-visible`) are handled automatically by CSS pseudo-classes.
|
|
100
|
+
|
|
101
|
+
## Visual States
|
|
102
|
+
|
|
103
|
+
All states are applied automatically via CSS pseudo-classes, except for error which is applied with a class.
|
|
104
|
+
|
|
105
|
+
| State | CSS Selector | Appearance | When Applied |
|
|
106
|
+
|-------|--------------|------------|--------------|
|
|
107
|
+
| **Error** | `.c-radio--error` | Error border color | Add `c-radio--error` class |
|
|
108
|
+
| **Unchecked** | `.c-radio` | Empty circle with border | Default state |
|
|
109
|
+
| **Checked** | `.c-radio:checked` | Filled circle with center dot | When selected |
|
|
110
|
+
| **Disabled** | `.c-radio:disabled` | Faded, not-allowed cursor | When `disabled` attribute is present |
|
|
111
|
+
| **Hover** | `.c-radio:hover` | Darkened background overlay | Mouse hover (not disabled) |
|
|
112
|
+
| **Active** | `.c-radio:active` | Further darkened overlay | Mouse press (not disabled) |
|
|
113
|
+
| **Focus** | `.c-radio:focus-visible` | Focus ring | Keyboard navigation only |
|
|
114
|
+
|
|
115
|
+
The focus ring is applied automatically on `:focus-visible` (keyboard navigation only) and will not show on mouse clicks.
|
|
116
|
+
|
|
117
|
+
### State Combinations
|
|
118
|
+
|
|
119
|
+
The radio input supports multiple state combinations:
|
|
120
|
+
|
|
121
|
+
- **Checked + Disabled**: Faded with dot visible
|
|
122
|
+
- **Error + Checked**: Error color with dot visible
|
|
123
|
+
- **Error + Disabled**: Faded (disabled takes precedence)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## Accessibility
|
|
127
|
+
|
|
128
|
+
When using native HTML radio inputs with the `c-radio` class, please follow the best practices found in the [MDN Web Docs on Radio Buttons](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/radio).
|
|
129
|
+
|
|
130
|
+
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Design Tokens Cookbook
|
|
2
|
+
|
|
3
|
+
Below are common recipes for using our design tokens. For web engineers, design tokens are simply **CSS variables** that expose raw values - such as **colours, spacing, and motion**. These form the foundation of the PIE visual language.
|
|
4
|
+
|
|
5
|
+
For a more in-depth introduction to design tokens, please visit our [design documentation website](https://pie.design/foundations/design-tokens/).
|
|
6
|
+
|
|
7
|
+
All of our design tokens can be added to your project by following our [CSS setup guide](https://github.com/justeattakeaway/pie/blob/main/packages/tools/pie-css/README.md#using-the-pie-css-css-stylesheet-in-your-web-application).
|
|
8
|
+
|
|
9
|
+
> ⚠️ Token names may evolve as the design system is updated. While we strive to keep this guide up-to-date, some variable names may differ in future versions.
|
|
10
|
+
>
|
|
11
|
+
> These examples are purely for illustrating how to use our design token variables. They are not intended as recommendations for how to structure your CSS or name your classes.
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Codepen](#codepen)
|
|
16
|
+
- [Colour](#colour)
|
|
17
|
+
- [Use brand colour as button background](#use-brand-colour-as-button-background)
|
|
18
|
+
- [Using HSL](#using-hsl)
|
|
19
|
+
- [Spacing](#spacing)
|
|
20
|
+
- [Stack items with spacing token](#stack-items-with-spacing-token)
|
|
21
|
+
- [Add padding using spacing alias](#add-padding-using-spacing-alias)
|
|
22
|
+
- [Typography](#typography)
|
|
23
|
+
- [Font size](#font-size)
|
|
24
|
+
- [Body text](#body-text)
|
|
25
|
+
- [Heading example](#heading-example)
|
|
26
|
+
- [Line height](#line-height)
|
|
27
|
+
- [Radius](#radius)
|
|
28
|
+
- [Rounded card](#rounded-card)
|
|
29
|
+
- [Motion](#motion)
|
|
30
|
+
- [Animate-in transition](#animate-in-transition)
|
|
31
|
+
- [Elevation](#elevation)
|
|
32
|
+
- [Card with elevation](#card-with-elevation)
|
|
33
|
+
|
|
34
|
+
## Codepen
|
|
35
|
+
All of these examples can be seen and edited on [Codepen](https://codepen.io/JamieMaguire/pen/azOKVxo)!
|
|
36
|
+
|
|
37
|
+
## Colour
|
|
38
|
+
This example uses a semantic colour token (`--dt-color-interactive-brand`) to define the background, and a complementary content token (`--dt-color-content-interactive-primary`) for the text. These tokens abstract away raw hex or HSL values in favour of role-based names, which makes them more adaptable to different themes (like dark mode) and helps maintain accessibility and brand consistency.
|
|
39
|
+
|
|
40
|
+
### Use brand colour as button background
|
|
41
|
+
```css
|
|
42
|
+
.box-brand {
|
|
43
|
+
background-color: var(--dt-color-interactive-brand);
|
|
44
|
+
color: var(--dt-color-content-interactive-primary);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Using HSL
|
|
49
|
+
|
|
50
|
+
For greater flexibility, we provide `-h`, `-s`, and `-l` variants of all our colour tokens. These expose the hue, saturation, and lightness components separately, allowing you to compose colours using the native CSS `hsl()` function.
|
|
51
|
+
|
|
52
|
+
You can combine these with our [state tokens](https://pie.design/foundations/colour/tokens/alias/light/#States), such as `--dt-color-hover-01`, which typically represents a percentage to dynamically adjust things like lightness for hover or focus states.
|
|
53
|
+
|
|
54
|
+
> You will need to apply the state token to a `calc()` css function with `-1` to darken the colour.
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
.hsl-example-darken {
|
|
58
|
+
background-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + calc(-1 * var(--dt-color-hover-01))));
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```css
|
|
63
|
+
.hsl-example-lighten {
|
|
64
|
+
background-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--dt-color-hover-01)));
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Spacing
|
|
69
|
+
|
|
70
|
+
### Stack items with spacing token
|
|
71
|
+
This example uses a spacing token (`--dt-spacing-d`) with the CSS gap property to control vertical rhythm between stacked elements. By using tokens for spacing rather than hardcoded values, we ensure consistent layout behaviour across all components and make global spacing updates easier to apply.
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
.stack-vertical {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
gap: var(--dt-spacing-d);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Add padding using spacing alias
|
|
82
|
+
A spacing token (`--dt-spacing-e`) is applied to padding, providing internal space around content. These tokens act as aliases for specific steps in our spacing scale, allowing for a semantically meaningful way to apply spacing while keeping layout consistent with the design system.
|
|
83
|
+
|
|
84
|
+
```css
|
|
85
|
+
.padded-box {
|
|
86
|
+
padding: var(--dt-spacing-e);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Typography
|
|
91
|
+
|
|
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
|
+
```
|
|
136
|
+
|
|
137
|
+
## Radius
|
|
138
|
+
|
|
139
|
+
### Rounded card
|
|
140
|
+
A radius token (`--dt-radius-rounded-c`) controls the roundness of corners, making the visual shape consistent with other rounded elements in the system. The token abstracts the exact pixel value, allowing us to tweak the roundness globally if the design direction changes.
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
.card-rounded {
|
|
144
|
+
border-radius: var(--dt-radius-rounded-c);
|
|
145
|
+
border: 1px solid var(--dt-color-border-default);
|
|
146
|
+
padding: var(--dt-spacing-e);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Motion
|
|
151
|
+
|
|
152
|
+
### Animate-in transition
|
|
153
|
+
This example uses motion tokens to control the timing and easing of a keyframe animation. The `--dt-motion-timing-200` token defines the duration of the animation, while `--dt-motion-easing-out` provides a standard easing curve.
|
|
154
|
+
|
|
155
|
+
By using tokens instead of hardcoded values, we ensure that all animations across the product feel consistent and aligned with the system's motion principles. These tokens abstract away raw timing values, allowing the design team to update motion characteristics centrally - improving coherence.
|
|
156
|
+
|
|
157
|
+
```css
|
|
158
|
+
@keyframes animate-in {
|
|
159
|
+
from {
|
|
160
|
+
transform: translateX(-100%);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
to {
|
|
164
|
+
transform: translateX(0);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.animated {
|
|
169
|
+
animation-duration: var(--dt-motion-timing-200);
|
|
170
|
+
animation-name: animate-in;
|
|
171
|
+
animation-timing-function: var(--dt-motion-easing-out);
|
|
172
|
+
transform: translateX(0);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Elevation
|
|
177
|
+
|
|
178
|
+
### Card with elevation
|
|
179
|
+
This uses an elevation token (`--dt-elevation-below-10`) to apply a standardized shadow. Elevation tokens encapsulate not just a single box-shadow, but a visual effect aligned with the design system's depth model, helping create consistent layering and hierarchy throughout the UI.
|
|
180
|
+
|
|
181
|
+
```css
|
|
182
|
+
.card-elevated {
|
|
183
|
+
box-shadow: var(--dt-elevation-below-10);
|
|
184
|
+
padding: var(--dt-spacing-e);
|
|
185
|
+
border-radius: var(--dt-radius-rounded-b);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# PIE CSS Typography Utility Classes
|
|
2
|
+
|
|
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
|
+
|
|
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.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Why?](#why)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Importing](#importing)
|
|
12
|
+
- [JavaScript/Framework Import (via bundler)](#javascriptframework-import-via-bundler)
|
|
13
|
+
- [SCSS/Sass Import](#scsssass-import)
|
|
14
|
+
- [Which Class Should I Use?](#which-class-should-i-use)
|
|
15
|
+
- [If You Have Designs](#if-you-have-designs)
|
|
16
|
+
- [If You Don't Have Designs](#if-you-dont-have-designs)
|
|
17
|
+
- [Available Classes](#available-classes)
|
|
18
|
+
- [the `font-theme` mixin](#the-font-theme-mixin)
|
|
19
|
+
- [Usage Examples](#usage-examples)
|
|
20
|
+
- [What Each Utility Class Applies](#what-each-utility-class-applies)
|
|
21
|
+
- [Troubleshooting](#troubleshooting)
|
|
22
|
+
- [Utilities Not Working](#utilities-not-working)
|
|
23
|
+
- [Font Not Displaying](#font-not-displaying)
|
|
24
|
+
|
|
25
|
+
## Why?
|
|
26
|
+
|
|
27
|
+
Our typography utility classes offer several key benefits:
|
|
28
|
+
|
|
29
|
+
- **Consistency**: Ensures all typography across your application follows the PIE design system standards
|
|
30
|
+
- **Responsive by Default**: Many utilities automatically adjust for narrow and wide viewports (breakpoint at 768px)
|
|
31
|
+
- **Design Token Integration**: Built directly on PIE design tokens, so updates to tokens automatically propagate
|
|
32
|
+
- **Maintainability**: Single source of truth for typography styles reduces duplication and makes updates easier. You don't need to manually apply individual token combinations, it's done for you
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
The typography utilities are included as part of the `@justeattakeaway/pie-css` package. If you haven't already installed it:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Using Yarn
|
|
40
|
+
yarn add @justeattakeaway/pie-css
|
|
41
|
+
|
|
42
|
+
# Using NPM
|
|
43
|
+
npm install @justeattakeaway/pie-css
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Importing
|
|
47
|
+
|
|
48
|
+
To use the typography utility classes, you need to import the typography CSS file. The import method depends on your project setup:
|
|
49
|
+
|
|
50
|
+
### JavaScript/Framework Import (via bundler)
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// Import the typography utilities
|
|
54
|
+
import '@justeattakeaway/pie-css/dist/helpers/typography.css';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### SCSS/Sass Import
|
|
58
|
+
|
|
59
|
+
```scss
|
|
60
|
+
@use '@justeattakeaway/pie-css/dist/helpers/typography.css';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **Note**: Make sure you've also imported the base `@justeattakeaway/pie-css` package, as the typography utilities depend on the design token CSS variables defined there.
|
|
64
|
+
|
|
65
|
+
## Which Class Should I Use?
|
|
66
|
+
|
|
67
|
+
### If You Have Designs
|
|
68
|
+
|
|
69
|
+
If you have access to Figma designs, the font token used in the design should be available in Figma. The CSS utility class name directly matches the token name by prefixing it with `u-font-`.
|
|
70
|
+
|
|
71
|
+
**Note**: In Figma, token names may appear differently in the Typography section. For example, the `body-l` token might be displayed as "Body Large", "Large", or "Body Large/Large". The underlying token name will match the CSS class name format.
|
|
72
|
+
|
|
73
|
+
For example:
|
|
74
|
+
- If the design uses the `body-l-link` token (may appear as "Body Large Link" in Figma) → use the `.u-font-body-l-link` class
|
|
75
|
+
- If the design uses the `heading-m` token (may appear as "Heading Medium" in Figma) → use the `.u-font-heading-m` class
|
|
76
|
+
- If the design uses the `caption-strong` token (may appear as "Caption Strong" in Figma) → use the `.u-font-caption-strong` class
|
|
77
|
+
|
|
78
|
+
Simply take the token name from Figma and add the `u-font-` prefix to get the corresponding CSS class.
|
|
79
|
+
|
|
80
|
+
### If You Don't Have Designs
|
|
81
|
+
|
|
82
|
+
If you don't have access to designs, you have two options:
|
|
83
|
+
|
|
84
|
+
1. **Use the most appropriate class** by reading the use cases for each utility class in the tables below. Each class is documented with its intended use case to help you make the right choice.
|
|
85
|
+
|
|
86
|
+
2. **Reach out to the design system team** for guidance on which typography utility class to use for your specific use case.
|
|
87
|
+
|
|
88
|
+
## Available Classes
|
|
89
|
+
|
|
90
|
+
The typography utilities are organized into several categories. This documentation is automatically generated from the CSS source file.
|
|
91
|
+
|
|
92
|
+
### the `font-theme` mixin
|
|
93
|
+
|
|
94
|
+
In addition to the typography utility classes, the `font-theme` mixin can also be used directly to apply the styles to your SCSS.
|
|
95
|
+
|
|
96
|
+
**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.**
|
|
97
|
+
|
|
98
|
+
Using the `font-theme` mixin will apply the corresponding typography styles to the element selected. It takes a typography token name as an argument.
|
|
99
|
+
|
|
100
|
+
To use the mixin as part of the full set of PIE SCSS Utilities, you can import the mixin as follows:
|
|
101
|
+
|
|
102
|
+
```scss
|
|
103
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|
|
104
|
+
|
|
105
|
+
.my-element {
|
|
106
|
+
@include p.font-theme('heading-l');
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Alternatively, you can import the mixin directly, without importing the other SCSS utilities:
|
|
111
|
+
|
|
112
|
+
```scss
|
|
113
|
+
@use '@justeattakeaway/pie-css/scss/mixins/font-theme' as *;
|
|
114
|
+
|
|
115
|
+
.my-element {
|
|
116
|
+
@include font-theme('heading-l');
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Headings
|
|
121
|
+
|
|
122
|
+
Heading utilities are designed for page titles, section headers, and other prominent text. All heading utilities are responsive and adjust font size and line height at the 768px breakpoint.
|
|
123
|
+
|
|
124
|
+
#### Standard Headings
|
|
125
|
+
|
|
126
|
+
| Class | Use Case |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `.u-font-heading-xxl` | Extra extra large heading |
|
|
129
|
+
| `.u-font-heading-xl` | Extra large heading |
|
|
130
|
+
| `.u-font-heading-l` | Large heading |
|
|
131
|
+
| `.u-font-heading-m` | Medium heading |
|
|
132
|
+
| `.u-font-heading-s` | Small heading |
|
|
133
|
+
| `.u-font-heading-xs` | Extra small heading |
|
|
134
|
+
|
|
135
|
+
#### Italic Headings
|
|
136
|
+
|
|
137
|
+
| Class | Use Case |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `.u-font-heading-xxl-italic` | Extra extra large heading italic |
|
|
140
|
+
| `.u-font-heading-xl-italic` | Extra large heading italic |
|
|
141
|
+
| `.u-font-heading-l-italic` | Large heading italic |
|
|
142
|
+
| `.u-font-heading-m-italic` | Medium heading italic |
|
|
143
|
+
| `.u-font-heading-s-italic` | Small heading italic |
|
|
144
|
+
| `.u-font-heading-xs-italic` | Extra small heading italic |
|
|
145
|
+
|
|
146
|
+
### Subheadings
|
|
147
|
+
|
|
148
|
+
Subheadings are used for secondary headings and section titles.
|
|
149
|
+
|
|
150
|
+
| Class | Use Case |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `.u-font-subheading-l` | Large subheading |
|
|
153
|
+
| `.u-font-subheading-s` | Small subheading |
|
|
154
|
+
|
|
155
|
+
### Interactive Text
|
|
156
|
+
|
|
157
|
+
Interactive text utilities are optimized for buttons, links, and other interactive elements.
|
|
158
|
+
|
|
159
|
+
| Class | Use Case |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `.u-font-interactive-l` | Large interactive text |
|
|
162
|
+
| `.u-font-interactive-s` | Small interactive text |
|
|
163
|
+
| `.u-font-interactive-xs` | Extra small interactive text |
|
|
164
|
+
|
|
165
|
+
### Body Text
|
|
166
|
+
|
|
167
|
+
Body text utilities are for paragraphs and general content. These utilities include automatic paragraph spacing via `margin-block-end`.
|
|
168
|
+
|
|
169
|
+
| Class | Use Case |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `.u-font-body-l` | Large body text |
|
|
172
|
+
| `.u-font-body-s` | Small body text |
|
|
173
|
+
|
|
174
|
+
### Body Link
|
|
175
|
+
|
|
176
|
+
Body link utilities combine body text styling with link-specific properties like text decoration.
|
|
177
|
+
|
|
178
|
+
| Class | Use Case |
|
|
179
|
+
| --- | --- |
|
|
180
|
+
| `.u-font-body-s-link` | Small body text link |
|
|
181
|
+
| `.u-font-body-l-link` | Large body text link |
|
|
182
|
+
|
|
183
|
+
### Body Strong
|
|
184
|
+
|
|
185
|
+
Body strong utilities are for bold/emphasized body text.
|
|
186
|
+
|
|
187
|
+
| Class | Use Case |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| `.u-font-body-strong-l` | Large body text bold/strong |
|
|
190
|
+
| `.u-font-body-strong-s` | Small body text bold/strong |
|
|
191
|
+
|
|
192
|
+
### Body Strong Link
|
|
193
|
+
|
|
194
|
+
Body strong link utilities combine bold body text styling with link properties.
|
|
195
|
+
|
|
196
|
+
| Class | Use Case |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| `.u-font-body-strong-s-link` | Small body text bold/strong link |
|
|
199
|
+
| `.u-font-body-strong-l-link` | Large body text bold/strong link |
|
|
200
|
+
|
|
201
|
+
### Captions
|
|
202
|
+
|
|
203
|
+
Caption utilities are for small supporting text, labels, and metadata.
|
|
204
|
+
|
|
205
|
+
| Class | Use Case |
|
|
206
|
+
| --- | --- |
|
|
207
|
+
| `.u-font-caption` | caption |
|
|
208
|
+
|
|
209
|
+
### Caption Link
|
|
210
|
+
|
|
211
|
+
Caption link utilities combine caption styling with link properties.
|
|
212
|
+
|
|
213
|
+
| Class | Use Case |
|
|
214
|
+
| --- | --- |
|
|
215
|
+
| `.u-font-caption-link` | caption link |
|
|
216
|
+
|
|
217
|
+
### Caption Strong
|
|
218
|
+
|
|
219
|
+
Caption strong utilities are for bold captions.
|
|
220
|
+
|
|
221
|
+
| Class | Use Case |
|
|
222
|
+
| --- | --- |
|
|
223
|
+
| `.u-font-caption-strong` | caption bold/strong |
|
|
224
|
+
| `.u-font-caption-strong-italic` | caption italic bold/strong |
|
|
225
|
+
|
|
226
|
+
### Caption Strong Link
|
|
227
|
+
|
|
228
|
+
Caption strong link utilities combine bold caption styling with link properties.
|
|
229
|
+
|
|
230
|
+
| Class | Use Case |
|
|
231
|
+
| --- | --- |
|
|
232
|
+
| `.u-font-caption-strong-link` | caption bold/strong link |
|
|
233
|
+
|
|
234
|
+
## Usage Examples
|
|
235
|
+
|
|
236
|
+
### Basic Usage
|
|
237
|
+
|
|
238
|
+
Simply add the utility class to your HTML element:
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<h1 class="u-font-heading-xl">Page Title</h1>
|
|
242
|
+
<p class="u-font-body-l">This is a paragraph of body text.</p>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### React Example
|
|
246
|
+
|
|
247
|
+
```jsx
|
|
248
|
+
function MyComponent() {
|
|
249
|
+
return (
|
|
250
|
+
<div>
|
|
251
|
+
<h1 className="u-font-heading-xl">Welcome</h1>
|
|
252
|
+
<h2 className="u-font-heading-m">Section Title</h2>
|
|
253
|
+
<p className="u-font-body-l">
|
|
254
|
+
This is a paragraph using the body large utility class.
|
|
255
|
+
</p>
|
|
256
|
+
<a href="#" className="u-font-body-l-link">Learn more</a>
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Vue Example
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<template>
|
|
266
|
+
<div>
|
|
267
|
+
<h1 class="u-font-heading-xl">Welcome</h1>
|
|
268
|
+
<h2 class="u-font-heading-m">Section Title</h2>
|
|
269
|
+
<p class="u-font-body-l">
|
|
270
|
+
This is a paragraph using the body large utility class.
|
|
271
|
+
</p>
|
|
272
|
+
<a href="#" class="u-font-body-l-link">Learn more</a>
|
|
273
|
+
</div>
|
|
274
|
+
</template>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Combining with Other Classes
|
|
278
|
+
|
|
279
|
+
You can combine typography utilities with other CSS classes:
|
|
280
|
+
|
|
281
|
+
```html
|
|
282
|
+
<div class="card">
|
|
283
|
+
<h2 class="u-font-heading-m card-title">Card Title</h2>
|
|
284
|
+
<p class="u-font-body-s card-description">Card description text.</p>
|
|
285
|
+
</div>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Responsive Behavior
|
|
289
|
+
|
|
290
|
+
Heading and subheading utilities automatically adjust at the 768px breakpoint:
|
|
291
|
+
|
|
292
|
+
```html
|
|
293
|
+
<!-- This heading will be smaller on mobile and larger on desktop -->
|
|
294
|
+
<h1 class="u-font-heading-xl">Responsive Heading</h1>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The utility classes handle the responsive behavior automatically, so you don't need to write additional media queries.
|
|
298
|
+
|
|
299
|
+
## What Each Utility Class Applies
|
|
300
|
+
|
|
301
|
+
Each typography utility class applies a complete set of typography properties:
|
|
302
|
+
|
|
303
|
+
- **`font-family`**: Uses the appropriate design token font family ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family))
|
|
304
|
+
- **`font-weight`**: Applies the correct font weight from design tokens ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight))
|
|
305
|
+
- **`font-size`**: Sets the font size (responsive for headings/subheadings) ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size))
|
|
306
|
+
- **`line-height`**: Applies the appropriate line height for readability ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height))
|
|
307
|
+
- **`font-style`**: Applied for italic variants ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style))
|
|
308
|
+
- **`text-decoration`**: Applied for link variants ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration))
|
|
309
|
+
- **`margin-block-end`**: Applied for body and caption variants to provide paragraph spacing ([MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-end))
|
|
310
|
+
|
|
311
|
+
## Troubleshooting
|
|
312
|
+
|
|
313
|
+
### Utilities Not Working
|
|
314
|
+
|
|
315
|
+
If the typography utilities aren't applying:
|
|
316
|
+
|
|
317
|
+
1. Ensure you've imported the typography CSS file: `@justeattakeaway/pie-css/dist/helpers/typography.css`
|
|
318
|
+
2. Verify the base `@justeattakeaway/pie-css` package is imported (required for design tokens)
|
|
319
|
+
3. Check that your build process is including the CSS file
|
|
320
|
+
4. Inspect the element in browser dev tools to see if classes are being applied
|
|
321
|
+
|
|
322
|
+
### Font Not Displaying
|
|
323
|
+
|
|
324
|
+
If fonts aren't displaying correctly:
|
|
325
|
+
|
|
326
|
+
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)
|
|
327
|
+
2. Check that font files are loading correctly
|
|
328
|
+
3. Verify font-face declarations are correct
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
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",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
12
12
|
"files": [
|
|
13
13
|
"scss",
|
|
14
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"docs"
|
|
15
16
|
],
|
|
16
17
|
"main": "dist/index.css",
|
|
17
18
|
"pieMetadata": {
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
24
|
"build": "run -T ts-node ./buildCss.ts && run -T sass --load-path=../../../node_modules scss/_internal/typography.scss dist/helpers/typography.css --no-source-map && run -T sass --load-path=../../../node_modules scss/_internal/radio.scss dist/components/radio.css --no-source-map",
|
|
25
|
+
"generate:typography-docs": "node scripts/generate-typography-docs.js",
|
|
24
26
|
"lint:scripts": "run -T eslint .",
|
|
25
27
|
"lint:scripts:fix": "yarn lint:scripts --fix",
|
|
26
28
|
"lint:style": "run -T stylelint ./**/*.{css,scss}",
|
|
@@ -7,7 +7,7 @@ $typography-names: font-heading-xs font-heading-s font-heading-m font-heading-l
|
|
|
7
7
|
font-body-s font-body-s-link font-body-l font-body-l-link
|
|
8
8
|
font-body-strong-s font-body-strong-s-link
|
|
9
9
|
font-body-strong-l font-body-strong-l-link
|
|
10
|
-
font-caption font-caption-link font-caption-strong font-caption-strong-link;
|
|
10
|
+
font-caption font-caption-link font-caption-strong font-caption-strong-italic font-caption-strong-link;
|
|
11
11
|
|
|
12
12
|
@each $name in $typography-names {
|
|
13
13
|
.u-#{$name} {
|