@justeattakeaway/pie-icon-button 0.8.0 → 0.10.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,14 +1,14 @@
1
- [13:51:03] @custom-elements-manifest/analyzer: Created new manifest.
1
+ [12:18:20 PM] @custom-elements-manifest/analyzer: Created new manifest.
2
2
  react wrapper has been added!
3
3
  vite v4.3.9 building for production...
4
4
  transforming...
5
- ✓ 886 modules transformed.
5
+ ✓ 22 modules transformed.
6
6
  rendering chunks...
7
7
  computing gzip size...
8
- dist/index.js  8.63 kB │ gzip: 2.50 kB
8
+ dist/index.js  6.06 kB │ gzip: 1.52 kB
9
9
  dist/react.js 59.03 kB │ gzip: 15.92 kB
10
-
11
- [vite:dts] Start generate declaration files...
12
- ✓ built in 5.30s
13
- [vite:dts] Declaration files built in 3770ms.
14
-
10
+ 
11
+ [vite:dts] Start generate declaration files...
12
+ ✓ built in 15.39s
13
+ [vite:dts] Declaration files built in 14191ms.
14
+ 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @justeattakeaway/pie-icon-button
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Changed] - expose icon-button size css variables for consumers ([#627](https://github.com/justeattakeaway/pie/pull/627)) by [@jamieomaguire](https://github.com/jamieomaguire)
8
+
9
+ ## 0.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [Changed] - Added slot info the the readme and peerDep added ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
14
+
15
+ - [Changed] - Ensure component implements it's props interface ([#611](https://github.com/justeattakeaway/pie/pull/611)) by [@jamieomaguire](https://github.com/jamieomaguire)
16
+
17
+ - [Fixed] - Added IconClose to Visual tests and modal ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
18
+
19
+ - [Added] - Slot added to pie-icon-button ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
20
+
3
21
  ## 0.8.0
4
22
 
5
23
  ### Minor Changes
package/README.md CHANGED
@@ -65,6 +65,31 @@ import { PieIconButton } from '@justeattakeaway/pie-icon-button';
65
65
  import { PieIconButton } from '@justeattakeaway/pie-icon-button/dist/react';
66
66
  ```
67
67
 
68
+ ## Importing Icons
69
+
70
+ We recommend using the `pie-icon-button` component alongside the `pie-icons-webc` package. This package contains all of the PIE iconset as importable web components and are built to work alongside our other PIE components.
71
+
72
+ `pie-icon-button` provides a slot into which you can pass your chosen icon, and it will automatically size it to the correct dimensions depending on the `size` of the `pie-icon-button` component.
73
+
74
+ ### Importing an icon with `pie-icons-webc`
75
+
76
+ To import an icon using `pie-icons-webc`, you should import the icon that you would like to use alongside the `pie-icon-button` component:
77
+
78
+ ```js
79
+ import { PieIconButton } from '@justeattakeaway/pie-icon-button';
80
+ import '@justeattakeaway/pie-icons-webc/icons/IconClose';
81
+ ```
82
+
83
+ Then, in your markup, you would implement the component like this:
84
+
85
+ ```html
86
+ <pie-icon-button><icon-close /></pie-icon-button>
87
+ ```
88
+
89
+ > **Warning**
90
+ > Usually, icons imported from `pie-icons-webc` can be resized by specifying the `size` prop (such as `<icon-close size="xl" />`).
91
+ > These size props will have no effect when used alongside the `pie-icon-button` component, as the icon is resized with respect to the size of the `pie-icon-button`.
92
+
68
93
 
69
94
  ## Props
70
95
 
@@ -74,14 +99,14 @@ import { PieIconButton } from '@justeattakeaway/pie-icon-button/dist/react';
74
99
  | variant | `String` | `primary` | Variant of the button, one of `variants` – `primary`, `secondary`, `outline`, `ghost`, `ghost-secondary` |
75
100
  | disabled | `Boolean` | `false` | If `true`, disables the button. |
76
101
 
77
- In your markup or JSX, you can then use these to set the properties for the `pie-icon-button` component:
102
+ In your HTML markup or JSX, you can then use these to set the properties for the `pie-icon-button` component, like so:
78
103
 
79
104
  ```html
80
105
  <!-- Native HTML -->
81
- <pie-icon-button size='medium' type='button' variant='primary'>Click me!</pie-icon-button>
106
+ <pie-icon-button size='small' type='button' variant='secondary'><icon-close /></pie-icon-button>
82
107
 
83
108
  <!-- JSX -->
84
- <PieIconButton size='medium' type='button' variant='primary'>Click me!</PieIconButton>
109
+ <PieIconButton size='small' type='button' variant='secondary'><icon-close /></PieIconButton>
85
110
  ```
86
111
 
87
112
  ## Events
@@ -95,21 +120,21 @@ For example, to add a click handler in various templates:
95
120
 
96
121
  ```html
97
122
  <!-- Other attributes omitted for clarity -->
98
- <pie-icon-button onclick="e => console.log(e)">Click me!</pie-icon-button>
123
+ <pie-icon-button onclick="e => console.log(e)"><icon-close /></pie-icon-button>
99
124
  ```
100
125
 
101
126
  ### Vue templates (using Nuxt 3)
102
127
 
103
128
  ```html
104
129
  <!-- Other attributes omitted for clarity -->
105
- <pie-icon-button @click="handleClick">Click me!</pie-icon-button>
130
+ <pie-icon-button @click="handleClick"><icon-close /></pie-icon-button>
106
131
  ```
107
132
 
108
133
  ### React templates (using Next 13)
109
134
 
110
135
  ```html
111
136
  <!-- Other attributes omitted for clarity -->
112
- <PieIconButton onClick={handleClick}>increment</PieIconButton>
137
+ <PieIconButton onClick={handleClick}><icon-close /></PieIconButton>
113
138
 
114
139
  ```
115
140
 
package/dist/index.js CHANGED
@@ -1,138 +1,64 @@
1
- import { unsafeCSS as I, LitElement as x, html as S } from "lit";
2
- import { property as v } from "lit/decorators.js";
1
+ import { unsafeCSS as h, LitElement as f, html as p } from "lit";
2
+ import { property as d } from "lit/decorators.js";
3
3
  import "lit/decorators/property.js";
4
- const g = (t, o, e) => function(n, r) {
5
- const i = `#${r}`;
6
- Object.defineProperty(n, r, {
4
+ const b = (i, o, n) => function(t, r) {
5
+ const a = `#${r}`;
6
+ Object.defineProperty(t, r, {
7
7
  get() {
8
- return this[i];
8
+ return this[a];
9
9
  },
10
- set(c) {
11
- const z = this[i];
12
- o.includes(c) ? this[i] = c : (console.error(
13
- `<${t}> Invalid value "${c}" provided for property "${r}".`,
10
+ set(l) {
11
+ const u = this[a];
12
+ o.includes(l) ? this[a] = l : (console.error(
13
+ `<${i}> Invalid value "${l}" provided for property "${r}".`,
14
14
  `Must be one of: ${o.join(" | ")}.`,
15
- `Falling back to default value: "${e}"`
16
- ), this[i] = e), this.requestUpdate(r, z);
15
+ `Falling back to default value: "${n}"`
16
+ ), this[a] = n), this.requestUpdate(r, u);
17
17
  }
18
18
  });
19
- }, s = {
20
- xs: 16,
21
- s: 20,
22
- m: 24,
23
- l: 28,
24
- xl: 32,
25
- xxl: 40
26
- }, p = Object.keys(s), f = "xs", m = 8, d = 32;
27
- function L(t, o, e) {
28
- const a = parseInt(t, 10), n = a % e === 0;
29
- return a >= o && n;
30
- }
31
- const B = {
32
- large: (t) => L(t, d, m),
33
- regular: (t) => p.includes(t)
34
- };
35
- function w(t) {
36
- const o = B.large(t);
37
- return { isValid: o, size: o ? t : d };
38
- }
39
- function $(t) {
40
- const o = B.regular(t), e = o ? s[t] : s[f];
41
- return { isValid: o, size: e };
42
- }
43
- const h = (t, o, e, a) => {
44
- const n = t.endsWith("Large") || t.endsWith("-large");
45
- let r, i;
46
- if (e) {
47
- if ({ isValid: r, size: i } = n ? w(e) : $(e), !r) {
48
- const c = n ? `Invalid prop "size" value supplied to "${a}". The prop value should be a number equal or greater than ${d} and multiple of ${m}.` : `Invalid prop "size" value supplied to "${a}". The prop value should be one of the following values: ${p.join(", ")}.`;
49
- console.error(c);
50
- }
51
- } else
52
- i = n ? d : s[f];
53
- return {
54
- class: [t, o].filter(Boolean).join(" "),
55
- width: i,
56
- height: i
57
- };
58
- }, y = document.createElement("template");
59
- y.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" fill="currentColor" viewBox="0 0 32 32" class="c-pieIcon c-pieIcon--closeLarge"><path d="m23.42 24.663 1.242-1.243L17.234 16l7.428-7.429-1.242-1.233L16 14.766 8.57 7.338 7.337 8.57 14.767 16l-7.43 7.42 1.234 1.242L16 17.235l7.42 7.428Z"></path></svg>';
60
- class k extends HTMLElement {
61
- constructor() {
62
- super();
63
- const o = y.content.cloneNode(!0);
64
- this.root = this.attachShadow({ mode: "open" }), this.root.append(o);
65
- }
66
- static get observedAttributes() {
67
- return ["size"];
68
- }
69
- get size() {
70
- return this.getAttribute("size");
71
- }
72
- set size(o) {
73
- this.setAttribute("size", o);
74
- }
75
- get class() {
76
- return this.getAttribute("class");
77
- }
78
- set class(o) {
79
- this.setAttribute("class", o);
80
- }
81
- connectedCallback() {
82
- const o = this.root.querySelector("svg"), e = h("c-pieIcon c-pieIcon--closeLarge", "", null, "IconCloseLarge");
83
- o.setAttribute("width", e.width), o.setAttribute("height", e.height), this.setAttribute("class", "c-pieIcon c-pieIcon--closeLarge"), this.root.append(o);
84
- }
85
- attributeChangedCallback(o, e, a) {
86
- const n = this.root.querySelector("svg");
87
- let r;
88
- o === "size" && (r = h("c-pieIcon c-pieIcon--closeLarge", "", a, "IconCloseLarge"), n.setAttribute("width", r.width), n.setAttribute("height", r.height), this.root.append(n));
89
- }
90
- }
91
- customElements.define("icon-close-large", k);
92
- const A = `.o-iconBtn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-dimension: 48px;--btn-bg-color: var(--dt-color-interactive-brand);--btn-icon-fill: var(--dt-color-content-interactive-primary);--btn-focus: var(--dt-color-focus-outer);--btn-icon-size: 24px;min-block-size:var(--btn-dimension);aspect-ratio:1/1;border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}@supports not (aspect-ratio: 1/1){.o-iconBtn{min-inline-size:var(--btn-dimension)}}.o-iconBtn:focus-visible{outline:2px solid var(--btn-focus)}.o-iconBtn svg{height:var(--btn-icon-size);width:var(--btn-icon-size)}.o-iconBtn svg,.o-iconBtn path{fill:var(--btn-icon-fill)}.o-iconBtn[variant=primary]:hover:not(:disabled){background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=primary]:active:not(:disabled){background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-icon-fill: var(--dt-color-content-interactive-secondary)}.o-iconBtn[variant=secondary]:hover:not(:disabled){background-color:hsl(var(--dt-color-interactive-secondary-h),var(--dt-color-interactive-secondary-s),calc(var(--dt-color-interactive-secondary-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=secondary]:active:not(:disabled){background-color:hsl(var(--dt-color-interactive-secondary-h),var(--dt-color-interactive-secondary-s),calc(var(--dt-color-interactive-secondary-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=outline]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-brand)}.o-iconBtn[variant=outline] .o-iconBtn{border:1px solid var(--dt-color-border-strong)}.o-iconBtn[variant=outline]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=outline]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=ghost]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-brand)}.o-iconBtn[variant=ghost]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=ghost]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=ghost-secondary]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-secondary)}.o-iconBtn[variant=ghost-secondary]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=ghost-secondary]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[disabled]{--btn-bg-color: var(--dt-color-disabled-01);--btn-icon-fill: var(--dt-color-content-disabled)}.o-iconBtn[disabled] .o-iconBtn{border:1px solid var(--dt-color-disabled-01);cursor:not-allowed}.o-iconBtn[disabled][variant=outline] .o-iconBtn{outline:none}.o-iconBtn[disabled][variant=ghost],.o-iconBtn[disabled][variant=ghost-secondary]{--btn-bg-color: transparent;--btn-icon-fill: var(--dt-color-content-default)}.o-iconBtn[disabled][variant=ghost] .o-iconBtn,.o-iconBtn[disabled][variant=ghost-secondary] .o-iconBtn{outline:none;border:none}.o-iconBtn[size=xsmall]{--btn-dimension: 32px}.o-iconBtn[size=small]{--btn-dimension: 40px}.o-iconBtn[size=large]{--btn-dimension: 56px;--btn-icon-size: 28px}
93
- `, P = ["xsmall", "small", "medium", "large"], j = ["primary", "secondary", "outline", "ghost", "ghost-secondary"];
94
- var C = Object.defineProperty, M = Object.getOwnPropertyDescriptor, u = (t, o, e, a) => {
95
- for (var n = a > 1 ? void 0 : a ? M(o, e) : o, r = t.length - 1, i; r >= 0; r--)
96
- (i = t[r]) && (n = (a ? i(o, e, n) : i(n)) || n);
97
- return a && n && C(o, e, n), n;
19
+ }, g = `:host{--btn-dimension: 48px;--btn-icon-size: 24px}.o-iconBtn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-bg-color: var(--dt-color-interactive-brand);--btn-icon-fill: var(--dt-color-content-interactive-primary);--btn-focus: var(--dt-color-focus-outer);min-block-size:var(--btn-dimension);aspect-ratio:1/1;border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);color:var(--btn-icon-fill);cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}@supports not (aspect-ratio: 1/1){.o-iconBtn{min-inline-size:var(--btn-dimension)}}.o-iconBtn:focus-visible{outline:2px solid var(--btn-focus)}.o-iconBtn svg{height:var(--btn-icon-size);width:var(--btn-icon-size)}.o-iconBtn[variant=primary]:hover:not(:disabled){background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=primary]:active:not(:disabled){background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-icon-fill: var(--dt-color-content-interactive-secondary)}.o-iconBtn[variant=secondary]:hover:not(:disabled){background-color:hsl(var(--dt-color-interactive-secondary-h),var(--dt-color-interactive-secondary-s),calc(var(--dt-color-interactive-secondary-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=secondary]:active:not(:disabled){background-color:hsl(var(--dt-color-interactive-secondary-h),var(--dt-color-interactive-secondary-s),calc(var(--dt-color-interactive-secondary-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=outline]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-brand)}.o-iconBtn[variant=outline] .o-iconBtn{border:1px solid var(--dt-color-border-strong)}.o-iconBtn[variant=outline]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=outline]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=ghost]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-brand)}.o-iconBtn[variant=ghost]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=ghost]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[variant=ghost-secondary]{--btn-bg-color: var(--dt-color-container-default);--btn-icon-fill: var(--dt-color-content-interactive-secondary)}.o-iconBtn[variant=ghost-secondary]:hover:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-hover-01)))}.o-iconBtn[variant=ghost-secondary]:active:not(:disabled){background-color:hsl(var(--dt-color-container-default-h),var(--dt-color-container-default-s),calc(var(--dt-color-container-default-l) - var(--dt-color-active-01)))}.o-iconBtn[disabled]{--btn-bg-color: var(--dt-color-disabled-01) !important;--btn-icon-fill: var(--dt-color-content-disabled) !important}.o-iconBtn[disabled] .o-iconBtn{border:1px solid var(--dt-color-disabled-01);cursor:not-allowed}.o-iconBtn[disabled][variant=outline] .o-iconBtn{outline:none}.o-iconBtn[disabled][variant=ghost],.o-iconBtn[disabled][variant=ghost-secondary]{--btn-bg-color: transparent;--btn-icon-fill: var(--dt-color-content-default)}.o-iconBtn[disabled][variant=ghost] .o-iconBtn,.o-iconBtn[disabled][variant=ghost-secondary] .o-iconBtn{outline:none;border:none}.o-iconBtn[size=xsmall]{--btn-dimension: 32px}.o-iconBtn[size=small]{--btn-dimension: 40px}.o-iconBtn[size=large]{--btn-dimension: 56px;--btn-icon-size: 28px}
20
+ `, m = ["xsmall", "small", "medium", "large"], B = ["primary", "secondary", "outline", "ghost", "ghost-secondary"];
21
+ var y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, s = (i, o, n, e) => {
22
+ for (var t = e > 1 ? void 0 : e ? x(o, n) : o, r = i.length - 1, a; r >= 0; r--)
23
+ (a = i[r]) && (t = (e ? a(o, n, t) : a(t)) || t);
24
+ return e && t && y(o, n, t), t;
98
25
  };
99
- const b = "pie-icon-button";
100
- class l extends x {
26
+ const v = "pie-icon-button";
27
+ class c extends f {
101
28
  constructor() {
102
29
  super(...arguments), this.size = "medium", this.variant = "primary", this.disabled = !1;
103
30
  }
104
31
  render() {
105
32
  const {
106
33
  disabled: o,
107
- size: e,
108
- variant: a
34
+ size: n,
35
+ variant: e
109
36
  } = this;
110
- return S`
37
+ return p`
111
38
  <button
112
39
  class="o-iconBtn"
113
- size=${e}
114
- variant=${a}
40
+ size=${n}
41
+ variant=${e}
115
42
  ?disabled=${o}>
116
- <icon-close-large />
43
+ <slot></slot>
117
44
  </button>`;
118
45
  }
119
46
  }
120
- l.styles = I(A);
121
- u([
122
- v(),
123
- g(b, P, "medium")
124
- ], l.prototype, "size", 2);
125
- u([
126
- v(),
127
- g(b, j, "primary")
128
- ], l.prototype, "variant", 2);
129
- u([
130
- v({ type: Boolean })
131
- ], l.prototype, "disabled", 2);
132
- customElements.define(b, l);
47
+ c.styles = h(g);
48
+ s([
49
+ d(),
50
+ b(v, m, "medium")
51
+ ], c.prototype, "size", 2);
52
+ s([
53
+ d(),
54
+ b(v, B, "primary")
55
+ ], c.prototype, "variant", 2);
56
+ s([
57
+ d({ type: Boolean })
58
+ ], c.prototype, "disabled", 2);
59
+ customElements.define(v, c);
133
60
  export {
134
- k as IconCloseLarge,
135
- l as PieIconButton,
136
- P as sizes,
137
- j as variants
61
+ c as PieIconButton,
62
+ m as sizes,
63
+ B as variants
138
64
  };
package/dist/react.js CHANGED
File without changes
File without changes
@@ -1,10 +1,8 @@
1
1
  import { LitElement } from 'lit';
2
- import { IconCloseLarge } from '@justeattakeaway/pie-icons-webc';
3
2
  import { IconButtonProps, sizes, variants } from './defs';
4
3
  export { type IconButtonProps, sizes, variants };
5
- export { IconCloseLarge };
6
4
  declare const componentSelector = "pie-icon-button";
7
- export declare class PieIconButton extends LitElement {
5
+ export declare class PieIconButton extends LitElement implements IconButtonProps {
8
6
  size: IconButtonProps['size'];
9
7
  variant: IconButtonProps['variant'];
10
8
  disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EACH,eAAe,EAAE,KAAK,EAAE,QAAQ,EACnC,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,QAAA,MAAM,iBAAiB,oBAAoB,CAAC;AAE5C,qBAAa,aAAc,SAAQ,UAAU;IAGlC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAY;IAIzC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAa;IAGhD,QAAQ,UAAS;IAExB,MAAM;IAiBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;KACtC;CACJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAKlD,OAAO,EACH,eAAe,EAAE,KAAK,EAAE,QAAQ,EACnC,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAEjD,QAAA,MAAM,iBAAiB,oBAAoB,CAAC;AAE5C,qBAAa,aAAc,SAAQ,UAAW,YAAW,eAAe;IAG7D,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAY;IAIzC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAa;IAGhD,QAAQ,UAAS;IAExB,MAAM;IAiBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;KACtC;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG9D,eAAO,MAAM,aAAa,qEAMxB,CAAC"}
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/react.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,aAAa,qEAMxB,CAAC"}
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-icon-button",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "PIE Design System Icon Button built using Web Components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,10 +16,11 @@
16
16
  "author": "JustEatTakeaway - Design System Web Team",
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
+ "@justeattakeaway/pie-icons-webc": "workspace:*",
19
20
  "@justeattakeaway/pie-webc-core": "workspace:*"
20
21
  },
21
- "dependencies": {
22
- "@justeattakeaway/pie-icons-webc": "workspace:*"
22
+ "peerDependencies": {
23
+ "pie-design-tokens": "5.3.0"
23
24
  },
24
25
  "volta": {
25
26
  "extends": "../../../package.json"
@@ -8,22 +8,24 @@
8
8
  }
9
9
  }
10
10
 
11
+ // Normally we don't expect consumers to override these, but there are situations where it may be necessary
12
+ :host {
13
+ // The base values are set to the size default, which is for the medium button size
14
+ --btn-dimension: 48px;
15
+ // Sizing is set to Medium button icon size, as that is the default
16
+ --btn-icon-size: 24px;
17
+ }
18
+
11
19
  // Base button styles
12
20
  .o-iconBtn {
13
21
  --btn-border-radius: var(--dt-radius-rounded-e);
14
22
 
15
- // The base values are set to the size default, which is for the medium button size
16
- --btn-dimension: 48px;
17
-
18
23
  // The following values set to default background and color
19
24
  // currently this sets the primary button styles
20
25
  --btn-bg-color: var(--dt-color-interactive-brand);
21
26
  --btn-icon-fill: var(--dt-color-content-interactive-primary);
22
27
  --btn-focus: var(--dt-color-focus-outer);
23
28
 
24
- // Sizing is set to Medium button icon size, as that is the default
25
- --btn-icon-size: 24px;
26
-
27
29
  min-block-size: var(--btn-dimension);
28
30
  aspect-ratio: 1 / 1;
29
31
 
@@ -35,6 +37,7 @@
35
37
  border-radius: var(--btn-border-radius);
36
38
  outline: none;
37
39
  background-color: var(--btn-bg-color);
40
+ color: var(--btn-icon-fill);
38
41
  cursor: pointer;
39
42
  user-select: none;
40
43
 
@@ -52,11 +55,6 @@
52
55
  width: var(--btn-icon-size);
53
56
  }
54
57
 
55
- svg,
56
- path {
57
- fill: var(--btn-icon-fill);
58
- }
59
-
60
58
  &[variant='primary'] {
61
59
  @include button-interactive-states('--dt-color-interactive-brand');
62
60
  }
@@ -94,8 +92,8 @@
94
92
  }
95
93
 
96
94
  &[disabled] {
97
- --btn-bg-color: var(--dt-color-disabled-01);
98
- --btn-icon-fill: var(--dt-color-content-disabled);
95
+ --btn-bg-color: var(--dt-color-disabled-01) !important;
96
+ --btn-icon-fill: var(--dt-color-content-disabled) !important;
99
97
 
100
98
  & .o-iconBtn {
101
99
  border: 1px solid var(--dt-color-disabled-01);
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
3
  import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
4
- import { IconCloseLarge } from '@justeattakeaway/pie-icons-webc';
5
4
 
6
5
  import styles from './iconButton.scss?inline';
7
6
  import {
@@ -10,11 +9,10 @@ import {
10
9
 
11
10
  // Valid values available to consumers
12
11
  export { type IconButtonProps, sizes, variants };
13
- export { IconCloseLarge };
14
12
 
15
13
  const componentSelector = 'pie-icon-button';
16
14
 
17
- export class PieIconButton extends LitElement {
15
+ export class PieIconButton extends LitElement implements IconButtonProps {
18
16
  @property()
19
17
  @validPropertyValues(componentSelector, sizes, 'medium')
20
18
  public size: IconButtonProps['size'] = 'medium';
@@ -38,7 +36,7 @@ export class PieIconButton extends LitElement {
38
36
  size=${size}
39
37
  variant=${variant}
40
38
  ?disabled=${disabled}>
41
- <icon-close-large />
39
+ <slot></slot>
42
40
  </button>`;
43
41
  }
44
42
 
@@ -13,6 +13,7 @@ import {
13
13
  WebComponentTestWrapper,
14
14
  } from '@justeattakeaway/pie-webc-testing/src/helpers/components/web-component-test-wrapper/WebComponentTestWrapper.ts';
15
15
  import { PieIconButton } from '@/index';
16
+
16
17
  import { sizes, variants } from '@/defs';
17
18
 
18
19
  const props: PropObject = {
@@ -21,8 +22,14 @@ const props: PropObject = {
21
22
  disabled: [true, false],
22
23
  };
23
24
 
25
+ // TODO: Currently setting the slot to use a straight up SVG
26
+ // This should be updated to use pie-icons-webc, but after some investigation, we think that we'll
27
+ // need to convert the webc icons to use Lit, as currently the components don't work well in a Node env like Playwright
28
+ // Atm, importing them like `import '@justeattakeaway/pie-icons-webc/icons/IconClose.js';` results in an `HTMLElement is not defined` error
29
+ const closeSVG = '<svg xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" fill="currentColor" viewBox="0 0 16 16" class="c-pieIcon c-pieIcon--close"><path d="M11.868 3.205 8 7.072 4.133 3.205l-.928.927L7.073 8l-3.868 3.867.928.928L8 8.927l3.868 3.868.927-.928L8.928 8l3.867-3.868-.927-.927Z"></path></svg>';
30
+
24
31
  // Renders a <pie-icon-button> HTML string with the given prop values
25
- const renderTestPieIconButton = (propVals: WebComponentPropValues) => `<pie-icon-button size="${propVals.size}" variant="${propVals.variant}" ${propVals.disabled ? 'disabled' : ''}></pie-icon-button>`;
32
+ const renderTestPieIconButton = (propVals: WebComponentPropValues) => `<pie-icon-button size="${propVals.size}" variant="${propVals.variant}" ${propVals.disabled ? 'disabled' : ''}>${closeSVG}</pie-icon-button>`;
26
33
 
27
34
  const componentPropsMatrix : WebComponentPropValues[] = getAllPropCombinations(props);
28
35
  const componentPropsMatrixByVariant: Record<string, WebComponentPropValues[]> = splitCombinationsByPropertyValue(componentPropsMatrix, 'variant');