@justeattakeaway/pie-button 0.5.1 → 0.6.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,7 +1,7 @@
1
- @justeattakeaway/pie-button:build: cache hit, replaying output c2fea04222d5810e
1
+ @justeattakeaway/pie-button:build: cache hit, replaying output 95e9489059d5a6b7
2
2
  @justeattakeaway/pie-button:build: vite v4.0.4 building for production...
3
3
  @justeattakeaway/pie-button:build: transforming...
4
4
  @justeattakeaway/pie-button:build: ✓ 4 modules transformed.
5
5
  @justeattakeaway/pie-button:build: rendering chunks...
6
6
  @justeattakeaway/pie-button:build: computing gzip size...
7
- @justeattakeaway/pie-button:build: dist/pie-button.js 2.73 kB │ gzip: 1.29 kB
7
+ @justeattakeaway/pie-button:build: dist/pie-button.js 3.52 kB │ gzip: 1.49 kB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Added] - state styling to button (focus/hover/active/disabled) ([#234](https://github.com/justeattakeaway/pie/pull/234)) by [@raoufswe](https://github.com/raoufswe)
8
+
3
9
  ## 0.5.1
4
10
 
5
11
  ### Patch Changes
@@ -1,65 +1,70 @@
1
- import { unsafeCSS as d, LitElement as m, html as h } from "lit";
2
- import { classMap as x } from "lit/directives/class-map.js";
3
- import { property as b, customElement as g } from "lit/decorators.js";
4
- const v = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;font-weight:700}.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--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--outline{border:1px solid #dbd9d7;background-color:#fff;color:#303d3f}.o-btn--ghost{background-color:#fff;color:#242e30}
5
- `, f = (t, r) => function(e, n) {
6
- const o = `_${n}`;
7
- Object.defineProperty(e, n, {
1
+ import { unsafeCSS as f, LitElement as g, html as h } from "lit";
2
+ import { classMap as m } from "lit/directives/class-map.js";
3
+ import { property as p, 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
+ `, u = (o, r) => function(t, n) {
6
+ const e = `_${n}`;
7
+ Object.defineProperty(t, n, {
8
8
  get() {
9
- return e[o];
9
+ return t[e];
10
10
  },
11
11
  set(i) {
12
- const p = e[o];
13
- t.includes(i) ? e[o] = i : (console.error(
12
+ const l = t[e];
13
+ o.includes(i) ? t[e] = i : (console.error(
14
14
  `[pie-button] Invalid value "${i}" provided for property "${n}".`,
15
- `Must be one of: ${t.join(" | ")}.`,
15
+ `Must be one of: ${o.join(" | ")}.`,
16
16
  `Falling back to default value: "${r}"`
17
- ), e[o] = r), this.requestUpdate(n, p);
17
+ ), t[e] = r), this.requestUpdate(n, l);
18
18
  }
19
19
  });
20
20
  };
21
- var l = /* @__PURE__ */ ((t) => (t.XSMALL = "xsmall", t.SMALL = "small", t.MEDIUM = "medium", t.LARGE = "large", t))(l || {}), a = /* @__PURE__ */ ((t) => (t.SUBMIT = "submit", t.BUTTON = "button", t.RESET = "reset", t.MENU = "menu", t))(a || {}), u = /* @__PURE__ */ ((t) => (t.PRIMARY = "primary", t.SECONDARY = "secondary", t.OUTLINE = "outline", t.GHOST = "ghost", t))(u || {}), M = Object.defineProperty, y = Object.getOwnPropertyDescriptor, c = (t, r, e, n) => {
22
- for (var o = n > 1 ? void 0 : n ? y(r, e) : r, i = t.length - 1, p; i >= 0; i--)
23
- (p = t[i]) && (o = (n ? p(r, e, o) : p(o)) || o);
24
- return n && o && M(r, e, o), o;
21
+ var c = /* @__PURE__ */ ((o) => (o.XSMALL = "xsmall", o.SMALL = "small", o.MEDIUM = "medium", o.LARGE = "large", o))(c || {}), b = /* @__PURE__ */ ((o) => (o.SUBMIT = "submit", o.BUTTON = "button", o.RESET = "reset", o.MENU = "menu", o))(b || {}), d = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.OUTLINE = "outline", o.GHOST = "ghost", o))(d || {}), y = Object.defineProperty, M = Object.getOwnPropertyDescriptor, a = (o, r, t, n) => {
22
+ for (var e = n > 1 ? void 0 : n ? M(r, t) : r, i = o.length - 1, l; i >= 0; i--)
23
+ (l = o[i]) && (e = (n ? l(r, t, e) : l(e)) || e);
24
+ return n && e && y(r, t, e), e;
25
25
  };
26
- let s = class extends m {
26
+ let s = class extends g {
27
27
  constructor() {
28
- super(...arguments), this.size = l.MEDIUM, this.type = a.SUBMIT, this.variant = u.PRIMARY;
28
+ super(...arguments), this.size = c.MEDIUM, this.type = b.SUBMIT, this.variant = d.PRIMARY, this.disabled = !1;
29
29
  }
30
30
  render() {
31
- const { size: t, type: r, variant: e } = this, n = {
31
+ const { size: o, type: r, variant: t, disabled: n } = this, e = {
32
32
  "o-btn": !0,
33
+ [`o-btn--${o}`]: o,
33
34
  [`o-btn--${t}`]: t,
34
- [`o-btn--${e}`]: e
35
+ "o-btn--is-disabled": n
35
36
  };
36
37
  return h`
37
38
  <button
38
- class=${x(n)}
39
- type=${r}>
39
+ class=${m(e)}
40
+ type=${r}
41
+ ?disabled=${n}>
40
42
  I'm a PIE button
41
43
  </button>`;
42
44
  }
43
45
  };
44
- s.styles = d(v);
45
- c([
46
- b(),
47
- f(Object.values(l), l.MEDIUM)
46
+ s.styles = f(x);
47
+ a([
48
+ p(),
49
+ u(Object.values(c), c.MEDIUM)
48
50
  ], s.prototype, "size", 2);
49
- c([
50
- b(),
51
- f(Object.values(a), a.SUBMIT)
51
+ a([
52
+ p(),
53
+ u(Object.values(b), b.SUBMIT)
52
54
  ], s.prototype, "type", 2);
53
- c([
54
- b(),
55
- f(Object.values(u), u.PRIMARY)
55
+ a([
56
+ p(),
57
+ u(Object.values(d), d.PRIMARY)
56
58
  ], s.prototype, "variant", 2);
57
- s = c([
58
- g("pie-button")
59
+ a([
60
+ p()
61
+ ], s.prototype, "disabled", 2);
62
+ s = a([
63
+ v("pie-button")
59
64
  ], s);
60
65
  export {
61
- l as BUTTON_SIZE,
62
- a as BUTTON_TYPE,
63
- u as BUTTON_VARIANT,
66
+ c as BUTTON_SIZE,
67
+ b as BUTTON_TYPE,
68
+ d as BUTTON_VARIANT,
64
69
  s as PieButton
65
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/pie-button.js",
package/src/button.scss CHANGED
@@ -5,6 +5,14 @@
5
5
  border: none;
6
6
  font-family: dt.$font-interactive-m-family;
7
7
  font-weight: dt.$font-interactive-m-weight;
8
+
9
+ cursor: pointer;
10
+ user-select: none;
11
+ outline: none;
12
+
13
+ &:focus-visible {
14
+ outline: 2px solid dt.$color-focus;
15
+ }
8
16
  }
9
17
 
10
18
  .o-btn--xsmall {
@@ -38,20 +46,65 @@
38
46
  .o-btn--primary {
39
47
  background-color: dt.$color-interactive-brand;
40
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
+ }
41
57
  }
42
58
 
43
59
  .o-btn--secondary {
44
60
  background-color: dt.$color-interactive-secondary;
45
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
+ }
46
70
  }
47
71
 
48
72
  .o-btn--outline {
49
- border: 1px solid dt.$color-border-strong;
73
+ outline: 1px solid dt.$color-border-strong;
50
74
  background-color: dt.$color-container-default;
51
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
+ }
52
84
  }
53
85
 
54
86
  .o-btn--ghost {
55
87
  background-color: dt.$color-container-default;
56
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
+ }
57
97
  }
98
+
99
+ .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;
103
+
104
+ cursor: default;
105
+
106
+ &.o-btn--ghost {
107
+ background-color: dt.$color-container-default;
108
+ outline: none;
109
+ }
110
+ }
package/src/index.ts CHANGED
@@ -23,23 +23,28 @@ export class PieButton extends LitElement {
23
23
  @validPropertyValues(Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
24
24
  variant : BUTTON_VARIANT = BUTTON_VARIANT.PRIMARY;
25
25
 
26
+ @property()
27
+ disabled : boolean = false;
28
+
26
29
  render () {
27
- const { size, type, variant } = this;
30
+ const { size, type, variant, disabled } = this;
28
31
 
29
32
  const classes = {
30
33
  'o-btn': true,
31
34
  [`o-btn--${size}`]: size,
32
- [`o-btn--${variant}`]: variant
35
+ [`o-btn--${variant}`]: variant,
36
+ 'o-btn--is-disabled': disabled,
33
37
  };
34
38
 
35
39
  return html`
36
40
  <button
37
41
  class=${classMap(classes)}
38
- type=${type}>
42
+ type=${type}
43
+ ?disabled=${disabled}>
39
44
  I'm a PIE button
40
45
  </button>`;
41
46
  }
42
47
 
43
48
  // Renders a `CSSResult` generated from SCSS by Vite
44
49
  static styles = unsafeCSS(styles);
45
- }
50
+ }