@justeattakeaway/pie-card 0.19.7 → 0.20.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/custom-elements.json +8 -0
- package/dist/index.js +73 -74
- package/dist/react.js +14 -13
- package/package.json +3 -2
- package/src/card.scss +28 -28
- package/src/index.ts +12 -11
package/custom-elements.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { unsafeCSS as m, LitElement as y, html as u, nothing as v } from "lit";
|
|
2
|
+
import { classMap as p } from "lit/directives/class-map.js";
|
|
3
|
+
import { ifDefined as S } from "lit/directives/if-defined.js";
|
|
4
|
+
import { property as t } from "lit/decorators.js";
|
|
5
|
+
import { validPropertyValues as g, defineCustomElement as $ } from "@justeattakeaway/pie-webc-core";
|
|
6
|
+
const k = `.c-card.c-card--draggable{cursor:grab}.c-card.c-card--draggable:active{cursor:grabbing}*,*:after,*:before{box-sizing:inherit}.c-card{--card-bg-color: var(--dt-color-container-default);--card-color: var(--dt-color-content-default);--card-radius: var(--dt-radius-rounded-c);--card-border-color: transparent;display:block;position:relative;color:var(--card-color);background-color:var(--card-bg-color);border:1px solid var(--card-border-color);border-radius:var(--card-radius);cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;text-decoration:none}.c-card:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-card.c-card--disabled{--card-bg-color: var(--dt-color-disabled-01);cursor:not-allowed}.c-card.c-card--disabled ::slotted(*){color:var(--dt-color-content-disabled)}.c-card.c-card--disabled img{opacity:.5}.c-card.c-card--default{box-shadow:var(--dt-elevation-card)}.c-card.c-card--default:hover:not(.c-card--disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card.c-card--default:active:not(.c-card--disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card.c-card--outline{border-color:var(--dt-color-border-strong)}.c-card.c-card--outline:hover:not(.c-card--disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card.c-card--outline:active:not(.c-card--disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card.c-card--inverse{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);box-shadow:var(--dt-elevation-dark-card)}.c-card.c-card--inverse:hover:not(.c-card--disabled){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card.c-card--inverse:active:not(.c-card--disabled){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card.c-card--outline-inverse{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);border-color:var(--dt-color-border-inverse)}.c-card.c-card--outline-inverse:hover:not(.c-card--disabled){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card.c-card--outline-inverse:active:not(.c-card--disabled){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card.c-card--inverse.c-card--disabled,.c-card.c-card--outline-inverse.c-card--disabled{--card-bg-color: var(--dt-color-disabled-01-inverse)}
|
|
7
|
+
`, x = ["default", "outline", "inverse", "outline-inverse"], C = ["a", "button"], h = ["a", "b", "c", "d", "e", "f", "g"], P = h.flatMap((i) => [i, ...h.map((o) => `${i},${o}`)]), l = {
|
|
7
8
|
disabled: !1,
|
|
8
9
|
variant: "default",
|
|
9
10
|
isDraggable: !1,
|
|
10
11
|
tag: "button"
|
|
11
12
|
};
|
|
12
|
-
var D = Object.defineProperty,
|
|
13
|
-
for (var
|
|
14
|
-
(s = i[n]) && (
|
|
15
|
-
return
|
|
13
|
+
var D = Object.defineProperty, w = Object.getOwnPropertyDescriptor, d = (i, o, e, r) => {
|
|
14
|
+
for (var a = r > 1 ? void 0 : r ? w(o, e) : o, n = i.length - 1, s; n >= 0; n--)
|
|
15
|
+
(s = i[n]) && (a = (r ? s(o, e, a) : s(a)) || a);
|
|
16
|
+
return r && a && D(o, e, a), a;
|
|
16
17
|
};
|
|
17
18
|
const b = "pie-card";
|
|
18
|
-
class
|
|
19
|
+
class c extends y {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments), this.tag = l.tag, this.variant = l.variant, this.disabled = l.disabled, this.isDraggable = l.isDraggable;
|
|
21
22
|
}
|
|
@@ -24,24 +25,21 @@ class t extends h {
|
|
|
24
25
|
*
|
|
25
26
|
* @private
|
|
26
27
|
*/
|
|
27
|
-
renderAnchor() {
|
|
28
|
-
var
|
|
28
|
+
renderAnchor(o) {
|
|
29
|
+
var r;
|
|
29
30
|
const e = this.generatePaddingCSS();
|
|
30
|
-
return
|
|
31
|
+
return u`
|
|
31
32
|
<a
|
|
32
|
-
class="
|
|
33
|
+
class="${p(o)}"
|
|
33
34
|
data-test-id="pie-card"
|
|
34
|
-
tag=${this.tag || "a"}
|
|
35
|
-
?isDraggable="${this.isDraggable}"
|
|
36
|
-
variant=${this.variant || "default"}
|
|
37
35
|
?disabled=${this.disabled}
|
|
38
36
|
href=${this.href || ""}
|
|
39
37
|
target=${this.target || v}
|
|
40
38
|
rel=${this.rel || v}
|
|
41
39
|
role="link"
|
|
42
|
-
aria-label=${((
|
|
40
|
+
aria-label=${((r = this.aria) == null ? void 0 : r.label) || v}
|
|
43
41
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
44
|
-
style=${
|
|
42
|
+
style=${S(e)}>
|
|
45
43
|
<slot></slot>
|
|
46
44
|
</div>
|
|
47
45
|
</a>`;
|
|
@@ -57,75 +55,76 @@ class t extends h {
|
|
|
57
55
|
* @private
|
|
58
56
|
*/
|
|
59
57
|
generatePaddingCSS() {
|
|
60
|
-
const { padding:
|
|
61
|
-
let
|
|
62
|
-
if (!
|
|
58
|
+
const { padding: o } = this;
|
|
59
|
+
let e = "";
|
|
60
|
+
if (!o)
|
|
63
61
|
return "";
|
|
64
|
-
const
|
|
65
|
-
return
|
|
62
|
+
const r = o.split(",").map((a) => a.trim()).filter((a) => /^[a-g]$/.test(a));
|
|
63
|
+
return r.length > 0 && r.length <= 2 && (e += `var(--dt-spacing-${r[0]})`, r.length > 1 && (e += ` var(--dt-spacing-${r[1]})`)), e ? `padding: ${e}` : "";
|
|
66
64
|
}
|
|
67
65
|
render() {
|
|
68
66
|
const {
|
|
69
|
-
variant:
|
|
70
|
-
disabled:
|
|
71
|
-
tag:
|
|
72
|
-
aria:
|
|
67
|
+
variant: o,
|
|
68
|
+
disabled: e,
|
|
69
|
+
tag: r,
|
|
70
|
+
aria: a,
|
|
73
71
|
isDraggable: n
|
|
74
|
-
} = this, s = this.generatePaddingCSS()
|
|
75
|
-
|
|
72
|
+
} = this, s = this.generatePaddingCSS(), f = {
|
|
73
|
+
"c-card": !0,
|
|
74
|
+
[`c-card--${o}`]: !0,
|
|
75
|
+
"c-card--draggable": n,
|
|
76
|
+
"c-card--disabled": e
|
|
77
|
+
};
|
|
78
|
+
return r === "a" ? this.renderAnchor(f) : u`
|
|
76
79
|
<div
|
|
77
|
-
class="
|
|
80
|
+
class="${p(f)}"
|
|
78
81
|
data-test-id="pie-card"
|
|
79
|
-
tag=${o || "button"}
|
|
80
|
-
?isDraggable="${n}"
|
|
81
|
-
variant=${e || "default"}
|
|
82
|
-
?disabled=${a}
|
|
83
82
|
role="button"
|
|
84
83
|
tabindex="0"
|
|
85
|
-
aria-label=${(
|
|
86
|
-
aria-disabled=${
|
|
84
|
+
aria-label=${(a == null ? void 0 : a.label) || v}
|
|
85
|
+
aria-disabled=${e ? "true" : "false"}
|
|
87
86
|
style=${s || ""}>
|
|
88
87
|
<slot></slot>
|
|
89
88
|
</div>
|
|
90
89
|
</div>`;
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
g(b,
|
|
97
|
-
],
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
g(b,
|
|
101
|
-
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
],
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
],
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
g(b,
|
|
123
|
-
],
|
|
124
|
-
|
|
92
|
+
c.styles = m(k);
|
|
93
|
+
d([
|
|
94
|
+
t(),
|
|
95
|
+
g(b, C, l.tag)
|
|
96
|
+
], c.prototype, "tag", 2);
|
|
97
|
+
d([
|
|
98
|
+
t(),
|
|
99
|
+
g(b, x, l.variant)
|
|
100
|
+
], c.prototype, "variant", 2);
|
|
101
|
+
d([
|
|
102
|
+
t({ type: String, reflect: !0 })
|
|
103
|
+
], c.prototype, "href", 2);
|
|
104
|
+
d([
|
|
105
|
+
t({ type: String, reflect: !0 })
|
|
106
|
+
], c.prototype, "target", 2);
|
|
107
|
+
d([
|
|
108
|
+
t({ type: String, reflect: !0 })
|
|
109
|
+
], c.prototype, "rel", 2);
|
|
110
|
+
d([
|
|
111
|
+
t({ type: Boolean })
|
|
112
|
+
], c.prototype, "disabled", 2);
|
|
113
|
+
d([
|
|
114
|
+
t({ type: Object })
|
|
115
|
+
], c.prototype, "aria", 2);
|
|
116
|
+
d([
|
|
117
|
+
t({ type: Boolean })
|
|
118
|
+
], c.prototype, "isDraggable", 2);
|
|
119
|
+
d([
|
|
120
|
+
t({ type: String }),
|
|
121
|
+
g(b, P, void 0)
|
|
122
|
+
], c.prototype, "padding", 2);
|
|
123
|
+
$(b, c);
|
|
125
124
|
export {
|
|
126
|
-
|
|
125
|
+
c as PieCard,
|
|
127
126
|
l as defaultProps,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
P as paddingValues,
|
|
128
|
+
C as tags,
|
|
129
|
+
x as variants
|
|
131
130
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { PieCard as
|
|
4
|
-
import { defaultProps as
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
import { createComponent as a } from "@lit/react";
|
|
3
|
+
import { PieCard as e } from "./index.js";
|
|
4
|
+
import { defaultProps as f, paddingValues as l, tags as g, variants as u } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
|
+
import "lit/directives/class-map.js";
|
|
6
7
|
import "lit/directives/if-defined.js";
|
|
7
8
|
import "lit/decorators.js";
|
|
8
9
|
import "@justeattakeaway/pie-webc-core";
|
|
9
|
-
const t =
|
|
10
|
+
const t = a({
|
|
10
11
|
displayName: "PieCard",
|
|
11
|
-
elementClass:
|
|
12
|
-
react:
|
|
12
|
+
elementClass: e,
|
|
13
|
+
react: r,
|
|
13
14
|
tagName: "pie-card",
|
|
14
15
|
events: {}
|
|
15
|
-
}),
|
|
16
|
+
}), c = t;
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
c as PieCard,
|
|
19
|
+
f as defaultProps,
|
|
20
|
+
l as paddingValues,
|
|
21
|
+
g as tags,
|
|
22
|
+
u as variants
|
|
22
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-card",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "PIE Design System Card built using Web Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
39
|
+
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
+
"@justeattakeaway/pie-css": "0.12.1",
|
|
40
41
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
41
42
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
43
|
},
|
package/src/card.scss
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@use '@justeattakeaway/pie-css/scss' as p;
|
|
2
2
|
|
|
3
3
|
@mixin card-interactive-states($bg-color, $mode: 'default') {
|
|
4
|
-
&:hover:not(
|
|
4
|
+
&:hover:not(.c-card--disabled) {
|
|
5
5
|
@if $mode == 'inverse' {
|
|
6
6
|
--hover-modifier: var(--dt-color-hover-01);
|
|
7
7
|
} @else {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
--card-bg-color: hsl(var(#{$bg-color}-h), var(#{$bg-color}-s), calc(var(#{$bg-color}-l) + var(--hover-modifier)));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
&:active:not(
|
|
14
|
+
&:active:not(.c-card--disabled) {
|
|
15
15
|
@if $mode == 'inverse' {
|
|
16
16
|
--active-modifier: var(--dt-color-active-01);
|
|
17
17
|
} @else {
|
|
@@ -39,19 +39,37 @@
|
|
|
39
39
|
outline: none;
|
|
40
40
|
text-decoration: none;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
&:focus-visible {
|
|
43
|
+
@include p.focus;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.c-card--disabled {
|
|
47
|
+
--card-bg-color: var(--dt-color-disabled-01);
|
|
48
|
+
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
|
|
51
|
+
::slotted(*) {
|
|
52
|
+
color: var(--dt-color-content-disabled);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
img {
|
|
56
|
+
opacity: 0.5;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.c-card--default {
|
|
43
61
|
box-shadow: var(--dt-elevation-card);
|
|
44
62
|
|
|
45
63
|
@include card-interactive-states('--dt-color-container-default');
|
|
46
64
|
}
|
|
47
65
|
|
|
48
|
-
|
|
66
|
+
&.c-card--outline {
|
|
49
67
|
border-color: var(--dt-color-border-strong);
|
|
50
68
|
|
|
51
69
|
@include card-interactive-states('--dt-color-container-default');
|
|
52
70
|
}
|
|
53
71
|
|
|
54
|
-
|
|
72
|
+
&.c-card--inverse {
|
|
55
73
|
--card-bg-color: var(--dt-color-container-dark);
|
|
56
74
|
--card-color: var(--dt-color-content-inverse);
|
|
57
75
|
|
|
@@ -60,7 +78,7 @@
|
|
|
60
78
|
@include card-interactive-states('--dt-color-container-dark', 'inverse');
|
|
61
79
|
}
|
|
62
80
|
|
|
63
|
-
|
|
81
|
+
&.c-card--outline-inverse {
|
|
64
82
|
--card-bg-color: var(--dt-color-container-dark);
|
|
65
83
|
--card-color: var(--dt-color-content-inverse);
|
|
66
84
|
|
|
@@ -69,30 +87,12 @@
|
|
|
69
87
|
@include card-interactive-states('--dt-color-container-dark', 'inverse');
|
|
70
88
|
}
|
|
71
89
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
cursor: not-allowed;
|
|
76
|
-
|
|
77
|
-
::slotted(*) {
|
|
78
|
-
color: var(--dt-color-content-disabled);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
img {
|
|
82
|
-
opacity: 0.5;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&[variant='inverse'],
|
|
86
|
-
&[variant='outline-inverse'] {
|
|
87
|
-
--card-bg-color: var(--dt-color-disabled-01-inverse);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&:focus-visible {
|
|
92
|
-
@include p.focus;
|
|
90
|
+
&.c-card--inverse.c-card--disabled,
|
|
91
|
+
&.c-card--outline-inverse.c-card--disabled {
|
|
92
|
+
--card-bg-color: var(--dt-color-disabled-01-inverse);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
&.c-card--draggable {
|
|
96
96
|
@extend %has-grab-cursor;
|
|
97
97
|
}
|
|
98
98
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
html, LitElement, unsafeCSS, nothing, TemplateResult,
|
|
3
3
|
} from 'lit';
|
|
4
|
+
import { classMap, type ClassInfo } from 'lit/directives/class-map.js';
|
|
4
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
import { property } from 'lit/decorators.js';
|
|
6
7
|
import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
@@ -57,16 +58,13 @@ export class PieCard extends LitElement implements CardProps {
|
|
|
57
58
|
*
|
|
58
59
|
* @private
|
|
59
60
|
*/
|
|
60
|
-
private renderAnchor (): TemplateResult {
|
|
61
|
+
private renderAnchor (classes: ClassInfo): TemplateResult {
|
|
61
62
|
const paddingCSS = this.generatePaddingCSS();
|
|
62
63
|
|
|
63
64
|
return html`
|
|
64
65
|
<a
|
|
65
|
-
class="
|
|
66
|
+
class="${classMap(classes)}"
|
|
66
67
|
data-test-id="pie-card"
|
|
67
|
-
tag=${this.tag || 'a'}
|
|
68
|
-
?isDraggable="${this.isDraggable}"
|
|
69
|
-
variant=${this.variant || 'default'}
|
|
70
68
|
?disabled=${this.disabled}
|
|
71
69
|
href=${this.href || ''}
|
|
72
70
|
target=${this.target || nothing}
|
|
@@ -130,16 +128,19 @@ export class PieCard extends LitElement implements CardProps {
|
|
|
130
128
|
|
|
131
129
|
const paddingCSS = this.generatePaddingCSS();
|
|
132
130
|
|
|
133
|
-
|
|
131
|
+
const classes = {
|
|
132
|
+
'c-card': true,
|
|
133
|
+
[`c-card--${variant}`]: true,
|
|
134
|
+
'c-card--draggable': isDraggable,
|
|
135
|
+
'c-card--disabled': disabled,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (tag === 'a') return this.renderAnchor(classes);
|
|
134
139
|
|
|
135
140
|
return html`
|
|
136
141
|
<div
|
|
137
|
-
class="
|
|
142
|
+
class="${classMap(classes)}"
|
|
138
143
|
data-test-id="pie-card"
|
|
139
|
-
tag=${tag || 'button'}
|
|
140
|
-
?isDraggable="${isDraggable}"
|
|
141
|
-
variant=${variant || 'default'}
|
|
142
|
-
?disabled=${disabled}
|
|
143
144
|
role="button"
|
|
144
145
|
tabindex="0"
|
|
145
146
|
aria-label=${aria?.label || nothing}
|