@justeattakeaway/pie-button 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
4
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
+
6
+ v0.3.0
7
+ ---------------------
8
+ *January 24, 2023*
9
+
10
+ ### Added
11
+ - Button default styling (medium).
12
+ - JET font family to html file.
13
+
14
+
15
+ v0.2.0
16
+ ---------------------
17
+ *January 23, 2023*
18
+
19
+ ### Added
20
+ - `actionType` property mapped to `type` attribute.
21
+
22
+
23
+ v0.1.0
24
+ ---------------------
25
+ *January 19, 2023*
26
+
27
+ ### Added
28
+ - Basic button using Lit
29
+ - Initial TypeScript and Vite config
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright (c) Just Eat Takeaway.com
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # pie-button
2
+
3
+ This button is a Web Component built using Lit.
4
+
5
+ ## Local development
6
+
7
+ Install dependencies at the root
8
+ ```
9
+ yarn
10
+ ```
11
+
12
+ Navigate to this folder, compile with TypeScript and build with Vite
13
+ ```
14
+ cd packages/components/pie-button
15
+ yarn build
16
+ ```
17
+
18
+ Local dev server using Vite (with hot module reloading)
19
+ ```
20
+ yarn dev
21
+ ```
package/index.html ADDED
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <link rel="stylesheet" href="https://unpkg.com/@justeat/pie-design-tokens@latest/dist/jet.css">
7
+ <link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2" as="font" type="font/woff2" crossorigin>
8
+ <style>
9
+ @font-face {
10
+ font-family: JETSansDigital;
11
+ src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2') format("woff2"),
12
+ url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff') format("woff");
13
+ font-weight: 400;
14
+ font-display: swap;
15
+ }
16
+ body {
17
+ font-feature-settings: "tnum"; /* Enable tabular numbers */
18
+ }
19
+ </style>
20
+ <script type="module" src="/src/index.ts"></script>
21
+ </head>
22
+ <body>
23
+ <!-- This is a temporary file for testing until Storybook is in place -->
24
+ <!-- Run `yarn dev` to serve this file -->
25
+ <pie-button />
26
+
27
+ <script>
28
+ (function () {
29
+ var boldFontUrls = 'url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2") format("woff2"), url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/ JETSansDigital-Bold-optimised.woff") format("woff")';
30
+ var extraboldFontUrls = 'url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2") format("woff2"), url("https://d30v2pzvrfyzpo.cloudfront.net/fonts/ JETSansDigital-ExtraBold-optimised.woff") format("woff")';
31
+
32
+ if('fonts' in document ) {
33
+ var bold = new FontFace('JETSansDigital', boldFontUrls, { weight: '700' });
34
+ var extrabold = new FontFace('JETSansDigital', extraboldFontUrls, { weight: '800' });
35
+
36
+ Promise.all([bold.load(), extrabold.load()])
37
+ .then(function (fonts) {
38
+ fonts.forEach(function (font) {
39
+ document.fonts.add(font);
40
+ });
41
+ })
42
+ .then(function () {
43
+ document.documentElement.classList.add ('webfonts-loaded');
44
+ });
45
+ }
46
+ })();
47
+ </script>
48
+ </body>
49
+ </html>
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@justeattakeaway/pie-button",
3
+ "version": "0.3.0",
4
+ "description": "PIE design system button built using web components",
5
+ "type": "module",
6
+ "main": "dist/pie-button.js",
7
+ "scripts": {
8
+ "build": "npx tsc && run -T vite build",
9
+ "dev": "run -T vite",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "author": "JustEatTakeaway - Design System Web Team",
13
+ "license": "Apache-2.0"
14
+ }
package/src/index.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+
4
+ @customElement('pie-button')
5
+ export class PieButton extends LitElement {
6
+ @property() actionType = 'submit';
7
+
8
+ static styles = [css`
9
+ button {
10
+ background-color: var(--dt-color-interactive-brand);
11
+ border-radius: var(--dt-radius-rounded-e);
12
+ border: none;
13
+ color: var(--dt-color-content-interactive-primary);
14
+ font-size: 20px; // A future ticket will pull in a helper for font size & line height.
15
+ line-height: 1.4;
16
+ font-family: var(--dt-font-interactive-m-family);
17
+ font-weight: var(--dt-font-interactive-m-weight);
18
+ padding: 10px var(--dt-spacing-e);
19
+ min-height: 48px;
20
+ }
21
+ `];
22
+
23
+ render () {
24
+ return html`
25
+ <button type=${this.actionType}>
26
+ I'm a PIE button
27
+ </button>`;
28
+ }
29
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ES2022",
4
+ "lib": ["es2020", "DOM", "DOM.Iterable"],
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "sourceMap": true,
8
+ "inlineSources": true,
9
+ "outDir": "./compiled",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "noUnusedLocals": true,
13
+ "noUnusedParameters": true,
14
+ "noImplicitReturns": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noImplicitAny": true,
17
+ "noImplicitThis": true,
18
+ "moduleResolution": "node",
19
+ "allowSyntheticDefaultImports": true,
20
+ "experimentalDecorators": true,
21
+ "forceConsistentCasingInFileNames": true
22
+ },
23
+ "include": ["src/**/*.ts"],
24
+ "exclude": []
25
+ }
package/vite.config.js ADDED
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ // https://vitejs.dev/config/
4
+ export default defineConfig({
5
+ build: {
6
+ lib: {
7
+ entry: 'src/index.ts',
8
+ formats: ['es'],
9
+ },
10
+ rollupOptions: {
11
+ external: /^lit/,
12
+ },
13
+ },
14
+ });