@justeattakeaway/pie-css 0.0.0-snapshot-release-20231123160549

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/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@justeattakeaway/pie-css",
3
+ "version": "0.0.0-snapshot-release-20231123160549",
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
+ "author": "Just Eat Takeaway.com - Design System Team",
6
+ "files": [
7
+ "scss"
8
+ ],
9
+ "main": "dist/index.css",
10
+ "scripts": {
11
+ "build": "run -T ts-node ./buildCss.ts",
12
+ "lint:scripts": "run -T eslint .",
13
+ "lint:scripts:fix": "yarn lint:scripts --fix",
14
+ "lint:style": "run -T stylelint ./**/*.{css,scss}",
15
+ "lint:style:fix": "yarn lint:style --fix",
16
+ "prepublishOnly": "yarn lint:style && yarn lint:scripts && yarn build && yarn test",
17
+ "test": "run -T vitest run",
18
+ "test:ci": "yarn test",
19
+ "test:watch": "run -T vitest"
20
+ },
21
+ "keywords": [
22
+ "PIE",
23
+ "CSS",
24
+ "SCSS",
25
+ "SASS"
26
+ ],
27
+ "repository": "https://github.com/justeattakeaway/pie.git",
28
+ "license": "Apache-2.0",
29
+ "devDependencies": {
30
+ "@types/postcss-import": "14.0.2",
31
+ "postcss": "8.4.31",
32
+ "postcss-import": "15.1.0",
33
+ "w3c-css-validator": "1.3.1"
34
+ }
35
+ }
@@ -0,0 +1,68 @@
1
+ // ----------------------------------------------
2
+ // Function for turning a unitless value into a px value
3
+ // The `to-px` function allows you to compute the size using a CSS variable.
4
+ // The resulting value will be multiplied by 1px.
5
+ // -
6
+ // @param {String} $token - The CSS variable name (including the `--` prefix) to be used for the to-px calculation.
7
+ // -
8
+ // @example
9
+ // .my-class {
10
+ // font-size: to-px(--design-token-variable);
11
+ // }
12
+ // -
13
+ // Outputs:
14
+ // .my-class {
15
+ // font-size: calc(var(--design-token-variable) * 1px);
16
+ // }
17
+ // ----------------------------------------------
18
+
19
+ @function to-px($token) {
20
+ @return calc(var(#{$token}) * 1px);
21
+ }
22
+
23
+ // ----------------------------------------------
24
+ // Function for calculating the font size.
25
+ // The `font-size` function allows you to compute the font size using a CSS variable.
26
+ // The resulting value will be multiplied by 1px.
27
+ // This currently calls the `to-px` function, but is built on top of it should we want to
28
+ // support other units (such as ems/rems) in the future.
29
+ // -
30
+ // @param {String} $token - The CSS variable name (including the `--` prefix) to be used for the font size calculation.
31
+ // -
32
+ // @example
33
+ // .my-class {
34
+ // font-size: font-size(--font-size-variable);
35
+ // }
36
+ // -
37
+ // Outputs:
38
+ // .my-class {
39
+ // font-size: calc(var(--font-size-variable) * 1px);
40
+ // }
41
+ // ----------------------------------------------
42
+ @function font-size($token) {
43
+ @return to-px($token);
44
+ }
45
+
46
+
47
+ // ----------------------------------------------
48
+ // Function for calculating the line-height.
49
+ // The `line-height` function allows you to compute the line height using a CSS variable.
50
+ // The resulting value will be multiplied by 1px.
51
+ // This currently calls the `to-px` function, but is built on top of it should we want to
52
+ // switch to using different units (such as unitless line heights) in the future.
53
+ // -
54
+ // @param {String} $token - The CSS variable name (including the `--` prefix) to be used for the font size calculation.
55
+ // -
56
+ // @example
57
+ // .my-class {
58
+ // font-size: font-size(--font-size-variable);
59
+ // }
60
+ // -
61
+ // Outputs:
62
+ // .my-class {
63
+ // font-size: calc(var(--font-size-variable) * 1px);
64
+ // }
65
+ // ----------------------------------------------
66
+ @function line-height($token) {
67
+ @return to-px($token);
68
+ }
@@ -0,0 +1 @@
1
+ @forward './unitModifiers';
@@ -0,0 +1,29 @@
1
+ // ----------------------------------------------
2
+ // Extendable Class for adding grab cursor styles.
3
+ // The `%has-grab-cursor` extendable class allows you to apply grab cursor styles to an element.
4
+ // It is intended to signify draggability to the user.
5
+ // It will show a `grab` cursor when the element is hovered,
6
+ // and a `grabbing` cursor when the element is active (being clicked).
7
+ // -
8
+ // @example
9
+ // .foo {
10
+ // &[isdraggable] {
11
+ // @extend %has-grab-cursor;
12
+ // }
13
+ // }
14
+ // -
15
+ // Outputs:
16
+ // .foo[isdraggable] {
17
+ // cursor: grab;
18
+ // &:active {
19
+ // cursor: grabbing;
20
+ // }
21
+ // }
22
+ // ----------------------------------------------
23
+ %has-grab-cursor {
24
+ cursor: grab;
25
+
26
+ &:active {
27
+ cursor: grabbing;
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ @forward './has-grab-cursor';
@@ -0,0 +1,3 @@
1
+ @forward 'mixins';
2
+ @forward 'functions';
3
+ @forward 'helpers';
@@ -0,0 +1,47 @@
1
+ // ----------------------------------------------
2
+ // Mixin to define button states for hover, active and loading.
3
+ // ---
4
+ // $bg-color: design token name to be used for the states
5
+ // $mode: 'default': apply the default lighten/darken to the color via hsl
6
+ // 'alt': applies a larger percentage change to the color (darken)
7
+ // 'inverse': inverts the modifier, so that it lightens the color rather than darken it
8
+ // 'transparent': uses hsla syntax to make the color semi-opaque (used for ghost and outline button variants)
9
+ // }
10
+ // ----------------------------------------------
11
+ @mixin button-interactive-states($bg-color, $mode: 'default') {
12
+ &:hover:not(:disabled) {
13
+ @if $mode == 'alt' {
14
+ --hover-modifier: calc(-1 * var(--dt-color-hover-02));
15
+ } @else if $mode == 'inverse' {
16
+ --hover-modifier: var(--dt-color-hover-02);
17
+ } @else {
18
+ --hover-modifier: calc(-1 * var(--dt-color-hover-01));
19
+ }
20
+
21
+ // for mode=transparent, use the hsla syntax to make the button background opaque by a set percentage
22
+ @if $mode == 'transparent' {
23
+ --hover-modifier: var(--dt-color-hover-01);
24
+ --btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), var(#{$bg-color}-l), var(--hover-modifier));
25
+ } @else {
26
+ --btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) + var(--hover-modifier)));
27
+ }
28
+ }
29
+
30
+ &:active:not(:disabled),
31
+ &[isLoading]:not(:disabled) {
32
+ @if $mode == 'alt' {
33
+ --active-modifier: calc(-1 * var(--dt-color-active-02));
34
+ } @else if $mode == 'inverse' {
35
+ --active-modifier: var(--dt-color-active-02);
36
+ } @else {
37
+ --active-modifier: calc(-1 * var(--dt-color-active-01));
38
+ }
39
+
40
+ @if $mode == 'transparent' {
41
+ --active-modifier: var(--dt-color-active-01);
42
+ --btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), var(#{$bg-color}-l), var(--active-modifier));
43
+ } @else {
44
+ --btn-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) + var(--active-modifier)));
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,18 @@
1
+ // ----------------------------------------------
2
+ // Mixin for adding focus styles.
3
+ // The `focus` mixin allows you to apply a box-shadow with inner and outer focus styles to an element.
4
+ // -
5
+ // @example
6
+ // &:focus-visible {
7
+ // @include focus;
8
+ // }
9
+ // -
10
+ // Outputs:
11
+ // &:focus-visible {
12
+ // box-shadow: 0 0 0 2px var(--dt-color-focus-inner), 0 0 0 4px var(--dt-color-focus-outer);
13
+ // }
14
+ // ----------------------------------------------
15
+ @mixin focus() {
16
+ box-shadow: 0 0 0 2px var(--dt-color-focus-inner), 0 0 0 4px var(--dt-color-focus-outer);
17
+ outline: none;
18
+ }
@@ -0,0 +1,44 @@
1
+ // ----------------------------------------------
2
+ // Mixin for setting the font size.
3
+ // The `font-size` mixin allows you to set the font size using a CSS variable.
4
+ // The resulting value will be multiplied by 1px.
5
+ // -
6
+ // @param {String} $token - The CSS variable name to be used for the font size.
7
+ // It should include the `--` prefix used in custom properties.
8
+ // -
9
+ // @example
10
+ // .text {
11
+ // @include font-size(--font-size-small);
12
+ // }
13
+ // -
14
+ // Outputs:
15
+ // .text {
16
+ // font-size: calc(var(--font-size-small) * 1px);
17
+ // }
18
+ // ----------------------------------------------
19
+ @mixin font-size($token) {
20
+ font-size: calc(var($token) * 1px);
21
+ }
22
+
23
+
24
+ // ----------------------------------------------
25
+ // Mixin for setting the line height.
26
+ // The `line-height` mixin allows you to set the line height using a CSS variable.
27
+ // The resulting value will be multiplied by 1px.
28
+ // -
29
+ // @param {String} $token - The CSS variable name to be used for the line height.
30
+ // It should include the `--` prefix used in custom properties.
31
+ // -
32
+ // @example
33
+ // .text {
34
+ // @include line-height(--dt-font-caption-line-height);
35
+ // }
36
+ // -
37
+ // Outputs:
38
+ // .text {
39
+ // line-height: calc(var(--dt-font-caption-line-height) * 1px);
40
+ // }
41
+ // ----------------------------------------------
42
+ @mixin line-height($token) {
43
+ line-height: calc(var($token) * 1px);
44
+ }
@@ -0,0 +1,10 @@
1
+ // Mixin to hide an element yet keep it available for screen readers.
2
+ @mixin visually-hidden() {
3
+ position: absolute;
4
+ display: block;
5
+ height: 1px;
6
+ width: 1px;
7
+ overflow: hidden;
8
+ padding: 1px;
9
+ white-space: nowrap;
10
+ }
@@ -0,0 +1,4 @@
1
+ @forward './buttonInteractiveStates';
2
+ @forward './unitModifiers';
3
+ @forward './focus';
4
+ @forward './visuallyHidden';