@proximus/lavender-button 1.2.0-alpha.37
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 +136 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { PxElement as s } from "@proximus/lavender-common";
|
|
2
|
+
const l = '.btn{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;font-family:var(--px-font-family);font-size:var(--px-text-size-base-mobile);line-height:var(--px-line-height-m);font-weight:700;gap:var(--px-spacing-between-icon-horizontal-mobile);cursor:pointer;text-decoration:none;--btn-transition: all .2s ease-in-out 0s;transition:var(--btn-transition);border:var(--px-border-m) solid transparent;--slotted-icon-size: var(--px-icon-size-xs-mobile)}.btn,.btn *{box-sizing:border-box}.btn:hover:not([disabled],[aria-disabled=true],.loading),.btn:focus:not([disabled],[aria-disabled=true],.loading){border-color:var(--px-color-border-action-hover-default);outline:0}.btn:active{transform:scale(.95)}.btn[disabled],.btn[aria-disabled=true]{cursor:default;pointer-events:none}.btn.loading{cursor:inherit}.btn.loading ::slotted(px-spinner){line-height:var(--px-line-height-xs)}.btn:not(.secondary,.tertiary,.patch){color:var(--px-color-txt-primary-inverted);background:var(--px-color-bg-action-primary-default);min-height:var(--px-size-action-mobile);padding:0 var(--px-padding-m);border-radius:var(--px-radius-button-small) var(--px-radius-button-small) var(--px-radius-button-big) var(--px-radius-button-small)}.btn:not(.secondary,.tertiary,.patch):hover:not([disabled],[aria-disabled=true],.loading),.btn:not(.secondary,.tertiary,.patch):focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-default);background:var(--px-color-bg-action-hover-bordered-default)}.btn:not(.secondary,.tertiary,.patch)[disabled],.btn:not(.secondary,.tertiary,.patch)[aria-disabled=true]{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-txt-disabled-default)}.btn:not(.secondary,.tertiary,.patch).loading{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-txt-primary-default);border-color:transparent}.btn:not(.secondary,.tertiary,.patch).extended{width:100%}.btn:not(.secondary,.tertiary,.patch).alternative{border-radius:var(--px-radius-button-small)}.btn.secondary{color:var(--px-color-txt-primary-default);background:var(--px-color-bg-action-secondary-default);min-height:var(--px-size-action-mobile);padding:0 var(--px-padding-m);border-radius:var(--px-radius-button-small) var(--px-radius-button-small) var(--px-radius-button-big) var(--px-radius-button-small)}.btn.secondary:hover:not([disabled],[aria-disabled=true],.loading),.btn.secondary:focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-default);background:var(--px-color-bg-action-hover-bordered-default)}.btn.secondary[disabled],.btn.secondary[aria-disabled=true]{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-txt-disabled-default)}.btn.secondary.loading{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-txt-primary-default);border-color:transparent}.btn.secondary.extended{width:100%}.btn.secondary.alternative{border-radius:var(--px-radius-button-small)}.btn.tertiary{background:none;color:var(--px-color-txt-primary-default);border-radius:var(--px-radius-pill);padding:0}.btn.tertiary ::slotted(px-icon){display:flex;align-items:center;justify-content:center;width:var(--px-icon-size-m-mobile);height:var(--px-icon-size-m-mobile);font-size:var(--px-icon-size-2xs-mobile);border-radius:var(--px-radius-pill);background:var(--px-color-bg-action-secondary-default);transition:var(--btn-transition)}.btn.tertiary:hover:not([disabled],[aria-disabled=true],.loading),.btn.tertiary:focus:not([disabled],[aria-disabled=true],.loading){gap:0;padding:0 .5rem}.btn.tertiary:hover:not([disabled],[aria-disabled=true],.loading) ::slotted(*),.btn.tertiary:focus:not([disabled],[aria-disabled=true],.loading) ::slotted(*){background:transparent}.btn.tertiary:hover:not([disabled],[aria-disabled=true],.loading) ::slotted(px-icon),.btn.tertiary:focus:not([disabled],[aria-disabled=true],.loading) ::slotted(px-icon){margin:0 -8px}.btn.tertiary:hover:not([disabled],[aria-disabled=true],.loading) ::slotted([slot="before"]),.btn.tertiary:focus:not([disabled],[aria-disabled=true],.loading) ::slotted([slot="before"]){margin:0 0 0 -.5rem}.btn.tertiary:hover:not([disabled],[aria-disabled=true],.loading) ::slotted([slot="after"]),.btn.tertiary:focus:not([disabled],[aria-disabled=true],.loading) ::slotted([slot="after"]){margin:0 -.5rem 0 0}.btn.tertiary[disabled],.btn.tertiary[aria-disabled=true]{color:var(--px-color-txt-disabled-default)}.btn.tertiary[disabled] ::slotted(px-icon),.btn.tertiary[aria-disabled=true] ::slotted(px-icon){background:var(--px-color-bg-action-disabled-default)}.btn.tertiary.loading{color:var(--px-color-txt-primary-default);border-color:transparent}.btn.tertiary.loading ::slotted(px-spinner){display:flex;align-items:center;justify-content:center;width:var(--px-icon-size-m-mobile);height:var(--px-icon-size-m-mobile);border-radius:var(--px-radius-pill);background:var(--px-color-bg-action-disabled-default)}.btn.patch{display:inline-flex}.btn.patch:hover:not([disabled],[aria-disabled=true],.loading),.btn.patch:focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-default);background:var(--px-color-bg-action-hover-bordered-default)}.btn.patch[disabled],.btn.patch[aria-disabled=true]{background:var(--px-color-bg-action-disabled-default);color:var(--px-color-txt-disabled-default)}button.link{background:none;border:none;text-decoration:underline;padding:0;cursor:pointer}button.link[disabled],button.link[aria-disabled=true]{cursor:default;pointer-events:none;color:var(--px-color-txt-disabled-default)}:host([inverted]) .btn:hover:not([disabled],[aria-disabled=true],.loading),:host([inverted]) .btn:focus:not([disabled],[aria-disabled=true],.loading){border-color:var(--px-color-border-action-hover-inverted)}:host([inverted]) .btn:not(.secondary,.tertiary,.patch){color:var(--px-color-txt-primary-default);background:var(--px-color-bg-action-primary-inverted)}:host([inverted]) .btn:not(.secondary,.tertiary,.patch):hover:not([disabled],[aria-disabled=true],.loading),:host([inverted]) .btn:not(.secondary,.tertiary,.patch):focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-inverted);background:var(--px-color-bg-action-hover-bordered-default-inverted)}:host([inverted]) .btn:not(.secondary,.tertiary,.patch)[disabled],:host([inverted]) .btn:not(.secondary,.tertiary,.patch)[aria-disabled=true]{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-txt-disabled-inverted)}:host([inverted]) .btn:not(.secondary,.tertiary,.patch).loading{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-txt-primary-inverted);border-color:transparent}:host([inverted]) .btn.secondary{color:var(--px-color-txt-primary-inverted);background:var(--px-color-bg-action-secondary-inverted)}:host([inverted]) .btn.secondary:hover:not([disabled],[aria-disabled=true],.loading),:host([inverted]) .btn.secondary:focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-inverted);background:var(--px-color-bg-action-hover-bordered-default-inverted)}:host([inverted]) .btn.secondary[disabled],:host([inverted]) .btn.secondary[aria-disabled=true]{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-txt-disabled-inverted)}:host([inverted]) .btn.secondary.loading{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-txt-primary-inverted);border-color:transparent}:host([inverted]) .btn.tertiary{color:var(--px-color-txt-primary-inverted)}:host([inverted]) .btn.tertiary ::slotted(px-icon){background:var(--px-color-bg-action-secondary-inverted)}:host([inverted]) .btn.tertiary[disabled],:host([inverted]) .btn.tertiary[aria-disabled=true]{color:var(--px-color-txt-disabled-inverted)}:host([inverted]) .btn.tertiary[disabled] ::slotted(px-icon),:host([inverted]) .btn.tertiary[aria-disabled=true] ::slotted(px-icon){background:var(--px-color-bg-action-disabled-inverted)}:host([inverted]) .btn.tertiary.loading{color:var(--px-color-txt-primary-inverted)}:host([inverted]) .btn.tertiary.loading ::slotted(px-spinner){background:var(--px-color-bg-action-disabled-inverted)}:host([inverted]) .btn.patch:hover:not([disabled],[aria-disabled=true],.loading),:host([inverted]) .btn.patch:focus:not([disabled],[aria-disabled=true],.loading){color:var(--px-color-txt-primary-inverted);background:var(--px-color-bg-action-hover-bordered-default-inverted)}:host([inverted]) .btn.patch[disabled],:host([inverted]) .btn.patch[aria-disabled=true]{background:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-txt-disabled-inverted)}:host([inverted]) button.link[disabled],:host([inverted]) button.link[aria-disabled=true]{color:var(--px-color-txt-disabled-inverted)}@media only screen and (min-width: 640px){.btn{font-size:var(--px-text-size-base-tablet);--slotted-icon-size: var(--px-icon-size-xs-tablet)}.btn:not(.secondary,.tertiary,.patch){min-height:var(--px-size-action-desktop)}.btn.secondary{min-height:var(--px-size-action-desktop)}.btn.tertiary ::slotted(px-spinner){width:var(--px-icon-size-m-tablet);height:var(--px-icon-size-m-tablet)}}@media only screen and (min-width: 640px){.btn{font-size:var(--px-text-size-base-desktop);--slotted-icon-size: var(--px-icon-size-xs-desktop)}.btn.tertiary ::slotted(px-spinner){width:var(--px-icon-size-m-desktop);height:var(--px-icon-size-m-desktop)}}@keyframes anim-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}', c = 'a,.link,::slotted(a){font-family:var(--px-font-family);font-size:var(--px-text-size-base-mobile);line-height:var(--px-line-height-m);font-weight:500;color:var(--px-color-txt-body-default)}a:hover,a:focus,.link:hover,.link:focus{color:var(--px-color-txt-hover-default)}a[aria-disabled=true],.link[aria-disabled=true]{cursor:default;pointer-events:none;color:var(--px-color-txt-disabled-default)}a ::slotted([slot="after"]),.link ::slotted([slot="after"]){margin-left:var(--px-spacing-text-to-icon-compact-horizontal)}a ::slotted(*),.link ::slotted(*){display:inline-block}::slotted(a:hover),::slotted(a:focus){color:var(--px-color-txt-hover-default)}a.no-style{color:inherit;text-decoration:none}a.no-style:hover,a.no-style:focus{color:inherit}a.skip-link{position:absolute;left:-10000px;top:auto;overflow:hidden;background-color:var(--px-color-bg-container-weak-default);padding:var(--px-padding-xs)}a.skip-link:focus{left:auto;z-index:999}:host([inverted]) a,:host([inverted]) .link,:host([inverted]) ::slotted(a){color:var(--px-color-txt-body-inverted)}:host([inverted]) a:hover,:host([inverted]) a:focus,:host([inverted]) .link:hover,:host([inverted]) .link:focus{color:var(--px-color-txt-hover-inverted)}:host([inverted]) a[aria-disabled=true],:host([inverted]) .link[aria-disabled=true]{color:var(--px-color-txt-disabled-inverted)}:host([inverted]) ::slotted(a:hover),:host([inverted]) ::slotted(a:focus){color:var(--px-color-txt-hover-inverted)}:host([inverted]) a.skip-link{background-color:var(--px-color-bg-container-weak-inverted)}@media only screen and (min-width: 64rem){a,.link,::slotted(a){font-size:var(--px-text-size-base-tablet)}}@media only screen and (min-width: 90rem){a,.link,::slotted(a){font-size:var(--px-text-size-base-desktop)}}', b = ".patch{display:inline-flex;align-items:center;padding:0 var(--px-padding-s);height:1.625rem;border:var(--px-border-m) solid transparent;border-radius:var(--px-radius-patch-big) var(--px-radius-patch-big) var(--px-radius-patch-big) var(--px-radius-patch-small);font-family:var(--px-font-family);font-weight:700;font-size:var(--px-text-size-base-mobile);line-height:var(--px-line-height-m);text-align:center;background-color:var(--px-color-bg-promo-default);color:var(--px-color-txt-primary-inverted)}.patch,.patch *{box-sizing:border-box}@media only screen and (min-width: 768px){.patch{font-size:var(--px-text-size-base-tablet)}}@media only screen and (min-width: 1025px){.patch{font-size:var(--px-text-size-base-desktop)}}:host([inverted]) .patch{background-color:var(--px-color-bg-promo-inverted);color:var(--px-color-txt-primary-inverted)}.bottom-right{border-radius:var(--px-radius-patch-big) var(--px-radius-patch-big) var(--px-radius-patch-small) var(--px-radius-patch-big)}.bottom-left{border-radius:var(--px-radius-patch-big) var(--px-radius-patch-big) var(--px-radius-patch-big) var(--px-radius-patch-small)}.info{background-color:var(--px-color-illu-blue-core);color:var(--px-color-txt-body-default)}:host([inverted]) .info{background-color:var(--px-color-illu-blue-core);color:var(--px-color-txt-body-default)}.black-friday{background-color:var(--px-color-bg-container-rich-default);color:var(--px-color-txt-inverted-default)}:host([inverted]) .black-friday{background-color:var(--px-color-bg-container-rich-inverted);color:var(--px-color-txt-inverted-inverted)}.eco{background-color:var(--px-color-bg-success-default);color:var(--px-color-txt-inverted-default)}:host([inverted]) .eco{background-color:var(--px-color-bg-success-inverted);color:var(--px-color-txt-inverted-inverted)}.greyed{background-color:var(--px-color-bg-action-disabled-default);color:var(--px-color-icon-disabled-default)}:host([inverted]) .greyed{background-color:var(--px-color-bg-action-disabled-inverted);color:var(--px-color-icon-disabled-inverted)}", i = new CSSStyleSheet(), d = new CSSStyleSheet(), n = new CSSStyleSheet();
|
|
3
|
+
i.replaceSync(l);
|
|
4
|
+
d.replaceSync(c);
|
|
5
|
+
n.replaceSync(b);
|
|
6
|
+
const o = class o extends s {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(i, d, n), this.template = () => '<slot name="before"></slot><slot></slot><slot name="after"></slot>';
|
|
9
|
+
const t = document.createElement(this.nativeName);
|
|
10
|
+
t.classList.add("btn"), t.innerHTML = this.template(), this.shadowRoot.appendChild(t);
|
|
11
|
+
}
|
|
12
|
+
static get observedAttributes() {
|
|
13
|
+
return [
|
|
14
|
+
...super.observedAttributes,
|
|
15
|
+
"variant",
|
|
16
|
+
"state",
|
|
17
|
+
"extended",
|
|
18
|
+
"loading",
|
|
19
|
+
"shape",
|
|
20
|
+
"inverted"
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
get variant() {
|
|
24
|
+
return this.getAttribute("variant");
|
|
25
|
+
}
|
|
26
|
+
set variant(t) {
|
|
27
|
+
this.setAttribute("variant", t);
|
|
28
|
+
}
|
|
29
|
+
get state() {
|
|
30
|
+
return this.getAttribute("state");
|
|
31
|
+
}
|
|
32
|
+
set state(t) {
|
|
33
|
+
this.setAttribute("state", t);
|
|
34
|
+
}
|
|
35
|
+
get extended() {
|
|
36
|
+
return this.getAttribute("extended");
|
|
37
|
+
}
|
|
38
|
+
set extended(t) {
|
|
39
|
+
this.setAttribute("extended", t);
|
|
40
|
+
}
|
|
41
|
+
get loading() {
|
|
42
|
+
return this.getAttribute("loading");
|
|
43
|
+
}
|
|
44
|
+
set loading(t) {
|
|
45
|
+
this.setAttribute("loading", t);
|
|
46
|
+
}
|
|
47
|
+
get shape() {
|
|
48
|
+
return this.getAttribute("shape");
|
|
49
|
+
}
|
|
50
|
+
set shape(t) {
|
|
51
|
+
this.setAttribute("shape", t);
|
|
52
|
+
}
|
|
53
|
+
get inverted() {
|
|
54
|
+
return this.getAttribute("inverted");
|
|
55
|
+
}
|
|
56
|
+
set inverted(t) {
|
|
57
|
+
this.setAttribute("inverted", t);
|
|
58
|
+
}
|
|
59
|
+
attributeChangedCallback(t, e, r) {
|
|
60
|
+
if (e !== r)
|
|
61
|
+
switch (t) {
|
|
62
|
+
case "variant":
|
|
63
|
+
this.updateVariant(e, r);
|
|
64
|
+
break;
|
|
65
|
+
case "state":
|
|
66
|
+
this.updateState(e, r);
|
|
67
|
+
break;
|
|
68
|
+
case "extended":
|
|
69
|
+
this.updateExtended();
|
|
70
|
+
break;
|
|
71
|
+
case "loading":
|
|
72
|
+
this.updateLoading();
|
|
73
|
+
break;
|
|
74
|
+
case "shape":
|
|
75
|
+
this.updateShape(e, r);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
super.attributeChangedCallback(t, e, r);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
checkName(t, e) {
|
|
83
|
+
return !!t.includes(e);
|
|
84
|
+
}
|
|
85
|
+
checkClass(t) {
|
|
86
|
+
if (t.startsWith("patch-")) {
|
|
87
|
+
const e = t.split(/-(.*)/s);
|
|
88
|
+
for (const r of e)
|
|
89
|
+
r != "" && this.$el.classList.toggle(r);
|
|
90
|
+
} else
|
|
91
|
+
this.$el.classList.toggle(t);
|
|
92
|
+
}
|
|
93
|
+
_toggleClass(t, e) {
|
|
94
|
+
t !== null && t !== "" && t !== "default" && this.checkClass(t), e !== null && e !== "" && e !== "default" && this.checkClass(e);
|
|
95
|
+
}
|
|
96
|
+
updateVariant(t, e) {
|
|
97
|
+
const r = [
|
|
98
|
+
"",
|
|
99
|
+
"default",
|
|
100
|
+
"secondary",
|
|
101
|
+
"tertiary",
|
|
102
|
+
"link",
|
|
103
|
+
"patch",
|
|
104
|
+
"patch-info",
|
|
105
|
+
"patch-black-friday",
|
|
106
|
+
"patch-eco"
|
|
107
|
+
];
|
|
108
|
+
e === "link" ? this.$el.classList.remove("btn") : this.$el.classList.add("btn"), this._toggleClass(t, e), this.checkName(r, e) || console.error(`Bad "variant" value for ${this.$el}`);
|
|
109
|
+
}
|
|
110
|
+
updateState(t, e) {
|
|
111
|
+
const r = ["", "default", "success", "error"];
|
|
112
|
+
this._toggleClass(t, e), this.checkName(r, e) || console.error(`Bad "sate" value for ${this.$el}`);
|
|
113
|
+
}
|
|
114
|
+
updateExtended() {
|
|
115
|
+
this.$el.classList.toggle("extended");
|
|
116
|
+
}
|
|
117
|
+
updateLoading() {
|
|
118
|
+
this.$el.classList.toggle("loading");
|
|
119
|
+
}
|
|
120
|
+
updateShape(t, e) {
|
|
121
|
+
const r = [
|
|
122
|
+
"",
|
|
123
|
+
"default",
|
|
124
|
+
"bottom-right",
|
|
125
|
+
"bottom-left",
|
|
126
|
+
"alternative"
|
|
127
|
+
];
|
|
128
|
+
this._toggleClass(t, e), this.checkName(r, e) || console.error(`Bad "shape" value for ${this.$el}`);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
o.nativeName = "button";
|
|
132
|
+
let a = o;
|
|
133
|
+
customElements.get("px-button") || customElements.define("px-button", a);
|
|
134
|
+
export {
|
|
135
|
+
a as Button
|
|
136
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-button",
|
|
3
|
+
"version": "1.2.0-alpha.37",
|
|
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
|
+
"gitHead": "15a231df98020f83813279639a9a7712a5a5e759",
|
|
28
|
+
"lerna": {
|
|
29
|
+
"command": {
|
|
30
|
+
"publish": {
|
|
31
|
+
"assets": [
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"package.json",
|
|
34
|
+
"dist/*.js",
|
|
35
|
+
"dist/css/**/*.css"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|