@justeattakeaway/pie-button 0.10.1 → 0.10.2
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 +11 -0
- package/CHANGELOG.md +7 -1
- package/dist/index.js +26 -26
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +6 -2
- package/playwright/index.html +41 -0
- package/playwright/index.ts +1 -0
- package/playwright-lit-visual.config.ts +43 -0
- package/playwright-lit.config.ts +52 -0
- package/src/index.ts +7 -1
- package/test/accessibility/pie-button.spec.ts +36 -0
- package/test/component/pie-button.spec.ts +51 -0
- package/test/visual/pie-button.spec.ts +31 -0
- package/tsconfig.json +29 -25
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[36mvite v4.2.1 [32mbuilding for production...[36m[39m
|
|
2
|
+
transforming...
|
|
3
|
+
[32m✓[39m 4 modules transformed.
|
|
4
|
+
rendering chunks...
|
|
5
|
+
computing gzip size...
|
|
6
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m3.85 kB[22m[1m[22m[2m │ gzip: 1.61 kB[22m
|
|
7
|
+
[32m
|
|
8
|
+
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
9
|
+
[32m✓[39m built in 8.24s
|
|
10
|
+
[32m[36m[vite:dts][32m Declaration files built in 7676ms.
|
|
11
|
+
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Added] Declare global statement back in. ([#393](https://github.com/justeattakeaway/pie/pull/393)) by [@kevinrodrigues](https://github.com/kevinrodrigues)
|
|
8
|
+
|
|
3
9
|
## 0.10.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
|
-
- [Fixed] - Added module entry for component
|
|
13
|
+
- [Fixed] - Added module entry for component ([#378](https://github.com/justeattakeaway/pie/pull/378)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
8
14
|
|
|
9
15
|
## 0.10.0
|
|
10
16
|
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { unsafeCSS as f, LitElement as h, html as g } from "lit";
|
|
2
2
|
import { classMap as m } from "lit/directives/class-map.js";
|
|
3
|
-
import { property as
|
|
3
|
+
import { property as b, customElement as v } from "lit/decorators.js";
|
|
4
4
|
const x = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;font-weight:700;cursor:pointer;user-select:none;outline:none}.o-btn:focus-visible{outline:2px solid #4996fd}.o-btn--xsmall{padding:6px 8px;min-height:32px;font-size:14px;line-height:20px}.o-btn--small{padding:8px 16px;min-height:40px;font-size:19px;line-height:28px}.o-btn--medium{padding:10px 24px;min-height:48px;font-size:20px;line-height:28px}.o-btn--large{padding:14px 24px;min-height:56px;font-size:20px;line-height:28px}.o-btn--primary{background-color:#f36805;color:#fff}.o-btn--primary:hover{background-color:#df5f05}.o-btn--primary:active{background-color:#b74e04}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--secondary:hover{background-color:#ede9e5}.o-btn--secondary:active{background-color:#dcd4cd}.o-btn--outline{outline:1px solid #dbd9d7;background-color:#fff;color:#303d3f}.o-btn--outline:hover{background-color:#f5f5f5}.o-btn--outline:active{background-color:#e0e0e0}.o-btn--ghost{background-color:#fff;color:#242e30}.o-btn--ghost:hover{background-color:#f5f5f5}.o-btn--ghost:active{background-color:#e0e0e0}.o-btn.o-btn--is-disabled{background-color:#efedea;color:#8c999b;outline:1px solid #efedea;cursor:default}.o-btn.o-btn--is-disabled.o-btn--ghost{background-color:#fff;outline:none}
|
|
5
|
-
`, p = (
|
|
6
|
-
const
|
|
5
|
+
`, p = (e, n) => function(i, t) {
|
|
6
|
+
const o = `#${t}`;
|
|
7
7
|
Object.defineProperty(i, t, {
|
|
8
8
|
get() {
|
|
9
|
-
return this[
|
|
9
|
+
return this[o];
|
|
10
10
|
},
|
|
11
11
|
set(r) {
|
|
12
|
-
const s = this[
|
|
13
|
-
|
|
12
|
+
const s = this[o];
|
|
13
|
+
e.includes(r) ? this[o] = r : (console.error(
|
|
14
14
|
`[pie-button] Invalid value "${r}" provided for property "${t}".`,
|
|
15
|
-
`Must be one of: ${
|
|
15
|
+
`Must be one of: ${e.join(" | ")}.`,
|
|
16
16
|
`Falling back to default value: "${n}"`
|
|
17
|
-
), this[
|
|
17
|
+
), this[o] = n), this.requestUpdate(t, s);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
-
var a = /* @__PURE__ */ ((
|
|
22
|
-
for (var
|
|
23
|
-
(s =
|
|
24
|
-
return t &&
|
|
21
|
+
var a = /* @__PURE__ */ ((e) => (e.XSMALL = "xsmall", e.SMALL = "small", e.MEDIUM = "medium", e.LARGE = "large", e))(a || {}), d = /* @__PURE__ */ ((e) => (e.SUBMIT = "submit", e.BUTTON = "button", e.RESET = "reset", e.MENU = "menu", e))(d || {}), u = /* @__PURE__ */ ((e) => (e.PRIMARY = "primary", e.SECONDARY = "secondary", e.OUTLINE = "outline", e.GHOST = "ghost", e))(u || {}), y = Object.defineProperty, M = Object.getOwnPropertyDescriptor, c = (e, n, i, t) => {
|
|
22
|
+
for (var o = t > 1 ? void 0 : t ? M(n, i) : n, r = e.length - 1, s; r >= 0; r--)
|
|
23
|
+
(s = e[r]) && (o = (t ? s(n, i, o) : s(o)) || o);
|
|
24
|
+
return t && o && y(n, i, o), o;
|
|
25
25
|
};
|
|
26
|
-
function k(
|
|
26
|
+
function k(e) {
|
|
27
27
|
return (n) => {
|
|
28
|
-
if (!customElements.get(
|
|
29
|
-
return v(
|
|
28
|
+
if (!customElements.get(e))
|
|
29
|
+
return v(e)(n);
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
let l = class extends h {
|
|
33
33
|
constructor() {
|
|
34
|
-
super(...arguments), this.size = a.MEDIUM, this.type = d.SUBMIT, this.variant =
|
|
34
|
+
super(...arguments), this.size = a.MEDIUM, this.type = d.SUBMIT, this.variant = u.PRIMARY, this.disabled = !1;
|
|
35
35
|
}
|
|
36
36
|
render() {
|
|
37
|
-
const { size:
|
|
37
|
+
const { size: e, type: n, variant: i, disabled: t } = this, o = {
|
|
38
38
|
"o-btn": !0,
|
|
39
|
-
[`o-btn--${
|
|
39
|
+
[`o-btn--${e}`]: e,
|
|
40
40
|
[`o-btn--${i}`]: i,
|
|
41
41
|
"o-btn--is-disabled": t
|
|
42
42
|
}, r = () => {
|
|
43
|
-
const s = new
|
|
43
|
+
const s = new CustomEvent("CustomEvent", { detail: "WC event dispatched" });
|
|
44
44
|
console.info("WC event dispatched"), this.dispatchEvent(s);
|
|
45
45
|
};
|
|
46
46
|
return g`
|
|
47
47
|
<button
|
|
48
|
-
class=${m(
|
|
48
|
+
class=${m(o)}
|
|
49
49
|
type=${n}
|
|
50
50
|
?disabled=${t}
|
|
51
51
|
@click="${r}">
|
|
@@ -55,19 +55,19 @@ let l = class extends h {
|
|
|
55
55
|
};
|
|
56
56
|
l.styles = f(x);
|
|
57
57
|
c([
|
|
58
|
-
|
|
58
|
+
b(),
|
|
59
59
|
p(Object.values(a), a.MEDIUM)
|
|
60
60
|
], l.prototype, "size", 2);
|
|
61
61
|
c([
|
|
62
|
-
|
|
62
|
+
b(),
|
|
63
63
|
p(Object.values(d), d.SUBMIT)
|
|
64
64
|
], l.prototype, "type", 2);
|
|
65
65
|
c([
|
|
66
|
-
|
|
67
|
-
p(Object.values(
|
|
66
|
+
b(),
|
|
67
|
+
p(Object.values(u), u.PRIMARY)
|
|
68
68
|
], l.prototype, "variant", 2);
|
|
69
69
|
c([
|
|
70
|
-
|
|
70
|
+
b({ type: Boolean, reflect: !0 })
|
|
71
71
|
], l.prototype, "disabled", 2);
|
|
72
72
|
l = c([
|
|
73
73
|
k("pie-button")
|
|
@@ -75,6 +75,6 @@ l = c([
|
|
|
75
75
|
export {
|
|
76
76
|
a as BUTTON_SIZE,
|
|
77
77
|
d as BUTTON_TYPE,
|
|
78
|
-
|
|
78
|
+
u as BUTTON_VARIANT,
|
|
79
79
|
l as PieButton
|
|
80
80
|
};
|
|
@@ -9,4 +9,9 @@ export declare class PieButton extends LitElement {
|
|
|
9
9
|
render(): import("lit-html").TemplateResult<1>;
|
|
10
10
|
static styles: import("lit").CSSResult;
|
|
11
11
|
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'pie-button': PieButton;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAWpD,qBACa,SAAU,SAAQ,UAAU;IAGrC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,EAAG,OAAO,CAAS;IAE3B,MAAM;IA2BN,MAAM,CAAC,MAAM,0BAAqB;CACrC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAWpD,qBACa,SAAU,SAAQ,UAAU;IAGrC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,EAAG,OAAO,CAAS;IAE3B,MAAM;IA2BN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,YAAY,EAAE,SAAS,CAAC;KAC3B;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"build": "run -T vite build",
|
|
11
11
|
"watch": "run -T vite build --watch",
|
|
12
12
|
"dev": "run -T vite",
|
|
13
|
-
"test": "echo \"Error: no test specified\" && exit 0"
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
14
|
+
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
|
|
15
|
+
"test:browsers:ci": "yarn test:browsers",
|
|
16
|
+
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_BUTTON} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
|
|
17
|
+
"test:visual:ci": "yarn test:visual"
|
|
14
18
|
},
|
|
15
19
|
"author": "JustEatTakeaway - Design System Web Team",
|
|
16
20
|
"license": "Apache-2.0",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
7
|
+
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
8
|
+
<link rel="preload" href="https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2" as="font" type="font/woff2" crossorigin>
|
|
9
|
+
<style>
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: JETSansDigital;
|
|
12
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff2') format("woff2"),
|
|
13
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Regular-optimised.woff') format("woff");
|
|
14
|
+
font-weight: 400;
|
|
15
|
+
font-display: swap;
|
|
16
|
+
}
|
|
17
|
+
@font-face {
|
|
18
|
+
font-family: JETSansDigital;
|
|
19
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff2') format("woff2"),
|
|
20
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-Bold-optimised.woff') format("woff");
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
font-display: swap;
|
|
23
|
+
}
|
|
24
|
+
@font-face {
|
|
25
|
+
font-family: JETSansDigital;
|
|
26
|
+
src: url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff2') format("woff2"),
|
|
27
|
+
url('https://d30v2pzvrfyzpo.cloudfront.net/fonts/JETSansDigital-ExtraBold-optimised.woff') format("woff");
|
|
28
|
+
font-weight: 800;
|
|
29
|
+
font-display: swap;
|
|
30
|
+
}
|
|
31
|
+
body {
|
|
32
|
+
font-feature-settings: "tnum"; /* Enable tabular numbers */
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
35
|
+
<title>Testing Page</title>
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
<div id="root"></div>
|
|
39
|
+
<script type="module" src="./index.ts"></script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//Import common styles here
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
6
|
+
*/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
/* Maximum time one test can run for. */
|
|
9
|
+
timeout: 10 * 1000,
|
|
10
|
+
/* Run tests in files in parallel */
|
|
11
|
+
fullyParallel: true,
|
|
12
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
13
|
+
forbidOnly: !!process.env.CI,
|
|
14
|
+
/* Retry on CI only */
|
|
15
|
+
retries: process.env.CI ? 2 : 0,
|
|
16
|
+
/* Opt out of parallel tests on CI. */
|
|
17
|
+
workers: '50%',
|
|
18
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
19
|
+
reporter: [['html', { outputFolder: 'lit-visual-report' }]],
|
|
20
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
21
|
+
use: {
|
|
22
|
+
ctViteConfig: {
|
|
23
|
+
resolve: {
|
|
24
|
+
alias: {
|
|
25
|
+
'@': resolve('./src'),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
30
|
+
trace: 'on',
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
/* Configure projects for major browsers */
|
|
34
|
+
projects: [
|
|
35
|
+
{
|
|
36
|
+
name: 'component:chrome',
|
|
37
|
+
use: {
|
|
38
|
+
...devices['Desktop Chrome'],
|
|
39
|
+
},
|
|
40
|
+
testMatch: ['**/test/visual/*.spec.ts']
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineConfig, devices } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
6
|
+
*/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
|
|
9
|
+
snapshotDir: './__snapshots__',
|
|
10
|
+
/* Maximum time one test can run for. */
|
|
11
|
+
timeout: 10 * 1000,
|
|
12
|
+
/* Run tests in files in parallel */
|
|
13
|
+
fullyParallel: true,
|
|
14
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
15
|
+
forbidOnly: !!process.env.CI,
|
|
16
|
+
/* Retry on CI only */
|
|
17
|
+
retries: process.env.CI ? 2 : 0,
|
|
18
|
+
/* Opt out of parallel tests on CI. */
|
|
19
|
+
workers: '50%',
|
|
20
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
21
|
+
reporter: [['html', { outputFolder: 'lit-browsers-report' }]],
|
|
22
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
23
|
+
use: {
|
|
24
|
+
ctViteConfig: {
|
|
25
|
+
resolve: {
|
|
26
|
+
alias: {
|
|
27
|
+
'@': resolve('./src'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
32
|
+
trace: 'on',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/* Configure projects for major browsers */
|
|
36
|
+
projects: [
|
|
37
|
+
{
|
|
38
|
+
name: 'component:chrome',
|
|
39
|
+
use: {
|
|
40
|
+
...devices['Desktop Chrome'],
|
|
41
|
+
},
|
|
42
|
+
testMatch: ['**/test/component/*.spec.ts']
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'a11y:chrome',
|
|
46
|
+
use: {
|
|
47
|
+
...devices['Desktop Chrome'],
|
|
48
|
+
},
|
|
49
|
+
testMatch: ['**/test/accessibility/*.spec.ts']
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -46,7 +46,7 @@ export class PieButton extends LitElement {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const raiseWCEvent = () => {
|
|
49
|
-
const event = new
|
|
49
|
+
const event = new CustomEvent('CustomEvent', { detail: 'WC event dispatched' })
|
|
50
50
|
console.info('WC event dispatched')
|
|
51
51
|
this.dispatchEvent(event)
|
|
52
52
|
}
|
|
@@ -64,3 +64,9 @@ export class PieButton extends LitElement {
|
|
|
64
64
|
// Renders a `CSSResult` generated from SCSS by Vite
|
|
65
65
|
static styles = unsafeCSS(styles);
|
|
66
66
|
}
|
|
67
|
+
|
|
68
|
+
declare global {
|
|
69
|
+
interface HTMLElementTagNameMap {
|
|
70
|
+
'pie-button': PieButton;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { test, expect } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { PieButton } from '@/index';
|
|
3
|
+
import { BUTTON_SIZE, BUTTON_VARIANT } from '@/defs';
|
|
4
|
+
import AxeBuilder from '@axe-core/playwright';
|
|
5
|
+
|
|
6
|
+
const sizes = Object.values(BUTTON_SIZE);
|
|
7
|
+
const variants = Object.values(BUTTON_VARIANT);
|
|
8
|
+
const disabledStates = [true, false];
|
|
9
|
+
|
|
10
|
+
variants.forEach(variant => {
|
|
11
|
+
test(`should render - ${variant}`, async ({ mount, page }) => {
|
|
12
|
+
|
|
13
|
+
for (const size of sizes) {
|
|
14
|
+
for (const isDisabled of disabledStates) {
|
|
15
|
+
const component = await mount(PieButton,
|
|
16
|
+
{
|
|
17
|
+
props: {
|
|
18
|
+
size,
|
|
19
|
+
variant,
|
|
20
|
+
disabled: isDisabled
|
|
21
|
+
},
|
|
22
|
+
slots: {
|
|
23
|
+
default: `Hello, ${size} ${variant} Button!`
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const results = await new AxeBuilder.default({ page })
|
|
30
|
+
.withTags(['wcag21a', 'wcag21aa', 'wcag143', 'cat.color', 'cat.aria'])
|
|
31
|
+
.disableRules(['color-contrast', 'color-contrast-enhanced'])
|
|
32
|
+
.analyze();
|
|
33
|
+
|
|
34
|
+
expect(results.violations).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { test, expect } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { PieButton } from '@/index';
|
|
3
|
+
import { BUTTON_SIZE, BUTTON_VARIANT } from '@/defs';
|
|
4
|
+
|
|
5
|
+
const sizes = Object.values(BUTTON_SIZE);
|
|
6
|
+
const variants = Object.values(BUTTON_VARIANT);
|
|
7
|
+
const disabledStates = [true, false];
|
|
8
|
+
|
|
9
|
+
variants.forEach(variant => {
|
|
10
|
+
test(`should render - ${variant}`, async ({ mount }) => {
|
|
11
|
+
|
|
12
|
+
for (const size of sizes) {
|
|
13
|
+
for (const isDisabled of disabledStates) {
|
|
14
|
+
const component = await mount(PieButton,
|
|
15
|
+
{
|
|
16
|
+
props: {
|
|
17
|
+
size,
|
|
18
|
+
variant,
|
|
19
|
+
disabled: isDisabled
|
|
20
|
+
},
|
|
21
|
+
slots: {
|
|
22
|
+
default: `Hello, ${size} ${variant} Button!`
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await expect(component).toContainText(`Hello, ${size} ${variant} Button!`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('should emit an event when clicked', async ({ mount }) => {
|
|
33
|
+
const messages: string[] = [];
|
|
34
|
+
const component = await mount(PieButton,
|
|
35
|
+
{
|
|
36
|
+
props: {
|
|
37
|
+
size: BUTTON_SIZE.LARGE,
|
|
38
|
+
variant: BUTTON_VARIANT.PRIMARY
|
|
39
|
+
},
|
|
40
|
+
slots: {
|
|
41
|
+
default: 'Click me!'
|
|
42
|
+
},
|
|
43
|
+
on: {
|
|
44
|
+
CustomEvent: (data: string) => messages.push(data),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await component.click();
|
|
49
|
+
|
|
50
|
+
expect(messages).toEqual(['WC event dispatched'])
|
|
51
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { test } from '@sand4rt/experimental-ct-web';
|
|
2
|
+
import { PieButton } from '@/index';
|
|
3
|
+
import percySnapshot from '@percy/playwright'
|
|
4
|
+
import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from '@/defs';
|
|
5
|
+
|
|
6
|
+
const sizes = Object.values(BUTTON_SIZE);
|
|
7
|
+
const variants = Object.values(BUTTON_VARIANT);
|
|
8
|
+
const disabledStates = [true, false];
|
|
9
|
+
|
|
10
|
+
variants.forEach(variant => {
|
|
11
|
+
test(`should render - ${variant}`, async ({ page, mount }) => {
|
|
12
|
+
|
|
13
|
+
for (const size of sizes) {
|
|
14
|
+
for (const isDisabled of disabledStates) {
|
|
15
|
+
await mount(PieButton,
|
|
16
|
+
{
|
|
17
|
+
props: {
|
|
18
|
+
type: BUTTON_TYPE.BUTTON,
|
|
19
|
+
size,
|
|
20
|
+
variant,
|
|
21
|
+
disabled: isDisabled
|
|
22
|
+
},
|
|
23
|
+
slots: {
|
|
24
|
+
default: `Hello, ${size} ${variant} Button!`
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
await percySnapshot(page, `PIE Button - ${variant}`);
|
|
30
|
+
});
|
|
31
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "ES2022",
|
|
5
|
+
"lib": ["es2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"inlineSources": true,
|
|
10
|
+
"outDir": "./compiled",
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"paths": {
|
|
13
|
+
"@/*": ["./src/*"]
|
|
14
|
+
},
|
|
15
|
+
"rootDir": ".",
|
|
16
|
+
"strict": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noImplicitAny": true,
|
|
22
|
+
"noImplicitThis": true,
|
|
23
|
+
"moduleResolution": "node",
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"experimentalDecorators": true,
|
|
26
|
+
"forceConsistentCasingInFileNames": true
|
|
27
|
+
},
|
|
28
|
+
"include": ["src/**/*.ts","./declaration.d.ts", "test/**/*.ts"],
|
|
29
|
+
"exclude": []
|
|
30
|
+
}
|