@justeattakeaway/pie-button 0.12.1 → 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.
@@ -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
- 'pie-button': PieButton;
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,3 @@
1
+ import { PieButton as PieButtonReact } from './index';
2
+ export declare const PieButton: import("@lit-labs/react").ReactWebComponent<PieButtonReact, {}>;
3
+ //# sourceMappingURL=react.d.ts.map
@@ -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.12.1",
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
- "watch": "run -T vite build --watch",
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",
@@ -17,6 +20,13 @@
17
20
  },
18
21
  "author": "JustEatTakeaway - Design System Web Team",
19
22
  "license": "Apache-2.0",
23
+ "dependencies": {
24
+ "@justeattakeaway/pie-webc-core": "workspace:*"
25
+ },
26
+ "devDependencies": {
27
+ "@justeat/pie-design-tokens": "5.1.0",
28
+ "@justeattakeaway/pie-components-config": "workspace:*"
29
+ },
20
30
  "volta": {
21
31
  "extends": "../../../package.json"
22
32
  }
@@ -1,51 +1,53 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- <head>
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
- @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
- }
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
- #root > * {
40
- display: block;
41
- margin-inline: auto;
42
- }
39
+ #root > * {
40
+ display: block;
41
+ margin-inline: auto;
42
+ }
43
43
 
44
- #root > * + * {
45
- margin-top: 1em;
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, devices } from '@sand4rt/experimental-ct-web';
2
- import { resolve } from 'path';
1
+ import { defineConfig } from '@sand4rt/experimental-ct-web';
2
+ import { getPlaywrightVisualConfig } from '@justeattakeaway/pie-components-config';
3
3
 
4
- /**
5
- * See https://playwright.dev/docs/test-configuration.
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());
@@ -1,52 +1,5 @@
1
- import { defineConfig, devices } from '@sand4rt/experimental-ct-web';
2
- import { resolve } from 'path';
1
+ import { defineConfig } from '@sand4rt/experimental-ct-web';
2
+ import { getPlaywrightConfig } from '@justeattakeaway/pie-components-config'
3
3
 
4
- /**
5
- * See https://playwright.dev/docs/test-configuration.
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
- @use '@justeat/pie-design-tokens/dist/jet.scss' as dt;
2
-
3
- $button-height-xs: 32px;
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;
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
- // '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
-
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
- @if $outline-color != null {
53
- border: 1px solid $outline-color;
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
- border-radius: $button-border-radius;
31
+ min-block-size: var(--btn-min-block-size);
32
+ padding: var(--btn-padding);
60
33
  border: none;
61
- font-family: $button-font;
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
- outline: 2px solid $button-focus;
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
- // Sizes
73
- $button-sizes: (
74
- 'xsmall': (
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
- // Variants
130
- .o-btn--primary {
131
- @include button-variant($button-bg-color-primary, $button-text-color-primary);
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
- .o-btn--secondary {
135
- @include button-variant($button-bg-color-secondary, $button-text-color-secondary);
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
- .o-btn--outline {
139
- @include button-variant($button-bg-color-outline, $button-text-color-outline, $button-outline-color-outline);
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
- .o-btn--ghost {
143
- @include button-variant($button-bg-color-ghost, $button-text-color-ghost);
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
- .o-btn.o-btn--is-disabled {
147
- @include button-variant($button-bg-color-disabled, $button-text-color-disabled, $button-outline-color-disabled);
91
+ // Additional modifiers
92
+ :host([isFullWidth]) .o-btn {
93
+ inline-size: 100%;
94
+ }
148
95
 
149
- cursor: not-allowed;
96
+ :host([disabled][variant='ghost']) {
97
+ --btn-bg-color: var(--dt-color-container-default);
150
98
 
151
- &.o-btn--ghost {
152
- background-color: $button-disabled-bg-color-ghost;
99
+ & .o-btn {
153
100
  outline: none;
154
101
  }
155
102
  }
156
103
 
157
- // Additional modifiers
158
- .o-btn--fullWidth {
159
- inline-size: 100%;
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,26 +1,26 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
- import { classMap } from 'lit/directives/class-map.js';
3
- import { customElement, property } from 'lit/decorators.js';
2
+ import { property } from 'lit/decorators.js';
3
+ import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
4
4
 
5
5
  import styles from './button.scss?inline';
6
- import { validPropertyValues } from './decorators';
7
6
  import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
8
7
 
9
8
  // Valid values available to consumers
10
9
  export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
11
10
 
12
- @customElement('pie-button')
11
+ const componentSelector = 'pie-button';
12
+
13
13
  export class PieButton extends LitElement {
14
14
  @property()
15
- @validPropertyValues(Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
15
+ @validPropertyValues(componentSelector, Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
16
16
  size : BUTTON_SIZE = BUTTON_SIZE.MEDIUM;
17
17
 
18
18
  @property()
19
- @validPropertyValues(Object.values(BUTTON_TYPE), BUTTON_TYPE.SUBMIT)
19
+ @validPropertyValues(componentSelector, Object.values(BUTTON_TYPE), BUTTON_TYPE.SUBMIT)
20
20
  type : BUTTON_TYPE = BUTTON_TYPE.SUBMIT;
21
21
 
22
22
  @property()
23
- @validPropertyValues(Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
23
+ @validPropertyValues(componentSelector, Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
24
24
  variant : BUTTON_VARIANT = BUTTON_VARIANT.PRIMARY;
25
25
 
26
26
  @property({ type: Boolean, reflect: true })
@@ -31,20 +31,12 @@ export class PieButton extends LitElement {
31
31
 
32
32
  render () {
33
33
  const {
34
- size, type, variant, disabled, isFullWidth,
34
+ type, disabled, isFullWidth,
35
35
  } = this;
36
36
 
37
- const classes = {
38
- 'o-btn': true,
39
- [`o-btn--${size}`]: size,
40
- [`o-btn--${variant}`]: variant,
41
- 'o-btn--is-disabled': disabled,
42
- 'o-btn--fullWidth': isFullWidth,
43
- };
44
-
45
37
  return html`
46
38
  <button
47
- class=${classMap(classes)}
39
+ class="o-btn"
48
40
  type=${type}
49
41
  ?disabled=${disabled}
50
42
  ?isFullWidth=${isFullWidth}>
@@ -56,8 +48,10 @@ export class PieButton extends LitElement {
56
48
  static styles = unsafeCSS(styles);
57
49
  }
58
50
 
51
+ customElements.define(componentSelector, PieButton);
52
+
59
53
  declare global {
60
54
  interface HTMLElementTagNameMap {
61
- 'pie-button': PieButton;
55
+ [componentSelector]: PieButton;
62
56
  }
63
57
  }
package/tsconfig.json CHANGED
@@ -1,30 +1,8 @@
1
1
  {
2
+ "extends": "../../../configs/pie-components-config/tsconfig.json",
2
3
  "compilerOptions": {
3
- "target": "ES6",
4
- "module": "ES2022",
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"}