@justeattakeaway/pie-link 0.9.0 → 0.11.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/README.md +4 -61
- package/dist/index.d.ts +1 -0
- package/dist/index.js +48 -44
- package/dist/react.d.ts +1 -0
- package/package.json +2 -2
- package/src/index.ts +3 -2
package/README.md
CHANGED
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
2. [Installation](#installation)
|
|
15
15
|
3. [Importing the component](#importing-the-component)
|
|
16
16
|
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
-
5. [
|
|
18
|
-
6. [
|
|
19
|
-
7. [Testing](#testing)
|
|
20
|
-
|
|
17
|
+
5. [Props](#props)
|
|
18
|
+
6. [Contributing](#contributing)
|
|
21
19
|
|
|
22
20
|
## pie-link
|
|
23
21
|
|
|
@@ -57,31 +55,6 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
57
55
|
> [!IMPORTANT]
|
|
58
56
|
> When using `pie-link`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
## Local development
|
|
62
|
-
|
|
63
|
-
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
yarn
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
To build the `pie-link` package, run the following command:
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
yarn build --filter=pie-link
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
yarn watch --filter=pie-link
|
|
79
|
-
|
|
80
|
-
# in a separate terminal tab, run
|
|
81
|
-
yarn dev --filter=pie-storybook
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
|
|
85
58
|
## Props
|
|
86
59
|
|
|
87
60
|
| Property | Type | Default | Description |
|
|
@@ -132,36 +105,6 @@ We recommend using `pie-icons-webc` when using the `icon` slot. Here is an examp
|
|
|
132
105
|
</pie-link>
|
|
133
106
|
```
|
|
134
107
|
|
|
135
|
-
##
|
|
136
|
-
|
|
137
|
-
### Browser tests
|
|
138
|
-
|
|
139
|
-
To run the browser tests, run the following command from the root of the monorepo:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
yarn test:browsers --filter=pie-link
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Visual tests
|
|
146
|
-
|
|
147
|
-
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
|
-
yarn test:visual --filter=pie-link
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
|
|
154
|
-
|
|
155
|
-
#### Setup via bash
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
export PERCY_TOKEN_PIE_LINK=abcde
|
|
159
|
-
```
|
|
108
|
+
## Contributing
|
|
160
109
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
Under scripts `test:visual` replace the environment variable with the below:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
PERCY_TOKEN_PIE_LINK=abcde
|
|
167
|
-
```
|
|
110
|
+
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as g, LitElement as k, html as u, nothing as c } from "lit";
|
|
2
2
|
import { property as i } from "lit/decorators.js";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
Object.defineProperty(r,
|
|
3
|
+
const p = (o, t, s) => function(r, l) {
|
|
4
|
+
const a = `#${l}`;
|
|
5
|
+
Object.defineProperty(r, l, {
|
|
6
6
|
get() {
|
|
7
|
-
return this[
|
|
7
|
+
return this[a];
|
|
8
8
|
},
|
|
9
|
-
set(
|
|
10
|
-
const
|
|
11
|
-
t.includes(
|
|
12
|
-
`<${
|
|
9
|
+
set(f) {
|
|
10
|
+
const v = this[a];
|
|
11
|
+
t.includes(f) ? this[a] = f : (console.error(
|
|
12
|
+
`<${o}> Invalid value "${f}" provided for property "${l}".`,
|
|
13
13
|
`Must be one of: ${t.join(" | ")}.`,
|
|
14
|
-
`Falling back to default value: "${
|
|
15
|
-
), this[
|
|
14
|
+
`Falling back to default value: "${s}"`
|
|
15
|
+
), this[a] = s), this.requestUpdate(l, v);
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
}, y = `.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);--link-icon-size: 16px;--link-icon-offset-top: var(--dt-spacing-a);display:inline-block;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:hover,.c-link:active{--link-text-decoration: none}.c-link[tag=button]{outline:none;border:none;user-select:none;background:transparent;padding:0}.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);--link-icon-offset-top: 2px}.c-link[underline=reversed][isStandalone]{--link-text-decoration: none}.c-link[underline=reversed][isStandalone]:hover,.c-link[underline=reversed][isStandalone]:active{--link-text-decoration: var(--dt-font-style-underline)}.c-link[isBold]{--link-font-weight: var(--dt-font-weight-bold)}.c-link[isStandalone]{display:block;width:fit-content}.c-link[hasVisited]:visited{color:var(--dt-color-content-link-visited)}.c-link[hasVisited]:visited[variant=inverse]{color:var(--dt-color-content-link-visited-inverse)}.c-link:focus-visible{outline:none;border-radius:2px;box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer)}.c-link-content{display:flex;gap:var(--dt-spacing-a)}::slotted(.c-pieIcon),::slotted(svg){display:inline-flex;margin-block-start:var(--link-icon-offset-top);height:var(--link-icon-size);width:var(--link-icon-size)}
|
|
19
|
-
`, m = ["default", "high-visibility", "inverse"], b = ["small", "medium"], $ = ["leading", "trailing"], x = ["a", "button"], S = ["submit", "button", "reset", "menu"], z = ["default", "reversed"];
|
|
20
|
-
var B = Object.defineProperty, P = Object.getOwnPropertyDescriptor, n = (p, t, o, h) => {
|
|
21
|
-
for (var r = h > 1 ? void 0 : h ? P(t, o) : t, s = p.length - 1, l; s >= 0; s--)
|
|
22
|
-
(l = p[s]) && (r = (h ? l(t, o, r) : l(r)) || r);
|
|
23
|
-
return h && r && B(t, o, r), r;
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
function y(o, t) {
|
|
20
|
+
customElements.get(o) ? console.warn(`PIE Web Component: "${o}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(o, t);
|
|
21
|
+
}
|
|
22
|
+
const m = `.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);--link-icon-size: 16px;--link-icon-offset-top: var(--dt-spacing-a);display:inline-block;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:hover,.c-link:active{--link-text-decoration: none}.c-link[tag=button]{outline:none;border:none;user-select:none;background:transparent;padding:0}.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);--link-icon-offset-top: 2px}.c-link[underline=reversed][isStandalone]{--link-text-decoration: none}.c-link[underline=reversed][isStandalone]:hover,.c-link[underline=reversed][isStandalone]:active{--link-text-decoration: var(--dt-font-style-underline)}.c-link[isBold]{--link-font-weight: var(--dt-font-weight-bold)}.c-link[isStandalone]{display:block;width:fit-content}.c-link[hasVisited]:visited{color:var(--dt-color-content-link-visited)}.c-link[hasVisited]:visited[variant=inverse]{color:var(--dt-color-content-link-visited-inverse)}.c-link:focus-visible{outline:none;border-radius:2px;box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer)}.c-link-content{display:flex;gap:var(--dt-spacing-a)}::slotted(.c-pieIcon),::slotted(svg){display:inline-flex;margin-block-start:var(--link-icon-offset-top);height:var(--link-icon-size);width:var(--link-icon-size)}
|
|
23
|
+
`, b = ["default", "high-visibility", "inverse"], $ = ["small", "medium"], x = ["leading", "trailing"], z = ["a", "button"], S = ["submit", "button", "reset", "menu"], P = ["default", "reversed"];
|
|
24
|
+
var B = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (o, t, s, h) => {
|
|
25
|
+
for (var r = h > 1 ? void 0 : h ? w(t, s) : t, l = o.length - 1, a; l >= 0; l--)
|
|
26
|
+
(a = o[l]) && (r = (h ? a(t, s, r) : a(r)) || r);
|
|
27
|
+
return h && r && B(t, s, r), r;
|
|
28
|
+
};
|
|
29
|
+
const d = "pie-link";
|
|
30
|
+
class e extends k {
|
|
27
31
|
constructor() {
|
|
28
32
|
super(...arguments), this.tag = "a", this.variant = "default", this.size = "medium", this.underline = "default", this.iconPlacement = "leading", this.isBold = !1, this.isStandalone = !1, this.hasVisited = !1, this.type = "submit";
|
|
29
33
|
}
|
|
@@ -33,12 +37,12 @@ class e extends g {
|
|
|
33
37
|
* @private
|
|
34
38
|
*/
|
|
35
39
|
renderContent() {
|
|
36
|
-
const { iconPlacement: t, isStandalone:
|
|
37
|
-
return
|
|
40
|
+
const { iconPlacement: t, isStandalone: s } = this;
|
|
41
|
+
return u`
|
|
38
42
|
<span class="c-link-content">
|
|
39
|
-
${
|
|
43
|
+
${s && t === "leading" ? u`<slot name="icon"></slot>` : c}
|
|
40
44
|
<slot></slot>
|
|
41
|
-
${
|
|
45
|
+
${s && t === "trailing" ? u`<slot name="icon"></slot>` : c}
|
|
42
46
|
</span>`;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
@@ -48,7 +52,7 @@ class e extends g {
|
|
|
48
52
|
*/
|
|
49
53
|
renderButton() {
|
|
50
54
|
var t;
|
|
51
|
-
return
|
|
55
|
+
return u`
|
|
52
56
|
<button
|
|
53
57
|
data-test-id="pie-link"
|
|
54
58
|
class="c-link"
|
|
@@ -59,8 +63,8 @@ class e extends g {
|
|
|
59
63
|
?isBold=${this.isBold}
|
|
60
64
|
?isStandalone=${this.isStandalone}
|
|
61
65
|
?hasVisited=${this.hasVisited}
|
|
62
|
-
type=${this.type ||
|
|
63
|
-
aria-label=${((t = this.aria) == null ? void 0 : t.label) ||
|
|
66
|
+
type=${this.type || c}
|
|
67
|
+
aria-label=${((t = this.aria) == null ? void 0 : t.label) || c}>
|
|
64
68
|
${this.renderContent()}
|
|
65
69
|
</button>`;
|
|
66
70
|
}
|
|
@@ -71,7 +75,7 @@ class e extends g {
|
|
|
71
75
|
*/
|
|
72
76
|
renderAnchor() {
|
|
73
77
|
var t;
|
|
74
|
-
return
|
|
78
|
+
return u`
|
|
75
79
|
<a
|
|
76
80
|
data-test-id="pie-link"
|
|
77
81
|
class="c-link"
|
|
@@ -82,10 +86,10 @@ class e extends g {
|
|
|
82
86
|
?isBold=${this.isBold}
|
|
83
87
|
?isStandalone=${this.isStandalone}
|
|
84
88
|
?hasVisited=${this.hasVisited}
|
|
85
|
-
href=${this.href ||
|
|
86
|
-
target=${this.target ||
|
|
87
|
-
rel=${this.rel ||
|
|
88
|
-
aria-label=${((t = this.aria) == null ? void 0 : t.label) ||
|
|
89
|
+
href=${this.href || c}
|
|
90
|
+
target=${this.target || c}
|
|
91
|
+
rel=${this.rel || c}
|
|
92
|
+
aria-label=${((t = this.aria) == null ? void 0 : t.label) || c}>
|
|
89
93
|
${this.renderContent()}
|
|
90
94
|
</a>`;
|
|
91
95
|
}
|
|
@@ -93,26 +97,26 @@ class e extends g {
|
|
|
93
97
|
return this.tag === "button" ? this.renderButton() : this.renderAnchor();
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
|
-
e.styles =
|
|
100
|
+
e.styles = g(m);
|
|
97
101
|
n([
|
|
98
102
|
i(),
|
|
99
|
-
d
|
|
103
|
+
p(d, z, "a")
|
|
100
104
|
], e.prototype, "tag", 2);
|
|
101
105
|
n([
|
|
102
106
|
i({ type: String }),
|
|
103
|
-
d
|
|
107
|
+
p(d, b, "default")
|
|
104
108
|
], e.prototype, "variant", 2);
|
|
105
109
|
n([
|
|
106
110
|
i({ type: String }),
|
|
107
|
-
d
|
|
111
|
+
p(d, $, "medium")
|
|
108
112
|
], e.prototype, "size", 2);
|
|
109
113
|
n([
|
|
110
114
|
i({ type: String }),
|
|
111
|
-
d
|
|
115
|
+
p(d, P, "default")
|
|
112
116
|
], e.prototype, "underline", 2);
|
|
113
117
|
n([
|
|
114
118
|
i({ type: String }),
|
|
115
|
-
d
|
|
119
|
+
p(d, x, "leading")
|
|
116
120
|
], e.prototype, "iconPlacement", 2);
|
|
117
121
|
n([
|
|
118
122
|
i({ type: String, reflect: !0 })
|
|
@@ -134,18 +138,18 @@ n([
|
|
|
134
138
|
], e.prototype, "hasVisited", 2);
|
|
135
139
|
n([
|
|
136
140
|
i(),
|
|
137
|
-
d
|
|
141
|
+
p(d, S, "submit")
|
|
138
142
|
], e.prototype, "type", 2);
|
|
139
143
|
n([
|
|
140
144
|
i({ type: Object })
|
|
141
145
|
], e.prototype, "aria", 2);
|
|
142
|
-
|
|
146
|
+
y(d, e);
|
|
143
147
|
export {
|
|
144
148
|
e as PieLink,
|
|
145
149
|
S as buttonTypes,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
x as iconPlacements,
|
|
151
|
+
$ as sizes,
|
|
152
|
+
z as tags,
|
|
153
|
+
P as underlineTypes,
|
|
154
|
+
b as variants
|
|
151
155
|
};
|
package/dist/react.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-link",
|
|
3
3
|
"description": "PIE Design System Link built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@justeattakeaway/pie-components-config": "0.4.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "0.11.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
html, LitElement, unsafeCSS, nothing, TemplateResult,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { property } from 'lit/decorators.js';
|
|
5
|
-
import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
5
|
+
import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
6
6
|
import styles from './link.scss?inline';
|
|
7
7
|
import {
|
|
8
8
|
LinkProps,
|
|
@@ -21,6 +21,7 @@ export * from './defs';
|
|
|
21
21
|
const componentSelector = 'pie-link';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
+
* @tagname pie-link
|
|
24
25
|
* @slot icon - The icon slot
|
|
25
26
|
* @slot - Default slot
|
|
26
27
|
*/
|
|
@@ -144,7 +145,7 @@ export class PieLink extends LitElement implements LinkProps {
|
|
|
144
145
|
static styles = unsafeCSS(styles);
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
defineCustomElement(componentSelector, PieLink);
|
|
148
149
|
|
|
149
150
|
declare global {
|
|
150
151
|
interface HTMLElementTagNameMap {
|