@proximus/lavender-button-icon 1.0.0-alpha.10
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 +93 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PxElement as a } from "@proximus/lavender-common";
|
|
2
|
+
const c = ".btn-icon{display:inline-flex;width:var(--px-action-size-l);height:var(--px-action-size-l);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-background-color-action-primary-default);color:var(--px-icon-color-action-brand-inverted);border-radius:var(--px-radius-pill);padding:var(--px-padding-xs-mobile);border:var(--px-border-size-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-background-color-action-hover-bordered-default);color:var(--px-icon-color-action-brand-default);border-color:var(--px-border-color-action-hover-default)}.btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-active-inverted);color:var(--px-icon-color-action-active-default);border-color:var(--px-border-color-action-active-default)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-mobile);outline:var(--px-focus-outline-mobile) solid var(--px-border-color-focus-outline-default)}.btn-icon[disabled],.btn-icon[aria-disabled=true]{background:var(--px-background-color-action-disabled-default);color:var(--px-icon-color-action-disabled-default);cursor:default;pointer-events:none}.btn-icon.btn-icon--state-loading{background:var(--px-background-color-action-disabled-default);color:var(--px-icon-color-action-brand-default);cursor:inherit}.btn-icon--size-small{padding:var(--px-padding-2xs-mobile);width:var(--px-action-size-m);height:var(--px-action-size-m)}.btn-icon--variant-secondary{background-color:var(--px-background-color-action-secondary-default);color:var(--px-icon-color-action-brand-default)}:host([inverted]) .btn-icon{background:var(--px-background-color-action-primary-inverted);color:var(--px-icon-color-action-brand-default)}:host([inverted]) .btn-icon:hover:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-hover-bordered-inverted);color:var(--px-icon-color-action-brand-inverted);border-color:var(--px-border-color-action-hover-inverted)}:host([inverted]) .btn-icon:active:not([disabled],[aria-disabled=true],.btn-icon--state-loading){background:var(--px-background-color-action-hover-default);color:var(--px-icon-color-action-active-inverted);border-color:var(--px-border-color-action-active-inverted)}:host([inverted]) .btn-icon:focus:not([disabled],[aria-disabled=true]){outline-color:var(--px-border-color-focus-outline-inverted)}:host([inverted]) .btn-icon[disabled],:host([inverted]) .btn-icon[aria-disabled=true]{background:var(--px-background-color-action-disabled-inverted);color:var(--px-icon-color-action-disabled-inverted)}:host([inverted]) .btn-icon.btn-icon--state-loading{background:var(--px-background-color-action-disabled-inverted);color:var(--px-icon-color-action-brand-inverted);border-color:transparent}:host([inverted]) .btn-icon--variant-secondary{background-color:var(--px-background-color-action-secondary-inverted);color:var(--px-icon-color-action-brand-inverted)}@media only screen and (min-width: 768px){.btn-icon{padding:var(--px-padding-xs-tablet)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-tablet);outline-width:var(--px-focus-outline-tablet)}.btn-icon--size-small{padding:var(--px-padding-2xs-tablet)}}@media only screen and (min-width: 1025px){.btn-icon{padding:var(--px-padding-xs-desktop)}.btn-icon:focus:not([disabled],[aria-disabled=true]){outline-offset:var(--px-focus-offset-desktop);outline-width:var(--px-focus-outline-desktop)}.btn-icon--size-small{padding:var(--px-padding-2xs-desktop)}}", r = new CSSStyleSheet();
|
|
3
|
+
r.replaceSync(c);
|
|
4
|
+
const s = ["", "default", "small"], d = ["", "default", "secondary"], n = class n extends a {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(r), 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");
|
|
22
|
+
if (t) {
|
|
23
|
+
const o = t.getAttribute("size"), i = t.getAttribute("color");
|
|
24
|
+
t.addEventListener("click", () => {
|
|
25
|
+
this.$el.focus();
|
|
26
|
+
}), o || t.setAttribute("size", "s"), this.size === "small" && t.setAttribute("size", "2xs"), i || t.setAttribute("color", "inherit");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
attributeChangedCallback(t, o, i) {
|
|
30
|
+
if (o !== i)
|
|
31
|
+
switch (t) {
|
|
32
|
+
case "loading":
|
|
33
|
+
this.updateLoading();
|
|
34
|
+
break;
|
|
35
|
+
case "size":
|
|
36
|
+
this.updateSize(o, i, s);
|
|
37
|
+
break;
|
|
38
|
+
case "variant":
|
|
39
|
+
this.updateVariant(o, i, d);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
super.attributeChangedCallback(t, o, i);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
checkName(t, o) {
|
|
47
|
+
return t.includes(o);
|
|
48
|
+
}
|
|
49
|
+
_toggleClass(t, o) {
|
|
50
|
+
t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(t), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(o);
|
|
51
|
+
}
|
|
52
|
+
updateLoading() {
|
|
53
|
+
this.$el.classList.toggle("btn-icon--state-loading");
|
|
54
|
+
}
|
|
55
|
+
updateSize(t, o, i) {
|
|
56
|
+
this.checkName(i, o) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--size-${t}`), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(`btn-icon--size-${o}`)) : console.error("Bad size value for", this.$el);
|
|
57
|
+
}
|
|
58
|
+
updateVariant(t, o, i) {
|
|
59
|
+
this.checkName(i, o) ? (t !== null && t !== "" && t !== "default" && this.$el.classList.toggle(`btn-icon--variant-${t}`), o !== null && o !== "" && o !== "default" && this.$el.classList.toggle(`btn-icon--variant-${o}`)) : console.error(`Bad "variant" value for ${this.$el}`);
|
|
60
|
+
}
|
|
61
|
+
get inverted() {
|
|
62
|
+
return this.getAttribute("inverted");
|
|
63
|
+
}
|
|
64
|
+
set inverted(t) {
|
|
65
|
+
this.setAttribute("inverted", t);
|
|
66
|
+
}
|
|
67
|
+
get loading() {
|
|
68
|
+
return this.getAttribute("loading");
|
|
69
|
+
}
|
|
70
|
+
set loading(t) {
|
|
71
|
+
this.setAttribute("loading", t);
|
|
72
|
+
}
|
|
73
|
+
get size() {
|
|
74
|
+
return this.getAttribute("size");
|
|
75
|
+
}
|
|
76
|
+
set size(t) {
|
|
77
|
+
this.setAttribute("size", t);
|
|
78
|
+
}
|
|
79
|
+
get variant() {
|
|
80
|
+
return this.getAttribute("variant");
|
|
81
|
+
}
|
|
82
|
+
set variant(t) {
|
|
83
|
+
this.setAttribute("variant", t);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
n.nativeName = "button";
|
|
87
|
+
let e = n;
|
|
88
|
+
customElements.get("px-button-icon") || customElements.define("px-button-icon", e);
|
|
89
|
+
export {
|
|
90
|
+
e as ButtonIcon,
|
|
91
|
+
s as buttonIconSizeValues,
|
|
92
|
+
d as buttonIconVariantValues
|
|
93
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-button-icon",
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
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": "671fab7ee21d1c0ec6498b45b0bb2fd47e6e6c84"
|
|
40
|
+
}
|