@proximus/lavender-skeleton 1.0.0-alpha.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/dist/index.js +82 -0
- package/package.json +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { PxElement as l } from "@proximus/lavender-common";
|
|
2
|
+
const d = ":host,:host>*{display:block;box-sizing:border-box}.skeleton-wrapper{display:flex;min-width:40px;flex-direction:column;align-items:flex-start;gap:10px;min-height:16px}.skeleton{border-radius:var(--px-radius-main);background-color:var(--px-background-color-action-disabled-default);align-self:stretch;height:16px;background-image:linear-gradient(-80deg,#0000,#0000 25%,#ffffff3d,#ffffff3d 55%,#0000 75%,#0000);background-size:200% 100%;animation:skeletonLoading 1.5s ease-in-out infinite}[inverted] .skeleton{background-color:var(--px-background-color-action-disabled-inverted);background-image:linear-gradient(-80deg,#fff0,#fff0 25%,#0000001a,#0000001a 55%,#fff0 75%,#fff0)}.skeleton.heading-s,.skeleton.heading-m,.skeleton.heading-l{max-width:240px}.skeleton.heading-s{height:24px}.skeleton.heading-m{height:32px}.skeleton.heading-l{height:40px}.skeleton.body,.skeleton.body-block{width:300px}.skeleton.body,.skeleton.body-block{height:16px}.skeleton.body-block:nth-of-type(3){width:180px}.skeleton.action-s,.skeleton.action-l{height:40px;border-radius:var(--px-radius-pill)}.skeleton.action-s{width:40px}.skeleton.action-l{width:160px}.skeleton.asset-s{width:40px;height:40px}.skeleton.asset-l{width:80px;height:80px}.skeleton.panel{width:300px;height:200px}@keyframes skeletonLoading{0%{background-position-x:150%}40%{background-position-x:-50%}to{background-position-x:-50%}}", a = new CSSStyleSheet();
|
|
3
|
+
a.replaceSync(d);
|
|
4
|
+
const h = [
|
|
5
|
+
"heading-s",
|
|
6
|
+
"heading-m",
|
|
7
|
+
"heading-l",
|
|
8
|
+
"body",
|
|
9
|
+
"body-block",
|
|
10
|
+
"action-s",
|
|
11
|
+
"action-l",
|
|
12
|
+
"asset-s",
|
|
13
|
+
"asset-l",
|
|
14
|
+
"panel"
|
|
15
|
+
], o = class o extends l {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(a), this.template = () => `<div class="skeleton-wrapper">
|
|
18
|
+
<div class="skeleton" aria-hidden="true"></div>
|
|
19
|
+
<slot name="skeleton-text"></slot>
|
|
20
|
+
</div>`, this.shadowRoot.innerHTML = this.template();
|
|
21
|
+
}
|
|
22
|
+
static get observedAttributes() {
|
|
23
|
+
return ["variant", "inverted"];
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
this.hasAttribute("variant") || this.setAttribute("variant", "body");
|
|
27
|
+
const e = this.shadowRoot.querySelector(
|
|
28
|
+
'slot[name="skeleton-text"]'
|
|
29
|
+
);
|
|
30
|
+
e && e.assignedNodes().length === 0 && console.error(
|
|
31
|
+
'The "skeleton-text" slot cannot be empty for accessibility. This text will only be visible to screen readers by adding `show--sr` property to the slot.'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
attributeChangedCallback(e, n, t) {
|
|
35
|
+
if (n !== t)
|
|
36
|
+
switch (e) {
|
|
37
|
+
case "variant":
|
|
38
|
+
if (this.updateVariant(t), this.$el.querySelector(".skeleton").classList.toggle(`${t}`), t === "body-block") {
|
|
39
|
+
const r = this.shadowRoot.querySelector(".skeleton-wrapper");
|
|
40
|
+
Array.from({ length: 2 }, () => {
|
|
41
|
+
const i = document.createElement("div");
|
|
42
|
+
return i.className = "skeleton body-block", i.setAttribute("aria-hidden", "true"), i;
|
|
43
|
+
}).forEach((i) => r.appendChild(i));
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case "inverted":
|
|
47
|
+
this.$el.toggleAttribute("inverted", t !== null);
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
super.attributeChangedCallback(e, n, t);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
updateVariant(e) {
|
|
55
|
+
if (!this.checkName(h, e)) {
|
|
56
|
+
console.error(`${e} is not a valid variant value for ${this.$el}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
get $container() {
|
|
61
|
+
return this.shadowRoot.querySelector("px-container");
|
|
62
|
+
}
|
|
63
|
+
get variant() {
|
|
64
|
+
return this.getAttribute("variant");
|
|
65
|
+
}
|
|
66
|
+
set variant(e) {
|
|
67
|
+
this.setAttribute("variant", e);
|
|
68
|
+
}
|
|
69
|
+
get inverted() {
|
|
70
|
+
return this.hasAttribute("inverted");
|
|
71
|
+
}
|
|
72
|
+
set inverted(e) {
|
|
73
|
+
e ? this.setAttribute("inverted", "") : this.removeAttribute("inverted");
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
o.nativeName = "div";
|
|
77
|
+
let s = o;
|
|
78
|
+
customElements.define("px-skeleton", s);
|
|
79
|
+
export {
|
|
80
|
+
s as Skeleton,
|
|
81
|
+
h as variantValues
|
|
82
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-skeleton",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.ts",
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./src/*.css": {
|
|
13
|
+
"development": "src/*.css"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc; vite build",
|
|
22
|
+
"test": "vitest run --coverage"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"lerna": {
|
|
28
|
+
"command": {
|
|
29
|
+
"publish": {
|
|
30
|
+
"assets": [
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"package.json",
|
|
33
|
+
"dist/*.js",
|
|
34
|
+
"dist/*.cjs",
|
|
35
|
+
"dist/css/**/*.css",
|
|
36
|
+
"dist/js/**/*.js",
|
|
37
|
+
"dist/*.svg",
|
|
38
|
+
"dist/*.ttf",
|
|
39
|
+
"dist/glyphmap.json",
|
|
40
|
+
"dist/*.d.ts"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "d2e5a1715a1636bad5022390b9f6e421317f120d"
|
|
46
|
+
}
|