@justeattakeaway/pie-icon-button 0.7.0 → 0.9.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.
- package/.turbo/turbo-build.log +5 -11
- package/CHANGELOG.md +23 -0
- package/README.md +31 -6
- package/declaration.d.ts +2 -0
- package/dist/index.js +42 -116
- package/dist/types/packages/components/pie-icon-button/src/index.d.ts +1 -3
- package/dist/types/packages/components/pie-icon-button/src/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/iconButton.scss +3 -7
- package/src/index.ts +5 -7
- package/test/visual/pie-icon-button.spec.ts +8 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[5:08:03 PM] @custom-elements-manifest/analyzer: Created new manifest.
|
|
2
2
|
react wrapper has been added!
|
|
3
3
|
[36mvite v4.3.9 [32mbuilding for production...[36m[39m
|
|
4
4
|
transforming...
|
|
5
|
-
[32m✓[39m
|
|
5
|
+
[32m✓[39m 22 modules transformed.
|
|
6
6
|
rendering chunks...
|
|
7
7
|
computing gzip size...
|
|
8
|
-
[2mdist/[22m[36mindex.js [39m[1m[2m
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 6.05 kB[22m[1m[22m[2m │ gzip: 1.52 kB[22m
|
|
9
9
|
[2mdist/[22m[36mreact.js [39m[1m[2m59.03 kB[22m[1m[22m[2m │ gzip: 15.92 kB[22m
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[7m4[0m import { IconCloseLarge } from '@justeattakeaway/pie-icons-webc';
|
|
16
|
-
[7m [0m [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[0m
|
|
17
|
-
|
|
18
|
-
[32m✓ built in 23.45s[39m
|
|
19
|
-
[32m[36m[vite:dts][32m Declaration files built in 18363ms.
|
|
12
|
+
[32m✓ built in 10.05s[39m
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 9123ms.
|
|
20
14
|
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @justeattakeaway/pie-icon-button
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [Changed] - Added slot info the the readme and peerDep added ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
8
|
+
|
|
9
|
+
- [Changed] - Ensure component implements it's props interface ([#611](https://github.com/justeattakeaway/pie/pull/611)) by [@jamieomaguire](https://github.com/jamieomaguire)
|
|
10
|
+
|
|
11
|
+
- [Fixed] - Added IconClose to Visual tests and modal ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
12
|
+
|
|
13
|
+
- [Added] - Slot added to pie-icon-button ([#604](https://github.com/justeattakeaway/pie/pull/604)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
14
|
+
|
|
15
|
+
## 0.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [Changed] - Set all component props to public ([#597](https://github.com/justeattakeaway/pie/pull/597)) by [@jamieomaguire](https://github.com/jamieomaguire)
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`816909e55`](https://github.com/justeattakeaway/pie/commit/816909e55f464fd191fa8a54e3407b8fbd0cdc29), [`816909e55`](https://github.com/justeattakeaway/pie/commit/816909e55f464fd191fa8a54e3407b8fbd0cdc29), [`816909e55`](https://github.com/justeattakeaway/pie/commit/816909e55f464fd191fa8a54e3407b8fbd0cdc29)]:
|
|
24
|
+
- @justeattakeaway/pie-icons-webc@0.2.0
|
|
25
|
+
|
|
3
26
|
## 0.7.0
|
|
4
27
|
|
|
5
28
|
### 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='
|
|
106
|
+
<pie-icon-button size='small' type='button' variant='secondary'><icon-close /></pie-icon-button>
|
|
82
107
|
|
|
83
108
|
<!-- JSX -->
|
|
84
|
-
<PieIconButton size='
|
|
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)"
|
|
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"
|
|
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}
|
|
137
|
+
<PieIconButton onClick={handleClick}><icon-close /></PieIconButton>
|
|
113
138
|
|
|
114
139
|
```
|
|
115
140
|
|
package/declaration.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,138 +1,64 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import { property as
|
|
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
|
|
5
|
-
const
|
|
6
|
-
Object.defineProperty(
|
|
4
|
+
const b = (i, o, n) => function(t, r) {
|
|
5
|
+
const a = `#${r}`;
|
|
6
|
+
Object.defineProperty(t, r, {
|
|
7
7
|
get() {
|
|
8
|
-
return this[
|
|
8
|
+
return this[a];
|
|
9
9
|
},
|
|
10
|
-
set(
|
|
11
|
-
const
|
|
12
|
-
o.includes(
|
|
13
|
-
`<${
|
|
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: "${
|
|
16
|
-
), this[
|
|
15
|
+
`Falling back to default value: "${n}"`
|
|
16
|
+
), this[a] = n), this.requestUpdate(r, u);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
}, s = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 = `.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);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
|
|
100
|
-
class
|
|
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:
|
|
108
|
-
variant:
|
|
34
|
+
size: n,
|
|
35
|
+
variant: e
|
|
109
36
|
} = this;
|
|
110
|
-
return
|
|
37
|
+
return p`
|
|
111
38
|
<button
|
|
112
39
|
class="o-iconBtn"
|
|
113
|
-
size=${
|
|
114
|
-
variant=${
|
|
40
|
+
size=${n}
|
|
41
|
+
variant=${e}
|
|
115
42
|
?disabled=${o}>
|
|
116
|
-
<
|
|
43
|
+
<slot></slot>
|
|
117
44
|
</button>`;
|
|
118
45
|
}
|
|
119
46
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
],
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
],
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
],
|
|
132
|
-
customElements.define(
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
j as variants
|
|
61
|
+
c as PieIconButton,
|
|
62
|
+
m as sizes,
|
|
63
|
+
B as variants
|
|
138
64
|
};
|
|
@@ -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;
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-icon-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"pie-design-tokens": "5.3.0"
|
|
23
24
|
},
|
|
24
25
|
"volta": {
|
|
25
26
|
"extends": "../../../package.json"
|
package/src/iconButton.scss
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
border-radius: var(--btn-border-radius);
|
|
36
36
|
outline: none;
|
|
37
37
|
background-color: var(--btn-bg-color);
|
|
38
|
+
color: var(--btn-icon-fill);
|
|
38
39
|
cursor: pointer;
|
|
39
40
|
user-select: none;
|
|
40
41
|
|
|
@@ -52,11 +53,6 @@
|
|
|
52
53
|
width: var(--btn-icon-size);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
svg,
|
|
56
|
-
path {
|
|
57
|
-
fill: var(--btn-icon-fill);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
56
|
&[variant='primary'] {
|
|
61
57
|
@include button-interactive-states('--dt-color-interactive-brand');
|
|
62
58
|
}
|
|
@@ -94,8 +90,8 @@
|
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
&[disabled] {
|
|
97
|
-
--btn-bg-color: var(--dt-color-disabled-01);
|
|
98
|
-
--btn-icon-fill: var(--dt-color-content-disabled);
|
|
93
|
+
--btn-bg-color: var(--dt-color-disabled-01) !important;
|
|
94
|
+
--btn-icon-fill: var(--dt-color-content-disabled) !important;
|
|
99
95
|
|
|
100
96
|
& .o-iconBtn {
|
|
101
97
|
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,21 +9,20 @@ 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';
|
|
21
19
|
|
|
22
20
|
@property()
|
|
23
21
|
@validPropertyValues(componentSelector, variants, 'primary')
|
|
24
|
-
|
|
22
|
+
public variant: IconButtonProps['variant'] = 'primary';
|
|
25
23
|
|
|
26
24
|
@property({ type: Boolean })
|
|
27
|
-
|
|
25
|
+
public disabled = false;
|
|
28
26
|
|
|
29
27
|
render () {
|
|
30
28
|
const {
|
|
@@ -38,7 +36,7 @@ export class PieIconButton extends LitElement {
|
|
|
38
36
|
size=${size}
|
|
39
37
|
variant=${variant}
|
|
40
38
|
?disabled=${disabled}>
|
|
41
|
-
<
|
|
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' : ''}
|
|
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');
|