@justeattakeaway/pie-button 0.16.1 → 0.17.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 -5
- package/CHANGELOG.md +12 -0
- package/README.md +7 -8
- package/dist/index.js +45 -99
- package/dist/types/packages/components/pie-button/src/defs.d.ts +14 -23
- package/dist/types/packages/components/pie-button/src/defs.d.ts.map +1 -1
- package/dist/types/packages/components/pie-button/src/index.d.ts +2 -2
- package/dist/types/packages/components/pie-button/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/button.scss +68 -18
- package/src/defs.ts +15 -42
- package/src/index.ts +7 -7
- package/test/accessibility/pie-button.spec.ts +5 -5
- package/test/visual/pie-button.spec.ts +17 -15
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[11:00:50 AM] @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 7.
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 7.09 kB[22m[1m[22m[2m │ gzip: 1.77 kB[22m
|
|
9
9
|
[2mdist/[22m[36mreact.js [39m[1m[2m59.01 kB[22m[1m[22m[2m │ gzip: 15.91 kB[22m
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
-
[32m✓ built in
|
|
13
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
12
|
+
[32m✓ built in 13.54s[39m
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 12277ms.
|
|
14
14
|
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [Changed] - Styles updated to fully match design updates ([#581](https://github.com/justeattakeaway/pie/pull/581)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
8
|
+
|
|
9
|
+
- Focus styles have been updated to the new style
|
|
10
|
+
- Padding, font-size and line-heights adjusted inline with designs
|
|
11
|
+
- Outline button text colour updated from `color-content-interactive-tertiary` to `color-content-interactive-secondary`
|
|
12
|
+
- Primary buttons at `xsmall` and `small-productive` now have darker background
|
|
13
|
+
- `ghost` variant background colour changed to `transparent` (rather than #fff)
|
|
14
|
+
|
|
3
15
|
## 0.16.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -65,13 +65,13 @@ import { PieButton } from '@justeattakeaway/pie-button/dist/react';
|
|
|
65
65
|
|
|
66
66
|
## Props
|
|
67
67
|
|
|
68
|
-
| Property | Type | Default | Description
|
|
69
|
-
|
|
70
|
-
| size | `String` | `medium` | Size of the button, one of `
|
|
71
|
-
| type | `String` | `submit` | Type of the button, one of `
|
|
72
|
-
| variant | `String` | `primary` | Variant of the button, one of `
|
|
73
|
-
| disabled | `Boolean` | `false` | If `true`, disables the button.
|
|
74
|
-
| isFullWidth | `Boolean` | `false` | If `true`, sets the button width to 100% of it's container.
|
|
68
|
+
| Property | Type | Default | Description |
|
|
69
|
+
|-------------|-----------|-----------------|----------------------------------------------------------------------|
|
|
70
|
+
| size | `String` | `medium` | Size of the button, one of `sizes` – `xsmall`, `small-expressive`, `small-productive`, `medium`, `large` |
|
|
71
|
+
| type | `String` | `submit` | Type of the button, one of `types` – `submit`, `button`, `reset`, `menu` |
|
|
72
|
+
| variant | `String` | `primary` | Variant of the button, one of `variants` – `primary`, `secondary`, `outline`, `ghost` |
|
|
73
|
+
| disabled | `Boolean` | `false` | If `true`, disables the button. |
|
|
74
|
+
| isFullWidth | `Boolean` | `false` | If `true`, sets the button width to 100% of it's container. |
|
|
75
75
|
|
|
76
76
|
In your markup or JSX, you can then use these to set the properties for the `pie-button` component:
|
|
77
77
|
|
|
@@ -111,7 +111,6 @@ For example, to add a click handler in various templates:
|
|
|
111
111
|
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
|
|
115
114
|
## Testing
|
|
116
115
|
|
|
117
116
|
### Browser tests
|
package/dist/index.js
CHANGED
|
@@ -1,130 +1,76 @@
|
|
|
1
|
-
import { unsafeCSS as h, LitElement as
|
|
1
|
+
import { unsafeCSS as h, LitElement as u, html as m } from "lit";
|
|
2
2
|
import { property as c } from "lit/decorators.js";
|
|
3
3
|
import "lit/decorators/property.js";
|
|
4
|
-
const b = (
|
|
5
|
-
const
|
|
6
|
-
Object.defineProperty(
|
|
4
|
+
const b = (l, o, a) => function(t, r) {
|
|
5
|
+
const e = `#${r}`;
|
|
6
|
+
Object.defineProperty(t, r, {
|
|
7
7
|
get() {
|
|
8
|
-
return this[
|
|
8
|
+
return this[e];
|
|
9
9
|
},
|
|
10
|
-
set(
|
|
11
|
-
const
|
|
12
|
-
o.includes(
|
|
13
|
-
`<${
|
|
10
|
+
set(v) {
|
|
11
|
+
const p = this[e];
|
|
12
|
+
o.includes(v) ? this[e] = v : (console.error(
|
|
13
|
+
`<${l}> Invalid value "${v}" 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: "${a}"`
|
|
16
|
+
), this[e] = a), this.requestUpdate(r, p);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
for (var t =
|
|
23
|
-
(
|
|
24
|
-
return
|
|
19
|
+
}, f = `.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-padding: 10px var(--dt-spacing-e);--btn-min-height: 48px;--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);min-block-size:var(--btn-min-block-size);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner);outline:none;position:relative}.o-btn:focus-visible:after{content:"";display:block;position:absolute;top:-3px;left:-3px;right:-3px;bottom:-3px;border-radius:var(--btn-border-radius);box-shadow:0 0 0 2px var(--dt-color-focus-outer)}.o-btn[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-btn[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-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){background-color:hsl(var(--dt-color-interactive-primary-h),var(--dt-color-interactive-primary-s),calc(var(--dt-color-interactive-primary-l) - var(--dt-color-hover-01)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled){background-color:hsl(var(--dt-color-interactive-primary-h),var(--dt-color-interactive-primary-s),calc(var(--dt-color-interactive-primary-l) - var(--dt-color-active-01)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[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-btn[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-btn[variant=outline]{--btn-bg-color: var(--dt-color-container-default);--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong)}.o-btn[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-btn[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-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link)}.o-btn[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-btn[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-btn[isFullWidth]{inline-size:100%}.o-btn[disabled]{--btn-text-color: var(--dt-color-content-disabled) !important;cursor:not-allowed}.o-btn[disabled]:not([variant=ghost]){--btn-bg-color: var(--dt-color-disabled-01) !important}.o-btn[disabled][variant=outline]{border-color:var(--dt-color-disabled-01)!important}.o-btn[size=xsmall]{--btn-padding: 6px var(--dt-spacing-b);--btn-font-size: calc(var(--dt-font-size-14) * 1px);--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px)}.o-btn[size=small-expressive]{--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}.o-btn[size=small-productive]{--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px)}.o-btn[size=large]{--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}
|
|
20
|
+
`, g = ["xsmall", "small-productive", "small-expressive", "medium", "large"], y = ["submit", "button", "reset", "menu"], x = ["primary", "secondary", "outline", "ghost"];
|
|
21
|
+
var z = Object.defineProperty, k = Object.getOwnPropertyDescriptor, d = (l, o, a, n) => {
|
|
22
|
+
for (var t = n > 1 ? void 0 : n ? k(o, a) : o, r = l.length - 1, e; r >= 0; r--)
|
|
23
|
+
(e = l[r]) && (t = (n ? e(o, a, t) : e(t)) || t);
|
|
24
|
+
return n && t && z(o, a, t), t;
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
super(...arguments), this.propKeyValues = "";
|
|
29
|
-
}
|
|
30
|
-
// Renders a string such as 'size: small, isFullWidth: true'
|
|
31
|
-
// as HTML such as:
|
|
32
|
-
// <p class="c-webComponentTestWrapper-label"><b>size</b>: <code>small</code></p>
|
|
33
|
-
// <p class="c-webComponentTestWrapper-label"><b>isFullWidth</b>: <code>true</code></p>
|
|
34
|
-
_renderPropKeyValues() {
|
|
35
|
-
return this.propKeyValues.split(",").map((o) => {
|
|
36
|
-
const [e, r] = o.split(":");
|
|
37
|
-
return v`<p class="c-webComponentTestWrapper-label"><b>${e}</b>: <code>${r}</code></p>`;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line class-methods-use-this
|
|
41
|
-
render() {
|
|
42
|
-
return v`
|
|
43
|
-
<div class="c-webComponentTestWrapper">
|
|
44
|
-
${this._renderPropKeyValues()}
|
|
45
|
-
<div class="c-webComponentTestWrapper-slot">
|
|
46
|
-
<slot></slot>
|
|
47
|
-
</div>
|
|
48
|
-
</div>`;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
p.styles = h(m);
|
|
52
|
-
z([
|
|
53
|
-
c({ type: String })
|
|
54
|
-
], p.prototype, "propKeyValues", 2);
|
|
55
|
-
const u = "web-component-test-wrapper";
|
|
56
|
-
customElements.get(u) || customElements.define(u, p);
|
|
57
|
-
const $ = `.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-padding: 10px var(--dt-spacing-e);--btn-min-height: 48px;--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-focus: var(--dt-color-focus-outer);min-block-size:var(--btn-min-block-size);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none}.o-btn:focus-visible{outline:2px solid var(--btn-focus)}.o-btn[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-btn[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-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[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-btn[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-btn[variant=outline]{--btn-bg-color: var(--dt-color-container-default);--btn-text-color: var(--dt-color-content-interactive-tertiary);border:1px solid var(--dt-color-border-strong)}.o-btn[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-btn[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-btn[variant=ghost]{--btn-bg-color: var(--dt-color-container-default);--btn-text-color: var(--dt-color-content-link)}.o-btn[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-btn[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-btn[isFullWidth]{inline-size:100%}.o-btn[disabled]{--btn-bg-color: var(--dt-color-disabled-01);--btn-text-color: var(--dt-color-content-disabled);border:1px solid var(--dt-color-disabled-01);cursor:not-allowed}.o-btn[disabled][variant=ghost]{--btn-bg-color: var(--dt-color-container-default);outline:none}.o-btn[size=xsmall]{--btn-padding: 6px var(--dt-spacing-b);--btn-min-block-size: 32px;--btn-font-size: calc(var(--dt-font-size-14) * 1px);--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px)}.o-btn[size=small]{--btn-padding: 8px var(--dt-spacing-d);--btn-min-block-size: 40px;--btn-font-size: calc(var(--dt-font-size-19) * 1px);--btn-line-height: calc(var(--dt-font-size-19-line-height) * 1px)}.o-btn[size=large]{--btn-padding: 14px var(--dt-spacing-e);--btn-min-block-size: 56px;--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px)}
|
|
58
|
-
`, w = [
|
|
59
|
-
"xsmall",
|
|
60
|
-
"small-expressive",
|
|
61
|
-
"small-productive",
|
|
62
|
-
"medium",
|
|
63
|
-
"large"
|
|
64
|
-
], k = [
|
|
65
|
-
"primary",
|
|
66
|
-
"secondary",
|
|
67
|
-
"outline",
|
|
68
|
-
"ghost"
|
|
69
|
-
], P = [
|
|
70
|
-
"submit",
|
|
71
|
-
"button",
|
|
72
|
-
"reset",
|
|
73
|
-
"menu"
|
|
74
|
-
];
|
|
75
|
-
var _ = Object.defineProperty, W = Object.getOwnPropertyDescriptor, s = (i, o, e, r) => {
|
|
76
|
-
for (var t = r > 1 ? void 0 : r ? W(o, e) : o, n = i.length - 1, a; n >= 0; n--)
|
|
77
|
-
(a = i[n]) && (t = (r ? a(o, e, t) : a(t)) || t);
|
|
78
|
-
return r && t && _(o, e, t), t;
|
|
79
|
-
};
|
|
80
|
-
const d = "pie-button";
|
|
81
|
-
class l extends f {
|
|
26
|
+
const s = "pie-button";
|
|
27
|
+
class i extends u {
|
|
82
28
|
constructor() {
|
|
83
29
|
super(...arguments), this.size = "medium", this.type = "submit", this.variant = "primary", this.disabled = !1, this.isFullWidth = !1;
|
|
84
30
|
}
|
|
85
31
|
render() {
|
|
86
32
|
const {
|
|
87
33
|
type: o,
|
|
88
|
-
disabled:
|
|
89
|
-
isFullWidth:
|
|
34
|
+
disabled: a,
|
|
35
|
+
isFullWidth: n,
|
|
90
36
|
variant: t,
|
|
91
|
-
size:
|
|
37
|
+
size: r
|
|
92
38
|
} = this;
|
|
93
|
-
return
|
|
39
|
+
return m`
|
|
94
40
|
<button
|
|
95
41
|
class="o-btn"
|
|
96
42
|
type=${o}
|
|
97
43
|
variant=${t}
|
|
98
|
-
size=${
|
|
99
|
-
?disabled=${
|
|
100
|
-
?isFullWidth=${
|
|
44
|
+
size=${r}
|
|
45
|
+
?disabled=${a}
|
|
46
|
+
?isFullWidth=${n}>
|
|
101
47
|
<slot></slot>
|
|
102
48
|
</button>`;
|
|
103
49
|
}
|
|
104
50
|
}
|
|
105
|
-
|
|
106
|
-
|
|
51
|
+
i.styles = h(f);
|
|
52
|
+
d([
|
|
107
53
|
c(),
|
|
108
|
-
b(
|
|
109
|
-
],
|
|
110
|
-
|
|
54
|
+
b(s, g, "medium")
|
|
55
|
+
], i.prototype, "size", 2);
|
|
56
|
+
d([
|
|
111
57
|
c(),
|
|
112
|
-
b(
|
|
113
|
-
],
|
|
114
|
-
|
|
58
|
+
b(s, y, "submit")
|
|
59
|
+
], i.prototype, "type", 2);
|
|
60
|
+
d([
|
|
115
61
|
c(),
|
|
116
|
-
b(
|
|
117
|
-
],
|
|
118
|
-
|
|
62
|
+
b(s, x, "primary")
|
|
63
|
+
], i.prototype, "variant", 2);
|
|
64
|
+
d([
|
|
119
65
|
c({ type: Boolean })
|
|
120
|
-
],
|
|
121
|
-
|
|
66
|
+
], i.prototype, "disabled", 2);
|
|
67
|
+
d([
|
|
122
68
|
c({ type: Boolean })
|
|
123
|
-
],
|
|
124
|
-
customElements.define(
|
|
69
|
+
], i.prototype, "isFullWidth", 2);
|
|
70
|
+
customElements.define(s, i);
|
|
125
71
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
72
|
+
i as PieButton,
|
|
73
|
+
g as sizes,
|
|
74
|
+
y as types,
|
|
75
|
+
x as variants
|
|
130
76
|
};
|
|
@@ -1,40 +1,31 @@
|
|
|
1
|
+
export declare const sizes: readonly ["xsmall", "small-productive", "small-expressive", "medium", "large"];
|
|
2
|
+
export declare const types: readonly ["submit", "button", "reset", "menu"];
|
|
3
|
+
export declare const variants: readonly ["primary", "secondary", "outline", "ghost"];
|
|
1
4
|
export interface ButtonProps {
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @default medium
|
|
6
|
+
* (Optional) What size the button should be.
|
|
7
|
+
* @default "medium"
|
|
5
8
|
*/
|
|
6
|
-
size:
|
|
9
|
+
size: typeof sizes[number];
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @default submit
|
|
11
|
+
* (Optional) What type attribute should be applied to the button. For example submit, button or menu.
|
|
12
|
+
* @default "submit"
|
|
10
13
|
*/
|
|
11
|
-
type:
|
|
14
|
+
type: typeof types[number];
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @default primary
|
|
16
|
+
* (Optional) What style variant the button should be such as primary, outline or ghost.
|
|
17
|
+
* @default "primary"
|
|
15
18
|
*/
|
|
16
|
-
variant:
|
|
19
|
+
variant: typeof variants[number];
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* (Optional) When true, the button element is disabled.
|
|
19
22
|
* @default false
|
|
20
23
|
*/
|
|
21
24
|
disabled: boolean;
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
26
|
+
* (Optional) When true, the button element will occupy the full width of its container.
|
|
24
27
|
* @default false
|
|
25
28
|
*/
|
|
26
29
|
isFullWidth: boolean;
|
|
27
30
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Button size variants
|
|
30
|
-
*/
|
|
31
|
-
export declare const buttonSizes: Array<ButtonProps['size']>;
|
|
32
|
-
/**
|
|
33
|
-
* Button style variants
|
|
34
|
-
*/
|
|
35
|
-
export declare const buttonVariants: Array<ButtonProps['variant']>;
|
|
36
|
-
/**
|
|
37
|
-
* Button type variants
|
|
38
|
-
*/
|
|
39
|
-
export declare const buttonTypes: Array<ButtonProps['type']>;
|
|
40
31
|
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,gFAAiF,CAAC;AACpG,eAAO,MAAM,KAAK,gDAAiD,CAAC;AACpE,eAAO,MAAM,QAAQ,uDAAwD,CAAC;AAE9E,MAAM,WAAW,WAAW;IACxB;;;OAGG;IACH,IAAI,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,IAAI,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,OAAO,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import { ButtonProps,
|
|
3
|
-
export { type ButtonProps,
|
|
2
|
+
import { ButtonProps, sizes, types, variants } from './defs';
|
|
3
|
+
export { type ButtonProps, sizes, types, variants, };
|
|
4
4
|
declare const componentSelector = "pie-button";
|
|
5
5
|
export declare class PieButton extends LitElement {
|
|
6
6
|
size: ButtonProps['size'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD,OAAO,EACH,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAIlD,OAAO,EACH,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EACtC,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,EACL,KAAK,EACL,QAAQ,GACX,CAAC;AAEF,QAAA,MAAM,iBAAiB,eAAe,CAAC;AAEvC,qBAAa,SAAU,SAAQ,UAAU;IAGjC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAY;IAIrC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAa;IAG5C,QAAQ,UAAS;IAGjB,WAAW,UAAS;IAExB,MAAM;IAkBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC;KAClC;CACJ"}
|
package/package.json
CHANGED
package/src/button.scss
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
// currently this sets the primary button styles
|
|
29
29
|
--btn-bg-color: var(--dt-color-interactive-brand);
|
|
30
30
|
--btn-text-color: var(--dt-color-content-interactive-primary);
|
|
31
|
-
--btn-focus: var(--dt-color-focus-outer);
|
|
32
31
|
|
|
33
32
|
min-block-size: var(--btn-min-block-size);
|
|
34
33
|
padding: var(--btn-padding);
|
|
@@ -45,13 +44,59 @@
|
|
|
45
44
|
user-select: none;
|
|
46
45
|
|
|
47
46
|
&:focus-visible {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
/*
|
|
48
|
+
TODO: This focus styling should be extracted out into a shared mixin to share among other components
|
|
49
|
+
Applying both shadows in a single declaration gives anti-aliasing artefacts.
|
|
50
|
+
box-shadow: 0 0 0 2px dt.$color-focus-inner, 0 0 0 4px dt.$color-focus-outer;
|
|
51
|
+
|
|
52
|
+
To prevent this, they should be separated so they don't bleed into each other,
|
|
53
|
+
i.e., one shadow on the element and another on a pseudo element like :after
|
|
54
|
+
*/
|
|
55
|
+
box-shadow: 0 0 0 2px var(--dt-color-focus-inner);
|
|
56
|
+
outline: none;
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
Setting the position to relative prevents the pseudo-element from
|
|
60
|
+
anchoring instead to the nearest ancestor with a specified position.
|
|
61
|
+
|
|
62
|
+
You can override this if you need another value.
|
|
63
|
+
*/
|
|
64
|
+
position: relative;
|
|
65
|
+
|
|
66
|
+
&:after {
|
|
67
|
+
content: '';
|
|
68
|
+
display: block;
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
The pseudo element has to be larger than the element itself, but not just by
|
|
72
|
+
2px (the thickness of the inner shadow), it has to be 1px larger than that to
|
|
73
|
+
account for the border thickness.
|
|
74
|
+
*/
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: -3px;
|
|
77
|
+
left: -3px;
|
|
78
|
+
right: -3px;
|
|
79
|
+
bottom: -3px;
|
|
80
|
+
border-radius: var(--btn-border-radius);
|
|
81
|
+
|
|
82
|
+
box-shadow: 0 0 0 2px var(--dt-color-focus-outer);
|
|
83
|
+
}
|
|
50
84
|
}
|
|
51
85
|
|
|
52
86
|
// Variant
|
|
53
87
|
&[variant='primary'] {
|
|
54
88
|
@include button-interactive-states('--dt-color-interactive-brand');
|
|
89
|
+
|
|
90
|
+
&[size='xsmall'],
|
|
91
|
+
&[size='small-productive'] {
|
|
92
|
+
/**
|
|
93
|
+
* Where the font-size is smaller,
|
|
94
|
+
* update the button backgrounds so that the text is accessible
|
|
95
|
+
**/
|
|
96
|
+
--btn-bg-color: var(--dt-color-interactive-primary);
|
|
97
|
+
|
|
98
|
+
@include button-interactive-states('--dt-color-interactive-primary');
|
|
99
|
+
}
|
|
55
100
|
}
|
|
56
101
|
|
|
57
102
|
&[variant='secondary'] {
|
|
@@ -63,7 +108,7 @@
|
|
|
63
108
|
|
|
64
109
|
&[variant='outline'] {
|
|
65
110
|
--btn-bg-color: var(--dt-color-container-default);
|
|
66
|
-
--btn-text-color: var(--dt-color-content-interactive-
|
|
111
|
+
--btn-text-color: var(--dt-color-content-interactive-secondary);
|
|
67
112
|
|
|
68
113
|
border: 1px solid var(--dt-color-border-strong);
|
|
69
114
|
|
|
@@ -71,7 +116,7 @@
|
|
|
71
116
|
}
|
|
72
117
|
|
|
73
118
|
&[variant='ghost'] {
|
|
74
|
-
--btn-bg-color:
|
|
119
|
+
--btn-bg-color: transparent;
|
|
75
120
|
--btn-text-color: var(--dt-color-content-link);
|
|
76
121
|
|
|
77
122
|
@include button-interactive-states('--dt-color-container-default');
|
|
@@ -83,31 +128,37 @@
|
|
|
83
128
|
}
|
|
84
129
|
|
|
85
130
|
&[disabled] {
|
|
86
|
-
--btn-
|
|
87
|
-
--btn-text-color: var(--dt-color-content-disabled);
|
|
131
|
+
--btn-text-color: var(--dt-color-content-disabled) !important;
|
|
88
132
|
|
|
89
|
-
border: 1px solid var(--dt-color-disabled-01);
|
|
90
133
|
cursor: not-allowed;
|
|
91
|
-
}
|
|
92
134
|
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
// For every variant except ghost, set the disabled background color
|
|
136
|
+
&:not([variant='ghost']) {
|
|
137
|
+
--btn-bg-color: var(--dt-color-disabled-01) !important;
|
|
138
|
+
}
|
|
95
139
|
|
|
96
|
-
outline
|
|
140
|
+
// For outline variants, set the border to the disabled color
|
|
141
|
+
&[variant='outline'] {
|
|
142
|
+
border-color: var(--dt-color-disabled-01) !important;
|
|
143
|
+
}
|
|
97
144
|
}
|
|
98
145
|
|
|
99
146
|
&[size='xsmall'] {
|
|
100
147
|
--btn-padding: 6px var(--dt-spacing-b);
|
|
101
|
-
--btn-min-block-size: 32px;
|
|
102
148
|
--btn-font-size: calc(var(--dt-font-size-14) * 1px);
|
|
103
149
|
--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
104
150
|
}
|
|
105
151
|
|
|
106
|
-
&[size='small'] {
|
|
152
|
+
&[size='small-expressive'] {
|
|
153
|
+
--btn-padding: 6px var(--dt-spacing-d);
|
|
154
|
+
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
155
|
+
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&[size='small-productive'] {
|
|
107
159
|
--btn-padding: 8px var(--dt-spacing-d);
|
|
108
|
-
--btn-
|
|
109
|
-
--btn-
|
|
110
|
-
--btn-line-height: calc(var(--dt-font-size-19-line-height) * 1px);
|
|
160
|
+
--btn-font-size: calc(var(--dt-font-size-16) * 1px);
|
|
161
|
+
--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);
|
|
111
162
|
}
|
|
112
163
|
|
|
113
164
|
&[size='medium'] {
|
|
@@ -116,7 +167,6 @@
|
|
|
116
167
|
|
|
117
168
|
&[size='large'] {
|
|
118
169
|
--btn-padding: 14px var(--dt-spacing-e);
|
|
119
|
-
--btn-min-block-size: 56px;
|
|
120
170
|
--btn-font-size: calc(var(--dt-font-size-20) * 1px);
|
|
121
171
|
--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);
|
|
122
172
|
}
|
package/src/defs.ts
CHANGED
|
@@ -1,58 +1,31 @@
|
|
|
1
|
+
export const sizes = ['xsmall', 'small-productive', 'small-expressive', 'medium', 'large'] as const;
|
|
2
|
+
export const types = ['submit', 'button', 'reset', 'menu'] as const;
|
|
3
|
+
export const variants = ['primary', 'secondary', 'outline', 'ghost'] as const;
|
|
4
|
+
|
|
1
5
|
export interface ButtonProps {
|
|
2
6
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @default medium
|
|
7
|
+
* (Optional) What size the button should be.
|
|
8
|
+
* @default "medium"
|
|
5
9
|
*/
|
|
6
|
-
size:
|
|
10
|
+
size: typeof sizes[number];
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @default submit
|
|
12
|
+
* (Optional) What type attribute should be applied to the button. For example submit, button or menu.
|
|
13
|
+
* @default "submit"
|
|
10
14
|
*/
|
|
11
|
-
type:
|
|
15
|
+
type: typeof types[number];
|
|
12
16
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @default primary
|
|
17
|
+
* (Optional) What style variant the button should be such as primary, outline or ghost.
|
|
18
|
+
* @default "primary"
|
|
15
19
|
*/
|
|
16
|
-
variant:
|
|
20
|
+
variant: typeof variants[number];
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* (Optional) When true, the button element is disabled.
|
|
19
23
|
* @default false
|
|
20
24
|
*/
|
|
21
25
|
disabled: boolean;
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
27
|
+
* (Optional) When true, the button element will occupy the full width of its container.
|
|
24
28
|
* @default false
|
|
25
29
|
*/
|
|
26
30
|
isFullWidth: boolean;
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Button size variants
|
|
31
|
-
*/
|
|
32
|
-
export const buttonSizes: Array<ButtonProps['size']> = [
|
|
33
|
-
'xsmall',
|
|
34
|
-
'small-expressive',
|
|
35
|
-
'small-productive',
|
|
36
|
-
'medium',
|
|
37
|
-
'large'
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Button style variants
|
|
42
|
-
*/
|
|
43
|
-
export const buttonVariants: Array<ButtonProps['variant']> = [
|
|
44
|
-
'primary',
|
|
45
|
-
'secondary',
|
|
46
|
-
'outline',
|
|
47
|
-
'ghost',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Button type variants
|
|
52
|
-
*/
|
|
53
|
-
export const buttonTypes: Array<ButtonProps['type']> = [
|
|
54
|
-
'submit',
|
|
55
|
-
'button',
|
|
56
|
-
'reset',
|
|
57
|
-
'menu',
|
|
58
|
-
];
|
package/src/index.ts
CHANGED
|
@@ -3,30 +3,30 @@ import { property } from 'lit/decorators.js';
|
|
|
3
3
|
import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
4
4
|
import styles from './button.scss?inline';
|
|
5
5
|
import {
|
|
6
|
-
ButtonProps,
|
|
6
|
+
ButtonProps, sizes, types, variants,
|
|
7
7
|
} from './defs';
|
|
8
8
|
|
|
9
9
|
// Valid values available to consumers
|
|
10
10
|
export {
|
|
11
11
|
type ButtonProps,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
sizes,
|
|
13
|
+
types,
|
|
14
|
+
variants,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const componentSelector = 'pie-button';
|
|
18
18
|
|
|
19
19
|
export class PieButton extends LitElement {
|
|
20
20
|
@property()
|
|
21
|
-
@validPropertyValues(componentSelector,
|
|
21
|
+
@validPropertyValues(componentSelector, sizes, 'medium')
|
|
22
22
|
size: ButtonProps['size'] = 'medium';
|
|
23
23
|
|
|
24
24
|
@property()
|
|
25
|
-
@validPropertyValues(componentSelector,
|
|
25
|
+
@validPropertyValues(componentSelector, types, 'submit')
|
|
26
26
|
type: ButtonProps['type'] = 'submit';
|
|
27
27
|
|
|
28
28
|
@property()
|
|
29
|
-
@validPropertyValues(componentSelector,
|
|
29
|
+
@validPropertyValues(componentSelector, variants, 'primary')
|
|
30
30
|
variant: ButtonProps['variant'] = 'primary';
|
|
31
31
|
|
|
32
32
|
@property({ type: Boolean })
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { test, expect } from '@sand4rt/experimental-ct-web';
|
|
2
2
|
import AxeBuilder from '@axe-core/playwright';
|
|
3
|
-
import { getAllPropCombinations, splitCombinationsByPropertyValue } from '@justeattakeaway/pie-webc-
|
|
4
|
-
import { PropObject, WebComponentPropValues } from '@justeattakeaway/pie-webc-
|
|
3
|
+
import { getAllPropCombinations, splitCombinationsByPropertyValue } from '@justeattakeaway/pie-webc-testing/src/helpers/get-all-prop-combos.ts';
|
|
4
|
+
import { PropObject, WebComponentPropValues } from '@justeattakeaway/pie-webc-testing/src/helpers/defs.ts';
|
|
5
5
|
import { PieButton } from '@/index';
|
|
6
|
-
import {
|
|
6
|
+
import { sizes, variants } from '@/defs';
|
|
7
7
|
|
|
8
8
|
const props: PropObject = {
|
|
9
|
-
variant:
|
|
10
|
-
size:
|
|
9
|
+
variant: variants,
|
|
10
|
+
size: sizes,
|
|
11
11
|
type: 'button', // Changing the type does not affect the appearance of the button
|
|
12
12
|
isFullWidth: [true, false],
|
|
13
13
|
disabled: [true, false],
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { test } from '@sand4rt/experimental-ct-web';
|
|
2
|
-
import { getLitPercyOptions } from '@justeattakeaway/pie-webc-core/src/test-helpers/percy-lit-options.ts';
|
|
3
2
|
import percySnapshot from '@percy/playwright';
|
|
4
3
|
import type {
|
|
5
4
|
PropObject, WebComponentPropValues, WebComponentTestInput,
|
|
6
|
-
} from '@justeattakeaway/pie-webc-
|
|
5
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/defs.ts';
|
|
7
6
|
import {
|
|
8
7
|
getAllPropCombinations, splitCombinationsByPropertyValue,
|
|
9
|
-
} from '@justeattakeaway/pie-webc-
|
|
8
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/get-all-prop-combos.ts';
|
|
10
9
|
import {
|
|
11
10
|
createTestWebComponent,
|
|
12
|
-
} from '@justeattakeaway/pie-webc-
|
|
11
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/rendering.ts';
|
|
13
12
|
import {
|
|
14
13
|
WebComponentTestWrapper,
|
|
15
|
-
} from '@justeattakeaway/pie-webc-
|
|
14
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/components/web-component-test-wrapper/WebComponentTestWrapper.ts';
|
|
16
15
|
import { PieButton } from '@/index';
|
|
17
|
-
import {
|
|
16
|
+
import { sizes, variants } from '@/defs';
|
|
18
17
|
|
|
19
18
|
const props: PropObject = {
|
|
20
|
-
variant:
|
|
21
|
-
size:
|
|
19
|
+
variant: variants,
|
|
20
|
+
size: sizes,
|
|
22
21
|
type: 'button', // Changing the type does not affect the appearance of the button
|
|
23
22
|
isFullWidth: [true, false],
|
|
24
23
|
disabled: [true, false],
|
|
@@ -33,14 +32,17 @@ const componentVariants: string[] = Object.keys(componentPropsMatrixByVariant);
|
|
|
33
32
|
|
|
34
33
|
// This ensures the component is registered in the DOM for each test
|
|
35
34
|
// This is not required if your tests mount the web component directly in the tests
|
|
36
|
-
test(
|
|
35
|
+
test.beforeEach(async ({ page, mount }) => {
|
|
37
36
|
await mount(
|
|
38
37
|
PieButton,
|
|
39
|
-
{
|
|
40
|
-
props: {},
|
|
41
|
-
slots: {},
|
|
42
|
-
},
|
|
38
|
+
{},
|
|
43
39
|
);
|
|
40
|
+
|
|
41
|
+
// Removing the element so it's not present in the tests (but is still registered in the DOM)
|
|
42
|
+
await page.evaluate(() => {
|
|
43
|
+
const element : Element | null = document.querySelector('pie-button');
|
|
44
|
+
element?.remove();
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
componentVariants.forEach((variant) => test(`Render all prop variations for Variant: ${variant}`, async ({ page, mount }) => {
|
|
@@ -53,11 +55,11 @@ componentVariants.forEach((variant) => test(`Render all prop variations for Vari
|
|
|
53
55
|
{
|
|
54
56
|
props: { propKeyValues },
|
|
55
57
|
slots: {
|
|
56
|
-
|
|
58
|
+
component: testComponent.renderedString.trim(),
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
);
|
|
60
62
|
}));
|
|
61
63
|
|
|
62
|
-
await percySnapshot(page, `PIE Button - Variant: ${variant}
|
|
64
|
+
await percySnapshot(page, `PIE Button - Variant: ${variant}`);
|
|
63
65
|
}));
|