@proximus/lavender-button-icon 1.0.0-alpha.3
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 +88 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PxElement as a } from "@proximus/lavender-common";
|
|
2
|
+
const s = ".btn-icon{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;cursor:pointer;--btn-transition: all .2s ease-in-out 0s;transition:var(--btn-transition);background:var(--px-color-bg-action-primary-default);color:var(--px-color-icon-primary-inverted);border-radius:var(--px-radius-pill);padding:var(--px-padding-xs);border:var(--px-border-m) solid transparent}.btn-icon,.btn-icon *{box-sizing:border-box}.btn-icon ::slotted(px-icon){line-height:0}.btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-bg-action-hover-bordered-default);color:var(--px-color-icon-primary-default);border-color:var(--px-color-border-action-hover-default)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-offset-s);outline:var(--px-outline-s) solid var(--px-color-outline-default)}.btn-icon[disabled],.btn-icon[aria-disabled=true]{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-icon-disabled-default);cursor:default;pointer-events:none}.btn-icon.btn-icon--state-loading{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-icon-primary-default);cursor:inherit}.btn-icon--size-small{padding:var(--px-padding-2xs)}.btn-icon--variant-secondary{background-color:var(--px-color-bg-action-secondary-default);color:var(--px-color-icon-primary-default)}:host([inverted]) .btn-icon{background:var(--px-color-bg-action-primary-inverted);color:var(--px-color-icon-primary-default)}:host([inverted]) .btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-color-bg-action-hover-bordered-default);color:var(--px-color-icon-primary-inverted);border-color:var(--px-color-border-action-hover-inverted)}:host([inverted]) .btn-icon:focus:not([disabled],[aria-disabled=true]){outline-color:var(--px-color-outline-inverted)}:host([inverted]) .btn-icon[disabled],:host([inverted]) .btn-icon[aria-disabled=true]{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-icon-disabled-inverted)}:host([inverted]) .btn-icon.btn-icon--state-loading{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-icon-primary-inverted);border-color:transparent}:host([inverted]) .btn-icon--variant-secondary{background-color:var(--px-color-bg-action-secondary-inverted);color:var(--px-color-icon-primary-inverted)}@media screen and (min-width: 1441px){.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-offset);outline-width:var(--px-outline)}}", n = new CSSStyleSheet();
|
|
3
|
+
n.replaceSync(s);
|
|
4
|
+
const c = ["", "default", "small"], d = ["", "default", "secondary"], o = class o extends a {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(n), this.template = () => "<slot></slot>";
|
|
7
|
+
const t = document.createElement(this.nativeName);
|
|
8
|
+
t.classList.add("btn-icon"), t.innerHTML = this.template(), this.shadowRoot.appendChild(t);
|
|
9
|
+
}
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return [
|
|
12
|
+
...super.observedAttributes,
|
|
13
|
+
"inverted",
|
|
14
|
+
"loading",
|
|
15
|
+
"size",
|
|
16
|
+
"variant"
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback();
|
|
21
|
+
const t = this.querySelector("px-icon"), i = t.getAttribute("size"), e = t.getAttribute("color");
|
|
22
|
+
t && (i || t.setAttribute("size", "xs"), e || t.setAttribute("color", "inherit"));
|
|
23
|
+
}
|
|
24
|
+
attributeChangedCallback(t, i, e) {
|
|
25
|
+
if (i !== e)
|
|
26
|
+
switch (t) {
|
|
27
|
+
case "loading":
|
|
28
|
+
this.updateLoading();
|
|
29
|
+
break;
|
|
30
|
+
case "size":
|
|
31
|
+
this.updateSize(i, e, c);
|
|
32
|
+
break;
|
|
33
|
+
case "variant":
|
|
34
|
+
this.updateVariant(i, e, d);
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
super.attributeChangedCallback(t, i, e);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
checkName(t, i) {
|
|
42
|
+
return t.includes(i);
|
|
43
|
+
}
|
|
44
|
+
_toggleClass(t, i) {
|
|
45
|
+
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), i !== null && i !== "" && i !== "default" && this.$el.classList.toggle(i);
|
|
46
|
+
}
|
|
47
|
+
updateLoading() {
|
|
48
|
+
this.$el.classList.toggle("btn-icon--state-loading");
|
|
49
|
+
}
|
|
50
|
+
updateSize(t, i, e) {
|
|
51
|
+
this.checkName(e, i) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--size-${t}`), i !== null && i !== "" && i !== "default" && this.$el.classList.toggle(`btn-icon--size-${i}`)) : console.error("Bad size value for", this.$el);
|
|
52
|
+
}
|
|
53
|
+
updateVariant(t, i, e) {
|
|
54
|
+
this.checkName(e, i) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--variant-${t}`), i !== null && i !== "" && i !== "default" && this.$el.classList.toggle(`btn-icon--variant-${i}`)) : console.error(`Bad "variant" value for ${this.$el}`);
|
|
55
|
+
}
|
|
56
|
+
get inverted() {
|
|
57
|
+
return this.getAttribute("inverted");
|
|
58
|
+
}
|
|
59
|
+
set inverted(t) {
|
|
60
|
+
this.setAttribute("inverted", t);
|
|
61
|
+
}
|
|
62
|
+
get loading() {
|
|
63
|
+
return this.getAttribute("loading");
|
|
64
|
+
}
|
|
65
|
+
set loading(t) {
|
|
66
|
+
this.setAttribute("loading", t);
|
|
67
|
+
}
|
|
68
|
+
get size() {
|
|
69
|
+
return this.getAttribute("size");
|
|
70
|
+
}
|
|
71
|
+
set size(t) {
|
|
72
|
+
this.setAttribute("size", t);
|
|
73
|
+
}
|
|
74
|
+
get variant() {
|
|
75
|
+
return this.getAttribute("variant");
|
|
76
|
+
}
|
|
77
|
+
set variant(t) {
|
|
78
|
+
this.setAttribute("variant", t);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
o.nativeName = "button";
|
|
82
|
+
let r = o;
|
|
83
|
+
customElements.get("px-button-icon") || customElements.define("px-button-icon", r);
|
|
84
|
+
export {
|
|
85
|
+
r as ButtonIcon,
|
|
86
|
+
c as sizeValues,
|
|
87
|
+
d as variantValues
|
|
88
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-button-icon",
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
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": "rm -rf dist;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/css/**/*.css"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "15a231df98020f83813279639a9a7712a5a5e759"
|
|
40
|
+
}
|