@justeattakeaway/pie-css 0.11.0 → 0.12.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.
- package/README.md +186 -26
- package/dist/index.css +26 -9
- package/package.json +2 -1
- package/scss/index.scss +1 -0
- package/scss/settings/_breakpoints.scss +19 -0
- package/scss/settings/_include-media.scss +596 -0
- package/scss/settings/_mq.scss +6 -0
- package/scss/settings/index.scss +1 -0
package/README.md
CHANGED
|
@@ -13,27 +13,32 @@
|
|
|
13
13
|
# Table of Contents
|
|
14
14
|
|
|
15
15
|
1. [Introduction](#introduction)
|
|
16
|
-
2. [
|
|
16
|
+
2. [Installation](#installation)
|
|
17
|
+
3. [Using the `pie-css` CSS stylesheet in your web application](#using-the-pie-css-css-stylesheet-in-your-web-application)
|
|
17
18
|
1. JS or Framework import (via bundler)
|
|
18
|
-
2.
|
|
19
|
+
2. Nuxt
|
|
19
20
|
3. Sass /SCSS
|
|
20
21
|
4. Native HTML
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
4. [What's included in the `pie-css` base stylesheet](#whats-included-in-the-pie-css-base-stylesheet)
|
|
23
|
+
4. [Using the `pie-css` SCSS helpers (mixins & functions)](#using-the-pie-css-scss-helpers-mixins--functions)
|
|
24
|
+
1. [Importing the `pie-css` SCSS helpers](#importing-the-pie-css-scss-helpers)
|
|
25
|
+
2. [`pie-css` SCSS Helper Definitions](#pie-css-scss-helper-definitions)
|
|
26
|
+
- [`font-size()`](#font-size)
|
|
27
|
+
- [`@include media()`](#include-media)
|
|
28
|
+
5. [Testing](#testing)
|
|
24
29
|
- [CSS](#css)
|
|
25
|
-
- [SCSS](#scss
|
|
30
|
+
- [SCSS](#scss)
|
|
26
31
|
|
|
27
32
|
## Introduction
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
`pie-css` is a styling library that provides both a minimal set of CSS styles to help PIE Web Components display as intended on web applications, and a set of optional SCSS style helpers (mixins & functions) to help with common styling tasks.
|
|
35
|
+
|
|
36
|
+
It also includes the PIE design tokens (and HSL colour variants) as CSS variables, as these variables are used across the PIE component styles and therefore need to be imported when using the PIE Web Components.
|
|
30
37
|
|
|
31
|
-
---
|
|
32
38
|
|
|
33
|
-
##
|
|
34
|
-
`pie-css` provides a base stylesheet that sets up some basic styles used by our components. It is essential that this stylesheet is included in any application that uses PIE Web Components. The stylesheet provides some basic styles for things like typography and provides the design tokens that are used by our components.
|
|
39
|
+
## Installation
|
|
35
40
|
|
|
36
|
-
To install
|
|
41
|
+
To install `pie-css`, run the following on your command line:
|
|
37
42
|
|
|
38
43
|
```bash
|
|
39
44
|
# npm
|
|
@@ -43,12 +48,19 @@ npm i @justeattakeaway/pie-css
|
|
|
43
48
|
yarn add @justeattakeaway/pie-css
|
|
44
49
|
```
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Using the `pie-css` CSS stylesheet in your web application
|
|
55
|
+
|
|
56
|
+
`pie-css` provides a base stylesheet that sets up some basic styles used by the PIE Web Components. It is essential that this stylesheet is included in any application that uses PIE Web Components. The stylesheet provides a minimal set of styles for ensuring typography displayed as intended, while also importing the PIE design tokens that are used by our components.
|
|
57
|
+
|
|
58
|
+
[Once installed](#installation), how you include these styles will largely depend on the type of application you are building (and your own preference), but here are a few examples.
|
|
47
59
|
|
|
48
60
|
|
|
49
61
|
### JS or Framework import (via bundler)
|
|
50
62
|
|
|
51
|
-
One common way of importing
|
|
63
|
+
One common way of importing the styles would be through a regular JS import as part of your application bundle.
|
|
52
64
|
|
|
53
65
|
```js
|
|
54
66
|
import '@justeattakeaway/pie-css';
|
|
@@ -80,12 +92,12 @@ import App from './App.vue';
|
|
|
80
92
|
createApp(App).mount('#app');
|
|
81
93
|
```
|
|
82
94
|
|
|
83
|
-
###
|
|
95
|
+
### Nuxt
|
|
84
96
|
|
|
85
|
-
If you are using
|
|
97
|
+
If you are using Nuxt, you can import `pie-css` in your `nuxt.config.js` file.
|
|
86
98
|
|
|
87
99
|
|
|
88
|
-
For
|
|
100
|
+
For Nuxt v3, this would look like this:
|
|
89
101
|
|
|
90
102
|
```js
|
|
91
103
|
// Nuxt v3
|
|
@@ -95,7 +107,7 @@ export default defineNuxtConfig({
|
|
|
95
107
|
});
|
|
96
108
|
```
|
|
97
109
|
|
|
98
|
-
For
|
|
110
|
+
For Nuxt v2, it is very similar, looking more like this:
|
|
99
111
|
|
|
100
112
|
```js
|
|
101
113
|
export default {
|
|
@@ -121,22 +133,43 @@ If you are using Sass, you could import the CSS file as part of your styles dire
|
|
|
121
133
|
Of course, you could include the styles straight inside your HTML document – most likely you'd want to link to the `/@justeattakeaway/pie-css/dist/index.css` CSS file in the head of your HTML.
|
|
122
134
|
|
|
123
135
|
|
|
136
|
+
## What's included in the `pie-css` base stylesheet
|
|
124
137
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
138
|
+
You can see the pre-compiled `pie-css` styles [in the `pie-css` repo](https://github.com/justeattakeaway/pie/blob/main/packages/tools/pie-css/css/input.css), but let's run through what's included.
|
|
139
|
+
|
|
140
|
+
### PIE Design Tokens
|
|
141
|
+
|
|
142
|
+
A core dependency of our PIE Web Components are the PIE design tokens. These are imported in the `pie-css` styles, as well as tokens for HSL colour variants (which are useful when needing to lighten/darken colours).
|
|
128
143
|
|
|
129
|
-
|
|
144
|
+
### box-sizing
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
We set `box-sizing: border-box` so that the CSS box model acts consistently when using PIE components.
|
|
132
147
|
|
|
133
|
-
|
|
148
|
+
### Typography
|
|
134
149
|
|
|
135
|
-
|
|
150
|
+
There are a number of typographic CSS rules that we specify to help with font rendering. These are:
|
|
136
151
|
|
|
137
|
-
|
|
152
|
+
```css
|
|
153
|
+
/* These rules with smooth fonts. It makes fonts look crisp and clean on devices
|
|
154
|
+
that support it. */
|
|
155
|
+
text-rendering: optimizelegibility;
|
|
156
|
+
-webkit-font-smoothing: antialiased;
|
|
157
|
+
-moz-font-smoothing: antialiased;
|
|
138
158
|
|
|
139
|
-
|
|
159
|
+
/* These are added to prevent text size adjustments in various browsers.
|
|
160
|
+
In some browsers, such as iOS Safari, will try to increase the font-size
|
|
161
|
+
when you rotate the screen. This can be jarring and break layouts. */
|
|
162
|
+
-webkit-text-size-adjust: 100%;
|
|
163
|
+
text-size-adjust: 100%;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### z-index variables
|
|
167
|
+
|
|
168
|
+
Some PIE Web Components use a z-index value to control how they stack on a webpage. These values are defined as CSS variables and are utilized internally.
|
|
169
|
+
|
|
170
|
+
In most cases, a webpage should follow the DOM's natural stacking order and the default z-index order assigned for each component. However, if you're creating custom components, refer to the following table to make sure they don't conflict with other components.
|
|
171
|
+
|
|
172
|
+
| Token | Z-Index Value |
|
|
140
173
|
| -------------------------- | ---------------|
|
|
141
174
|
| --dt-z-index-dropdown | 1000 |
|
|
142
175
|
| --dt-z-index-fab | 1000 |
|
|
@@ -148,6 +181,133 @@ Some PIE Web Components use a z-index value to control how they stack on a webpa
|
|
|
148
181
|
| --dt-z-index-cookie-banner | 5000 |
|
|
149
182
|
| --dt-z-index-toast | 6000 |
|
|
150
183
|
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Using the `pie-css` SCSS helpers (mixins & functions)
|
|
187
|
+
|
|
188
|
+
PIE CSS provides an optional set of SCSS helpers that are used by the PIE Web Components. These can also be used by web applications using SCSS, by importing the helpers into their project.
|
|
189
|
+
|
|
190
|
+
These helpers are for carrying out common tasks when interacting with the PIE design tokens, such as setting font sizes and media-queries in a consistent way, and for sharing styles definitions via SCSS mixins and functions.
|
|
191
|
+
|
|
192
|
+
One common example is to add unit suffixes (such as `px`) to the end of `font-size` declarations, as these are imported as unit-less values from our design tokens.
|
|
193
|
+
|
|
194
|
+
### Importing the `pie-css` SCSS helpers
|
|
195
|
+
|
|
196
|
+
Ensure you have installed `pie-css` as set out in [the installation section](Installation).
|
|
197
|
+
|
|
198
|
+
Once you have done this, you can then import the helpers by writing the following in your SCSS:
|
|
199
|
+
|
|
200
|
+
```scss
|
|
201
|
+
@use '@justeattakeaway/pie-css/scss' as *;
|
|
202
|
+
|
|
203
|
+
// or to namespace the mixins and functions, to avoid collisions
|
|
204
|
+
// import the helpers while defining a namespace
|
|
205
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
You should now be able to use the `pie-scss` helpers in that SCSS scope.
|
|
209
|
+
|
|
210
|
+
Be aware that if you want to set this up globally across your application, you'll need to add this import to your application SCSS config, but it's recommended to `@use` the helpers only in the SCSS files that use them on your project.
|
|
211
|
+
|
|
212
|
+
### `pie-css` SCSS Helper Definitions
|
|
213
|
+
|
|
214
|
+
#### `font-size()`
|
|
215
|
+
|
|
216
|
+
Used to reference design token font variables to add `px` unit values.
|
|
217
|
+
|
|
218
|
+
`font-size` can be used as a mixin to output the full style declaration, or as a function when you would like to assign the design token to a CSS variable.
|
|
219
|
+
|
|
220
|
+
```scss
|
|
221
|
+
// Use the font-size() mixin
|
|
222
|
+
.c-label {
|
|
223
|
+
@include font-size(--dt-font-body-s-size);
|
|
224
|
+
}
|
|
225
|
+
// Outputs:
|
|
226
|
+
.c-label {
|
|
227
|
+
font-size: calc(var(--dt-font-body-s-size) * 1px);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```scss
|
|
232
|
+
// Use the font-size function
|
|
233
|
+
--body-font-size: #{font-size(--dt-font-body-s-size)};
|
|
234
|
+
|
|
235
|
+
.c-label {
|
|
236
|
+
font-size: var(--body-font-size);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Outputs:
|
|
240
|
+
--body-font-size: calc(var(--dt-font-body-s-size) * 1px);
|
|
241
|
+
|
|
242
|
+
.c-label {
|
|
243
|
+
font-size: var(--dt-font-body-s-size);
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### `@include media()`
|
|
248
|
+
|
|
249
|
+
For media queries, we use an SCSS helper library called [include-media](https://eduardoboucas.github.io/include-media).
|
|
250
|
+
|
|
251
|
+
This library allows you to setup shortcut names for common breakpoints and provides a nicer syntax for working with media queries through the use of logical operators (such as `>=` and `<=`).
|
|
252
|
+
|
|
253
|
+
As part of the `pie-css` SCSS helpers, we setup the breakpoint shortcut names such that:
|
|
254
|
+
|
|
255
|
+
```scss
|
|
256
|
+
$breakpoints: (
|
|
257
|
+
xs: 320px,
|
|
258
|
+
sm: 600px,
|
|
259
|
+
md: 768px,
|
|
260
|
+
lg: 1024px,
|
|
261
|
+
xl: 1280px,
|
|
262
|
+
xxl: 1440px
|
|
263
|
+
);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
You can then use these in your SCSS like so:
|
|
267
|
+
|
|
268
|
+
```scss
|
|
269
|
+
@use '@justeattakeaway/pie-css/scss' as *;
|
|
270
|
+
|
|
271
|
+
.c-formField {
|
|
272
|
+
color: red;
|
|
273
|
+
|
|
274
|
+
@include media('>=sm') {
|
|
275
|
+
color: blue;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Outputs:
|
|
280
|
+
.c-formField {
|
|
281
|
+
color: red;
|
|
282
|
+
}
|
|
283
|
+
@media (min-width: 600px) {
|
|
284
|
+
.c-formField {
|
|
285
|
+
color: blue;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
It also lets you write nice expressions like this:
|
|
291
|
+
|
|
292
|
+
```scss
|
|
293
|
+
.c-formField {
|
|
294
|
+
// target between sm and md breakpoints on retina2x devices
|
|
295
|
+
@include media('>=sm', '<=md', 'retina2x') {
|
|
296
|
+
color: purple;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
To see the full list of features `include-media` provides, [check out their website](https://eduardoboucas.github.io/include-media).
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
### Other SCSS helpers
|
|
306
|
+
|
|
307
|
+
We will be writing more in-depth docs on all of our SCSS helpers shortly, but for now, feel free to browse the [SCSS code in the PIE mono-repo](https://github.com/justeattakeaway/pie/tree/main/packages/tools/pie-css/scss) – or reach out to one of the DS team who can take you through what's available.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
151
311
|
## Testing
|
|
152
312
|
|
|
153
313
|
We strive to ensure all styles are appropriately tested. How we test the styles differs for CSS and SCSS. Below, we outline both approaches.
|
package/dist/index.css
CHANGED
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
--dt-color-border-strong: var(--dt-color-mozzarella-30);
|
|
82
82
|
--dt-color-border-inverse: var(--dt-color-mozzarella-70);
|
|
83
83
|
--dt-color-border-selected: var(--dt-color-mozzarella-50);
|
|
84
|
+
--dt-color-border-selected-brand: var(--dt-color-orange);
|
|
84
85
|
--dt-color-divider-default: rgb(0,0,0,0.08);
|
|
85
86
|
--dt-color-divider-inverse: rgb(255,255,255,0.20);
|
|
86
87
|
--dt-color-interactive-brand: var(--dt-color-orange);
|
|
@@ -101,6 +102,8 @@
|
|
|
101
102
|
--dt-color-support-info-02: var(--dt-color-blue-10);
|
|
102
103
|
--dt-color-support-info-inverse: var(--dt-color-blue-30);
|
|
103
104
|
--dt-color-support-positive-inverse: var(--dt-color-green-30);
|
|
105
|
+
--dt-color-support-neutral-persistent: var(--dt-color-mozzarella-20);
|
|
106
|
+
--dt-color-support-error-inverse: var(--dt-color-red-30);
|
|
104
107
|
--dt-color-support-brand-01: var(--dt-color-orange-30);
|
|
105
108
|
--dt-color-support-brand-02: var(--dt-color-orange-10);
|
|
106
109
|
--dt-color-support-brand-03: var(--dt-color-blue-25);
|
|
@@ -145,6 +148,7 @@
|
|
|
145
148
|
--dt-color-active-01-dark: 12%;
|
|
146
149
|
--dt-color-active-02: 20%;
|
|
147
150
|
--dt-color-active-02-light: 20%;
|
|
151
|
+
--dt-color-resting: 0%;
|
|
148
152
|
--dt-color-focus-inner: var(--dt-color-white);
|
|
149
153
|
--dt-color-focus-outer: var(--dt-color-blue-70);
|
|
150
154
|
--dt-color-disabled-01: var(--dt-color-mozzarella-20);
|
|
@@ -167,6 +171,7 @@
|
|
|
167
171
|
--dt-color-highcontrast-border-strong: var(--dt-color-black);
|
|
168
172
|
--dt-color-highcontrast-border-inverse: var(--dt-color-white);
|
|
169
173
|
--dt-color-highcontrast-border-selected: var(--dt-color-black);
|
|
174
|
+
--dt-color-highcontrast-border-selected-brand: var(--dt-color-orange-dark-hc);
|
|
170
175
|
--dt-color-highcontrast-divider-default: var(--dt-color-black);
|
|
171
176
|
--dt-color-highcontrast-divider-inverse: var(--dt-color-white);
|
|
172
177
|
--dt-color-highcontrast-interactive-brand: var(--dt-color-orange-dark-hc);
|
|
@@ -187,6 +192,8 @@
|
|
|
187
192
|
--dt-color-highcontrast-support-info-02: var(--dt-color-white);
|
|
188
193
|
--dt-color-highcontrast-support-info-inverse: var(--dt-color-blue-light-hc);
|
|
189
194
|
--dt-color-highcontrast-support-positive-inverse: var(--dt-color-green-light-hc);
|
|
195
|
+
--dt-color-highcontrast-support-neutral-persistent: var(--dt-color-white);
|
|
196
|
+
--dt-color-highcontrast-support-error-inverse: var(--dt-color-red-light-hc);
|
|
190
197
|
--dt-color-highcontrast-support-brand-01: var(--dt-color-orange-30);
|
|
191
198
|
--dt-color-highcontrast-support-brand-02: var(--dt-color-white);
|
|
192
199
|
--dt-color-highcontrast-support-brand-03: var(--dt-color-white);
|
|
@@ -231,6 +238,7 @@
|
|
|
231
238
|
--dt-color-highcontrast-active-01-dark: 12%;
|
|
232
239
|
--dt-color-highcontrast-active-02: 20%;
|
|
233
240
|
--dt-color-highcontrast-active-02-light: 20%;
|
|
241
|
+
--dt-color-highcontrast-resting: 0%;
|
|
234
242
|
--dt-color-highcontrast-focus-inner: var(--dt-color-white);
|
|
235
243
|
--dt-color-highcontrast-focus-outer: var(--dt-color-blue-70);
|
|
236
244
|
--dt-color-highcontrast-disabled-01: var(--dt-color-mozzarella-20);
|
|
@@ -253,6 +261,7 @@
|
|
|
253
261
|
--dt-color-dark-border-strong: var(--dt-color-mozzarella-60);
|
|
254
262
|
--dt-color-dark-border-inverse: var(--dt-color-mozzarella-20);
|
|
255
263
|
--dt-color-dark-border-selected: var(--dt-color-mozzarella-30);
|
|
264
|
+
--dt-color-dark-border-selected-brand: var(--dt-color-orange);
|
|
256
265
|
--dt-color-dark-divider-default: rgb(255,255,255,0.20);
|
|
257
266
|
--dt-color-dark-divider-inverse: rgb(0,0,0,0.08);
|
|
258
267
|
--dt-color-dark-interactive-brand: var(--dt-color-orange);
|
|
@@ -262,7 +271,7 @@
|
|
|
262
271
|
--dt-color-dark-interactive-light: var(--dt-color-white);
|
|
263
272
|
--dt-color-dark-interactive-form: var(--dt-color-mozzarella-50);
|
|
264
273
|
--dt-color-dark-overlay: rgb(0,0,0,0.55);
|
|
265
|
-
--dt-color-dark-support-error: var(--dt-color-red);
|
|
274
|
+
--dt-color-dark-support-error: var(--dt-color-red-30);
|
|
266
275
|
--dt-color-dark-support-warning: var(--dt-color-yellow);
|
|
267
276
|
--dt-color-dark-support-positive: var(--dt-color-green-30);
|
|
268
277
|
--dt-color-dark-support-info: var(--dt-color-blue-30);
|
|
@@ -273,6 +282,8 @@
|
|
|
273
282
|
--dt-color-dark-support-info-02: var(--dt-color-blue-90);
|
|
274
283
|
--dt-color-dark-support-info-inverse: var(--dt-color-blue);
|
|
275
284
|
--dt-color-dark-support-positive-inverse: var(--dt-color-green);
|
|
285
|
+
--dt-color-dark-support-neutral-persistent: var(--dt-color-mozzarella-20);
|
|
286
|
+
--dt-color-dark-support-error-inverse: var(--dt-color-red);
|
|
276
287
|
--dt-color-dark-support-brand-01: var(--dt-color-orange-30);
|
|
277
288
|
--dt-color-dark-support-brand-02: var(--dt-color-orange-90);
|
|
278
289
|
--dt-color-dark-support-brand-03: var(--dt-color-blue-25);
|
|
@@ -317,6 +328,7 @@
|
|
|
317
328
|
--dt-color-dark-active-01-dark: 12%;
|
|
318
329
|
--dt-color-dark-active-02: 12%;
|
|
319
330
|
--dt-color-dark-active-02-light: 20%;
|
|
331
|
+
--dt-color-dark-resting: 0%;
|
|
320
332
|
--dt-color-dark-focus-inner: var(--dt-color-black);
|
|
321
333
|
--dt-color-dark-focus-outer: var(--dt-color-blue-30);
|
|
322
334
|
--dt-color-dark-disabled-01: var(--dt-color-mozzarella-80);
|
|
@@ -339,6 +351,7 @@
|
|
|
339
351
|
--dt-color-highcontrast-dark-border-strong: var(--dt-color-white);
|
|
340
352
|
--dt-color-highcontrast-dark-border-inverse: var(--dt-color-black);
|
|
341
353
|
--dt-color-highcontrast-dark-border-selected: var(--dt-color-white);
|
|
354
|
+
--dt-color-highcontrast-dark-border-selected-brand: var(--dt-color-orange-30);
|
|
342
355
|
--dt-color-highcontrast-dark-divider-default: var(--dt-color-white);
|
|
343
356
|
--dt-color-highcontrast-dark-divider-inverse: var(--dt-color-black);
|
|
344
357
|
--dt-color-highcontrast-dark-interactive-brand: var(--dt-color-orange-30);
|
|
@@ -359,6 +372,8 @@
|
|
|
359
372
|
--dt-color-highcontrast-dark-support-info-02: var(--dt-color-black);
|
|
360
373
|
--dt-color-highcontrast-dark-support-info-inverse: var(--dt-color-blue-dark-hc);
|
|
361
374
|
--dt-color-highcontrast-dark-support-positive-inverse: var(--dt-color-green-dark-hc);
|
|
375
|
+
--dt-color-highcontrast-dark-support-neutral-persistent: var(--dt-color-black);
|
|
376
|
+
--dt-color-highcontrast-dark-support-error-inverse: var(--dt-color-red-dark-hc);
|
|
362
377
|
--dt-color-highcontrast-dark-support-brand-01: var(--dt-color-orange-30);
|
|
363
378
|
--dt-color-highcontrast-dark-support-brand-02: var(--dt-color-black);
|
|
364
379
|
--dt-color-highcontrast-dark-support-brand-03: var(--dt-color-black);
|
|
@@ -403,6 +418,7 @@
|
|
|
403
418
|
--dt-color-highcontrast-dark-active-01-dark: 12%;
|
|
404
419
|
--dt-color-highcontrast-dark-active-02: 12%;
|
|
405
420
|
--dt-color-highcontrast-dark-active-02-light: 20%;
|
|
421
|
+
--dt-color-highcontrast-dark-resting: 0%;
|
|
406
422
|
--dt-color-highcontrast-dark-focus-inner: var(--dt-color-black);
|
|
407
423
|
--dt-color-highcontrast-dark-focus-outer: var(--dt-color-blue-30);
|
|
408
424
|
--dt-color-highcontrast-dark-disabled-01: var(--dt-color-mozzarella-80);
|
|
@@ -426,9 +442,6 @@
|
|
|
426
442
|
/* Size-16 font theme */
|
|
427
443
|
--dt-font-size-16: 16;
|
|
428
444
|
--dt-font-size-16-line-height: 24;
|
|
429
|
-
/* Size-19 font theme */
|
|
430
|
-
--dt-font-size-19: 19;
|
|
431
|
-
--dt-font-size-19-line-height: 28;
|
|
432
445
|
/* Size-20 font theme */
|
|
433
446
|
--dt-font-size-20: 20;
|
|
434
447
|
--dt-font-size-20-line-height: 28;
|
|
@@ -508,11 +521,6 @@
|
|
|
508
521
|
--dt-font-interactive-s-family: var(--dt-font-family-primary);
|
|
509
522
|
--dt-font-interactive-s-weight: var(--dt-font-weight-bold);
|
|
510
523
|
--dt-font-interactive-s-line-height: var(--dt-font-size-16-line-height);
|
|
511
|
-
/* Interactive-m font theme */
|
|
512
|
-
--dt-font-interactive-m-size: var(--dt-font-size-19);
|
|
513
|
-
--dt-font-interactive-m-family: var(--dt-font-family-primary);
|
|
514
|
-
--dt-font-interactive-m-weight: var(--dt-font-weight-bold);
|
|
515
|
-
--dt-font-interactive-m-line-height: var(--dt-font-size-19-line-height);
|
|
516
524
|
/* Interactive-l font theme */
|
|
517
525
|
--dt-font-interactive-l-size: var(--dt-font-size-20);
|
|
518
526
|
--dt-font-interactive-l-family: var(--dt-font-family-primary);
|
|
@@ -911,6 +919,9 @@
|
|
|
911
919
|
--dt-color-border-selected-h: var(--dt-color-mozzarella-50-h);
|
|
912
920
|
--dt-color-border-selected-s: var(--dt-color-mozzarella-50-s);
|
|
913
921
|
--dt-color-border-selected-l: var(--dt-color-mozzarella-50-l);
|
|
922
|
+
--dt-color-border-selected-brand-h: var(--dt-color-orange-h);
|
|
923
|
+
--dt-color-border-selected-brand-s: var(--dt-color-orange-s);
|
|
924
|
+
--dt-color-border-selected-brand-l: var(--dt-color-orange-l);
|
|
914
925
|
--dt-color-interactive-brand-h: var(--dt-color-orange-h);
|
|
915
926
|
--dt-color-interactive-brand-s: var(--dt-color-orange-s);
|
|
916
927
|
--dt-color-interactive-brand-l: var(--dt-color-orange-l);
|
|
@@ -962,6 +973,12 @@
|
|
|
962
973
|
--dt-color-support-positive-inverse-h: var(--dt-color-green-30-h);
|
|
963
974
|
--dt-color-support-positive-inverse-s: var(--dt-color-green-30-s);
|
|
964
975
|
--dt-color-support-positive-inverse-l: var(--dt-color-green-30-l);
|
|
976
|
+
--dt-color-support-neutral-persistent-h: var(--dt-color-mozzarella-20-h);
|
|
977
|
+
--dt-color-support-neutral-persistent-s: var(--dt-color-mozzarella-20-s);
|
|
978
|
+
--dt-color-support-neutral-persistent-l: var(--dt-color-mozzarella-20-l);
|
|
979
|
+
--dt-color-support-error-inverse-h: var(--dt-color-red-30-h);
|
|
980
|
+
--dt-color-support-error-inverse-s: var(--dt-color-red-30-s);
|
|
981
|
+
--dt-color-support-error-inverse-l: var(--dt-color-red-30-l);
|
|
965
982
|
--dt-color-support-brand-01-h: var(--dt-color-orange-30-h);
|
|
966
983
|
--dt-color-support-brand-01-s: var(--dt-color-orange-30-s);
|
|
967
984
|
--dt-color-support-brand-01-l: var(--dt-color-orange-30-l);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
6
6
|
"files": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/postcss-import": "14.0.3",
|
|
31
|
+
"include-media": "2.0.0",
|
|
31
32
|
"postcss": "8.4.32",
|
|
32
33
|
"postcss-import": "15.1.0",
|
|
33
34
|
"w3c-css-validator": "1.3.1"
|
package/scss/index.scss
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Interval settings to be used by @include-media Sass library
|
|
2
|
+
// https://eduardoboucas.github.io/include-media/documentation/#variable-unit-intervals
|
|
3
|
+
$unit-intervals: (
|
|
4
|
+
'px': 1,
|
|
5
|
+
'em': 0.001, // We need more sensitivity, some browsers are very specific with breakpoints
|
|
6
|
+
'rem': 0.1,
|
|
7
|
+
'': 0
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
// Breakpoints to be used by @include-media Sass library
|
|
11
|
+
// https://eduardoboucas.github.io/include-media/documentation/#variable-breakpoints
|
|
12
|
+
$breakpoints: (
|
|
13
|
+
xs: 320px,
|
|
14
|
+
sm: 600px,
|
|
15
|
+
md: 768px,
|
|
16
|
+
lg: 1024px,
|
|
17
|
+
xl: 1280px,
|
|
18
|
+
xxl: 1440px
|
|
19
|
+
);
|
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
//
|
|
2
|
+
// !IMPORTANT: This file is a copy of the original include-media SCSS library
|
|
3
|
+
// !DO NOT directly edit this file/
|
|
4
|
+
//
|
|
5
|
+
// _ _ _ _ _
|
|
6
|
+
// (_) | | | | | (_)
|
|
7
|
+
// _ _ __ ___| |_ _ __| | ___ _ __ ___ ___ __| |_ __ _
|
|
8
|
+
// | | '_ \ / __| | | | |/ _` |/ _ \ | '_ ` _ \ / _ \/ _` | |/ _` |
|
|
9
|
+
// | | | | | (__| | |_| | (_| | __/ | | | | | | __/ (_| | | (_| |
|
|
10
|
+
// |_|_| |_|\___|_|\__,_|\__,_|\___| |_| |_| |_|\___|\__,_|_|\__,_|
|
|
11
|
+
//
|
|
12
|
+
// Simple, elegant and maintainable media queries in Sass
|
|
13
|
+
// v2.0.0
|
|
14
|
+
//
|
|
15
|
+
// https://eduardoboucas.github.io/include-media
|
|
16
|
+
//
|
|
17
|
+
// Authors: Eduardo Boucas (@eduardoboucas)
|
|
18
|
+
// Kitty Giraudel (@kittygiraudel)
|
|
19
|
+
//
|
|
20
|
+
// This project is licensed under the terms of the MIT license
|
|
21
|
+
@charset "UTF-8";
|
|
22
|
+
|
|
23
|
+
////
|
|
24
|
+
/// include-media library public configuration
|
|
25
|
+
/// @author Eduardo Boucas
|
|
26
|
+
/// @access public
|
|
27
|
+
////
|
|
28
|
+
@use 'sass:math';
|
|
29
|
+
@use 'sass:map';
|
|
30
|
+
@use 'sass:list';
|
|
31
|
+
@use 'sass:string';
|
|
32
|
+
@use 'sass:meta';
|
|
33
|
+
|
|
34
|
+
///
|
|
35
|
+
/// Creates a list of global breakpoints
|
|
36
|
+
///
|
|
37
|
+
/// @example scss - Creates a single breakpoint with the label `phone`
|
|
38
|
+
/// $breakpoints: ('phone': 320px);
|
|
39
|
+
///
|
|
40
|
+
$breakpoints: (
|
|
41
|
+
'phone': 320px,
|
|
42
|
+
'tablet': 768px,
|
|
43
|
+
'desktop': 1024px,
|
|
44
|
+
) !default;
|
|
45
|
+
|
|
46
|
+
///
|
|
47
|
+
/// Creates a list of static expressions or media types
|
|
48
|
+
///
|
|
49
|
+
/// @example scss - Creates a single media type (screen)
|
|
50
|
+
/// $media-expressions: ('screen': 'screen');
|
|
51
|
+
///
|
|
52
|
+
/// @example scss - Creates a static expression with logical disjunction (OR operator)
|
|
53
|
+
/// $media-expressions: (
|
|
54
|
+
/// 'retina2x': '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)'
|
|
55
|
+
/// );
|
|
56
|
+
///
|
|
57
|
+
$media-expressions: (
|
|
58
|
+
'screen': 'screen',
|
|
59
|
+
'print': 'print',
|
|
60
|
+
'handheld': 'handheld',
|
|
61
|
+
'landscape': '(orientation: landscape)',
|
|
62
|
+
'portrait': '(orientation: portrait)',
|
|
63
|
+
'retina2x':
|
|
64
|
+
'(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 2dppx)',
|
|
65
|
+
'retina3x':
|
|
66
|
+
'(-webkit-min-device-pixel-ratio: 3), (min-resolution: 350dpi), (min-resolution: 3dppx)',
|
|
67
|
+
) !default;
|
|
68
|
+
|
|
69
|
+
///
|
|
70
|
+
/// Defines a number to be added or subtracted from each unit when declaring breakpoints with exclusive intervals
|
|
71
|
+
///
|
|
72
|
+
/// @example scss - Interval for pixels is defined as `1` by default
|
|
73
|
+
/// @include media('>128px') {}
|
|
74
|
+
///
|
|
75
|
+
/// /* Generates: */
|
|
76
|
+
/// @media (min-width: 129px) {}
|
|
77
|
+
///
|
|
78
|
+
/// @example scss - Interval for ems is defined as `0.01` by default
|
|
79
|
+
/// @include media('>20em') {}
|
|
80
|
+
///
|
|
81
|
+
/// /* Generates: */
|
|
82
|
+
/// @media (min-width: 20.01em) {}
|
|
83
|
+
///
|
|
84
|
+
/// @example scss - Interval for rems is defined as `0.1` by default, to be used with `font-size: 62.5%;`
|
|
85
|
+
/// @include media('>2.0rem') {}
|
|
86
|
+
///
|
|
87
|
+
/// /* Generates: */
|
|
88
|
+
/// @media (min-width: 2.1rem) {}
|
|
89
|
+
///
|
|
90
|
+
$unit-intervals: (
|
|
91
|
+
'px': 1,
|
|
92
|
+
'em': 0.01,
|
|
93
|
+
'rem': 0.1,
|
|
94
|
+
'': 0,
|
|
95
|
+
) !default;
|
|
96
|
+
|
|
97
|
+
///
|
|
98
|
+
/// Defines whether support for media queries is available, useful for creating separate stylesheets
|
|
99
|
+
/// for browsers that don't support media queries.
|
|
100
|
+
///
|
|
101
|
+
/// @example scss - Disables support for media queries
|
|
102
|
+
/// $im-media-support: false;
|
|
103
|
+
/// @include media('>=tablet') {
|
|
104
|
+
/// .foo {
|
|
105
|
+
/// color: tomato;
|
|
106
|
+
/// }
|
|
107
|
+
/// }
|
|
108
|
+
///
|
|
109
|
+
/// /* Generates: */
|
|
110
|
+
/// .foo {
|
|
111
|
+
/// color: tomato;
|
|
112
|
+
/// }
|
|
113
|
+
///
|
|
114
|
+
$im-media-support: true !default;
|
|
115
|
+
|
|
116
|
+
///
|
|
117
|
+
/// Selects which breakpoint to emulate when support for media queries is disabled. Media queries that start at or
|
|
118
|
+
/// intercept the breakpoint will be displayed, any others will be ignored.
|
|
119
|
+
///
|
|
120
|
+
/// @example scss - This media query will show because it intercepts the static breakpoint
|
|
121
|
+
/// $im-media-support: false;
|
|
122
|
+
/// $im-no-media-breakpoint: 'desktop';
|
|
123
|
+
/// @include media('>=tablet') {
|
|
124
|
+
/// .foo {
|
|
125
|
+
/// color: tomato;
|
|
126
|
+
/// }
|
|
127
|
+
/// }
|
|
128
|
+
///
|
|
129
|
+
/// /* Generates: */
|
|
130
|
+
/// .foo {
|
|
131
|
+
/// color: tomato;
|
|
132
|
+
/// }
|
|
133
|
+
///
|
|
134
|
+
/// @example scss - This media query will NOT show because it does not intercept the desktop breakpoint
|
|
135
|
+
/// $im-media-support: false;
|
|
136
|
+
/// $im-no-media-breakpoint: 'tablet';
|
|
137
|
+
/// @include media('>=desktop') {
|
|
138
|
+
/// .foo {
|
|
139
|
+
/// color: tomato;
|
|
140
|
+
/// }
|
|
141
|
+
/// }
|
|
142
|
+
///
|
|
143
|
+
/// /* No output */
|
|
144
|
+
///
|
|
145
|
+
$im-no-media-breakpoint: 'desktop' !default;
|
|
146
|
+
|
|
147
|
+
///
|
|
148
|
+
/// Selects which media expressions are allowed in an expression for it to be used when media queries
|
|
149
|
+
/// are not supported.
|
|
150
|
+
///
|
|
151
|
+
/// @example scss - This media query will show because it intercepts the static breakpoint and contains only accepted media expressions
|
|
152
|
+
/// $im-media-support: false;
|
|
153
|
+
/// $im-no-media-breakpoint: 'desktop';
|
|
154
|
+
/// $im-no-media-expressions: ('screen');
|
|
155
|
+
/// @include media('>=tablet', 'screen') {
|
|
156
|
+
/// .foo {
|
|
157
|
+
/// color: tomato;
|
|
158
|
+
/// }
|
|
159
|
+
/// }
|
|
160
|
+
///
|
|
161
|
+
/// /* Generates: */
|
|
162
|
+
/// .foo {
|
|
163
|
+
/// color: tomato;
|
|
164
|
+
/// }
|
|
165
|
+
///
|
|
166
|
+
/// @example scss - This media query will NOT show because it intercepts the static breakpoint but contains a media expression that is not accepted
|
|
167
|
+
/// $im-media-support: false;
|
|
168
|
+
/// $im-no-media-breakpoint: 'desktop';
|
|
169
|
+
/// $im-no-media-expressions: ('screen');
|
|
170
|
+
/// @include media('>=tablet', 'retina2x') {
|
|
171
|
+
/// .foo {
|
|
172
|
+
/// color: tomato;
|
|
173
|
+
/// }
|
|
174
|
+
/// }
|
|
175
|
+
///
|
|
176
|
+
/// /* No output */
|
|
177
|
+
///
|
|
178
|
+
$im-no-media-expressions: ('screen', 'portrait', 'landscape') !default;
|
|
179
|
+
|
|
180
|
+
////
|
|
181
|
+
/// Cross-engine logging engine
|
|
182
|
+
/// @author Kitty Giraudel
|
|
183
|
+
/// @access private
|
|
184
|
+
////
|
|
185
|
+
|
|
186
|
+
///
|
|
187
|
+
/// Log a message either with `@error` if supported
|
|
188
|
+
/// else with `@warn`, using `feature-exists('at-error')`
|
|
189
|
+
/// to detect support.
|
|
190
|
+
///
|
|
191
|
+
/// @param {String} $message - Message to log
|
|
192
|
+
///
|
|
193
|
+
@function im-log($message) {
|
|
194
|
+
@if meta.feature-exists('at-error') {
|
|
195
|
+
@error $message;
|
|
196
|
+
} @else {
|
|
197
|
+
@warn $message;
|
|
198
|
+
|
|
199
|
+
$_: noop();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@return $message;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
///
|
|
206
|
+
/// Wrapper mixin for the log function so it can be used with a more friendly
|
|
207
|
+
/// API than `@if im-log('..') {}` or `$_: im-log('..')`. Basically, use the function
|
|
208
|
+
/// within functions because it is not possible to include a mixin in a function
|
|
209
|
+
/// and use the mixin everywhere else because it's much more elegant.
|
|
210
|
+
///
|
|
211
|
+
/// @param {String} $message - Message to log
|
|
212
|
+
///
|
|
213
|
+
@mixin log($message) {
|
|
214
|
+
@if im-log($message) {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
///
|
|
219
|
+
/// Function with no `@return` called next to `@warn` in Sass 3.3
|
|
220
|
+
/// to trigger a compiling error and stop the process.
|
|
221
|
+
///
|
|
222
|
+
@function noop() {
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
///
|
|
226
|
+
/// Determines whether a list of conditions is intercepted by the static breakpoint.
|
|
227
|
+
///
|
|
228
|
+
/// @param {Arglist} $conditions - Media query conditions
|
|
229
|
+
///
|
|
230
|
+
/// @return {Boolean} - Returns true if the conditions are intercepted by the static breakpoint
|
|
231
|
+
///
|
|
232
|
+
@function im-intercepts-static-breakpoint($conditions...) {
|
|
233
|
+
$no-media-breakpoint-value: map.get($breakpoints, $im-no-media-breakpoint);
|
|
234
|
+
|
|
235
|
+
@if not $no-media-breakpoint-value {
|
|
236
|
+
@if im-log('`#{$im-no-media-breakpoint}` is not a valid breakpoint.') {
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@each $condition in $conditions {
|
|
241
|
+
@if not map.has-key($media-expressions, $condition) {
|
|
242
|
+
$operator: get-expression-operator($condition);
|
|
243
|
+
$prefix: get-expression-prefix($operator);
|
|
244
|
+
$value: get-expression-value($condition, $operator);
|
|
245
|
+
|
|
246
|
+
@if ($prefix == 'max' and $value <= $no-media-breakpoint-value) or
|
|
247
|
+
($prefix == 'min' and $value > $no-media-breakpoint-value)
|
|
248
|
+
{
|
|
249
|
+
@return false;
|
|
250
|
+
}
|
|
251
|
+
} @else if not list.index($im-no-media-expressions, $condition) {
|
|
252
|
+
@return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@return true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
////
|
|
260
|
+
/// Parsing engine
|
|
261
|
+
/// @author Kitty Giraudel
|
|
262
|
+
/// @access private
|
|
263
|
+
////
|
|
264
|
+
|
|
265
|
+
///
|
|
266
|
+
/// Get operator of an expression
|
|
267
|
+
///
|
|
268
|
+
/// @param {String} $expression - Expression to extract operator from
|
|
269
|
+
///
|
|
270
|
+
/// @return {String} - Any of `>=`, `>`, `<=`, `<`, `≥`, `≤`
|
|
271
|
+
///
|
|
272
|
+
@function get-expression-operator($expression) {
|
|
273
|
+
@each $operator in ('>=', '>', '<=', '<', '≥', '≤') {
|
|
274
|
+
@if string.index($expression, $operator) {
|
|
275
|
+
@return $operator;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// It is not possible to include a mixin inside a function, so we have to
|
|
280
|
+
// rely on the `im-log(..)` function rather than the `log(..)` mixin. Because
|
|
281
|
+
// functions cannot be called anywhere in Sass, we need to hack the call in
|
|
282
|
+
// a dummy variable, such as `$_`. If anybody ever raise a scoping issue with
|
|
283
|
+
// Sass 3.3, change this line in `@if im-log(..) {}` instead.
|
|
284
|
+
$_: im-log('No operator found in `#{$expression}`.');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
///
|
|
288
|
+
/// Get dimension of an expression, based on a found operator
|
|
289
|
+
///
|
|
290
|
+
/// @param {String} $expression - Expression to extract dimension from
|
|
291
|
+
/// @param {String} $operator - Operator from `$expression`
|
|
292
|
+
///
|
|
293
|
+
/// @return {String} - `width` or `height` (or potentially anything else)
|
|
294
|
+
///
|
|
295
|
+
@function get-expression-dimension($expression, $operator) {
|
|
296
|
+
$operator-index: string.index($expression, $operator);
|
|
297
|
+
$parsed-dimension: string.slice($expression, 0, $operator-index - 1);
|
|
298
|
+
$dimension: 'width';
|
|
299
|
+
|
|
300
|
+
@if string.length($parsed-dimension) > 0 {
|
|
301
|
+
$dimension: $parsed-dimension;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@return $dimension;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
///
|
|
308
|
+
/// Get dimension prefix based on an operator
|
|
309
|
+
///
|
|
310
|
+
/// @param {String} $operator - Operator
|
|
311
|
+
///
|
|
312
|
+
/// @return {String} - `min` or `max`
|
|
313
|
+
///
|
|
314
|
+
@function get-expression-prefix($operator) {
|
|
315
|
+
@return if(list.index(('<', '<=', '≤'), $operator), 'max', 'min');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
///
|
|
319
|
+
/// Get value of an expression, based on a found operator
|
|
320
|
+
///
|
|
321
|
+
/// @param {String} $expression - Expression to extract value from
|
|
322
|
+
/// @param {String} $operator - Operator from `$expression`
|
|
323
|
+
///
|
|
324
|
+
/// @return {Number} - A numeric value
|
|
325
|
+
///
|
|
326
|
+
@function get-expression-value($expression, $operator) {
|
|
327
|
+
$operator-index: string.index($expression, $operator);
|
|
328
|
+
$value: string.slice($expression, $operator-index + string.length($operator));
|
|
329
|
+
|
|
330
|
+
@if map.has-key($breakpoints, $value) {
|
|
331
|
+
$value: map.get($breakpoints, $value);
|
|
332
|
+
} @else {
|
|
333
|
+
$value: to-number($value);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
$interval: map.get($unit-intervals, math.unit($value));
|
|
337
|
+
|
|
338
|
+
@if not $interval {
|
|
339
|
+
// It is not possible to include a mixin inside a function, so we have to
|
|
340
|
+
// rely on the `im-log(..)` function rather than the `log(..)` mixin. Because
|
|
341
|
+
// functions cannot be called anywhere in Sass, we need to hack the call in
|
|
342
|
+
// a dummy variable, such as `$_`. If anybody ever raise a scoping issue with
|
|
343
|
+
// Sass 3.3, change this line in `@if im-log(..) {}` instead.
|
|
344
|
+
$_: im-log('Unknown unit `#{math.unit($value)}`.');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
@if $operator == '>' {
|
|
348
|
+
$value: $value + $interval;
|
|
349
|
+
} @else if $operator == '<' {
|
|
350
|
+
$value: $value - $interval;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
@return $value;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
///
|
|
357
|
+
/// Parse an expression to return a valid media-query expression
|
|
358
|
+
///
|
|
359
|
+
/// @param {String} $expression - Expression to parse
|
|
360
|
+
///
|
|
361
|
+
/// @return {String} - Valid media query
|
|
362
|
+
///
|
|
363
|
+
@function parse-expression($expression) {
|
|
364
|
+
// If it is part of $media-expressions, it has no operator
|
|
365
|
+
// then there is no need to go any further, just return the value
|
|
366
|
+
@if map.has-key($media-expressions, $expression) {
|
|
367
|
+
@return map.get($media-expressions, $expression);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
$operator: get-expression-operator($expression);
|
|
371
|
+
$dimension: get-expression-dimension($expression, $operator);
|
|
372
|
+
$prefix: get-expression-prefix($operator);
|
|
373
|
+
$value: get-expression-value($expression, $operator);
|
|
374
|
+
|
|
375
|
+
@return '(#{$prefix}-#{$dimension}: #{$value})';
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
///
|
|
379
|
+
/// Slice `$list` between `$start` and `$end` indexes
|
|
380
|
+
///
|
|
381
|
+
/// @access private
|
|
382
|
+
///
|
|
383
|
+
/// @param {List} $list - List to slice
|
|
384
|
+
/// @param {Number} $start [1] - Start index
|
|
385
|
+
/// @param {Number} $end [length($list)] - End index
|
|
386
|
+
///
|
|
387
|
+
/// @return {List} Sliced list
|
|
388
|
+
///
|
|
389
|
+
@function slice($list, $start: 1, $end: list.length($list)) {
|
|
390
|
+
@if list.length($list) < 1 or $start > $end {
|
|
391
|
+
@return ();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
$result: ();
|
|
395
|
+
|
|
396
|
+
@for $i from $start through $end {
|
|
397
|
+
$result: list.append($result, list.nth($list, $i), comma);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@return $result;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
////
|
|
404
|
+
/// String to number converter
|
|
405
|
+
/// @author Kitty Giraudel
|
|
406
|
+
/// @access private
|
|
407
|
+
////
|
|
408
|
+
|
|
409
|
+
///
|
|
410
|
+
/// Casts a string into a number
|
|
411
|
+
///
|
|
412
|
+
/// @param {String | Number} $value - Value to be parsed
|
|
413
|
+
///
|
|
414
|
+
/// @return {Number}
|
|
415
|
+
///
|
|
416
|
+
|
|
417
|
+
@function to-number($value) {
|
|
418
|
+
@if meta.type-of($value) == 'number' {
|
|
419
|
+
@return $value;
|
|
420
|
+
} @else if meta.type-of($value) != 'string' {
|
|
421
|
+
$_: im-log('Value for `to-number` should be a number or a string.');
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
$first-character: string.slice($value, 1, 1);
|
|
425
|
+
$result: 0;
|
|
426
|
+
$digits: 0;
|
|
427
|
+
$minus: ($first-character == '-');
|
|
428
|
+
$numbers: (
|
|
429
|
+
'0': 0,
|
|
430
|
+
'1': 1,
|
|
431
|
+
'2': 2,
|
|
432
|
+
'3': 3,
|
|
433
|
+
'4': 4,
|
|
434
|
+
'5': 5,
|
|
435
|
+
'6': 6,
|
|
436
|
+
'7': 7,
|
|
437
|
+
'8': 8,
|
|
438
|
+
'9': 9,
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
// Remove +/- sign if present at first character
|
|
442
|
+
@if $first-character == '+' or $first-character == '-' {
|
|
443
|
+
$value: string.slice($value, 2);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
@for $i from 1 through string.length($value) {
|
|
447
|
+
$character: string.slice($value, $i, $i);
|
|
448
|
+
|
|
449
|
+
@if not(list.index(map.keys($numbers), $character) or $character == '.') {
|
|
450
|
+
@return to-length(if($minus, -$result, $result), string.slice($value, $i));
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@if $character == '.' {
|
|
454
|
+
$digits: 1;
|
|
455
|
+
} @else if $digits == 0 {
|
|
456
|
+
$result: $result * 10 + map.get($numbers, $character);
|
|
457
|
+
} @else {
|
|
458
|
+
$digits: $digits * 10;
|
|
459
|
+
$result: $result + math.div(map.get($numbers, $character), $digits);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
@return if($minus, -$result, $result);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
///
|
|
467
|
+
/// Add `$unit` to `$value`
|
|
468
|
+
///
|
|
469
|
+
/// @param {Number} $value - Value to add unit to
|
|
470
|
+
/// @param {String} $unit - String representation of the unit
|
|
471
|
+
///
|
|
472
|
+
/// @return {Number} - `$value` expressed in `$unit`
|
|
473
|
+
///
|
|
474
|
+
@function to-length($value, $unit) {
|
|
475
|
+
$units: (
|
|
476
|
+
'px': 1px,
|
|
477
|
+
'cm': 1cm,
|
|
478
|
+
'mm': 1mm,
|
|
479
|
+
'%': 1%,
|
|
480
|
+
'ch': 1ch,
|
|
481
|
+
'pc': 1pc,
|
|
482
|
+
'in': 1in,
|
|
483
|
+
'em': 1em,
|
|
484
|
+
'rem': 1rem,
|
|
485
|
+
'pt': 1pt,
|
|
486
|
+
'ex': 1ex,
|
|
487
|
+
'vw': 1vw,
|
|
488
|
+
'vh': 1vh,
|
|
489
|
+
'vmin': 1vmin,
|
|
490
|
+
'vmax': 1vmax,
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
@if not list.index(map.keys($units), $unit) {
|
|
494
|
+
$_: im-log('Invalid unit `#{$unit}`.');
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
@return $value * map.get($units, $unit);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
///
|
|
501
|
+
/// This mixin aims at redefining the configuration just for the scope of
|
|
502
|
+
/// the call. It is helpful when having a component needing an extended
|
|
503
|
+
/// configuration such as custom breakpoints (referred to as tweakpoints)
|
|
504
|
+
/// for instance.
|
|
505
|
+
///
|
|
506
|
+
/// @author Kitty Giraudel
|
|
507
|
+
///
|
|
508
|
+
/// @param {Map} $tweakpoints [()] - Map of tweakpoints to be merged with `$breakpoints`
|
|
509
|
+
/// @param {Map} $tweak-media-expressions [()] - Map of tweaked media expressions to be merged with `$media-expression`
|
|
510
|
+
///
|
|
511
|
+
/// @example scss - Extend the global breakpoints with a tweakpoint
|
|
512
|
+
/// @include media-context(('custom': 678px)) {
|
|
513
|
+
/// .foo {
|
|
514
|
+
/// @include media('>phone', '<=custom') {
|
|
515
|
+
/// // ...
|
|
516
|
+
/// }
|
|
517
|
+
/// }
|
|
518
|
+
/// }
|
|
519
|
+
///
|
|
520
|
+
/// @example scss - Extend the global media expressions with a custom one
|
|
521
|
+
/// @include media-context($tweak-media-expressions: ('all': 'all')) {
|
|
522
|
+
/// .foo {
|
|
523
|
+
/// @include media('all', '>phone') {
|
|
524
|
+
/// // ...
|
|
525
|
+
/// }
|
|
526
|
+
/// }
|
|
527
|
+
/// }
|
|
528
|
+
///
|
|
529
|
+
/// @example scss - Extend both configuration maps
|
|
530
|
+
/// @include media-context(('custom': 678px), ('all': 'all')) {
|
|
531
|
+
/// .foo {
|
|
532
|
+
/// @include media('all', '>phone', '<=custom') {
|
|
533
|
+
/// // ...
|
|
534
|
+
/// }
|
|
535
|
+
/// }
|
|
536
|
+
/// }
|
|
537
|
+
///
|
|
538
|
+
@mixin media-context($tweakpoints: (), $tweak-media-expressions: ()) {
|
|
539
|
+
// Save global configuration
|
|
540
|
+
$global-breakpoints: $breakpoints;
|
|
541
|
+
$global-media-expressions: $media-expressions;
|
|
542
|
+
|
|
543
|
+
// Update global configuration
|
|
544
|
+
$breakpoints: map.merge($breakpoints, $tweakpoints) !global;
|
|
545
|
+
$media-expressions: map.merge($media-expressions, $tweak-media-expressions) !global;
|
|
546
|
+
|
|
547
|
+
@content;
|
|
548
|
+
|
|
549
|
+
// Restore global configuration
|
|
550
|
+
$breakpoints: $global-breakpoints !global;
|
|
551
|
+
$media-expressions: $global-media-expressions !global;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
////
|
|
555
|
+
/// include-media public exposed API
|
|
556
|
+
/// @author Eduardo Boucas
|
|
557
|
+
/// @access public
|
|
558
|
+
////
|
|
559
|
+
|
|
560
|
+
///
|
|
561
|
+
/// Generates a media query based on a list of conditions
|
|
562
|
+
///
|
|
563
|
+
/// @param {Arglist} $conditions - Media query conditions
|
|
564
|
+
///
|
|
565
|
+
/// @example scss - With a single set breakpoint
|
|
566
|
+
/// @include media('>phone') { }
|
|
567
|
+
///
|
|
568
|
+
/// @example scss - With two set breakpoints
|
|
569
|
+
/// @include media('>phone', '<=tablet') { }
|
|
570
|
+
///
|
|
571
|
+
/// @example scss - With custom values
|
|
572
|
+
/// @include media('>=358px', '<850px') { }
|
|
573
|
+
///
|
|
574
|
+
/// @example scss - With set breakpoints with custom values
|
|
575
|
+
/// @include media('>desktop', '<=1350px') { }
|
|
576
|
+
///
|
|
577
|
+
/// @example scss - With a static expression
|
|
578
|
+
/// @include media('retina2x') { }
|
|
579
|
+
///
|
|
580
|
+
/// @example scss - Mixing everything
|
|
581
|
+
/// @include media('>=350px', '<tablet', 'retina3x') { }
|
|
582
|
+
///
|
|
583
|
+
@mixin media($conditions...) {
|
|
584
|
+
@if ($im-media-support and list.length($conditions) == 0) or
|
|
585
|
+
(not $im-media-support and im-intercepts-static-breakpoint($conditions...))
|
|
586
|
+
{
|
|
587
|
+
@content;
|
|
588
|
+
} @else if $im-media-support and list.length($conditions) > 0 {
|
|
589
|
+
@media #{string.unquote(parse-expression(list.nth($conditions, 1)))} {
|
|
590
|
+
// Recursive call
|
|
591
|
+
@include media(slice($conditions, 2)...) {
|
|
592
|
+
@content;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './mq';
|