@justeattakeaway/pie-button 0.12.2 → 0.14.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/.turbo/turbo-build.log +7 -4
- package/CHANGELOG.md +29 -0
- package/README.md +10 -0
- package/dist/index.js +59 -64
- package/dist/react.js +1605 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/{src → packages/components/pie-button/src}/index.d.ts +2 -1
- package/dist/types/packages/components/pie-button/src/index.d.ts.map +1 -0
- package/dist/types/packages/components/pie-button/src/react.d.ts +3 -0
- package/dist/types/packages/components/pie-button/src/react.d.ts.map +1 -0
- package/dist/types/react.d.ts +1 -0
- package/package.json +10 -3
- package/playwright/index.html +40 -38
- package/playwright-lit-visual.config.ts +4 -51
- package/playwright-lit.config.ts +4 -51
- package/src/button.scss +95 -132
- package/src/index.ts +17 -20
- package/tsconfig.json +3 -25
- package/dist/types/src/decorators.d.ts +0 -9
- package/dist/types/src/decorators.d.ts.map +0 -1
- package/dist/types/src/index.d.ts.map +0 -1
- package/src/decorators.ts +0 -34
- package/vite.config.js +0 -21
- /package/dist/types/{src → packages/components/pie-button/src}/defs.d.ts +0 -0
- /package/dist/types/{src → packages/components/pie-button/src}/defs.d.ts.map +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src/index'
|
|
1
|
+
export * from './packages/components/pie-button/src/index'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
|
|
3
3
|
export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
|
|
4
|
+
declare const componentSelector = "pie-button";
|
|
4
5
|
export declare class PieButton extends LitElement {
|
|
5
6
|
size: BUTTON_SIZE;
|
|
6
7
|
type: BUTTON_TYPE;
|
|
@@ -12,7 +13,7 @@ export declare class PieButton extends LitElement {
|
|
|
12
13
|
}
|
|
13
14
|
declare global {
|
|
14
15
|
interface HTMLElementTagNameMap {
|
|
15
|
-
|
|
16
|
+
[componentSelector]: PieButton;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAKlD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAEpD,QAAA,MAAM,iBAAiB,eAAe,CAAC;AAEvC,qBAAa,SAAU,SAAQ,UAAU;IAGjC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,UAAS;IAGjB,WAAW,UAAS;IAExB,MAAM;IAkBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;KAClC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAGtD,eAAO,MAAM,SAAS,iEAMpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './packages/components/pie-button/src/react'
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "run -T vite build",
|
|
11
|
-
"
|
|
10
|
+
"build": "yarn build:wrapper pie-button && run -T vite build --config ../../../configs/pie-components-config/vite.config.js",
|
|
11
|
+
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
12
|
+
"lint:style:fix": "yarn lint:style --fix",
|
|
13
|
+
"watch": "run -T vite build --config ../../../configs/pie-components-config/vite.config.js --watch",
|
|
12
14
|
"test": "echo \"Error: no test specified\" && exit 0",
|
|
15
|
+
"test:ci": "yarn test",
|
|
13
16
|
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
|
|
14
17
|
"test:browsers:ci": "yarn test:browsers",
|
|
15
18
|
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_BUTTON} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
|
|
@@ -20,6 +23,10 @@
|
|
|
20
23
|
"dependencies": {
|
|
21
24
|
"@justeattakeaway/pie-webc-core": "workspace:*"
|
|
22
25
|
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@justeat/pie-design-tokens": "5.1.0",
|
|
28
|
+
"@justeattakeaway/pie-components-config": "workspace:*"
|
|
29
|
+
},
|
|
23
30
|
"volta": {
|
|
24
31
|
"extends": "../../../package.json"
|
|
25
32
|
}
|
package/playwright/index.html
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
3
|
+
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
7
7
|
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
8
8
|
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
9
|
-
<style>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
<style>
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: JETSansDigital;
|
|
12
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2') format("woff2"),
|
|
13
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff') format("woff");
|
|
14
|
+
font-weight: 400;
|
|
15
|
+
font-display: swap;
|
|
16
|
+
}
|
|
17
|
+
@font-face {
|
|
18
|
+
font-family: JETSansDigital;
|
|
19
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2') format("woff2"),
|
|
20
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff') format("woff");
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
font-display: swap;
|
|
23
|
+
}
|
|
24
|
+
@font-face {
|
|
25
|
+
font-family: JETSansDigital;
|
|
26
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2') format("woff2"),
|
|
27
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff') format("woff");
|
|
28
|
+
font-weight: 800;
|
|
29
|
+
font-display: swap;
|
|
30
|
+
}
|
|
31
|
+
body {
|
|
32
|
+
font-feature-settings: "tnum"; /* Enable tabular numbers */
|
|
33
|
+
}
|
|
34
|
+
/* basic styles to center align components and give them some spacing */
|
|
35
|
+
#root {
|
|
36
|
+
padding: 1em;
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
#root > * {
|
|
40
|
+
display: block;
|
|
41
|
+
margin-inline: auto;
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
</style>
|
|
44
|
+
#root > * + * {
|
|
45
|
+
margin-top: 1em;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
48
|
<title>Testing Page</title>
|
|
49
|
+
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@justeat/pie-design-tokens/dist/jet.css" />
|
|
50
|
+
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@justeat/pie-design-tokens/dist/jet-hsl-colors.css" />
|
|
49
51
|
</head>
|
|
50
52
|
<body>
|
|
51
53
|
<div id="root"></div>
|
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
import { defineConfig
|
|
2
|
-
import {
|
|
1
|
+
import { defineConfig } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { getPlaywrightVisualConfig } from '@justeattakeaway/pie-components-config';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
/* Maximum time one test can run for. */
|
|
9
|
-
timeout: 10 * 1000,
|
|
10
|
-
/* Run tests in files in parallel */
|
|
11
|
-
fullyParallel: true,
|
|
12
|
-
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
13
|
-
forbidOnly: !!process.env.CI,
|
|
14
|
-
/* Retry on CI only */
|
|
15
|
-
retries: process.env.CI ? 2 : 0,
|
|
16
|
-
/* Opt out of parallel tests on CI. */
|
|
17
|
-
workers: '50%',
|
|
18
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
19
|
-
reporter: [['html', { outputFolder: 'lit-visual-report' }]],
|
|
20
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
21
|
-
use: {
|
|
22
|
-
ctViteConfig: {
|
|
23
|
-
resolve: {
|
|
24
|
-
alias: {
|
|
25
|
-
'@': resolve('./src'),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
30
|
-
trace: 'on',
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
/* Configure projects for major browsers */
|
|
34
|
-
projects: [
|
|
35
|
-
{
|
|
36
|
-
name: 'visual:desktop',
|
|
37
|
-
grepInvert: /@mobile/,
|
|
38
|
-
use: {
|
|
39
|
-
...devices['Desktop Chrome'],
|
|
40
|
-
},
|
|
41
|
-
testMatch: ['**/test/visual/*.spec.ts']
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'visual:mobile',
|
|
45
|
-
grep: /@mobile/,
|
|
46
|
-
use: {
|
|
47
|
-
...devices['Pixel 5'],
|
|
48
|
-
},
|
|
49
|
-
testMatch: ['**/test/visual/*.spec.ts']
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
});
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
export default defineConfig(getPlaywrightVisualConfig());
|
package/playwright-lit.config.ts
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
import { defineConfig
|
|
2
|
-
import {
|
|
1
|
+
import { defineConfig } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { getPlaywrightConfig } from '@justeattakeaway/pie-components-config'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
|
|
9
|
-
snapshotDir: './__snapshots__',
|
|
10
|
-
/* Maximum time one test can run for. */
|
|
11
|
-
timeout: 10 * 1000,
|
|
12
|
-
/* Run tests in files in parallel */
|
|
13
|
-
fullyParallel: true,
|
|
14
|
-
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
15
|
-
forbidOnly: !!process.env.CI,
|
|
16
|
-
/* Retry on CI only */
|
|
17
|
-
retries: process.env.CI ? 2 : 0,
|
|
18
|
-
/* Opt out of parallel tests on CI. */
|
|
19
|
-
workers: '50%',
|
|
20
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
21
|
-
reporter: [['html', { outputFolder: 'lit-browsers-report' }]],
|
|
22
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
23
|
-
use: {
|
|
24
|
-
ctViteConfig: {
|
|
25
|
-
resolve: {
|
|
26
|
-
alias: {
|
|
27
|
-
'@': resolve('./src'),
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
32
|
-
trace: 'on',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/* Configure projects for major browsers */
|
|
36
|
-
projects: [
|
|
37
|
-
{
|
|
38
|
-
name: 'component:chrome',
|
|
39
|
-
use: {
|
|
40
|
-
...devices['Desktop Chrome'],
|
|
41
|
-
},
|
|
42
|
-
testMatch: ['**/test/component/*.spec.ts']
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'a11y:chrome',
|
|
46
|
-
use: {
|
|
47
|
-
...devices['Desktop Chrome'],
|
|
48
|
-
},
|
|
49
|
-
testMatch: ['**/test/accessibility/*.spec.ts']
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
});
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
export default defineConfig(getPlaywrightConfig());
|
package/src/button.scss
CHANGED
|
@@ -1,160 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
$button-height-s: 40px;
|
|
5
|
-
$button-height-m: 48px;
|
|
6
|
-
$button-height-l: 56px;
|
|
7
|
-
|
|
8
|
-
$button-border-radius: dt.$radius-rounded-e;
|
|
9
|
-
$button-font: dt.$font-interactive-m-family;
|
|
10
|
-
$button-focus: dt.$color-focus;
|
|
11
|
-
|
|
12
|
-
$button-bg-color-primary: dt.$color-interactive-brand;
|
|
13
|
-
$button-text-color-primary: dt.$color-content-interactive-primary;
|
|
14
|
-
|
|
15
|
-
$button-bg-color-secondary: dt.$color-interactive-secondary;
|
|
16
|
-
$button-text-color-secondary: dt.$color-content-interactive-secondary;
|
|
17
|
-
|
|
18
|
-
$button-bg-color-outline: dt.$color-container-default;
|
|
19
|
-
$button-text-color-outline: dt.$color-content-interactive-tertiary;
|
|
20
|
-
$button-outline-color-outline: dt.$color-border-strong;
|
|
21
|
-
|
|
22
|
-
$button-bg-color-ghost: dt.$color-container-default;
|
|
23
|
-
$button-text-color-ghost: dt.$color-content-link;
|
|
24
|
-
$button-disabled-bg-color-ghost: dt.$color-container-default;
|
|
25
|
-
|
|
26
|
-
$button-bg-color-disabled: dt.$color-disabled-01;
|
|
27
|
-
$button-text-color-disabled: dt.$color-content-disabled;
|
|
28
|
-
$button-outline-color-disabled: dt.$color-disabled-01;
|
|
29
|
-
|
|
30
|
-
// Sets up the size of a button such as xsmall or large
|
|
31
|
-
@mixin button-sizing($min-block-size, $padding-block, $padding-inline, $font-size, $font-weight, $line-height) {
|
|
32
|
-
min-block-size: $min-block-size;
|
|
33
|
-
padding: $padding-block $padding-inline;
|
|
34
|
-
font-size: $font-size * 1px;
|
|
35
|
-
font-weight: $font-weight;
|
|
36
|
-
line-height: $line-height * 1px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// 'Themes' a button for it's particular variant, such as primary, secondary, outline, ghost
|
|
40
|
-
@mixin button-variant($bg-color, $text-color, $outline-color: null) {
|
|
41
|
-
background-color: $bg-color;
|
|
42
|
-
color: $text-color;
|
|
43
|
-
|
|
1
|
+
// Defines button interactive states for hover and active using HSL & calc
|
|
2
|
+
// Takes a color token name as an argument
|
|
3
|
+
@mixin button-interactive-states($bg-color) {
|
|
44
4
|
&:hover:not(:disabled) {
|
|
45
|
-
background-color:
|
|
5
|
+
background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-hover-01)));
|
|
46
6
|
}
|
|
47
7
|
|
|
48
8
|
&:active:not(:disabled) {
|
|
49
|
-
background-color:
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@if $outline-color != null {
|
|
53
|
-
border: 1px solid $outline-color;
|
|
9
|
+
background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-active-01)));
|
|
54
10
|
}
|
|
55
11
|
}
|
|
56
12
|
|
|
57
13
|
// Base button styles
|
|
58
14
|
.o-btn {
|
|
59
|
-
|
|
15
|
+
// Custom Property Declarations
|
|
16
|
+
// These are defined here instead of :host to encapsulate them inside Shadow DOM
|
|
17
|
+
--btn-border-radius: var(--dt-radius-rounded-e);
|
|
18
|
+
--btn-font-family: var(--dt-font-interactive-m-family);
|
|
19
|
+
--btn-font-weight: var(--dt-font-interactive-m-weight);
|
|
20
|
+
|
|
21
|
+
// The base values are set to the size default, which is for the medium button size
|
|
22
|
+
--btn-padding: 10px var(--dt-spacing-e);
|
|
23
|
+
--btn-min-height: 48px;
|
|
24
|
+
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
25
|
+
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
26
|
+
|
|
27
|
+
// The following values set to default background and color
|
|
28
|
+
// currently this sets the primary button styles
|
|
29
|
+
--btn-bg-color: var(--dt-color-interactive-brand);
|
|
30
|
+
--btn-text-color: var(--dt-color-content-interactive-primary);
|
|
31
|
+
--btn-focus: var(--dt-color-focus-outer);
|
|
32
|
+
|
|
33
|
+
min-block-size: var(--btn-min-block-size);
|
|
34
|
+
padding: var(--btn-padding);
|
|
60
35
|
border: none;
|
|
61
|
-
|
|
62
|
-
|
|
36
|
+
border-radius: var(--btn-border-radius);
|
|
37
|
+
outline: none;
|
|
38
|
+
background-color: var(--btn-bg-color);
|
|
39
|
+
font-family: var(--btn-font-family);
|
|
40
|
+
font-size: var(--btn-font-size);
|
|
41
|
+
font-weight: var(--btn-font-weight);
|
|
42
|
+
color: var(--btn-text-color);
|
|
43
|
+
line-height: var(--btn-line-height);
|
|
63
44
|
cursor: pointer;
|
|
64
45
|
user-select: none;
|
|
65
|
-
outline: none;
|
|
66
46
|
|
|
67
47
|
&:focus-visible {
|
|
68
|
-
|
|
48
|
+
// TODO - Need to update to use the latest focus styling
|
|
49
|
+
outline: 2px solid var(--btn-focus);
|
|
69
50
|
}
|
|
70
|
-
}
|
|
71
51
|
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'min-block-size': $button-height-xs,
|
|
76
|
-
'padding-block': 6px,
|
|
77
|
-
'padding-inline': dt.$spacing-b,
|
|
78
|
-
'font-size': dt.$font-interactive-xs-size,
|
|
79
|
-
'font-weight': dt.$font-interactive-xs-weight,
|
|
80
|
-
'line-height': dt.$font-interactive-xs-line-height
|
|
81
|
-
),
|
|
82
|
-
'small-productive': (
|
|
83
|
-
'min-block-size': $button-height-s,
|
|
84
|
-
'padding-block': dt.$spacing-b,
|
|
85
|
-
'padding-inline': dt.$spacing-d,
|
|
86
|
-
'font-size': dt.$font-interactive-s-size,
|
|
87
|
-
'font-weight': dt.$font-interactive-s-weight,
|
|
88
|
-
'line-height': dt.$font-interactive-s-line-height
|
|
89
|
-
),
|
|
90
|
-
'small-expressive': (
|
|
91
|
-
'min-block-size': $button-height-s,
|
|
92
|
-
'padding-block': 6px,
|
|
93
|
-
'padding-inline': dt.$spacing-d,
|
|
94
|
-
'font-size': dt.$font-interactive-l-size,
|
|
95
|
-
'font-weight': dt.$font-interactive-l-weight,
|
|
96
|
-
'line-height': dt.$font-interactive-l-line-height
|
|
97
|
-
),
|
|
98
|
-
'medium': (
|
|
99
|
-
'min-block-size': $button-height-m,
|
|
100
|
-
'padding-block': 10px,
|
|
101
|
-
'padding-inline': dt.$spacing-e,
|
|
102
|
-
'font-size': dt.$font-interactive-l-size,
|
|
103
|
-
'font-weight': dt.$font-interactive-l-weight,
|
|
104
|
-
'line-height': dt.$font-interactive-l-line-height
|
|
105
|
-
),
|
|
106
|
-
'large': (
|
|
107
|
-
'min-block-size': $button-height-l,
|
|
108
|
-
'padding-block': 14px,
|
|
109
|
-
'padding-inline': dt.$spacing-e,
|
|
110
|
-
'font-size': dt.$font-interactive-l-size,
|
|
111
|
-
'font-weight': dt.$font-interactive-l-weight,
|
|
112
|
-
'line-height': dt.$font-interactive-l-line-height
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
@each $size, $values in $button-sizes {
|
|
117
|
-
.o-btn--#{$size} {
|
|
118
|
-
@include button-sizing(
|
|
119
|
-
map-get($values, 'min-block-size'),
|
|
120
|
-
map-get($values, 'padding-block'),
|
|
121
|
-
map-get($values, 'padding-inline'),
|
|
122
|
-
map-get($values, 'font-size'),
|
|
123
|
-
map-get($values, 'font-weight'),
|
|
124
|
-
map-get($values, 'line-height')
|
|
125
|
-
);
|
|
52
|
+
// Variant
|
|
53
|
+
&[variant='primary'] {
|
|
54
|
+
@include button-interactive-states('--dt-color-interactive-brand');
|
|
126
55
|
}
|
|
127
|
-
}
|
|
128
56
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
57
|
+
&[variant='secondary'] {
|
|
58
|
+
--btn-bg-color: var(--dt-color-interactive-secondary);
|
|
59
|
+
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
133
60
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
61
|
+
@include button-interactive-states('--dt-color-interactive-secondary');
|
|
62
|
+
}
|
|
137
63
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
64
|
+
&[variant='outline'] {
|
|
65
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
66
|
+
--btn-text-color: var(--dt-color-content-interactive-tertiary);
|
|
141
67
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
68
|
+
border: 1px solid var(--dt-color-border-strong);
|
|
69
|
+
|
|
70
|
+
@include button-interactive-states('--dt-color-container-default');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&[variant='ghost'] {
|
|
74
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
75
|
+
--btn-text-color: var(--dt-color-content-link);
|
|
76
|
+
|
|
77
|
+
@include button-interactive-states('--dt-color-container-default');
|
|
78
|
+
}
|
|
145
79
|
|
|
146
|
-
|
|
147
|
-
|
|
80
|
+
// Additional modifiers
|
|
81
|
+
&[isFullWidth] {
|
|
82
|
+
inline-size: 100%;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&[disabled] {
|
|
86
|
+
--btn-bg-color: var(--dt-color-disabled-01);
|
|
87
|
+
--btn-text-color: var(--dt-color-content-disabled);
|
|
88
|
+
|
|
89
|
+
border: 1px solid var(--dt-color-disabled-01);
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
}
|
|
148
92
|
|
|
149
|
-
|
|
93
|
+
&[disabled][variant='ghost'] {
|
|
94
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
150
95
|
|
|
151
|
-
&.o-btn--ghost {
|
|
152
|
-
background-color: $button-disabled-bg-color-ghost;
|
|
153
96
|
outline: none;
|
|
154
97
|
}
|
|
155
|
-
}
|
|
156
98
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
99
|
+
&[size='xsmall'] {
|
|
100
|
+
--btn-padding: 6px var(--dt-spacing-b);
|
|
101
|
+
--btn-min-block-size: 32px;
|
|
102
|
+
--btn-font-size: calc(var(--dt-font-size-14) * 1px);
|
|
103
|
+
--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&[size='small'] {
|
|
107
|
+
--btn-padding: 8px var(--dt-spacing-d);
|
|
108
|
+
--btn-min-block-size: 40px;
|
|
109
|
+
--btn-font-size: calc(var(--dt-font-size-19) * 1px);
|
|
110
|
+
--btn-line-height: calc(var(--dt-font-size-19-line-height) * 1px);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&[size='medium'] {
|
|
114
|
+
/* Same as default styles */
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&[size='large'] {
|
|
118
|
+
--btn-padding: 14px var(--dt-spacing-e);
|
|
119
|
+
--btn-min-block-size: 56px;
|
|
120
|
+
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
121
|
+
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
122
|
+
}
|
|
160
123
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,50 +1,45 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
4
|
+
|
|
4
5
|
import styles from './button.scss?inline';
|
|
5
|
-
import { validPropertyValues } from './decorators';
|
|
6
6
|
import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
|
|
7
7
|
|
|
8
8
|
// Valid values available to consumers
|
|
9
9
|
export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const componentSelector = 'pie-button';
|
|
12
|
+
|
|
12
13
|
export class PieButton extends LitElement {
|
|
13
14
|
@property()
|
|
14
|
-
@validPropertyValues(Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
|
|
15
|
+
@validPropertyValues(componentSelector, Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
|
|
15
16
|
size : BUTTON_SIZE = BUTTON_SIZE.MEDIUM;
|
|
16
17
|
|
|
17
18
|
@property()
|
|
18
|
-
@validPropertyValues(Object.values(BUTTON_TYPE), BUTTON_TYPE.SUBMIT)
|
|
19
|
+
@validPropertyValues(componentSelector, Object.values(BUTTON_TYPE), BUTTON_TYPE.SUBMIT)
|
|
19
20
|
type : BUTTON_TYPE = BUTTON_TYPE.SUBMIT;
|
|
20
21
|
|
|
21
22
|
@property()
|
|
22
|
-
@validPropertyValues(Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
|
|
23
|
+
@validPropertyValues(componentSelector, Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
|
|
23
24
|
variant : BUTTON_VARIANT = BUTTON_VARIANT.PRIMARY;
|
|
24
25
|
|
|
25
|
-
@property({ type: Boolean
|
|
26
|
+
@property({ type: Boolean })
|
|
26
27
|
disabled = false;
|
|
27
28
|
|
|
28
|
-
@property({ type: Boolean
|
|
29
|
+
@property({ type: Boolean })
|
|
29
30
|
isFullWidth = false;
|
|
30
31
|
|
|
31
32
|
render () {
|
|
32
33
|
const {
|
|
33
|
-
|
|
34
|
+
type, disabled, isFullWidth, variant, size,
|
|
34
35
|
} = this;
|
|
35
36
|
|
|
36
|
-
const classes = {
|
|
37
|
-
'o-btn': true,
|
|
38
|
-
[`o-btn--${size}`]: size,
|
|
39
|
-
[`o-btn--${variant}`]: variant,
|
|
40
|
-
'o-btn--is-disabled': disabled,
|
|
41
|
-
'o-btn--fullWidth': isFullWidth,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
37
|
return html`
|
|
45
38
|
<button
|
|
46
|
-
class
|
|
39
|
+
class="o-btn"
|
|
47
40
|
type=${type}
|
|
41
|
+
variant=${variant}
|
|
42
|
+
size=${size}
|
|
48
43
|
?disabled=${disabled}
|
|
49
44
|
?isFullWidth=${isFullWidth}>
|
|
50
45
|
<slot></slot>
|
|
@@ -55,8 +50,10 @@ export class PieButton extends LitElement {
|
|
|
55
50
|
static styles = unsafeCSS(styles);
|
|
56
51
|
}
|
|
57
52
|
|
|
53
|
+
customElements.define('pie-button', PieButton);
|
|
54
|
+
|
|
58
55
|
declare global {
|
|
59
56
|
interface HTMLElementTagNameMap {
|
|
60
|
-
|
|
57
|
+
[componentSelector]: PieButton;
|
|
61
58
|
}
|
|
62
59
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../../configs/pie-components-config/tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"lib": ["es2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"sourceMap": true,
|
|
9
|
-
"inlineSources": true,
|
|
10
|
-
"outDir": "./compiled",
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"paths": {
|
|
13
|
-
"@/*": ["./src/*"]
|
|
14
|
-
},
|
|
15
|
-
"rootDir": ".",
|
|
16
|
-
"strict": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": true,
|
|
19
|
-
"noImplicitReturns": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"noImplicitAny": true,
|
|
22
|
-
"noImplicitThis": true,
|
|
23
|
-
"moduleResolution": "node",
|
|
24
|
-
"allowSyntheticDefaultImports": true,
|
|
25
|
-
"experimentalDecorators": true,
|
|
26
|
-
"forceConsistentCasingInFileNames": true
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"rootDir": ".",
|
|
27
6
|
},
|
|
28
7
|
"include": ["src/**/*.ts","./declaration.d.ts", "test/**/*.ts"],
|
|
29
|
-
"exclude": []
|
|
30
8
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A decorator for specifying a list of valid values for a property.
|
|
3
|
-
* If this property's setter is called with an invalid value, an error is logged and the default value will be assigned instead.
|
|
4
|
-
* @param validValues - The array of valid values
|
|
5
|
-
* @param defaultValue - The value to fall back on
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const validPropertyValues: (validValues: any[], defaultValue: any) => (target: any, propertyKey: string) => void;
|
|
9
|
-
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,gBAAiB,GAAG,EAAE,gBAAgB,GAAG,cAC5C,GAAG,eAAe,MAAM,KAAI,IAyBxD,CAAC"}
|