@justeattakeaway/pie-button 0.6.0 → 0.7.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,6 @@
1
- @justeattakeaway/pie-button:build: cache hit, replaying output 95e9489059d5a6b7
2
- @justeattakeaway/pie-button:build: vite v4.0.4 building for production...
3
- @justeattakeaway/pie-button:build: transforming...
4
- @justeattakeaway/pie-button:build: ✓ 4 modules transformed.
5
- @justeattakeaway/pie-button:build: rendering chunks...
6
- @justeattakeaway/pie-button:build: computing gzip size...
7
- @justeattakeaway/pie-button:build: dist/pie-button.js 3.52 kB │ gzip: 1.49 kB
1
+ vite v4.0.4 building for production...
2
+ transforming...
3
+ ✓ 4 modules transformed.
4
+ rendering chunks...
5
+ computing gzip size...
6
+ dist/pie-button.js 3.69 kB │ gzip: 1.55 kB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Updated] button to handle custom events ([#309](https://github.com/justeattakeaway/pie/pull/309)) by [@FayeCarter](https://github.com/FayeCarter)
8
+
9
+ ### Patch Changes
10
+
11
+ - Add missing Volta settings to package.json ([#322](https://github.com/justeattakeaway/pie/pull/322)) by [@fernandofranca](https://github.com/fernandofranca)
12
+
13
+ ## 0.6.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [Added] `watch` script in `package.json` ([#233](https://github.com/justeattakeaway/pie/pull/233)) by [@LTurns](https://github.com/LTurns)
18
+
19
+ [Added] README content for `yarn watch` script
20
+
3
21
  ## 0.6.0
4
22
 
5
23
  ### Minor Changes
package/README.md CHANGED
@@ -15,6 +15,11 @@ cd packages/components/pie-button
15
15
  yarn build
16
16
  ```
17
17
 
18
+ compile using Vite (auto-compiles `dist` on save)
19
+ ```
20
+ yarn watch
21
+ ```
22
+
18
23
  Local dev server using Vite (with hot module reloading)
19
24
  ```
20
25
  yarn dev
@@ -1,70 +1,74 @@
1
- import { unsafeCSS as f, LitElement as g, html as h } from "lit";
1
+ import { unsafeCSS as f, LitElement as h, html as g } from "lit";
2
2
  import { classMap as m } from "lit/directives/class-map.js";
3
3
  import { property as p, customElement as v } from "lit/decorators.js";
4
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, {
5
+ `, u = (o, n) => function(i, t) {
6
+ const e = `#${t}`;
7
+ Object.defineProperty(i, t, {
8
8
  get() {
9
- return t[e];
9
+ return this[e];
10
10
  },
11
- set(i) {
12
- const l = t[e];
13
- o.includes(i) ? t[e] = i : (console.error(
14
- `[pie-button] Invalid value "${i}" provided for property "${n}".`,
11
+ set(r) {
12
+ const s = this[e];
13
+ o.includes(r) ? this[e] = r : (console.error(
14
+ `[pie-button] Invalid value "${r}" provided for property "${t}".`,
15
15
  `Must be one of: ${o.join(" | ")}.`,
16
- `Falling back to default value: "${r}"`
17
- ), t[e] = r), this.requestUpdate(n, l);
16
+ `Falling back to default value: "${n}"`
17
+ ), this[e] = n), this.requestUpdate(t, s);
18
18
  }
19
19
  });
20
20
  };
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;
21
+ var c = /* @__PURE__ */ ((o) => (o.XSMALL = "xsmall", o.SMALL = "small", o.MEDIUM = "medium", o.LARGE = "large", o))(c || {}), 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, M = Object.getOwnPropertyDescriptor, a = (o, n, i, t) => {
22
+ for (var e = t > 1 ? void 0 : t ? M(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
- let s = class extends g {
26
+ let l = class extends h {
27
27
  constructor() {
28
- super(...arguments), this.size = c.MEDIUM, this.type = b.SUBMIT, this.variant = d.PRIMARY, this.disabled = !1;
28
+ super(...arguments), this.size = c.MEDIUM, this.type = d.SUBMIT, this.variant = b.PRIMARY, this.disabled = !1;
29
29
  }
30
30
  render() {
31
- const { size: o, type: r, variant: t, disabled: n } = this, e = {
31
+ const { size: o, type: n, variant: i, disabled: t } = this, e = {
32
32
  "o-btn": !0,
33
33
  [`o-btn--${o}`]: o,
34
- [`o-btn--${t}`]: t,
35
- "o-btn--is-disabled": n
34
+ [`o-btn--${i}`]: i,
35
+ "o-btn--is-disabled": t
36
+ }, r = () => {
37
+ const s = new Event("CustomEvent");
38
+ console.info("WC event dispatched"), this.dispatchEvent(s);
36
39
  };
37
- return h`
40
+ return g`
38
41
  <button
39
42
  class=${m(e)}
40
- type=${r}
41
- ?disabled=${n}>
43
+ type=${n}
44
+ ?disabled=${t}
45
+ @click="${r}">
42
46
  I'm a PIE button
43
47
  </button>`;
44
48
  }
45
49
  };
46
- s.styles = f(x);
50
+ l.styles = f(x);
47
51
  a([
48
52
  p(),
49
53
  u(Object.values(c), c.MEDIUM)
50
- ], s.prototype, "size", 2);
54
+ ], l.prototype, "size", 2);
51
55
  a([
52
56
  p(),
53
- u(Object.values(b), b.SUBMIT)
54
- ], s.prototype, "type", 2);
57
+ u(Object.values(d), d.SUBMIT)
58
+ ], l.prototype, "type", 2);
55
59
  a([
56
60
  p(),
57
- u(Object.values(d), d.PRIMARY)
58
- ], s.prototype, "variant", 2);
61
+ u(Object.values(b), b.PRIMARY)
62
+ ], l.prototype, "variant", 2);
59
63
  a([
60
64
  p()
61
- ], s.prototype, "disabled", 2);
62
- s = a([
65
+ ], l.prototype, "disabled", 2);
66
+ l = a([
63
67
  v("pie-button")
64
- ], s);
68
+ ], l);
65
69
  export {
66
70
  c as BUTTON_SIZE,
67
- b as BUTTON_TYPE,
68
- d as BUTTON_VARIANT,
69
- s as PieButton
71
+ d as BUTTON_TYPE,
72
+ b as BUTTON_VARIANT,
73
+ l as PieButton
70
74
  };
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/pie-button.js",
7
7
  "scripts": {
8
- "build": "npx tsc && run -T vite build",
8
+ "build": "run -T vite build",
9
+ "watch": "run -T vite build --watch",
9
10
  "dev": "run -T vite",
10
11
  "test": "echo \"Error: no test specified\" && exit 1"
11
12
  },
12
13
  "author": "JustEatTakeaway - Design System Web Team",
13
- "license": "Apache-2.0"
14
+ "license": "Apache-2.0",
15
+ "volta": {
16
+ "extends": "../../../package.json"
17
+ }
14
18
  }
package/src/decorators.ts CHANGED
@@ -7,14 +7,14 @@
7
7
  */
8
8
  export const validPropertyValues = (validValues: any[], defaultValue: any) => {
9
9
  return function (target: any, propertyKey: string) : void {
10
- const privatePropertyKey = `_${propertyKey}`;
10
+ const privatePropertyKey = `#${propertyKey}`;
11
11
 
12
12
  Object.defineProperty(target, propertyKey, {
13
13
  get () : any {
14
- return target[privatePropertyKey];
14
+ return this[privatePropertyKey];
15
15
  },
16
16
  set (value: any) : void {
17
- const oldValue = target[privatePropertyKey];
17
+ const oldValue = this[privatePropertyKey];
18
18
 
19
19
  if (!validValues.includes(value)) {
20
20
  console.error(
@@ -22,9 +22,9 @@ export const validPropertyValues = (validValues: any[], defaultValue: any) => {
22
22
  `Must be one of: ${validValues.join(' | ')}.`,
23
23
  `Falling back to default value: "${defaultValue}"`
24
24
  );
25
- target[privatePropertyKey] = defaultValue;
25
+ this[privatePropertyKey] = defaultValue;
26
26
  } else {
27
- target[privatePropertyKey] = value;
27
+ this[privatePropertyKey] = value;
28
28
  }
29
29
 
30
30
  this.requestUpdate(propertyKey, oldValue);
package/src/index.ts CHANGED
@@ -36,15 +36,22 @@ export class PieButton extends LitElement {
36
36
  'o-btn--is-disabled': disabled,
37
37
  };
38
38
 
39
+ const raiseWCEvent = () => {
40
+ const event = new Event('CustomEvent')
41
+ console.info('WC event dispatched')
42
+ this.dispatchEvent(event)
43
+ }
44
+
39
45
  return html`
40
46
  <button
41
47
  class=${classMap(classes)}
42
48
  type=${type}
43
- ?disabled=${disabled}>
49
+ ?disabled=${disabled}
50
+ @click="${raiseWCEvent}">
44
51
  I'm a PIE button
45
52
  </button>`;
46
53
  }
47
54
 
48
55
  // Renders a `CSSResult` generated from SCSS by Vite
49
56
  static styles = unsafeCSS(styles);
50
- }
57
+ }