@justeattakeaway/pie-button 0.12.2 → 0.13.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 +21 -0
- package/README.md +10 -0
- package/dist/index.js +56 -65
- 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 +93 -126
- package/src/index.ts +13 -18
- 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;IAgBN,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.13.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,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
1
|
+
:host {
|
|
2
|
+
--btn-border-radius: var(--dt-radius-rounded-e);
|
|
3
|
+
--btn-font-family: var(--dt-font-interactive-m-family);
|
|
4
|
+
--btn-font-weight: var(--dt-font-interactive-m-weight);
|
|
5
|
+
|
|
6
|
+
// The base values are set to the size default, which is for the medium button size
|
|
7
|
+
--btn-padding: 10px var(--dt-spacing-e);
|
|
8
|
+
--btn-min-height: 48px;
|
|
9
|
+
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
10
|
+
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
11
|
+
|
|
12
|
+
// The following values set to default background and color
|
|
13
|
+
// currently this sets the primary button styles
|
|
14
|
+
--btn-bg-color: var(--dt-color-interactive-brand);
|
|
15
|
+
--btn-text-color: var(--dt-color-content-interactive-primary);
|
|
16
|
+
--btn-focus: var(--dt-color-focus-outer);
|
|
37
17
|
}
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
color: $text-color;
|
|
43
|
-
|
|
44
|
-
&:hover:not(:disabled) {
|
|
45
|
-
background-color: darken($bg-color, dt.$color-hover-01);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&:active:not(:disabled) {
|
|
49
|
-
background-color: darken($bg-color, dt.$color-active-01);
|
|
19
|
+
@mixin button-interactive-states($bg-color) {
|
|
20
|
+
& .o-btn:hover:not(:disabled) {
|
|
21
|
+
background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-hover-01)));
|
|
50
22
|
}
|
|
51
23
|
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
& .o-btn:active:not(:disabled) {
|
|
25
|
+
background-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) - var(--dt-color-active-01)));
|
|
54
26
|
}
|
|
55
27
|
}
|
|
56
28
|
|
|
57
29
|
// Base button styles
|
|
58
30
|
.o-btn {
|
|
59
|
-
|
|
31
|
+
min-block-size: var(--btn-min-block-size);
|
|
32
|
+
padding: var(--btn-padding);
|
|
60
33
|
border: none;
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
border-radius: var(--btn-border-radius);
|
|
35
|
+
outline: none;
|
|
36
|
+
background-color: var(--btn-bg-color);
|
|
37
|
+
font-family: var(--btn-font-family);
|
|
38
|
+
font-size: var(--btn-font-size);
|
|
39
|
+
font-weight: var(--btn-font-weight);
|
|
40
|
+
color: var(--btn-text-color);
|
|
41
|
+
line-height: var(--btn-line-height);
|
|
63
42
|
cursor: pointer;
|
|
64
43
|
user-select: none;
|
|
65
|
-
outline: none;
|
|
66
44
|
|
|
67
45
|
&:focus-visible {
|
|
68
|
-
|
|
46
|
+
// TODO - Need to update to use the latest focus styling
|
|
47
|
+
outline: 2px solid var(--btn-focus);
|
|
69
48
|
}
|
|
70
49
|
}
|
|
71
50
|
|
|
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
|
-
);
|
|
126
|
-
}
|
|
51
|
+
// Variants
|
|
52
|
+
:host([variant='primary']) {
|
|
53
|
+
@include button-interactive-states('--dt-color-interactive-brand');
|
|
127
54
|
}
|
|
128
55
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
56
|
+
:host([variant='secondary']) {
|
|
57
|
+
--btn-bg-color: var(--dt-color-interactive-secondary);
|
|
58
|
+
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
59
|
+
|
|
60
|
+
@include button-interactive-states('--dt-color-interactive-secondary');
|
|
132
61
|
}
|
|
133
62
|
|
|
134
|
-
|
|
135
|
-
|
|
63
|
+
:host([variant='outline']) {
|
|
64
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
65
|
+
--btn-text-color: var(--dt-color-content-interactive-tertiary);
|
|
66
|
+
|
|
67
|
+
& .o-btn {
|
|
68
|
+
border: 1px solid var(--dt-color-border-strong);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@include button-interactive-states('--dt-color-container-default');
|
|
136
72
|
}
|
|
137
73
|
|
|
138
|
-
|
|
139
|
-
|
|
74
|
+
:host([variant='ghost']) {
|
|
75
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
76
|
+
--btn-text-color: var(--dt-color-content-link);
|
|
77
|
+
|
|
78
|
+
@include button-interactive-states('--dt-color-container-default');
|
|
140
79
|
}
|
|
141
80
|
|
|
142
|
-
|
|
143
|
-
|
|
81
|
+
:host([disabled]) {
|
|
82
|
+
--btn-bg-color: var(--dt-color-disabled-01);
|
|
83
|
+
--btn-text-color: var(--dt-color-content-disabled);
|
|
84
|
+
|
|
85
|
+
& .o-btn {
|
|
86
|
+
border: 1px solid var(--dt-color-disabled-01);
|
|
87
|
+
cursor: not-allowed;
|
|
88
|
+
}
|
|
144
89
|
}
|
|
145
90
|
|
|
146
|
-
|
|
147
|
-
|
|
91
|
+
// Additional modifiers
|
|
92
|
+
:host([isFullWidth]) .o-btn {
|
|
93
|
+
inline-size: 100%;
|
|
94
|
+
}
|
|
148
95
|
|
|
149
|
-
|
|
96
|
+
:host([disabled][variant='ghost']) {
|
|
97
|
+
--btn-bg-color: var(--dt-color-container-default);
|
|
150
98
|
|
|
151
|
-
|
|
152
|
-
background-color: $button-disabled-bg-color-ghost;
|
|
99
|
+
& .o-btn {
|
|
153
100
|
outline: none;
|
|
154
101
|
}
|
|
155
102
|
}
|
|
156
103
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
104
|
+
:host([size='xsmall']) {
|
|
105
|
+
--btn-padding: 6px var(--dt-spacing-b);
|
|
106
|
+
--btn-min-block-size: 32px;
|
|
107
|
+
--btn-font-size: calc(var(--dt-font-size-14) * 1px);
|
|
108
|
+
--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host([size='small']) {
|
|
112
|
+
--btn-padding: 8px var(--dt-spacing-d);
|
|
113
|
+
--btn-min-block-size: 40px;
|
|
114
|
+
--btn-font-size: calc(var(--dt-font-size-19) * 1px);
|
|
115
|
+
--btn-line-height: calc(var(--dt-font-size-19-line-height) * 1px);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host([size='medium']) {
|
|
119
|
+
/* Same as default styles */
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:host([size='large']) {
|
|
123
|
+
--btn-padding: 14px var(--dt-spacing-e);
|
|
124
|
+
--btn-min-block-size: 56px;
|
|
125
|
+
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
126
|
+
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
160
127
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
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
26
|
@property({ type: Boolean, reflect: true })
|
|
@@ -30,20 +31,12 @@ export class PieButton extends LitElement {
|
|
|
30
31
|
|
|
31
32
|
render () {
|
|
32
33
|
const {
|
|
33
|
-
|
|
34
|
+
type, disabled, isFullWidth,
|
|
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}
|
|
48
41
|
?disabled=${disabled}
|
|
49
42
|
?isFullWidth=${isFullWidth}>
|
|
@@ -55,8 +48,10 @@ export class PieButton extends LitElement {
|
|
|
55
48
|
static styles = unsafeCSS(styles);
|
|
56
49
|
}
|
|
57
50
|
|
|
51
|
+
customElements.define(componentSelector, PieButton);
|
|
52
|
+
|
|
58
53
|
declare global {
|
|
59
54
|
interface HTMLElementTagNameMap {
|
|
60
|
-
|
|
55
|
+
[componentSelector]: PieButton;
|
|
61
56
|
}
|
|
62
57
|
}
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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,qBACa,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;IAwBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,YAAY,EAAE,SAAS,CAAC;KAC3B;CACJ"}
|