@justeattakeaway/pie-link 0.11.2 → 0.12.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 +5 -89
- package/dist/index.js +50 -68
- package/dist/react.js +10 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,15 +8,6 @@
|
|
|
8
8
|
</a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
# Table of Contents
|
|
12
|
-
|
|
13
|
-
1. [Introduction](#pie-link)
|
|
14
|
-
2. [Installation](#installation)
|
|
15
|
-
3. [Importing the component](#importing-the-component)
|
|
16
|
-
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
-
5. [Props](#props)
|
|
18
|
-
6. [Contributing](#contributing)
|
|
19
|
-
|
|
20
11
|
## pie-link
|
|
21
12
|
|
|
22
13
|
`pie-link` is a Web Component built using the Lit library.
|
|
@@ -36,89 +27,14 @@ $ npm i @justeattakeaway/pie-link
|
|
|
36
27
|
$ yarn add @justeattakeaway/pie-link
|
|
37
28
|
```
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Importing the component
|
|
43
|
-
|
|
44
|
-
#### JavaScript
|
|
45
|
-
```js
|
|
46
|
-
// Default – for Native JS Applications, Vue, Angular, Svelte, etc.
|
|
47
|
-
import { PieLink } from '@justeattakeaway/pie-link';
|
|
48
|
-
|
|
49
|
-
// If you don't need to reference the imported object, you can simply
|
|
50
|
-
// import the module which registers the component as a custom element.
|
|
51
|
-
import '@justeattakeaway/pie-link';
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
#### React
|
|
55
|
-
```js
|
|
56
|
-
// React
|
|
57
|
-
// For React, you will need to import our React-specific component build
|
|
58
|
-
// which wraps the web component using @lit/react
|
|
59
|
-
import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
> [!NOTE]
|
|
63
|
-
> When using the React version of the component, please make sure to also
|
|
64
|
-
> include React as a [peer dependency](#peer-dependencies) in your project.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Peer Dependencies
|
|
68
|
-
|
|
69
|
-
> [!IMPORTANT]
|
|
70
|
-
> 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.
|
|
71
|
-
|
|
72
|
-
## Props
|
|
73
|
-
|
|
74
|
-
| Property | Type | Default | Description |
|
|
75
|
-
| ------------- | --------- | ----------- | ---------------------------------------------------------------------------------------------------- |
|
|
76
|
-
| tag | `String` | `a` | The rendered HTML element of the link, one of `tags` – `a`, `button` |
|
|
77
|
-
| variant | `String` | `default` | Variant of the link, one of `variants` – `default`, `high-visibility`, `inverse` |
|
|
78
|
-
| size | `String` | `medium` | Size of the link, one of `sizes` – `medium`, `small` |
|
|
79
|
-
| underline | `String` | `default` | The underline behaviour of the link, one of `underlineTypes` – `default`, `reversed`. The `reverse` type can only be used if `isStandalone` is set to `true` |
|
|
80
|
-
| href | `String` | `undefined` | Native html `href` attribute |
|
|
81
|
-
| rel | `String` | `undefined` | Native html `rel` attribute |
|
|
82
|
-
| target | `String` | `undefined` | Native html `target` attribute |
|
|
83
|
-
| type | `String` | `submit` | Native html `type` attribute if the tag is set to `button` |
|
|
84
|
-
| isBold | `Boolean` | `false` | If `true`, sets the link text bold |
|
|
85
|
-
| isStandalone | `Boolean` | `false` | If `true`, sets the link as a block element |
|
|
86
|
-
| hasVisited | `Boolean` | `false` | If `true`, the link will apply the styles for the visited state |
|
|
87
|
-
| iconPlacement | `String` | `leading` | Icon placements of the icon slot, if provided, one of `iconPlacements` - `leading`, `trailing`. Can only be used if `isStandalone` is `true` |
|
|
88
|
-
| aria | `object` | `undefined` | The ARIA labels used for the link. |
|
|
89
|
-
|
|
90
|
-
In your markup or JSX, you can then use these to set the properties for the `pie-link` component:
|
|
91
|
-
|
|
92
|
-
```html
|
|
93
|
-
<!-- Native HTML -->
|
|
94
|
-
<pie-link></pie-link>
|
|
95
|
-
|
|
96
|
-
<!-- JSX -->
|
|
97
|
-
<PieLink></PieLink>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Slots
|
|
30
|
+
## Documentation
|
|
101
31
|
|
|
102
|
-
|
|
103
|
-
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
104
|
-
| Default slot | The default slot is used to pass text into the link component. |
|
|
105
|
-
| icon | Used to pass in an icon to the link component. The icon placement can be controlled via the `iconPlacement` prop and we recommend using `pie-icons-webc` for defining this icon, but this can also accept an SVG icon. |
|
|
32
|
+
Visit [Link | PIE Design System](https://pie.design/components/link/overview) to view more information on this component.
|
|
106
33
|
|
|
107
|
-
|
|
34
|
+
## Questions
|
|
108
35
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
```html
|
|
112
|
-
<!--
|
|
113
|
-
Note that pie-link and the icons that you want to use will need to be imported as components into your application.
|
|
114
|
-
See the `pie-icons-webc` README for more info on importing these icons.
|
|
115
|
-
-->
|
|
116
|
-
<pie-link>
|
|
117
|
-
<icon-plus-circle slot="icon"></icon-plus-circle>
|
|
118
|
-
Search
|
|
119
|
-
</pie-link>
|
|
120
|
-
```
|
|
36
|
+
Please head to [FAQs | PIE Design System](https://pie.design/support/contact-us/) to see our FAQs and get in touch.
|
|
121
37
|
|
|
122
38
|
## Contributing
|
|
123
39
|
|
|
124
|
-
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).
|
|
40
|
+
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.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as u, LitElement as f, html as c, nothing as o } from "lit";
|
|
2
2
|
import { property as i } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
t.includes(f) ? this[c] = f : (console.error(
|
|
11
|
-
`<${o}> Invalid value "${f}" provided for property "${a}".`,
|
|
12
|
-
`Must be one of: ${t.join(" | ")}.`,
|
|
13
|
-
`Falling back to default value: "${r}"`
|
|
14
|
-
), this[c] = r);
|
|
15
|
-
},
|
|
16
|
-
configurable: !0
|
|
17
|
-
});
|
|
3
|
+
import { validPropertyValues as a, defineCustomElement as k } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
const g = `.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)}
|
|
5
|
+
`, y = ["default", "high-visibility", "inverse"], m = ["small", "medium"], b = ["leading", "trailing"], x = ["a", "button"], $ = ["submit", "button", "reset", "menu"], S = ["default", "reversed"];
|
|
6
|
+
var z = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (p, e, s, d) => {
|
|
7
|
+
for (var r = d > 1 ? void 0 : d ? B(e, s) : e, h = p.length - 1, v; h >= 0; h--)
|
|
8
|
+
(v = p[h]) && (r = (d ? v(e, s, r) : v(r)) || r);
|
|
9
|
+
return d && r && z(e, s, r), r;
|
|
18
10
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
const 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)}
|
|
23
|
-
`, m = ["default", "high-visibility", "inverse"], b = ["small", "medium"], $ = ["leading", "trailing"], x = ["a", "button"], z = ["submit", "button", "reset", "menu"], S = ["default", "reversed"];
|
|
24
|
-
var P = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (o, t, r, h) => {
|
|
25
|
-
for (var s = h > 1 ? void 0 : h ? B(t, r) : t, a = o.length - 1, c; a >= 0; a--)
|
|
26
|
-
(c = o[a]) && (s = (h ? c(t, r, s) : c(s)) || s);
|
|
27
|
-
return h && s && P(t, r, s), s;
|
|
28
|
-
};
|
|
29
|
-
const d = "pie-link";
|
|
30
|
-
class e extends g {
|
|
11
|
+
const l = "pie-link";
|
|
12
|
+
class t extends f {
|
|
31
13
|
constructor() {
|
|
32
14
|
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";
|
|
33
15
|
}
|
|
@@ -37,12 +19,12 @@ class e extends g {
|
|
|
37
19
|
* @private
|
|
38
20
|
*/
|
|
39
21
|
renderContent() {
|
|
40
|
-
const { iconPlacement:
|
|
41
|
-
return
|
|
22
|
+
const { iconPlacement: e, isStandalone: s } = this;
|
|
23
|
+
return c`
|
|
42
24
|
<span class="c-link-content">
|
|
43
|
-
${
|
|
25
|
+
${s && e === "leading" ? c`<slot name="icon"></slot>` : o}
|
|
44
26
|
<slot></slot>
|
|
45
|
-
${
|
|
27
|
+
${s && e === "trailing" ? c`<slot name="icon"></slot>` : o}
|
|
46
28
|
</span>`;
|
|
47
29
|
}
|
|
48
30
|
/**
|
|
@@ -51,8 +33,8 @@ class e extends g {
|
|
|
51
33
|
* @private
|
|
52
34
|
*/
|
|
53
35
|
renderButton() {
|
|
54
|
-
var
|
|
55
|
-
return
|
|
36
|
+
var e;
|
|
37
|
+
return c`
|
|
56
38
|
<button
|
|
57
39
|
data-test-id="pie-link"
|
|
58
40
|
class="c-link"
|
|
@@ -63,8 +45,8 @@ class e extends g {
|
|
|
63
45
|
?isBold=${this.isBold}
|
|
64
46
|
?isStandalone=${this.isStandalone}
|
|
65
47
|
?hasVisited=${this.hasVisited}
|
|
66
|
-
type=${this.type ||
|
|
67
|
-
aria-label=${((
|
|
48
|
+
type=${this.type || o}
|
|
49
|
+
aria-label=${((e = this.aria) == null ? void 0 : e.label) || o}>
|
|
68
50
|
${this.renderContent()}
|
|
69
51
|
</button>`;
|
|
70
52
|
}
|
|
@@ -74,8 +56,8 @@ class e extends g {
|
|
|
74
56
|
* @private
|
|
75
57
|
*/
|
|
76
58
|
renderAnchor() {
|
|
77
|
-
var
|
|
78
|
-
return
|
|
59
|
+
var e;
|
|
60
|
+
return c`
|
|
79
61
|
<a
|
|
80
62
|
data-test-id="pie-link"
|
|
81
63
|
class="c-link"
|
|
@@ -86,10 +68,10 @@ class e extends g {
|
|
|
86
68
|
?isBold=${this.isBold}
|
|
87
69
|
?isStandalone=${this.isStandalone}
|
|
88
70
|
?hasVisited=${this.hasVisited}
|
|
89
|
-
href=${this.href ||
|
|
90
|
-
target=${this.target ||
|
|
91
|
-
rel=${this.rel ||
|
|
92
|
-
aria-label=${((
|
|
71
|
+
href=${this.href || o}
|
|
72
|
+
target=${this.target || o}
|
|
73
|
+
rel=${this.rel || o}
|
|
74
|
+
aria-label=${((e = this.aria) == null ? void 0 : e.label) || o}>
|
|
93
75
|
${this.renderContent()}
|
|
94
76
|
</a>`;
|
|
95
77
|
}
|
|
@@ -97,59 +79,59 @@ class e extends g {
|
|
|
97
79
|
return this.tag === "button" ? this.renderButton() : this.renderAnchor();
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
|
-
|
|
82
|
+
t.styles = u(g);
|
|
101
83
|
n([
|
|
102
84
|
i(),
|
|
103
|
-
|
|
104
|
-
],
|
|
85
|
+
a(l, x, "a")
|
|
86
|
+
], t.prototype, "tag", 2);
|
|
105
87
|
n([
|
|
106
88
|
i({ type: String }),
|
|
107
|
-
|
|
108
|
-
],
|
|
89
|
+
a(l, y, "default")
|
|
90
|
+
], t.prototype, "variant", 2);
|
|
109
91
|
n([
|
|
110
92
|
i({ type: String }),
|
|
111
|
-
|
|
112
|
-
],
|
|
93
|
+
a(l, m, "medium")
|
|
94
|
+
], t.prototype, "size", 2);
|
|
113
95
|
n([
|
|
114
96
|
i({ type: String }),
|
|
115
|
-
|
|
116
|
-
],
|
|
97
|
+
a(l, S, "default")
|
|
98
|
+
], t.prototype, "underline", 2);
|
|
117
99
|
n([
|
|
118
100
|
i({ type: String }),
|
|
119
|
-
|
|
120
|
-
],
|
|
101
|
+
a(l, b, "leading")
|
|
102
|
+
], t.prototype, "iconPlacement", 2);
|
|
121
103
|
n([
|
|
122
104
|
i({ type: String, reflect: !0 })
|
|
123
|
-
],
|
|
105
|
+
], t.prototype, "href", 2);
|
|
124
106
|
n([
|
|
125
107
|
i({ type: String, reflect: !0 })
|
|
126
|
-
],
|
|
108
|
+
], t.prototype, "target", 2);
|
|
127
109
|
n([
|
|
128
110
|
i({ type: String, reflect: !0 })
|
|
129
|
-
],
|
|
111
|
+
], t.prototype, "rel", 2);
|
|
130
112
|
n([
|
|
131
113
|
i({ type: Boolean })
|
|
132
|
-
],
|
|
114
|
+
], t.prototype, "isBold", 2);
|
|
133
115
|
n([
|
|
134
116
|
i({ type: Boolean })
|
|
135
|
-
],
|
|
117
|
+
], t.prototype, "isStandalone", 2);
|
|
136
118
|
n([
|
|
137
119
|
i({ type: Boolean })
|
|
138
|
-
],
|
|
120
|
+
], t.prototype, "hasVisited", 2);
|
|
139
121
|
n([
|
|
140
122
|
i(),
|
|
141
|
-
|
|
142
|
-
],
|
|
123
|
+
a(l, $, "submit")
|
|
124
|
+
], t.prototype, "type", 2);
|
|
143
125
|
n([
|
|
144
126
|
i({ type: Object })
|
|
145
|
-
],
|
|
146
|
-
k(
|
|
127
|
+
], t.prototype, "aria", 2);
|
|
128
|
+
k(l, t);
|
|
147
129
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
130
|
+
t as PieLink,
|
|
131
|
+
$ as buttonTypes,
|
|
132
|
+
b as iconPlacements,
|
|
133
|
+
m as sizes,
|
|
152
134
|
x as tags,
|
|
153
135
|
S as underlineTypes,
|
|
154
|
-
|
|
136
|
+
y as variants
|
|
155
137
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { createComponent as i } from "@lit/react";
|
|
3
3
|
import { PieLink as t } from "./index.js";
|
|
4
|
-
import { buttonTypes as
|
|
4
|
+
import { buttonTypes as l, iconPlacements as k, sizes as P, tags as f, underlineTypes as L, variants as y } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
6
|
import "lit/decorators.js";
|
|
7
|
-
|
|
7
|
+
import "@justeattakeaway/pie-webc-core";
|
|
8
|
+
const s = i({
|
|
8
9
|
displayName: "PieLink",
|
|
9
10
|
elementClass: t,
|
|
10
11
|
react: e,
|
|
@@ -12,11 +13,11 @@ const m = i({
|
|
|
12
13
|
events: {}
|
|
13
14
|
});
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
s as PieLink,
|
|
17
|
+
l as buttonTypes,
|
|
18
|
+
k as iconPlacements,
|
|
19
|
+
P as sizes,
|
|
20
|
+
f as tags,
|
|
21
|
+
L as underlineTypes,
|
|
22
|
+
y as variants
|
|
22
23
|
};
|
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.12.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.7.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "0.13.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"extends": "../../../package.json"
|