@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/README.md ADDED
@@ -0,0 +1,178 @@
1
+ <p align="center">
2
+ <img align="center" src="../../../readme_image.png" height="200" alt="">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/@justeattakeaway/pie-css">
7
+ <img alt="Currently released NPM version" src="https://img.shields.io/npm/v/@justeattakeaway/pie-css.svg">
8
+ </a>
9
+ </p>
10
+
11
+ # PIE CSS
12
+
13
+ # Table of Contents
14
+
15
+ 1. [Introduction](#introduction)
16
+ 2. [Using pie-css for building web applications](#using-pie-css-for-building-web-applications)
17
+ 1. JS or Framework import (via bundler)
18
+ 2. NuxtJS
19
+ 3. Sass /SCSS
20
+ 4. Native HTML
21
+ 3. [Using pie-css for building web components](#using-pie-css-for-building-web-components)
22
+ - [Z-index](#z-index)
23
+ 4. [Testing](#testing)
24
+ - [CSS](#css)
25
+ - [SCSS](#scss )
26
+
27
+ ## Introduction
28
+
29
+ PIE CSS is 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.
30
+
31
+ ---
32
+
33
+ ## Using pie-css for building web applications
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.
35
+
36
+ To install the PIE CSS library, run the following on your command line:
37
+
38
+ ```bash
39
+ # npm
40
+ npm i @justeattakeaway/pie-css
41
+
42
+ # yarn
43
+ yarn add @justeattakeaway/pie-css
44
+ ```
45
+
46
+ Once installed, how you include PIE CSS will largely depend on the type of application you are building (and your own preference), but here are a few examples.
47
+
48
+
49
+ ### JS or Framework import (via bundler)
50
+
51
+ One common way of importing PIE CSS would be through a regular JS import as part of your application bundle.
52
+
53
+ ```js
54
+ import '@justeattakeaway/pie-css';
55
+ ```
56
+
57
+
58
+ For example, in React (or NextJS), you could add the `pie-css` import to your `App.js` file:
59
+
60
+ ```js
61
+ import '@justeattakeaway/pie-css';
62
+
63
+ function App () {
64
+ return (
65
+
66
+ );
67
+ }
68
+
69
+ export default App;
70
+ ```
71
+
72
+ Similarly, in Vue 3, you will likely include it as part of your `/src/main.ts` file:
73
+
74
+
75
+ ```js
76
+ import { createApp } from 'vue';
77
+ import '@justeattakeaway/pie-css';
78
+ import App from './App.vue';
79
+
80
+ createApp(App).mount('#app');
81
+ ```
82
+
83
+ ### NuxtJS
84
+
85
+ If you are using NuxtJS, you can import PIE CSS in your `nuxt.config.js` file.
86
+
87
+
88
+ For NuxtJS v3, this would look like this:
89
+
90
+ ```js
91
+ // Nuxt v3
92
+ export default defineNuxtConfig({
93
+ css: ['@justeattakeaway/pie-css'],
94
+
95
+ });
96
+ ```
97
+
98
+ For NuxtJS v2, it is very similar, looking more like this:
99
+
100
+ ```js
101
+ export default {
102
+ css: [
103
+ '@justeattakeaway/pie-css',
104
+ ],
105
+
106
+ }
107
+ ```
108
+
109
+
110
+ ### Sass / SCSS
111
+
112
+ If you are using Sass, you could import the CSS file as part of your styles directly.
113
+
114
+ ```scss
115
+ @use 'node_modules/@justeattakeaway/pie-css/dist/index.css';
116
+ ```
117
+
118
+
119
+ ### Native HTML
120
+
121
+ 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
+
123
+
124
+
125
+ ## Using pie-css for building web components
126
+ > [!NOTE]
127
+ > The following section is only relevant if you are building web components as a part of our component library within the PIE monorepo.
128
+
129
+ PIE CSS provides an optional set of SCSS helpers that are used by the PIE Web Components.
130
+
131
+ These are for carrying out common tasks in our styles, such as setting font sizes in consistent ways and sharing styles across components via SCSS mixins and functions.
132
+
133
+ We will be writing more in-depth docs on these 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).
134
+
135
+ ### z-index
136
+
137
+ Some PIE Web Components use a z-index value to control how they stack on a webpage. These values are defined in the `pie-css` package as css variables and are utilized internally. 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.
138
+
139
+ | Token | Z-Index Value |
140
+ | -------------------------- | ---------------|
141
+ | --dt-z-index-dropdown | 1000 |
142
+ | --dt-z-index-fab | 1000 |
143
+ | --dt-z-index-tooltip | 2000 |
144
+ | --dt-z-index-popover | 3000 |
145
+ | --dt-z-index-bottom-sheet | 4000 |
146
+ | --dt-z-index-side-sheet | 4000 |
147
+ | --dt-z-index-modal | 4000 |
148
+ | --dt-z-index-cookie-banner | 5000 |
149
+ | --dt-z-index-toast | 6000 |
150
+
151
+ ## Testing
152
+
153
+ We strive to ensure all styles are appropriately tested. How we test the styles differs for CSS and SCSS. Below, we outline both approaches.
154
+
155
+ > [!WARNING]
156
+ > Any pull requests that fail to test newly added or altered styling will likely be rejected. Please do ensure that tests have been added before raising a pull request.
157
+
158
+ ### CSS
159
+
160
+ For our raw CSS styles, we test two things:
161
+
162
+ 1. Ensure that all our our CSS passes W3C CSS validation. This is done by reading the built CSS file and making a network request to the W3C validation service.
163
+
164
+ 2. Ensure that our CSS output is what we expect via snapshot testing. We use some tools such as PostCSS to generate the output, so we want to ensure that we catch any regressions before our consumers do!
165
+
166
+ > [!NOTE]
167
+ > Our CSS tests can be found under `/test/css`.
168
+
169
+ ### SCSS
170
+
171
+ Our SCSS styles are tested in a number of ways:
172
+
173
+ 1. Unit tests to ensure that our SCSS mixins and functions output the expected CSS. These unit tests are written using `vitest`. What we do is write out a string of SCSS that calls the SCSS code we want to test and then run it through a compiler function to generate CSS. We then compare the output CSS to what we expect. This is done for all SCSS. To make things easier, we strip whitespace from the compiled CSS we test.
174
+
175
+ 2. Ensure that all of the compiled CSS passes W3C CSS validation. This is done by compiling the SCSS to CSS and then making a request to the W3C validation service. Because we do not want to spam network requests, we add all the SCSS to `./test/scss/validityTest.scss` and use that file to compile during the test.
176
+
177
+ > [!NOTE]
178
+ > Our SCSS tests can be found under `/test/scss`.