@proximus/lavender-image 1.0.0-alpha.13 → 1.0.0-alpha.15
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 +154 -69
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PxElement as
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
class
|
|
1
|
+
import { PxElement as p, noBorderRadiusValues as l, borderRadiusValues as h } from "@proximus/lavender-common";
|
|
2
|
+
const m = ':host{display:inline-block;line-height:0}picture{display:inline-block}img{display:inline-block;border-style:none;width:var(--img-width--mobile, auto);max-width:100%}.border-radius-main,.border-radius-main img{border-radius:var(--px-radius-main)}.border-radius-pill,.border-radius-pill img{border-radius:var(--px-radius-pill)}.no-border-radius-top,.no-border-radius-top img{border-top-left-radius:var(--px-radius-none);border-top-right-radius:var(--px-radius-none)}.no-border-radius-right,.no-border-radius-right img{border-top-right-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-bottom,.no-border-radius-bottom img{border-bottom-left-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-left,.no-border-radius-left img{border-top-left-radius:var(--px-radius-none);border-bottom-left-radius:var(--px-radius-none)}.no-border-radius-all,.no-border-radius-all img{border-radius:var(--px-radius-none)}@media only screen and (max-width: 767px){:host([hide-for="mobile"]),:host([show-for="tablet"]),:host([show-for="laptop"]),.hide-for-mobile,.show-for-tablet,.show-for-laptop{display:none}.no-border-radius-top--mobile,.no-border-radius-top--mobile img{border-top-left-radius:var(--px-radius-none);border-top-right-radius:var(--px-radius-none)}.no-border-radius-right--mobile,.no-border-radius-right--mobile img{border-top-right-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-bottom--mobile,.no-border-radius-bottom--mobile img{border-bottom-left-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-left--mobile,.no-border-radius-left--mobile img{border-top-left-radius:var(--px-radius-none);border-bottom-left-radius:var(--px-radius-none)}.no-border-radius-all--mobile,.no-border-radius-all--mobile img{border-radius:var(--px-radius-none)}}@media only screen and (min-width: 768px) and (max-width: 1024px){img{width:var(--img-width--tablet, auto)}:host([hide-for="tablet"]),:host([show-for="mobile"]),:host([show-for="laptop"]),.hide-for-tablet,.show-for-mobile,.show-for-laptop{display:none}.no-border-radius-top--tablet,.no-border-radius-top--tablet img{border-top-left-radius:var(--px-radius-none);border-top-right-radius:var(--px-radius-none)}.no-border-radius-right--tablet,.no-border-radius-right--tablet img{border-top-right-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-bottom--tablet,.no-border-radius-bottom--tablet img{border-bottom-left-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-left--tablet,.no-border-radius-left--tablet img{border-top-left-radius:var(--px-radius-none);border-bottom-left-radius:var(--px-radius-none)}.no-border-radius-all--tablet,.no-border-radius-all--tablet img{border-radius:var(--px-radius-none)}}@media only screen and (min-width: 1025px){img{width:var(--img-width--laptop, auto)}:host([hide-for="laptop"]),:host([show-for="mobile"]),:host([show-for="tablet"]),.hide-for-laptop,.show-for-mobile,.show-for-tablet{display:none}.no-border-radius-top--laptop,.no-border-radius-top--laptop img{border-top-left-radius:var(--px-radius-none);border-top-right-radius:var(--px-radius-none)}.no-border-radius-right--laptop,.no-border-radius-right--laptop img{border-top-right-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-bottom--laptop,.no-border-radius-bottom--laptop img{border-bottom-left-radius:var(--px-radius-none);border-bottom-right-radius:var(--px-radius-none)}.no-border-radius-left--laptop,.no-border-radius-left--laptop img{border-top-left-radius:var(--px-radius-none);border-bottom-left-radius:var(--px-radius-none)}.no-border-radius-all--laptop,.no-border-radius-all--laptop img{border-radius:var(--px-radius-none)}}@media only screen and (min-width: 1441px){img{width:var(--img-width--desktop, auto)}}', n = new CSSStyleSheet();
|
|
3
|
+
n.replaceSync(m);
|
|
4
|
+
const g = ["", "mobile", "tablet", "laptop"], f = ["", "default", "s", "m", "l"];
|
|
5
|
+
class c extends p {
|
|
6
6
|
constructor() {
|
|
7
|
-
super(
|
|
7
|
+
super(n);
|
|
8
8
|
}
|
|
9
9
|
static get observedAttributes() {
|
|
10
10
|
return [
|
|
@@ -13,103 +13,188 @@ class p extends s {
|
|
|
13
13
|
"show-for",
|
|
14
14
|
"border-radius",
|
|
15
15
|
"no-border-radius",
|
|
16
|
-
"no-border-radius
|
|
17
|
-
"no-border-radius
|
|
18
|
-
"no-border-radius
|
|
16
|
+
"no-border-radius--mobile",
|
|
17
|
+
"no-border-radius--tablet",
|
|
18
|
+
"no-border-radius--laptop",
|
|
19
|
+
"width",
|
|
20
|
+
"width--mobile",
|
|
21
|
+
"width--tablet",
|
|
22
|
+
"width--laptop",
|
|
23
|
+
"width--desktop"
|
|
19
24
|
];
|
|
20
25
|
}
|
|
26
|
+
attributeChangedCallback(t, o, r) {
|
|
27
|
+
if (o !== r)
|
|
28
|
+
switch (t) {
|
|
29
|
+
case "hide-for":
|
|
30
|
+
case "show-for":
|
|
31
|
+
this.updateAttribute(t, o, r, g);
|
|
32
|
+
break;
|
|
33
|
+
case "border-radius":
|
|
34
|
+
this.updateAttribute(
|
|
35
|
+
t,
|
|
36
|
+
o,
|
|
37
|
+
r,
|
|
38
|
+
h
|
|
39
|
+
);
|
|
40
|
+
break;
|
|
41
|
+
case "no-border-radius":
|
|
42
|
+
case "no-border-radius--mobile":
|
|
43
|
+
case "no-border-radius--tablet":
|
|
44
|
+
case "no-border-radius--laptop":
|
|
45
|
+
this.updateAttribute(
|
|
46
|
+
t,
|
|
47
|
+
o,
|
|
48
|
+
r,
|
|
49
|
+
l
|
|
50
|
+
);
|
|
51
|
+
break;
|
|
52
|
+
case "width":
|
|
53
|
+
case "width--mobile":
|
|
54
|
+
case "width--tablet":
|
|
55
|
+
case "width--laptop":
|
|
56
|
+
case "width--desktop":
|
|
57
|
+
this.updateWidth(t, o, r, f);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
super.attributeChangedCallback(t, o, r);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
updateWidth(t, o, r, a) {
|
|
65
|
+
if (!this.checkName(a, r)) {
|
|
66
|
+
console.error(
|
|
67
|
+
`${r} is not an allowed ${t} value for ${this.$el}`
|
|
68
|
+
);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const i = t.indexOf("--") > -1, e = i ? t.split("--")[0] : t, d = [];
|
|
72
|
+
if (!i)
|
|
73
|
+
this.getAttribute(e + "--mobile") || d.push("mobile"), this.getAttribute(e + "--tablet") || d.push("tablet"), this.getAttribute(e + "--laptop") || d.push("laptop"), this.getAttribute(e + "--desktop") || d.push("desktop"), d.forEach((s) => {
|
|
74
|
+
this.updateStyle(e, s, o), this.updateStyle(e, s, r);
|
|
75
|
+
});
|
|
76
|
+
else {
|
|
77
|
+
const s = t.split("--")[1];
|
|
78
|
+
this.updateStyle(e, s, o), this.updateStyle(e, s, r);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
updateStyle(t, o, r) {
|
|
82
|
+
r !== null && r !== "" && r !== "default" && this.$el.style.setProperty(
|
|
83
|
+
`--img-${t}--${o}`,
|
|
84
|
+
`var(--px-image-${r}-${o === "laptop" ? "desktop" : o})`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
updateAttribute(t, o, r, a) {
|
|
88
|
+
if (!this.checkName(a, r))
|
|
89
|
+
console.error(
|
|
90
|
+
`${r} is not an allowed ${t} value for ${this.$el}`
|
|
91
|
+
);
|
|
92
|
+
else {
|
|
93
|
+
const i = this.splitAttrNameFromBreakpoint(t), e = i.breakpoint;
|
|
94
|
+
o !== null && o !== "" && this.$el.classList.toggle(
|
|
95
|
+
`${i.attrName}-${o}${e}`
|
|
96
|
+
), r !== null && r !== "" && this.$el.classList.toggle(
|
|
97
|
+
`${i.attrName}-${r}${e}`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
splitAttrNameFromBreakpoint(t) {
|
|
102
|
+
let o = "";
|
|
103
|
+
if (["--mobile", "--tablet", "--laptop"].some(
|
|
104
|
+
(r) => t.includes(r)
|
|
105
|
+
)) {
|
|
106
|
+
const r = t.split("--");
|
|
107
|
+
t = r[0], o = `--${r[1]}`;
|
|
108
|
+
}
|
|
109
|
+
return { attrName: t, breakpoint: o };
|
|
110
|
+
}
|
|
111
|
+
checkName(t, o) {
|
|
112
|
+
return t.includes(o);
|
|
113
|
+
}
|
|
114
|
+
//get & set
|
|
21
115
|
get hidefor() {
|
|
22
116
|
return this.getAttribute("hide-for");
|
|
23
117
|
}
|
|
24
|
-
set hidefor(
|
|
25
|
-
this.setAttribute("hide-for",
|
|
118
|
+
set hidefor(t) {
|
|
119
|
+
this.setAttribute("hide-for", t);
|
|
26
120
|
}
|
|
27
121
|
get showfor() {
|
|
28
122
|
return this.getAttribute("show-for");
|
|
29
123
|
}
|
|
30
|
-
set showfor(
|
|
31
|
-
this.setAttribute("show-for",
|
|
124
|
+
set showfor(t) {
|
|
125
|
+
this.setAttribute("show-for", t);
|
|
32
126
|
}
|
|
33
127
|
get borderRadius() {
|
|
34
128
|
return this.getAttribute("border-radius");
|
|
35
129
|
}
|
|
36
|
-
set borderRadius(
|
|
37
|
-
this.setAttribute("border-radius",
|
|
130
|
+
set borderRadius(t) {
|
|
131
|
+
this.setAttribute("border-radius", t);
|
|
38
132
|
}
|
|
39
133
|
get noBorderRadius() {
|
|
40
134
|
return this.getAttribute("no-border-radius");
|
|
41
135
|
}
|
|
42
|
-
set noBorderRadius(
|
|
43
|
-
this.setAttribute("no-border-radius",
|
|
136
|
+
set noBorderRadius(t) {
|
|
137
|
+
this.setAttribute("no-border-radius", t);
|
|
44
138
|
}
|
|
45
139
|
get noBorderRadiusMobile() {
|
|
46
|
-
return this.getAttribute("no-border-radius
|
|
140
|
+
return this.getAttribute("no-border-radius--mobile");
|
|
47
141
|
}
|
|
48
|
-
set noBorderRadiusMobile(
|
|
49
|
-
this.setAttribute("no-border-radius
|
|
142
|
+
set noBorderRadiusMobile(t) {
|
|
143
|
+
this.setAttribute("no-border-radius--mobile", t);
|
|
50
144
|
}
|
|
51
145
|
get noBorderRadiusTablet() {
|
|
52
|
-
return this.getAttribute("no-border-radius
|
|
146
|
+
return this.getAttribute("no-border-radius--tablet");
|
|
53
147
|
}
|
|
54
|
-
set noBorderRadiusTablet(
|
|
55
|
-
this.setAttribute("no-border-radius
|
|
148
|
+
set noBorderRadiusTablet(t) {
|
|
149
|
+
this.setAttribute("no-border-radius--tablet", t);
|
|
56
150
|
}
|
|
57
151
|
get noBorderRadiusLaptop() {
|
|
58
|
-
return this.getAttribute("no-border-radius
|
|
152
|
+
return this.getAttribute("no-border-radius--laptop");
|
|
59
153
|
}
|
|
60
|
-
set noBorderRadiusLaptop(
|
|
61
|
-
this.setAttribute("no-border-radius
|
|
154
|
+
set noBorderRadiusLaptop(t) {
|
|
155
|
+
this.setAttribute("no-border-radius--laptop", t);
|
|
62
156
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
switch (r) {
|
|
66
|
-
case "hide-for":
|
|
67
|
-
case "show-for":
|
|
68
|
-
this.updateAttribute(r, o, t, l);
|
|
69
|
-
break;
|
|
70
|
-
case "border-radius":
|
|
71
|
-
this.updateAttribute(
|
|
72
|
-
r,
|
|
73
|
-
o,
|
|
74
|
-
t,
|
|
75
|
-
n
|
|
76
|
-
);
|
|
77
|
-
break;
|
|
78
|
-
case "no-border-radius":
|
|
79
|
-
case "no-border-radius-mobile":
|
|
80
|
-
case "no-border-radius-tablet":
|
|
81
|
-
case "no-border-radius-laptop":
|
|
82
|
-
this.updateAttribute(
|
|
83
|
-
r,
|
|
84
|
-
o,
|
|
85
|
-
t,
|
|
86
|
-
b
|
|
87
|
-
);
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
super.attributeChangedCallback(r, o, t);
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
157
|
+
get width() {
|
|
158
|
+
return this.getAttribute("width");
|
|
93
159
|
}
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
|
|
160
|
+
set width(t) {
|
|
161
|
+
this.setAttribute("width", t);
|
|
162
|
+
}
|
|
163
|
+
get widthMobile() {
|
|
164
|
+
return this.getAttribute("width--mobile");
|
|
165
|
+
}
|
|
166
|
+
set widthMobile(t) {
|
|
167
|
+
this.setAttribute("width--mobile", t);
|
|
168
|
+
}
|
|
169
|
+
get widthTablet() {
|
|
170
|
+
return this.getAttribute("width--tablet");
|
|
171
|
+
}
|
|
172
|
+
set widthTablet(t) {
|
|
173
|
+
this.setAttribute("width--tablet", t);
|
|
174
|
+
}
|
|
175
|
+
get widthLaptop() {
|
|
176
|
+
return this.getAttribute("width--laptop");
|
|
177
|
+
}
|
|
178
|
+
set widthLaptop(t) {
|
|
179
|
+
this.setAttribute("width--laptop", t);
|
|
180
|
+
}
|
|
181
|
+
get widthDesktop() {
|
|
182
|
+
return this.getAttribute("width--desktop");
|
|
98
183
|
}
|
|
99
|
-
|
|
100
|
-
|
|
184
|
+
set widthDesktop(t) {
|
|
185
|
+
this.setAttribute("width--desktop", t);
|
|
101
186
|
}
|
|
102
187
|
}
|
|
103
|
-
const
|
|
188
|
+
const u = class u extends c {
|
|
104
189
|
constructor() {
|
|
105
190
|
super();
|
|
106
|
-
const
|
|
107
|
-
this.shadowRoot.appendChild(
|
|
191
|
+
const t = document.createElement(this.nativeName);
|
|
192
|
+
this.shadowRoot.appendChild(t);
|
|
108
193
|
}
|
|
109
194
|
};
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
customElements.define("px-img",
|
|
195
|
+
u.nativeName = "img";
|
|
196
|
+
let b = u;
|
|
197
|
+
customElements.define("px-img", b);
|
|
113
198
|
export {
|
|
114
|
-
|
|
199
|
+
b as Image
|
|
115
200
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-image",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "c8d45175b616fee668fd663475c537625377c6b7",
|
|
28
28
|
"lerna": {
|
|
29
29
|
"command": {
|
|
30
30
|
"publish": {
|