@justeattakeaway/pie-link 0.4.0 → 0.6.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 +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +40 -41
- package/dist/react.d.ts +5 -3
- package/dist/react.js +15 -16
- package/package.json +3 -3
- package/src/defs.ts +4 -2
- package/src/index.ts +12 -6
- package/src/link.scss +10 -5
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
62
62
|
| tag | `String` | `a` | The rendered HTML element of the link, one of `tags` – `a`, `button` |
|
|
63
63
|
| variant | `String` | `default` | Variant of the link, one of `variants` – `default`, `high-visibility`, `inverse` |
|
|
64
64
|
| size | `String` | `medium` | Size of the link, one of `sizes` – `medium`, `small` |
|
|
65
|
-
| underline | `String` | `default` | The underline behavior of the link, one of `underlineTypes` – `default`, `reversed` |
|
|
65
|
+
| underline | `String` | `default` | The underline behavior of the link, one of `underlineTypes` – `default`, `reversed`. The `reverse` type can only be used if `isStandalone` is set to `true` |
|
|
66
66
|
| href | `String` | `undefined` | Native html `href` attribute |
|
|
67
67
|
| rel | `String` | `undefined` | Native html `rel` attribute |
|
|
68
68
|
| target | `String` | `undefined` | Native html `target` attribute |
|
|
@@ -70,7 +70,7 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
70
70
|
| isBold | `Boolean` | `false` | If `true`, sets the link text bold |
|
|
71
71
|
| isStandalone | `Boolean` | `false` | If `true`, sets the link as a block element |
|
|
72
72
|
| hasVisited | `Boolean` | `false` | If `true`, the link will apply the styles for the visited state |
|
|
73
|
-
| iconPlacement | `String` | `leading` | Icon placements of the icon slot, if provided, one of `iconPlacements` - `leading`, `trailing` |
|
|
73
|
+
| iconPlacement | `String` | `leading` | Icon placements of the icon slot, if provided, one of `iconPlacements` - `leading`, `trailing`. Can only be used if `isStandalone` is `true` |
|
|
74
74
|
| aria | `object` | `undefined` | The ARIA labels used for the link. |
|
|
75
75
|
|
|
76
76
|
In your markup or JSX, you can then use these to set the properties for the `pie-link` component:
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,8 @@ export declare interface LinkProps {
|
|
|
28
28
|
*/
|
|
29
29
|
size: typeof sizes[number];
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Defines what underline behavior the link should have, such as default or reversed.
|
|
32
|
+
* The `reversed` type can only be used if the link is a block element (isStandalone = true)
|
|
32
33
|
*/
|
|
33
34
|
underline: typeof underlineTypes[number];
|
|
34
35
|
/**
|
|
@@ -56,7 +57,8 @@ export declare interface LinkProps {
|
|
|
56
57
|
*/
|
|
57
58
|
hasVisited: boolean;
|
|
58
59
|
/**
|
|
59
|
-
* The placement of the icon slot, if provided, such as leading or trailing
|
|
60
|
+
* The placement of the icon slot, if provided, such as leading or trailing.
|
|
61
|
+
* Will only apply if the link is a block element (isStandalone = true)
|
|
60
62
|
*/
|
|
61
63
|
iconPlacement?: typeof iconPlacements[number];
|
|
62
64
|
/**
|
|
@@ -85,7 +87,7 @@ export declare class PieLink extends LitElement implements LinkProps {
|
|
|
85
87
|
aria: AriaProps;
|
|
86
88
|
/**
|
|
87
89
|
* Renders the link content.
|
|
88
|
-
*
|
|
90
|
+
* Icons are only shown in block elements
|
|
89
91
|
* @private
|
|
90
92
|
*/
|
|
91
93
|
private renderContent;
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as k, LitElement as g, html as v, nothing as a } from "lit";
|
|
2
2
|
import { property as i } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(o, r, {
|
|
3
|
+
const d = (p, t, o) => function(r, s) {
|
|
4
|
+
const l = `#${s}`;
|
|
5
|
+
Object.defineProperty(r, s, {
|
|
7
6
|
get() {
|
|
8
7
|
return this[l];
|
|
9
8
|
},
|
|
10
|
-
set(
|
|
9
|
+
set(u) {
|
|
11
10
|
const f = this[l];
|
|
12
|
-
t.includes(
|
|
13
|
-
`<${
|
|
11
|
+
t.includes(u) ? this[l] = u : (console.error(
|
|
12
|
+
`<${p}> Invalid value "${u}" provided for property "${s}".`,
|
|
14
13
|
`Must be one of: ${t.join(" | ")}.`,
|
|
15
|
-
`Falling back to default value: "${
|
|
16
|
-
), this[l] =
|
|
14
|
+
`Falling back to default value: "${o}"`
|
|
15
|
+
), this[l] = o), this.requestUpdate(s, f);
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
|
-
}, 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;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[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)}.c-link[underline=
|
|
20
|
-
`, m = ["default", "high-visibility", "inverse"], b = ["small", "medium"], $ = ["leading", "trailing"], x = ["a", "button"],
|
|
21
|
-
var B = Object.defineProperty, P = Object.getOwnPropertyDescriptor, n = (
|
|
22
|
-
for (var
|
|
23
|
-
(l =
|
|
24
|
-
return
|
|
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}.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;
|
|
25
24
|
};
|
|
26
|
-
const
|
|
27
|
-
class e extends
|
|
25
|
+
const c = "pie-link";
|
|
26
|
+
class e extends g {
|
|
28
27
|
constructor() {
|
|
29
28
|
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";
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
31
|
* Renders the link content.
|
|
33
|
-
*
|
|
32
|
+
* Icons are only shown in block elements
|
|
34
33
|
* @private
|
|
35
34
|
*/
|
|
36
35
|
renderContent() {
|
|
37
|
-
const { iconPlacement: t } = this;
|
|
38
|
-
return
|
|
36
|
+
const { iconPlacement: t, isStandalone: o } = this;
|
|
37
|
+
return v`
|
|
39
38
|
<span class="c-link-content">
|
|
40
|
-
${t === "leading" ?
|
|
39
|
+
${o && t === "leading" ? v`<slot name="icon"></slot>` : a}
|
|
41
40
|
<slot></slot>
|
|
42
|
-
${t === "trailing" ?
|
|
41
|
+
${o && t === "trailing" ? v`<slot name="icon"></slot>` : a}
|
|
43
42
|
</span>`;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
@@ -49,7 +48,7 @@ class e extends k {
|
|
|
49
48
|
*/
|
|
50
49
|
renderButton() {
|
|
51
50
|
var t;
|
|
52
|
-
return
|
|
51
|
+
return v`
|
|
53
52
|
<button
|
|
54
53
|
data-test-id="pie-link"
|
|
55
54
|
class="c-link"
|
|
@@ -60,8 +59,8 @@ class e extends k {
|
|
|
60
59
|
?isBold=${this.isBold}
|
|
61
60
|
?isStandalone=${this.isStandalone}
|
|
62
61
|
?hasVisited=${this.hasVisited}
|
|
63
|
-
type=${this.type ||
|
|
64
|
-
aria-label=${((t = this.aria) == null ? void 0 : t.label) ||
|
|
62
|
+
type=${this.type || a}
|
|
63
|
+
aria-label=${((t = this.aria) == null ? void 0 : t.label) || a}>
|
|
65
64
|
${this.renderContent()}
|
|
66
65
|
</button>`;
|
|
67
66
|
}
|
|
@@ -72,7 +71,7 @@ class e extends k {
|
|
|
72
71
|
*/
|
|
73
72
|
renderAnchor() {
|
|
74
73
|
var t;
|
|
75
|
-
return
|
|
74
|
+
return v`
|
|
76
75
|
<a
|
|
77
76
|
data-test-id="pie-link"
|
|
78
77
|
class="c-link"
|
|
@@ -83,10 +82,10 @@ class e extends k {
|
|
|
83
82
|
?isBold=${this.isBold}
|
|
84
83
|
?isStandalone=${this.isStandalone}
|
|
85
84
|
?hasVisited=${this.hasVisited}
|
|
86
|
-
href=${this.href ||
|
|
87
|
-
target=${this.target ||
|
|
88
|
-
rel=${this.rel ||
|
|
89
|
-
aria-label=${((t = this.aria) == null ? void 0 : t.label) ||
|
|
85
|
+
href=${this.href || a}
|
|
86
|
+
target=${this.target || a}
|
|
87
|
+
rel=${this.rel || a}
|
|
88
|
+
aria-label=${((t = this.aria) == null ? void 0 : t.label) || a}>
|
|
90
89
|
${this.renderContent()}
|
|
91
90
|
</a>`;
|
|
92
91
|
}
|
|
@@ -94,26 +93,26 @@ class e extends k {
|
|
|
94
93
|
return this.tag === "button" ? this.renderButton() : this.renderAnchor();
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
|
-
e.styles =
|
|
96
|
+
e.styles = k(y);
|
|
98
97
|
n([
|
|
99
98
|
i(),
|
|
100
|
-
d(
|
|
99
|
+
d(c, x, "a")
|
|
101
100
|
], e.prototype, "tag", 2);
|
|
102
101
|
n([
|
|
103
102
|
i({ type: String }),
|
|
104
|
-
d(
|
|
103
|
+
d(c, m, "default")
|
|
105
104
|
], e.prototype, "variant", 2);
|
|
106
105
|
n([
|
|
107
106
|
i({ type: String }),
|
|
108
|
-
d(
|
|
107
|
+
d(c, b, "medium")
|
|
109
108
|
], e.prototype, "size", 2);
|
|
110
109
|
n([
|
|
111
110
|
i({ type: String }),
|
|
112
|
-
d(
|
|
111
|
+
d(c, z, "default")
|
|
113
112
|
], e.prototype, "underline", 2);
|
|
114
113
|
n([
|
|
115
114
|
i({ type: String }),
|
|
116
|
-
d(
|
|
115
|
+
d(c, $, "leading")
|
|
117
116
|
], e.prototype, "iconPlacement", 2);
|
|
118
117
|
n([
|
|
119
118
|
i({ type: String, reflect: !0 })
|
|
@@ -135,18 +134,18 @@ n([
|
|
|
135
134
|
], e.prototype, "hasVisited", 2);
|
|
136
135
|
n([
|
|
137
136
|
i(),
|
|
138
|
-
d(
|
|
137
|
+
d(c, S, "submit")
|
|
139
138
|
], e.prototype, "type", 2);
|
|
140
139
|
n([
|
|
141
140
|
i({ type: Object })
|
|
142
141
|
], e.prototype, "aria", 2);
|
|
143
|
-
customElements.define(
|
|
142
|
+
customElements.define(c, e);
|
|
144
143
|
export {
|
|
145
144
|
e as PieLink,
|
|
146
|
-
|
|
145
|
+
S as buttonTypes,
|
|
147
146
|
$ as iconPlacements,
|
|
148
147
|
b as sizes,
|
|
149
148
|
x as tags,
|
|
150
|
-
|
|
149
|
+
z as underlineTypes,
|
|
151
150
|
m as variants
|
|
152
151
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -29,7 +29,8 @@ export declare interface LinkProps {
|
|
|
29
29
|
*/
|
|
30
30
|
size: typeof sizes[number];
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Defines what underline behavior the link should have, such as default or reversed.
|
|
33
|
+
* The `reversed` type can only be used if the link is a block element (isStandalone = true)
|
|
33
34
|
*/
|
|
34
35
|
underline: typeof underlineTypes[number];
|
|
35
36
|
/**
|
|
@@ -57,7 +58,8 @@ export declare interface LinkProps {
|
|
|
57
58
|
*/
|
|
58
59
|
hasVisited: boolean;
|
|
59
60
|
/**
|
|
60
|
-
* The placement of the icon slot, if provided, such as leading or trailing
|
|
61
|
+
* The placement of the icon slot, if provided, such as leading or trailing.
|
|
62
|
+
* Will only apply if the link is a block element (isStandalone = true)
|
|
61
63
|
*/
|
|
62
64
|
iconPlacement?: typeof iconPlacements[number];
|
|
63
65
|
/**
|
|
@@ -88,7 +90,7 @@ declare class PieLink_2 extends LitElement implements LinkProps {
|
|
|
88
90
|
aria: AriaProps;
|
|
89
91
|
/**
|
|
90
92
|
* Renders the link content.
|
|
91
|
-
*
|
|
93
|
+
* Icons are only shown in block elements
|
|
92
94
|
* @private
|
|
93
95
|
*/
|
|
94
96
|
private renderContent;
|
package/dist/react.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import * as L from "react";
|
|
2
2
|
import { PieLink as g } from "./index.js";
|
|
3
|
-
import { buttonTypes as
|
|
3
|
+
import { buttonTypes as j, iconPlacements as D, sizes as G, tags as O, underlineTypes as S, variants as _ } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/decorators.js";
|
|
6
|
-
import "lit/decorators/property.js";
|
|
7
6
|
/**
|
|
8
7
|
* @license
|
|
9
8
|
* Copyright 2018 Google LLC
|
|
10
9
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
10
|
*/
|
|
12
|
-
const E = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), P = (
|
|
11
|
+
const E = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), P = (d, l, p, m, h) => {
|
|
13
12
|
const n = h == null ? void 0 : h[l];
|
|
14
|
-
n === void 0 ||
|
|
13
|
+
n === void 0 || p === m ? p == null && l in HTMLElement.prototype ? d.removeAttribute(l) : d[l] = p : ((s, t, u) => {
|
|
15
14
|
let o = w.get(s);
|
|
16
15
|
o === void 0 && w.set(s, o = /* @__PURE__ */ new Map());
|
|
17
16
|
let a = o.get(t);
|
|
18
17
|
u !== void 0 ? a === void 0 ? (o.set(t, a = { handleEvent: u }), s.addEventListener(t, a)) : a.handleEvent = u : a !== void 0 && (o.delete(t), s.removeEventListener(t, a));
|
|
19
|
-
})(
|
|
18
|
+
})(d, n, p);
|
|
20
19
|
};
|
|
21
|
-
function b(
|
|
20
|
+
function b(d = window.React, l, p, m, h) {
|
|
22
21
|
let n, s, t;
|
|
23
22
|
if (l === void 0) {
|
|
24
|
-
const r =
|
|
23
|
+
const r = d;
|
|
25
24
|
({ tagName: s, elementClass: t, events: m, displayName: h } = r), n = r.react;
|
|
26
25
|
} else
|
|
27
|
-
n =
|
|
26
|
+
n = d, t = p, s = l;
|
|
28
27
|
const u = n.Component, o = n.createElement, a = new Set(Object.keys(m ?? {}));
|
|
29
28
|
class f extends u {
|
|
30
29
|
constructor() {
|
|
@@ -58,7 +57,7 @@ function b(p = window.React, l, d, m, h) {
|
|
|
58
57
|
const N = n.forwardRef((r, e) => o(f, { ...r, _$Gl: e }, r == null ? void 0 : r.children));
|
|
59
58
|
return N.displayName = f.displayName, N;
|
|
60
59
|
}
|
|
61
|
-
const
|
|
60
|
+
const R = b({
|
|
62
61
|
displayName: "PieLink",
|
|
63
62
|
elementClass: g,
|
|
64
63
|
react: L,
|
|
@@ -66,11 +65,11 @@ const T = b({
|
|
|
66
65
|
events: {}
|
|
67
66
|
});
|
|
68
67
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
R as PieLink,
|
|
69
|
+
j as buttonTypes,
|
|
70
|
+
D as iconPlacements,
|
|
71
|
+
G as sizes,
|
|
72
|
+
O as tags,
|
|
73
|
+
S as underlineTypes,
|
|
74
|
+
_ as variants
|
|
76
75
|
};
|
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.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"author": "JustEatTakeaway.com - Design System Web Team",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@justeattakeaway/pie-components-config": "
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.4.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@justeattakeaway/pie-webc-core": "
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "0.9.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"extends": "../../../package.json"
|
package/src/defs.ts
CHANGED
|
@@ -27,7 +27,8 @@ export interface LinkProps {
|
|
|
27
27
|
*/
|
|
28
28
|
size: typeof sizes[number];
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Defines what underline behavior the link should have, such as default or reversed.
|
|
31
|
+
* The `reversed` type can only be used if the link is a block element (isStandalone = true)
|
|
31
32
|
*/
|
|
32
33
|
underline: typeof underlineTypes[number];
|
|
33
34
|
/**
|
|
@@ -55,7 +56,8 @@ export interface LinkProps {
|
|
|
55
56
|
*/
|
|
56
57
|
hasVisited: boolean;
|
|
57
58
|
/**
|
|
58
|
-
* The placement of the icon slot, if provided, such as leading or trailing
|
|
59
|
+
* The placement of the icon slot, if provided, such as leading or trailing.
|
|
60
|
+
* Will only apply if the link is a block element (isStandalone = true)
|
|
59
61
|
*/
|
|
60
62
|
iconPlacement?: typeof iconPlacements[number];
|
|
61
63
|
/**
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,14 @@ import { property } from 'lit/decorators.js';
|
|
|
5
5
|
import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
6
6
|
import styles from './link.scss?inline';
|
|
7
7
|
import {
|
|
8
|
-
LinkProps,
|
|
9
|
-
|
|
8
|
+
LinkProps,
|
|
9
|
+
variants,
|
|
10
|
+
sizes,
|
|
11
|
+
iconPlacements,
|
|
12
|
+
tags,
|
|
13
|
+
buttonTypes,
|
|
14
|
+
underlineTypes,
|
|
15
|
+
type AriaProps,
|
|
10
16
|
} from './defs';
|
|
11
17
|
|
|
12
18
|
// Valid values available to consumers
|
|
@@ -67,16 +73,16 @@ export class PieLink extends LitElement implements LinkProps {
|
|
|
67
73
|
|
|
68
74
|
/**
|
|
69
75
|
* Renders the link content.
|
|
70
|
-
*
|
|
76
|
+
* Icons are only shown in block elements
|
|
71
77
|
* @private
|
|
72
78
|
*/
|
|
73
79
|
private renderContent (): TemplateResult {
|
|
74
|
-
const { iconPlacement } = this;
|
|
80
|
+
const { iconPlacement, isStandalone } = this;
|
|
75
81
|
return html`
|
|
76
82
|
<span class="c-link-content">
|
|
77
|
-
${iconPlacement === 'leading' ? html`<slot name="icon"></slot>` : nothing}
|
|
83
|
+
${isStandalone && iconPlacement === 'leading' ? html`<slot name="icon"></slot>` : nothing}
|
|
78
84
|
<slot></slot>
|
|
79
|
-
${iconPlacement === 'trailing' ? html`<slot name="icon"></slot>` : nothing}
|
|
85
|
+
${isStandalone && iconPlacement === 'trailing' ? html`<slot name="icon"></slot>` : nothing}
|
|
80
86
|
</span>`;
|
|
81
87
|
}
|
|
82
88
|
|
package/src/link.scss
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
--link-text-color: var(--dt-color-content-link);
|
|
21
21
|
--link-text-decoration: var(--dt-font-style-underline);
|
|
22
22
|
--link-icon-size: 16px;
|
|
23
|
+
--link-icon-offset-top: var(--dt-spacing-a);
|
|
23
24
|
|
|
24
25
|
display: inline-block;
|
|
25
26
|
font-family: var(--link-font-family);
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
text-decoration: var(--link-text-decoration);
|
|
31
32
|
cursor: pointer;
|
|
32
33
|
|
|
34
|
+
@include link-interactive-states('default');
|
|
35
|
+
|
|
36
|
+
|
|
33
37
|
&[tag='a'] {
|
|
34
38
|
/* Same as default styles */
|
|
35
39
|
}
|
|
@@ -57,6 +61,7 @@
|
|
|
57
61
|
&[size='small'] {
|
|
58
62
|
--link-font-size: #{p.font-size(--dt-font-size-14)};
|
|
59
63
|
--link-line-height: calc(var(--dt-font-size-14-line-height) * 1px);
|
|
64
|
+
--link-icon-offset-top: 2px;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
&[size='medium'] {
|
|
@@ -65,11 +70,9 @@
|
|
|
65
70
|
|
|
66
71
|
&[underline='default'] {
|
|
67
72
|
/* Same as default styles */
|
|
68
|
-
|
|
69
|
-
@include link-interactive-states('default');
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
&[underline='reversed'] {
|
|
75
|
+
&[underline='reversed'][isStandalone] {
|
|
73
76
|
--link-text-decoration: none;
|
|
74
77
|
|
|
75
78
|
@include link-interactive-states('reversed');
|
|
@@ -92,7 +95,9 @@
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
&:focus-visible {
|
|
95
|
-
|
|
98
|
+
outline: none;
|
|
99
|
+
border-radius: 2px;
|
|
100
|
+
box-shadow: 0 0 0 2px var(--dt-color-focus-inner), 0 0 0 4px var(--dt-color-focus-outer);
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
|
|
@@ -104,7 +109,7 @@
|
|
|
104
109
|
::slotted(.c-pieIcon),
|
|
105
110
|
::slotted(svg) {
|
|
106
111
|
display: inline-flex;
|
|
107
|
-
margin-block-start: var(--
|
|
112
|
+
margin-block-start: var(--link-icon-offset-top);
|
|
108
113
|
height: var(--link-icon-size);
|
|
109
114
|
width: var(--link-icon-size);
|
|
110
115
|
}
|