@justeattakeaway/pie-button 0.10.2 → 0.11.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.
@@ -3,9 +3,9 @@ transforming...
3
3
  ✓ 4 modules transformed.
4
4
  rendering chunks...
5
5
  computing gzip size...
6
- dist/index.js 3.85 kB │ gzip: 1.61 kB
6
+ dist/index.js 4.12 kB │ gzip: 1.65 kB
7
7
  
8
8
  [vite:dts] Start generate declaration files...
9
- ✓ built in 8.24s
10
- [vite:dts] Declaration files built in 7676ms.
9
+ ✓ built in 8.92s
10
+ [vite:dts] Declaration files built in 8276ms.
11
11
  
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Changed] - Improved readme files ([#418](https://github.com/justeattakeaway/pie/pull/418)) by [@jamieomaguire](https://github.com/jamieomaguire)
8
+
9
+ - [Changed] - Refactor SCSS to reduce duplication ([#416](https://github.com/justeattakeaway/pie/pull/416)) by [@jamieomaguire](https://github.com/jamieomaguire)
10
+
11
+ - [Changed] - Copy playwright projects from monorepo root ([#416](https://github.com/justeattakeaway/pie/pull/416)) by [@jamieomaguire](https://github.com/jamieomaguire)
12
+
13
+ - [Changed] - Split small size into expressive and productive ([#416](https://github.com/justeattakeaway/pie/pull/416)) by [@jamieomaguire](https://github.com/jamieomaguire)
14
+
15
+ ### Patch Changes
16
+
17
+ - [Removed] the custom decorator and uses the native `customElement` decorator instead ([#417](https://github.com/justeattakeaway/pie/pull/417)) by [@fernandofranca](https://github.com/fernandofranca)
18
+
3
19
  ## 0.10.2
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -1,3 +1,13 @@
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-button">
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-button.svg">
8
+ </a>
9
+ </p>
10
+
1
11
  # pie-button
2
12
 
3
13
  This button is a Web Component built using Lit.
@@ -24,3 +34,23 @@ Local dev server using Vite (with hot module reloading)
24
34
  ```
25
35
  yarn dev
26
36
  ```
37
+
38
+
39
+ ## Running tests
40
+
41
+ ### Browser tests
42
+
43
+ Run at the root of the monorepo:
44
+ ```
45
+ yarn test:browsers --filter=pie-button
46
+ ```
47
+
48
+ ### Visual tests
49
+
50
+ Run at the root of the monorepo:
51
+ ```
52
+ yarn test:visual --filter=pie-button
53
+ ```
54
+
55
+
56
+
package/dist/index.js CHANGED
@@ -1,51 +1,45 @@
1
- import { unsafeCSS as f, LitElement as h, html as g } from "lit";
2
- import { classMap as m } from "lit/directives/class-map.js";
3
- import { property as b, customElement as v } from "lit/decorators.js";
4
- const x = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;font-weight:700;cursor:pointer;user-select:none;outline:none}.o-btn:focus-visible{outline:2px solid #4996fd}.o-btn--xsmall{padding:6px 8px;min-height:32px;font-size:14px;line-height:20px}.o-btn--small{padding:8px 16px;min-height:40px;font-size:19px;line-height:28px}.o-btn--medium{padding:10px 24px;min-height:48px;font-size:20px;line-height:28px}.o-btn--large{padding:14px 24px;min-height:56px;font-size:20px;line-height:28px}.o-btn--primary{background-color:#f36805;color:#fff}.o-btn--primary:hover{background-color:#df5f05}.o-btn--primary:active{background-color:#b74e04}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--secondary:hover{background-color:#ede9e5}.o-btn--secondary:active{background-color:#dcd4cd}.o-btn--outline{outline:1px solid #dbd9d7;background-color:#fff;color:#303d3f}.o-btn--outline:hover{background-color:#f5f5f5}.o-btn--outline:active{background-color:#e0e0e0}.o-btn--ghost{background-color:#fff;color:#242e30}.o-btn--ghost:hover{background-color:#f5f5f5}.o-btn--ghost:active{background-color:#e0e0e0}.o-btn.o-btn--is-disabled{background-color:#efedea;color:#8c999b;outline:1px solid #efedea;cursor:default}.o-btn.o-btn--is-disabled.o-btn--ghost{background-color:#fff;outline:none}
5
- `, p = (e, n) => function(i, t) {
6
- const o = `#${t}`;
1
+ import { unsafeCSS as f, LitElement as g, html as h } from "lit";
2
+ import { classMap as v } from "lit/directives/class-map.js";
3
+ import { property as p, customElement as m } from "lit/decorators.js";
4
+ const x = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;cursor:pointer;user-select:none;outline:none}.o-btn:focus-visible{outline:2px solid #4996fd}.o-btn--xsmall{min-block-size:32px;padding:6px 8px;font-size:14px;font-weight:700;line-height:20px}.o-btn--small-productive{min-block-size:40px;padding:8px 16px;font-size:16px;font-weight:700;line-height:24px}.o-btn--small-expressive{min-block-size:40px;padding:6px 16px;font-size:20px;font-weight:700;line-height:28px}.o-btn--medium{min-block-size:48px;padding:10px 24px;font-size:20px;font-weight:700;line-height:28px}.o-btn--large{min-block-size:56px;padding:14px 24px;font-size:20px;font-weight:700;line-height:28px}.o-btn--primary{background-color:#f36805;color:#fff}.o-btn--primary:hover{background-color:#df5f05}.o-btn--primary:active{background-color:#b74e04}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--secondary:hover{background-color:#ede9e5}.o-btn--secondary:active{background-color:#dcd4cd}.o-btn--outline{background-color:#fff;color:#303d3f;outline:1px solid #dbd9d7}.o-btn--outline:hover{background-color:#f5f5f5}.o-btn--outline:active{background-color:#e0e0e0}.o-btn--ghost{background-color:#fff;color:#242e30}.o-btn--ghost:hover{background-color:#f5f5f5}.o-btn--ghost:active{background-color:#e0e0e0}.o-btn.o-btn--is-disabled{background-color:#efedea;color:#8c999b;outline:1px solid #efedea;cursor:default}.o-btn.o-btn--is-disabled:hover{background-color:#e6e3de}.o-btn.o-btn--is-disabled:active{background-color:#d5cfc7}.o-btn.o-btn--is-disabled.o-btn--ghost{background-color:#fff;outline:none}
5
+ `, u = (o, n) => function(i, t) {
6
+ const e = `#${t}`;
7
7
  Object.defineProperty(i, t, {
8
8
  get() {
9
- return this[o];
9
+ return this[e];
10
10
  },
11
11
  set(r) {
12
- const s = this[o];
13
- e.includes(r) ? this[o] = r : (console.error(
12
+ const s = this[e];
13
+ o.includes(r) ? this[e] = r : (console.error(
14
14
  `[pie-button] Invalid value "${r}" provided for property "${t}".`,
15
- `Must be one of: ${e.join(" | ")}.`,
15
+ `Must be one of: ${o.join(" | ")}.`,
16
16
  `Falling back to default value: "${n}"`
17
- ), this[o] = n), this.requestUpdate(t, s);
17
+ ), this[e] = n), this.requestUpdate(t, s);
18
18
  }
19
19
  });
20
20
  };
21
- var a = /* @__PURE__ */ ((e) => (e.XSMALL = "xsmall", e.SMALL = "small", e.MEDIUM = "medium", e.LARGE = "large", e))(a || {}), d = /* @__PURE__ */ ((e) => (e.SUBMIT = "submit", e.BUTTON = "button", e.RESET = "reset", e.MENU = "menu", e))(d || {}), u = /* @__PURE__ */ ((e) => (e.PRIMARY = "primary", e.SECONDARY = "secondary", e.OUTLINE = "outline", e.GHOST = "ghost", e))(u || {}), y = Object.defineProperty, M = Object.getOwnPropertyDescriptor, c = (e, n, i, t) => {
22
- for (var o = t > 1 ? void 0 : t ? M(n, i) : n, r = e.length - 1, s; r >= 0; r--)
23
- (s = e[r]) && (o = (t ? s(n, i, o) : s(o)) || o);
24
- return t && o && y(n, i, o), o;
21
+ var a = /* @__PURE__ */ ((o) => (o.XSMALL = "xsmall", o.SMALL_EXPRESSIVE = "small-expressive", o.SMALL_PRODUCTIVE = "small-productive", o.MEDIUM = "medium", o.LARGE = "large", o))(a || {}), d = /* @__PURE__ */ ((o) => (o.SUBMIT = "submit", o.BUTTON = "button", o.RESET = "reset", o.MENU = "menu", o))(d || {}), b = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.OUTLINE = "outline", o.GHOST = "ghost", o))(b || {}), y = Object.defineProperty, k = Object.getOwnPropertyDescriptor, c = (o, n, i, t) => {
22
+ for (var e = t > 1 ? void 0 : t ? k(n, i) : n, r = o.length - 1, s; r >= 0; r--)
23
+ (s = o[r]) && (e = (t ? s(n, i, e) : s(e)) || e);
24
+ return t && e && y(n, i, e), e;
25
25
  };
26
- function k(e) {
27
- return (n) => {
28
- if (!customElements.get(e))
29
- return v(e)(n);
30
- };
31
- }
32
- let l = class extends h {
26
+ let l = class extends g {
33
27
  constructor() {
34
- super(...arguments), this.size = a.MEDIUM, this.type = d.SUBMIT, this.variant = u.PRIMARY, this.disabled = !1;
28
+ super(...arguments), this.size = a.MEDIUM, this.type = d.SUBMIT, this.variant = b.PRIMARY, this.disabled = !1;
35
29
  }
36
30
  render() {
37
- const { size: e, type: n, variant: i, disabled: t } = this, o = {
31
+ const { size: o, type: n, variant: i, disabled: t } = this, e = {
38
32
  "o-btn": !0,
39
- [`o-btn--${e}`]: e,
33
+ [`o-btn--${o}`]: o,
40
34
  [`o-btn--${i}`]: i,
41
35
  "o-btn--is-disabled": t
42
36
  }, r = () => {
43
37
  const s = new CustomEvent("CustomEvent", { detail: "WC event dispatched" });
44
38
  console.info("WC event dispatched"), this.dispatchEvent(s);
45
39
  };
46
- return g`
40
+ return h`
47
41
  <button
48
- class=${m(o)}
42
+ class=${v(e)}
49
43
  type=${n}
50
44
  ?disabled=${t}
51
45
  @click="${r}">
@@ -55,26 +49,26 @@ let l = class extends h {
55
49
  };
56
50
  l.styles = f(x);
57
51
  c([
58
- b(),
59
- p(Object.values(a), a.MEDIUM)
52
+ p(),
53
+ u(Object.values(a), a.MEDIUM)
60
54
  ], l.prototype, "size", 2);
61
55
  c([
62
- b(),
63
- p(Object.values(d), d.SUBMIT)
56
+ p(),
57
+ u(Object.values(d), d.SUBMIT)
64
58
  ], l.prototype, "type", 2);
65
59
  c([
66
- b(),
67
- p(Object.values(u), u.PRIMARY)
60
+ p(),
61
+ u(Object.values(b), b.PRIMARY)
68
62
  ], l.prototype, "variant", 2);
69
63
  c([
70
- b({ type: Boolean, reflect: !0 })
64
+ p({ type: Boolean, reflect: !0 })
71
65
  ], l.prototype, "disabled", 2);
72
66
  l = c([
73
- k("pie-button")
67
+ m("pie-button")
74
68
  ], l);
75
69
  export {
76
70
  a as BUTTON_SIZE,
77
71
  d as BUTTON_TYPE,
78
- u as BUTTON_VARIANT,
72
+ b as BUTTON_VARIANT,
79
73
  l as PieButton
80
74
  };
@@ -3,7 +3,8 @@
3
3
  */
4
4
  export declare enum BUTTON_SIZE {
5
5
  XSMALL = "xsmall",
6
- SMALL = "small",
6
+ SMALL_EXPRESSIVE = "small-expressive",
7
+ SMALL_PRODUCTIVE = "small-productive",
7
8
  MEDIUM = "medium",
8
9
  LARGE = "large"
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CAClB;AAED;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;CAClB"}
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,MAAM,WAAW;IACjB,KAAK,UAAU;CAClB;AAED;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAWpD,qBACa,SAAU,SAAQ,UAAU;IAGrC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,EAAG,OAAO,CAAS;IAE3B,MAAM;IA2BN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,YAAY,EAAE,SAAS,CAAC;KAC3B;CACJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,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;IAGrC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,EAAG,OAAO,CAAS;IAE3B,MAAM;IA2BN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,YAAY,EAAE,SAAS,CAAC;KAC3B;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,6 +31,14 @@
31
31
  body {
32
32
  font-feature-settings: "tnum"; /* Enable tabular numbers */
33
33
  }
34
+ #root {
35
+ padding: 1.5em;
36
+ display: flex;
37
+ gap: 1em;
38
+ justify-content: center;
39
+ align-items: center;
40
+ flex-direction: column;
41
+ }
34
42
  </style>
35
43
  <title>Testing Page</title>
36
44
  </head>
@@ -38,4 +46,4 @@
38
46
  <div id="root"></div>
39
47
  <script type="module" src="./index.ts"></script>
40
48
  </body>
41
- </html>
49
+ </html>
@@ -33,11 +33,20 @@ export default defineConfig({
33
33
  /* Configure projects for major browsers */
34
34
  projects: [
35
35
  {
36
- name: 'component:chrome',
36
+ name: 'visual:desktop',
37
+ grepInvert: /@mobile/,
37
38
  use: {
38
39
  ...devices['Desktop Chrome'],
39
40
  },
40
41
  testMatch: ['**/test/visual/*.spec.ts']
41
- }
42
+ },
43
+ {
44
+ name: 'visual:mobile',
45
+ grep: /@mobile/,
46
+ use: {
47
+ ...devices['Pixel 5'],
48
+ },
49
+ testMatch: ['**/test/visual/*.spec.ts']
50
+ },
42
51
  ],
43
- });
52
+ });
package/src/button.scss CHANGED
@@ -1,110 +1,155 @@
1
1
  @use '@justeat/pie-design-tokens/dist/jet.scss' as dt;
2
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;
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
+
44
+ &:hover {
45
+ background-color: darken($bg-color, dt.$color-hover-01);
46
+ }
47
+
48
+ &:active {
49
+ background-color: darken($bg-color, dt.$color-active-01);
50
+ }
51
+
52
+ @if $outline-color != null {
53
+ outline: 1px solid $outline-color;
54
+ }
55
+ }
56
+
57
+ // Base button styles
3
58
  .o-btn {
4
- border-radius: dt.$radius-rounded-e;
59
+ border-radius: $button-border-radius;
5
60
  border: none;
6
- font-family: dt.$font-interactive-m-family;
7
- font-weight: dt.$font-interactive-m-weight;
61
+ font-family: $button-font;
8
62
 
9
63
  cursor: pointer;
10
64
  user-select: none;
11
65
  outline: none;
12
66
 
13
67
  &:focus-visible {
14
- outline: 2px solid dt.$color-focus;
68
+ outline: 2px solid $button-focus;
15
69
  }
16
70
  }
17
71
 
18
- .o-btn--xsmall {
19
- padding: 6px dt.$spacing-b;
20
- min-height: 32px;
21
- font-size: dt.$font-size-14 * 1px;
22
- line-height: dt.$font-size-14-line-height * 1px;
23
- }
24
-
25
- .o-btn--small {
26
- padding: 8px dt.$spacing-d;
27
- min-height: 40px;
28
- font-size: dt.$font-size-19 * 1px;
29
- line-height: dt.$font-size-19-line-height * 1px;
30
- }
31
-
32
- .o-btn--medium {
33
- padding: 10px dt.$spacing-e;
34
- min-height: 48px;
35
- font-size: dt.$font-size-20 * 1px;
36
- line-height: dt.$font-size-20-line-height * 1px;
37
- }
38
-
39
- .o-btn--large {
40
- padding: 14px dt.$spacing-e;
41
- min-height: 56px;
42
- font-size: dt.$font-size-20 * 1px;
43
- line-height: dt.$font-size-20-line-height * 1px;
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
+ }
44
127
  }
45
128
 
129
+ // Variants
46
130
  .o-btn--primary {
47
- background-color: dt.$color-interactive-brand;
48
- color: dt.$color-content-interactive-primary;
49
-
50
- &:hover {
51
- background-color: darken(dt.$color-interactive-brand, dt.$color-hover-01);
52
- }
53
-
54
- &:active {
55
- background-color: darken(dt.$color-interactive-brand, dt.$color-active-01);
56
- }
131
+ @include button-variant($button-bg-color-primary, $button-text-color-primary);
57
132
  }
58
133
 
59
134
  .o-btn--secondary {
60
- background-color: dt.$color-interactive-secondary;
61
- color: dt.$color-content-interactive-secondary;
62
-
63
- &:hover {
64
- background-color: darken(dt.$color-interactive-secondary, dt.$color-hover-01);
65
- }
66
-
67
- &:active {
68
- background-color: darken(dt.$color-interactive-secondary, dt.$color-active-01);
69
- }
135
+ @include button-variant($button-bg-color-secondary, $button-text-color-secondary);
70
136
  }
71
137
 
72
138
  .o-btn--outline {
73
- outline: 1px solid dt.$color-border-strong;
74
- background-color: dt.$color-container-default;
75
- color: dt.$color-content-interactive-tertiary;
76
-
77
- &:hover {
78
- background-color: darken(dt.$color-container-default, dt.$color-hover-01);
79
- }
80
-
81
- &:active {
82
- background-color: darken(dt.$color-container-default, dt.$color-active-01);
83
- }
139
+ @include button-variant($button-bg-color-outline, $button-text-color-outline, $button-outline-color-outline);
84
140
  }
85
141
 
86
142
  .o-btn--ghost {
87
- background-color: dt.$color-container-default;
88
- color: dt.$color-content-link;
89
-
90
- &:hover {
91
- background-color: darken(dt.$color-container-default, dt.$color-hover-01);
92
- }
93
-
94
- &:active {
95
- background-color: darken(dt.$color-container-default, dt.$color-active-01);
96
- }
143
+ @include button-variant($button-bg-color-ghost, $button-text-color-ghost);
97
144
  }
98
145
 
99
146
  .o-btn.o-btn--is-disabled {
100
- background-color: dt.$color-disabled-01;
101
- color: dt.$color-content-disabled;
102
- outline: 1px solid dt.$color-disabled-01;
147
+ @include button-variant($button-bg-color-disabled, $button-text-color-disabled, $button-outline-color-disabled);
103
148
 
104
149
  cursor: default;
105
150
 
106
151
  &.o-btn--ghost {
107
- background-color: dt.$color-container-default;
152
+ background-color: $button-disabled-bg-color-ghost;
108
153
  outline: none;
109
154
  }
110
- }
155
+ }
package/src/defs.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  */
4
4
  export enum BUTTON_SIZE {
5
5
  XSMALL = 'xsmall',
6
- SMALL = 'small',
6
+ SMALL_EXPRESSIVE = 'small-expressive',
7
+ SMALL_PRODUCTIVE = 'small-productive',
7
8
  MEDIUM = 'medium',
8
9
  LARGE = 'large'
9
10
  }
package/src/index.ts CHANGED
@@ -9,16 +9,7 @@ import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
9
9
  // Valid values available to consumers
10
10
  export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
11
11
 
12
- // TODO: Extract as a utility function in a shared package
13
- function defineCustomElement(elementName:string) {
14
- return (elementClass:typeof LitElement) => {
15
- if(customElements.get(elementName)) return;
16
-
17
- return customElement(elementName)(elementClass);
18
- }
19
- }
20
-
21
- @defineCustomElement('pie-button')
12
+ @customElement('pie-button')
22
13
  export class PieButton extends LitElement {
23
14
  @property()
24
15
  @validPropertyValues(Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)