@justeattakeaway/pie-link 0.0.0 → 0.1.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 +6 -6
- package/CHANGELOG.md +7 -0
- package/README.md +10 -4
- package/dist/index.js +81 -7
- package/dist/react.js +5 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/packages/components/pie-link/src/defs.d.ts +33 -0
- package/dist/types/packages/components/pie-link/src/defs.d.ts.map +1 -0
- package/dist/types/{src → packages/components/pie-link/src}/index.d.ts +9 -2
- package/dist/types/packages/components/pie-link/src/index.d.ts.map +1 -0
- package/dist/types/react.d.ts +1 -1
- package/package.json +1 -1
- package/src/defs.ts +33 -3
- package/src/index.ts +46 -3
- package/src/link.scss +46 -0
- package/test/component/pie-link.spec.ts +11 -3
- package/test/visual/pie-link.spec.ts +47 -7
- package/dist/types/src/defs.d.ts +0 -3
- package/dist/types/src/defs.d.ts.map +0 -1
- package/dist/types/src/index.d.ts.map +0 -1
- /package/dist/types/{src → packages/components/pie-link/src}/react.d.ts +0 -0
- /package/dist/types/{src → packages/components/pie-link/src}/react.d.ts.map +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[2:03:47 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
|
|
9
|
-
[2mdist/[22m[36mreact.js [39m[1m[
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 3.27 kB[22m[1m[22m[2m │ gzip: 1.24 kB[22m
|
|
9
|
+
[2mdist/[22m[36mreact.js [39m[1m[2m59.04 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
|
-
[32m✓ built in
|
|
13
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
12
|
+
[32m✓ built in 45.82s[39m
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 43014ms.
|
|
14
14
|
[39m
|
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -57,9 +57,15 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
57
57
|
|
|
58
58
|
## Props
|
|
59
59
|
|
|
60
|
-
| Property
|
|
61
|
-
|
|
62
|
-
|
|
|
60
|
+
| Property | Type | Default | Description |
|
|
61
|
+
| ------------ | ----------- | ------------- | --------------------------------------------------------------------------- |
|
|
62
|
+
| variant | `String` | `default` | Variant of the link, one of variants – default, high-visibility or inverse |
|
|
63
|
+
| size | `String` | `medium` | Size of the link, one of `sizes` – `medium`, `small` |
|
|
64
|
+
| href | `String` | `undefined` | Native html `href` attribute |
|
|
65
|
+
| rel | `String` | `undefined` | Native html `rel` attribute |
|
|
66
|
+
| target | `String` | `undefined` | Native html `target` attribute |
|
|
67
|
+
| isBold | `Boolean` | `false` | If `true`, sets the link text bold |
|
|
68
|
+
| isStandalone | `Boolean` | `false` | If `true`, sets the link as a block element |
|
|
63
69
|
|
|
64
70
|
In your markup or JSX, you can then use these to set the properties for the `pie-link` component:
|
|
65
71
|
|
|
@@ -103,4 +109,4 @@ Under scripts `test:visual` replace the environment variable with the below:
|
|
|
103
109
|
|
|
104
110
|
```bash
|
|
105
111
|
PERCY_TOKEN_PIE_LINK=abcde
|
|
106
|
-
```
|
|
112
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,86 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { unsafeCSS as k, LitElement as g, html as m } from "lit";
|
|
2
|
+
import { property as s } from "lit/decorators.js";
|
|
3
|
+
import { ifDefined as d } from "lit/directives/if-defined.js";
|
|
4
|
+
import "lit/decorators/property.js";
|
|
5
|
+
const v = (c, n, r) => function(t, e) {
|
|
6
|
+
const i = `#${e}`;
|
|
7
|
+
Object.defineProperty(t, e, {
|
|
8
|
+
get() {
|
|
9
|
+
return this[i];
|
|
10
|
+
},
|
|
11
|
+
set(f) {
|
|
12
|
+
const h = this[i];
|
|
13
|
+
n.includes(f) ? this[i] = f : (console.error(
|
|
14
|
+
`<${c}> Invalid value "${f}" provided for property "${e}".`,
|
|
15
|
+
`Must be one of: ${n.join(" | ")}.`,
|
|
16
|
+
`Falling back to default value: "${r}"`
|
|
17
|
+
), this[i] = r), this.requestUpdate(e, h);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}, u = `.c-link{--link-font-family: var(--dt-font-interactive-m-family);--link-font-size: calc(var(--dt-font-size-16) * 1px);--link-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--link-font-weight: var(--dt-font-weight-regular);--link-text-color: var(--dt-color-content-link);--link-text-decoration: var(--dt-font-style-underline);font-family:var(--link-font-family);font-size:var(--link-font-size);line-height:var(--link-line-height);font-weight:var(--link-font-weight);color:var(--link-text-color);text-decoration:var(--link-text-decoration);cursor:pointer}.c-link[variant=high-visibility]{--link-text-color: var(--dt-color-content-link-distinct)}.c-link[variant=inverse]{--link-text-color: var(--dt-color-content-link-inverse)}.c-link[size=small]{--link-font-size: calc(var(--dt-font-size-14) * 1px);--link-line-height: calc(var(--dt-font-size-14-line-height) * 1px)}.c-link[isBold]{--link-font-weight: var(--dt-font-weight-bold)}.c-link[isStandalone]{display:block}
|
|
21
|
+
`, y = ["default", "high-visibility", "inverse"], z = ["small", "medium"];
|
|
22
|
+
var x = Object.defineProperty, S = Object.getOwnPropertyDescriptor, a = (c, n, r, l) => {
|
|
23
|
+
for (var t = l > 1 ? void 0 : l ? S(n, r) : n, e = c.length - 1, i; e >= 0; e--)
|
|
24
|
+
(i = c[e]) && (t = (l ? i(n, r, t) : i(t)) || t);
|
|
25
|
+
return l && t && x(n, r, t), t;
|
|
26
|
+
};
|
|
27
|
+
const p = "pie-link";
|
|
28
|
+
class o extends g {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments), this.variant = "default", this.size = "medium", this.isBold = !1, this.isStandalone = !1;
|
|
31
|
+
}
|
|
4
32
|
render() {
|
|
5
|
-
|
|
33
|
+
const {
|
|
34
|
+
variant: n,
|
|
35
|
+
size: r,
|
|
36
|
+
href: l,
|
|
37
|
+
target: t,
|
|
38
|
+
rel: e,
|
|
39
|
+
isBold: i,
|
|
40
|
+
isStandalone: f
|
|
41
|
+
} = this;
|
|
42
|
+
return m`
|
|
43
|
+
<a
|
|
44
|
+
data-test-id="pie-link"
|
|
45
|
+
class="c-link"
|
|
46
|
+
variant=${n}
|
|
47
|
+
size=${r}
|
|
48
|
+
href=${d(l)}
|
|
49
|
+
target=${d(t)}
|
|
50
|
+
rel=${d(e)}
|
|
51
|
+
?isBold=${i}
|
|
52
|
+
?isStandalone=${f}>
|
|
53
|
+
<slot></slot>
|
|
54
|
+
</a>`;
|
|
6
55
|
}
|
|
7
56
|
}
|
|
8
|
-
|
|
9
|
-
|
|
57
|
+
o.styles = k(u);
|
|
58
|
+
a([
|
|
59
|
+
s({ type: String }),
|
|
60
|
+
v(p, y, "default")
|
|
61
|
+
], o.prototype, "variant", 2);
|
|
62
|
+
a([
|
|
63
|
+
s({ type: String }),
|
|
64
|
+
v(p, z, "medium")
|
|
65
|
+
], o.prototype, "size", 2);
|
|
66
|
+
a([
|
|
67
|
+
s({ type: String, reflect: !0 })
|
|
68
|
+
], o.prototype, "href", 2);
|
|
69
|
+
a([
|
|
70
|
+
s({ type: String, reflect: !0 })
|
|
71
|
+
], o.prototype, "target", 2);
|
|
72
|
+
a([
|
|
73
|
+
s({ type: String, reflect: !0 })
|
|
74
|
+
], o.prototype, "rel", 2);
|
|
75
|
+
a([
|
|
76
|
+
s({ type: Boolean })
|
|
77
|
+
], o.prototype, "isBold", 2);
|
|
78
|
+
a([
|
|
79
|
+
s({ type: Boolean })
|
|
80
|
+
], o.prototype, "isStandalone", 2);
|
|
81
|
+
customElements.define(p, o);
|
|
10
82
|
export {
|
|
11
|
-
|
|
83
|
+
o as PieLink,
|
|
84
|
+
z as sizes,
|
|
85
|
+
y as variants
|
|
12
86
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { PieLink as Lr } from "./index.js";
|
|
2
2
|
import "lit";
|
|
3
|
+
import "lit/decorators.js";
|
|
4
|
+
import "lit/directives/if-defined.js";
|
|
5
|
+
import "lit/decorators/property.js";
|
|
3
6
|
function Nr(g, c) {
|
|
4
7
|
for (var U = 0; U < c.length; U++) {
|
|
5
8
|
const k = c[U];
|
|
@@ -1577,7 +1580,7 @@ function zr(g = window.React, c, U, k, A) {
|
|
|
1577
1580
|
const J = T.forwardRef((D, P) => N(H, { ...D, _$Gl: P }, D == null ? void 0 : D.children));
|
|
1578
1581
|
return J.displayName = H.displayName, J;
|
|
1579
1582
|
}
|
|
1580
|
-
const
|
|
1583
|
+
const Qr = zr({
|
|
1581
1584
|
displayName: "PieLink",
|
|
1582
1585
|
elementClass: Lr,
|
|
1583
1586
|
react: Vr,
|
|
@@ -1585,5 +1588,5 @@ const qr = zr({
|
|
|
1585
1588
|
events: {}
|
|
1586
1589
|
});
|
|
1587
1590
|
export {
|
|
1588
|
-
|
|
1591
|
+
Qr as PieLink
|
|
1589
1592
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src/index'
|
|
1
|
+
export * from './packages/components/pie-link/src/index'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const variants: readonly ["default", "high-visibility", "inverse"];
|
|
2
|
+
export declare const sizes: readonly ["small", "medium"];
|
|
3
|
+
export interface LinkProps {
|
|
4
|
+
/**
|
|
5
|
+
* What style variant the link should be such as default, high-visibility or inverse.
|
|
6
|
+
*/
|
|
7
|
+
variant?: typeof variants[number];
|
|
8
|
+
/**
|
|
9
|
+
* What size the link should be.
|
|
10
|
+
*/
|
|
11
|
+
size?: typeof sizes[number];
|
|
12
|
+
/**
|
|
13
|
+
* The URL that the hyperlink should point to
|
|
14
|
+
*/
|
|
15
|
+
href?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Where to display the linked URL such as _self, _blank, _parent or _top
|
|
18
|
+
*/
|
|
19
|
+
target?: string;
|
|
20
|
+
/**
|
|
21
|
+
* What the relationship of the linked URL is
|
|
22
|
+
*/
|
|
23
|
+
rel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* When true, the link text will be bold.
|
|
26
|
+
*/
|
|
27
|
+
isBold?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* When true, the link will be treated as a block box
|
|
30
|
+
*/
|
|
31
|
+
isStandalone?: boolean;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,oDAAqD,CAAC;AAC3E,eAAO,MAAM,KAAK,8BAA+B,CAAC;AAElD,MAAM,WAAW,SAAS;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import { LinkProps } from './defs';
|
|
3
|
-
export { type LinkProps, };
|
|
2
|
+
import { LinkProps, variants, sizes } from './defs';
|
|
3
|
+
export { type LinkProps, variants, sizes, };
|
|
4
4
|
declare const componentSelector = "pie-link";
|
|
5
5
|
export declare class PieLink extends LitElement implements LinkProps {
|
|
6
|
+
variant: LinkProps['variant'];
|
|
7
|
+
size: LinkProps['size'];
|
|
8
|
+
href?: string;
|
|
9
|
+
target?: string;
|
|
10
|
+
rel?: string;
|
|
11
|
+
isBold: boolean;
|
|
12
|
+
isStandalone: boolean;
|
|
6
13
|
render(): import("lit-html").TemplateResult<1>;
|
|
7
14
|
static styles: import("lit").CSSResult;
|
|
8
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAKlD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAGpD,OAAO,EACH,KAAK,SAAS,EACd,QAAQ,EACR,KAAK,GACR,CAAC;AAEF,QAAA,MAAM,iBAAiB,aAAa,CAAC;AAErC,qBAAa,OAAQ,SAAQ,UAAW,YAAW,SAAS;IAGjD,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAAa;IAI1C,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAY;IAGnC,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,MAAM,UAAS;IAGf,YAAY,UAAS;IAE5B,MAAM;IAqBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAChC;CACJ"}
|
package/dist/types/react.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src/react'
|
|
1
|
+
export * from './packages/components/pie-link/src/react'
|
package/package.json
CHANGED
package/src/defs.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const variants = ['default', 'high-visibility', 'inverse'] as const;
|
|
2
|
+
export const sizes = ['small', 'medium'] as const;
|
|
3
|
+
|
|
4
|
+
export interface LinkProps {
|
|
5
|
+
/**
|
|
6
|
+
* What style variant the link should be such as default, high-visibility or inverse.
|
|
7
|
+
*/
|
|
8
|
+
variant?: typeof variants[number];
|
|
9
|
+
/**
|
|
10
|
+
* What size the link should be.
|
|
11
|
+
*/
|
|
12
|
+
size?: typeof sizes[number];
|
|
13
|
+
/**
|
|
14
|
+
* The URL that the hyperlink should point to
|
|
15
|
+
*/
|
|
16
|
+
href?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Where to display the linked URL such as _self, _blank, _parent or _top
|
|
19
|
+
*/
|
|
20
|
+
target?: string;
|
|
21
|
+
/**
|
|
22
|
+
* What the relationship of the linked URL is
|
|
23
|
+
*/
|
|
24
|
+
rel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* When true, the link text will be bold.
|
|
27
|
+
*/
|
|
28
|
+
isBold?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* When true, the link will be treated as a block box
|
|
31
|
+
*/
|
|
32
|
+
isStandalone?: boolean;
|
|
33
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,18 +1,61 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
-
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
3
5
|
import styles from './link.scss?inline';
|
|
4
|
-
import { LinkProps } from './defs';
|
|
6
|
+
import { LinkProps, variants, sizes } from './defs';
|
|
5
7
|
|
|
6
8
|
// Valid values available to consumers
|
|
7
9
|
export {
|
|
8
10
|
type LinkProps,
|
|
11
|
+
variants,
|
|
12
|
+
sizes,
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
const componentSelector = 'pie-link';
|
|
12
16
|
|
|
13
17
|
export class PieLink extends LitElement implements LinkProps {
|
|
18
|
+
@property({ type: String })
|
|
19
|
+
@validPropertyValues(componentSelector, variants, 'default')
|
|
20
|
+
public variant: LinkProps['variant'] = 'default';
|
|
21
|
+
|
|
22
|
+
@property({ type: String })
|
|
23
|
+
@validPropertyValues(componentSelector, sizes, 'medium')
|
|
24
|
+
public size: LinkProps['size'] = 'medium';
|
|
25
|
+
|
|
26
|
+
@property({ type: String, reflect: true })
|
|
27
|
+
public href?: string;
|
|
28
|
+
|
|
29
|
+
@property({ type: String, reflect: true })
|
|
30
|
+
public target?: string;
|
|
31
|
+
|
|
32
|
+
@property({ type: String, reflect: true })
|
|
33
|
+
public rel?: string;
|
|
34
|
+
|
|
35
|
+
@property({ type: Boolean })
|
|
36
|
+
public isBold = false;
|
|
37
|
+
|
|
38
|
+
@property({ type: Boolean })
|
|
39
|
+
public isStandalone = false;
|
|
40
|
+
|
|
14
41
|
render () {
|
|
15
|
-
|
|
42
|
+
const {
|
|
43
|
+
variant, size, href, target, rel, isBold, isStandalone,
|
|
44
|
+
} = this;
|
|
45
|
+
|
|
46
|
+
return html`
|
|
47
|
+
<a
|
|
48
|
+
data-test-id="pie-link"
|
|
49
|
+
class="c-link"
|
|
50
|
+
variant=${variant}
|
|
51
|
+
size=${size}
|
|
52
|
+
href=${ifDefined(href)}
|
|
53
|
+
target=${ifDefined(target)}
|
|
54
|
+
rel=${ifDefined(rel)}
|
|
55
|
+
?isBold=${isBold}
|
|
56
|
+
?isStandalone=${isStandalone}>
|
|
57
|
+
<slot></slot>
|
|
58
|
+
</a>`;
|
|
16
59
|
}
|
|
17
60
|
|
|
18
61
|
// Renders a `CSSResult` generated from SCSS by Vite
|
package/src/link.scss
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
1
|
@use '@justeattakeaway/pie-css/scss' as p;
|
|
2
|
+
|
|
3
|
+
.c-link {
|
|
4
|
+
--link-font-family: var(--dt-font-interactive-m-family);
|
|
5
|
+
--link-font-size: #{p.font-size(--dt-font-size-16)};
|
|
6
|
+
--link-line-height: calc(var(--dt-font-size-16-line-height) * 1px);
|
|
7
|
+
--link-font-weight: var(--dt-font-weight-regular);
|
|
8
|
+
--link-text-color: var(--dt-color-content-link);
|
|
9
|
+
--link-text-decoration: var(--dt-font-style-underline);
|
|
10
|
+
|
|
11
|
+
font-family: var(--link-font-family);
|
|
12
|
+
font-size: var(--link-font-size);
|
|
13
|
+
line-height: var(--link-line-height);
|
|
14
|
+
font-weight: var(--link-font-weight);
|
|
15
|
+
color: var(--link-text-color);
|
|
16
|
+
text-decoration: var(--link-text-decoration);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
|
|
19
|
+
&[variant='default'] {
|
|
20
|
+
/* Same as default styles */
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&[variant='high-visibility'] {
|
|
24
|
+
--link-text-color: var(--dt-color-content-link-distinct);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&[variant='inverse'] {
|
|
28
|
+
--link-text-color: var(--dt-color-content-link-inverse);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&[size='small'] {
|
|
32
|
+
--link-font-size: #{p.font-size(--dt-font-size-14)};
|
|
33
|
+
--link-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&[size='medium'] {
|
|
37
|
+
/* Same as default styles */
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&[isBold] {
|
|
41
|
+
--link-font-weight: var(--dt-font-weight-bold);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[isStandalone] {
|
|
45
|
+
display: block;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -4,17 +4,25 @@ import { PieLink, LinkProps } from '@/index';
|
|
|
4
4
|
|
|
5
5
|
const componentSelector = '[data-test-id="pie-link"]';
|
|
6
6
|
|
|
7
|
+
const props: LinkProps = {
|
|
8
|
+
href: '#',
|
|
9
|
+
target: '_blank',
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
test.describe('PieLink - Component tests', () => {
|
|
8
|
-
test('should
|
|
13
|
+
test('should be visible', async ({ mount, page }) => {
|
|
9
14
|
// Arrange
|
|
10
15
|
await mount(PieLink, {
|
|
11
|
-
props
|
|
16
|
+
props,
|
|
17
|
+
slots: { default: 'Link!' },
|
|
12
18
|
});
|
|
13
19
|
|
|
14
20
|
// Act
|
|
15
21
|
const link = page.locator(componentSelector);
|
|
16
22
|
|
|
17
23
|
// Assert
|
|
18
|
-
expect(link).toBeVisible();
|
|
24
|
+
await expect(link).toBeVisible();
|
|
25
|
+
await expect(link).toHaveAttribute('href', '#');
|
|
26
|
+
await expect(link).toHaveAttribute('target', '_blank');
|
|
19
27
|
});
|
|
20
28
|
});
|
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
|
|
2
2
|
import { test } from '@sand4rt/experimental-ct-web';
|
|
3
3
|
import percySnapshot from '@percy/playwright';
|
|
4
|
-
import {
|
|
4
|
+
import type {
|
|
5
|
+
PropObject, WebComponentPropValues, WebComponentTestInput,
|
|
6
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/defs.ts';
|
|
7
|
+
import {
|
|
8
|
+
getAllPropCombinations, splitCombinationsByPropertyValue,
|
|
9
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/get-all-prop-combos.ts';
|
|
10
|
+
import {
|
|
11
|
+
createTestWebComponent,
|
|
12
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/rendering.ts';
|
|
13
|
+
import {
|
|
14
|
+
WebComponentTestWrapper,
|
|
15
|
+
} from '@justeattakeaway/pie-webc-testing/src/helpers/components/web-component-test-wrapper/WebComponentTestWrapper.ts';
|
|
16
|
+
import { variants, sizes } from '@/defs';
|
|
17
|
+
import { PieLink } from '@/index';
|
|
5
18
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
const props: PropObject = {
|
|
20
|
+
variant: variants,
|
|
21
|
+
size: sizes,
|
|
22
|
+
href: 'pie.design',
|
|
23
|
+
target: '_blank',
|
|
24
|
+
isBold: [true, false],
|
|
25
|
+
isStandalone: [true, false],
|
|
26
|
+
};
|
|
11
27
|
|
|
12
|
-
|
|
28
|
+
const renderTestPieLink = (propVals: WebComponentPropValues) => `<pie-link variant="${propVals.variant}" size="${propVals.size}" href="${propVals.href}" target="${propVals.target}" ${propVals.isBold ? 'isBold' : ''} ${propVals.isStandalone ? 'isStandalone' : ''} />`;
|
|
29
|
+
|
|
30
|
+
const componentPropsMatrix : WebComponentPropValues[] = getAllPropCombinations(props);
|
|
31
|
+
const componentPropsMatrixByVariant: Record<string, WebComponentPropValues[]> = splitCombinationsByPropertyValue(componentPropsMatrix, 'variant');
|
|
32
|
+
const componentVariants: string[] = Object.keys(componentPropsMatrixByVariant);
|
|
33
|
+
|
|
34
|
+
test.beforeEach(async ({ page, mount }) => {
|
|
35
|
+
await mount(PieLink, {});
|
|
36
|
+
await page.evaluate(() => {
|
|
37
|
+
const element : Element | null = document.querySelector('pie-link');
|
|
38
|
+
element?.remove();
|
|
13
39
|
});
|
|
14
40
|
});
|
|
41
|
+
|
|
42
|
+
componentVariants.forEach((variant) => test(`Render all prop variations for Variant: ${variant}`, async ({ page, mount }) => {
|
|
43
|
+
await Promise.all(componentPropsMatrixByVariant[variant].map(async (combo: WebComponentPropValues) => {
|
|
44
|
+
const testComponent: WebComponentTestInput = createTestWebComponent(combo, renderTestPieLink);
|
|
45
|
+
const propKeyValues = `size: ${testComponent.propValues.size}, isBold: ${testComponent.propValues.isBold}, isStandalone: ${testComponent.propValues.isStandalone}, href: ${testComponent.propValues.href}, target: ${testComponent.propValues.target}, target: ${testComponent.propValues.target}`;
|
|
46
|
+
|
|
47
|
+
await mount(
|
|
48
|
+
WebComponentTestWrapper,
|
|
49
|
+
{ props: { propKeyValues, darkMode: variant === 'inverse' } },
|
|
50
|
+
);
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
await percySnapshot(page, `PIE Link - Variant: ${variant}`);
|
|
54
|
+
}));
|
package/dist/types/src/defs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
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,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,EACH,KAAK,SAAS,GACjB,CAAC;AAEF,QAAA,MAAM,iBAAiB,aAAa,CAAC;AAErC,qBAAa,OAAQ,SAAQ,UAAW,YAAW,SAAS;IACxD,MAAM;IAKN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAChC;CACJ"}
|
|
File without changes
|
|
File without changes
|