@proximus/lavender-banner 1.0.0-alpha.15 → 1.0.0-alpha.17
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/Banner.d.ts +11 -0
- package/dist/index.es.js +93 -27
- package/package.json +1 -1
package/dist/Banner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Container } from '@proximus/lavender-container';
|
|
2
|
+
import { Grid } from '@proximus/lavender-grid';
|
|
2
3
|
import { PxElement } from '@proximus/lavender-common';
|
|
3
4
|
export declare class Banner extends PxElement<HTMLDivElement> {
|
|
4
5
|
static nativeName: string;
|
|
@@ -8,6 +9,8 @@ export declare class Banner extends PxElement<HTMLDivElement> {
|
|
|
8
9
|
connectedCallback(): void;
|
|
9
10
|
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
10
11
|
createGridTemplateAreas(): void;
|
|
12
|
+
createGridding(): void;
|
|
13
|
+
get $grid(): Grid;
|
|
11
14
|
get $container(): Container;
|
|
12
15
|
get $children(): NodeListOf<Element>;
|
|
13
16
|
get backgroundColor(): string;
|
|
@@ -34,4 +37,12 @@ export declare class Banner extends PxElement<HTMLDivElement> {
|
|
|
34
37
|
set inverted(value: boolean);
|
|
35
38
|
get reduced(): boolean;
|
|
36
39
|
set reduced(value: boolean);
|
|
40
|
+
get hasGridding(): boolean;
|
|
41
|
+
set hasGridding(value: boolean);
|
|
42
|
+
get hasGriddingMobile(): boolean;
|
|
43
|
+
set hasGriddingMobile(value: boolean);
|
|
44
|
+
get hasGriddingTablet(): boolean;
|
|
45
|
+
set hasGriddingTablet(value: boolean);
|
|
46
|
+
get hasGriddingLaptop(): boolean;
|
|
47
|
+
set hasGriddingLaptop(value: boolean);
|
|
37
48
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { PxElement as d, backgroundSizeValues as
|
|
1
|
+
import { PxElement as d, backgroundSizeValues as g, gradientValues as c, backgroundColorValues as l } from "@proximus/lavender-common";
|
|
2
2
|
const b = ':host{position:relative}:host,:host>*{display:block;box-sizing:border-box}.banner{position:relative;min-height:8em}.banner[reduced]{min-height:5em}px-container{height:100%}.banner-content{display:grid;grid-template-columns:1fr;grid-template-rows:minmax(0,auto);row-gap:var(--px-spacing-s-mobile);z-index:2;position:relative}[reduced] .banner-content{grid-template-columns:min-content minmax(0,1fr);column-gap:var(--px-spacing-default-mobile)}::slotted([slot="tag"]){grid-area:tag}::slotted([slot="media"]){grid-area:media;align-self:start}::slotted([slot="title"]){grid-area:title}::slotted([slot="description"]){grid-area:description}::slotted([slot="content"]){grid-area:content}:host(:not([reduced])) ::slotted([slot="action"]){grid-area:action;margin-top:calc(var(--px-spacing-default-mobile) - var(--px-spacing-s-mobile))}.contrast-helper{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;pointer-events:none;display:none;border-radius:var(--px-radius-main)}[contrast-helper-gradient] .contrast-helper{display:block;background-image:linear-gradient(90deg,#fff 23.43%,#fff0 81.69%)}[inverted] :is([contrast-helper-gradient] .contrast-helper){background-image:linear-gradient(90deg,#000 23.43%,#0000 81.69%)}[contrast-helper-overlay] .contrast-helper{display:block;background-color:#ffffffb3}[inverted] :is([contrast-helper-overlay] .contrast-helper){background-color:#0006}@media only screen and (min-width: 48em){.banner-content{row-gap:var(--px-spacing-s-desktop)}[reduced] .banner-content{column-gap:var(--px-spacing-default-desktop)}.banner-content :host(:not([reduced])) ::slotted([slot="action"]){margin-top:calc(var(--px-spacing-default-desktop) - var(--px-spacing-s-desktop))}}@media only screen and (min-width: 64.0625em){.banner-content{row-gap:var(--px-spacing-s-desktop)}[reduced] .banner-content{column-gap:var(--px-spacing-default-desktop)}.banner-content :host(:not([reduced])) ::slotted([slot="action"]){margin-top:calc(var(--px-spacing-default-desktop) - var(--px-spacing-s-desktop))}}', s = new CSSStyleSheet();
|
|
3
3
|
s.replaceSync(b);
|
|
4
4
|
const o = class o extends d {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(s), this.template = () => `<div class="banner">
|
|
7
7
|
<div class="contrast-helper"></div>
|
|
8
|
-
<px-container padding="${this.reduced ? "m" : "l"}" padding--mobile="m" border-radius="main" >
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
<px-container class="banner-container" padding="${this.reduced ? "m" : "l"}" padding--mobile="m" border-radius="main" >
|
|
9
|
+
<px-grid gap="none">
|
|
10
|
+
<px-container padding="none" background-color="none" background-image="none" background-image--mobile="none" background-image--tablet="none" background-image--laptop="none" >
|
|
11
|
+
<div class="banner-content">
|
|
12
|
+
<slot name="tag"></slot>
|
|
13
|
+
<slot name="media"></slot>
|
|
14
|
+
<slot name="title"></slot>
|
|
15
|
+
<slot name="description"></slot>
|
|
16
|
+
<slot name="content"></slot>
|
|
17
|
+
<slot name="action"></slot>
|
|
18
|
+
</div>
|
|
19
|
+
</px-container>
|
|
20
|
+
</px-grid>
|
|
17
21
|
</px-container>
|
|
18
22
|
</div>`, this.shadowRoot.innerHTML = this.template();
|
|
19
23
|
}
|
|
@@ -29,22 +33,26 @@ const o = class o extends d {
|
|
|
29
33
|
"background-position",
|
|
30
34
|
"contrast-helper-gradient",
|
|
31
35
|
"contrast-helper-overlay",
|
|
36
|
+
"has-gridding",
|
|
37
|
+
"has-gridding--mobile",
|
|
38
|
+
"has-gridding--tablet",
|
|
39
|
+
"has-gridding--laptop",
|
|
32
40
|
"reduced",
|
|
33
41
|
"inverted"
|
|
34
42
|
];
|
|
35
43
|
}
|
|
36
44
|
connectedCallback() {
|
|
37
45
|
var t;
|
|
38
|
-
(t = super.connectedCallback) == null || t.call(this), this.createGridTemplateAreas();
|
|
46
|
+
(t = super.connectedCallback) == null || t.call(this), this.createGridTemplateAreas(), this.createGridding();
|
|
39
47
|
}
|
|
40
|
-
attributeChangedCallback(t,
|
|
41
|
-
if (
|
|
48
|
+
attributeChangedCallback(t, i, e) {
|
|
49
|
+
if (i !== e)
|
|
42
50
|
switch (t) {
|
|
43
51
|
case "background-color":
|
|
44
52
|
this.$container.backgroundColor = l.indexOf(e) > 0 ? e : "none";
|
|
45
53
|
break;
|
|
46
54
|
case "background-gradient":
|
|
47
|
-
this.$container.gradient =
|
|
55
|
+
this.$container.gradient = c.indexOf(e) > 0 ? e : "none";
|
|
48
56
|
break;
|
|
49
57
|
case "background-image":
|
|
50
58
|
this.$container.backgroundImage = e;
|
|
@@ -59,7 +67,7 @@ const o = class o extends d {
|
|
|
59
67
|
this.$container.backgroundImageLaptop = e;
|
|
60
68
|
break;
|
|
61
69
|
case "background-size":
|
|
62
|
-
this.$container.backgroundSize =
|
|
70
|
+
this.$container.backgroundSize = g.indexOf(e) > 0 ? e : "";
|
|
63
71
|
break;
|
|
64
72
|
case "background-position":
|
|
65
73
|
this.$container.backgroundPosition = e;
|
|
@@ -67,40 +75,74 @@ const o = class o extends d {
|
|
|
67
75
|
case "reduced":
|
|
68
76
|
this.$el.toggleAttribute("reduced", e !== null), this.createGridTemplateAreas();
|
|
69
77
|
break;
|
|
78
|
+
case "has-gridding":
|
|
79
|
+
case "has-gridding--mobile":
|
|
80
|
+
case "has-gridding--tablet":
|
|
81
|
+
case "has-gridding--laptop":
|
|
82
|
+
this.createGridding();
|
|
83
|
+
break;
|
|
70
84
|
case "inverted":
|
|
71
85
|
for (let r = 0; r < this.$children.length; r++)
|
|
72
86
|
this.$children[r].hasAttribute("inverted") || this.$children[r].toggleAttribute("inverted");
|
|
73
87
|
this.$el.toggleAttribute("inverted", e !== null);
|
|
74
88
|
break;
|
|
75
89
|
default:
|
|
76
|
-
super.attributeChangedCallback(t,
|
|
90
|
+
super.attributeChangedCallback(t, i, e);
|
|
77
91
|
break;
|
|
78
92
|
}
|
|
79
93
|
}
|
|
80
94
|
createGridTemplateAreas() {
|
|
81
95
|
const t = this.shadowRoot.querySelector(
|
|
82
96
|
".banner-content"
|
|
83
|
-
),
|
|
97
|
+
), i = ["tag", "media", "title", "description", "content", "action"];
|
|
84
98
|
let e = "";
|
|
85
|
-
this.reduced ?
|
|
86
|
-
const
|
|
99
|
+
this.reduced ? i.forEach((r) => {
|
|
100
|
+
const a = this.shadowRoot.querySelector(
|
|
87
101
|
`slot[name="${r}"]`
|
|
88
102
|
);
|
|
89
|
-
if (
|
|
103
|
+
if (a && a.assignedElements().length > 0) {
|
|
90
104
|
if (r === "media") return;
|
|
91
105
|
e += `'media ${r}'
|
|
92
106
|
`;
|
|
93
107
|
}
|
|
94
|
-
}) :
|
|
95
|
-
const
|
|
108
|
+
}) : i.forEach((r) => {
|
|
109
|
+
const a = this.shadowRoot.querySelector(
|
|
96
110
|
`slot[name="${r}"]`
|
|
97
111
|
);
|
|
98
|
-
|
|
112
|
+
a && a.assignedElements().length > 0 && (e += `'${r}'
|
|
99
113
|
`);
|
|
100
114
|
}), e || (e = "'content'"), t.style.gridTemplateAreas = e;
|
|
101
115
|
}
|
|
116
|
+
createGridding() {
|
|
117
|
+
const t = [
|
|
118
|
+
{ prop: "hasGridding", gridProp: "gridCols", attr: "col-span" },
|
|
119
|
+
{
|
|
120
|
+
prop: "hasGriddingMobile",
|
|
121
|
+
gridProp: "gridColsMobile",
|
|
122
|
+
attr: "col-span--mobile"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
prop: "hasGriddingTablet",
|
|
126
|
+
gridProp: "gridColsTablet",
|
|
127
|
+
attr: "col-span--tablet"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
prop: "hasGriddingLaptop",
|
|
131
|
+
gridProp: "gridColsLaptop",
|
|
132
|
+
attr: "col-span--laptop"
|
|
133
|
+
}
|
|
134
|
+
], i = this.shadowRoot.querySelector(
|
|
135
|
+
"px-grid > px-container"
|
|
136
|
+
);
|
|
137
|
+
t.forEach(({ prop: e, gridProp: r, attr: a }) => {
|
|
138
|
+
this[e] && (this.$grid[r] = "3", i.setAttribute(a, "2"));
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
get $grid() {
|
|
142
|
+
return this.shadowRoot.querySelector("px-grid");
|
|
143
|
+
}
|
|
102
144
|
get $container() {
|
|
103
|
-
return this.shadowRoot.querySelector("
|
|
145
|
+
return this.shadowRoot.querySelector(".banner-container");
|
|
104
146
|
}
|
|
105
147
|
get $children() {
|
|
106
148
|
return this.querySelectorAll("px-banner > *");
|
|
@@ -177,10 +219,34 @@ const o = class o extends d {
|
|
|
177
219
|
set reduced(t) {
|
|
178
220
|
t ? this.setAttribute("reduced", "") : this.removeAttribute("reduced");
|
|
179
221
|
}
|
|
222
|
+
get hasGridding() {
|
|
223
|
+
return this.hasAttribute("has-gridding");
|
|
224
|
+
}
|
|
225
|
+
set hasGridding(t) {
|
|
226
|
+
t ? this.setAttribute("has-gridding", "") : this.removeAttribute("has-gridding");
|
|
227
|
+
}
|
|
228
|
+
get hasGriddingMobile() {
|
|
229
|
+
return this.hasAttribute("has-gridding--mobile");
|
|
230
|
+
}
|
|
231
|
+
set hasGriddingMobile(t) {
|
|
232
|
+
t ? this.setAttribute("has-gridding--mobile", "") : this.removeAttribute("has-gridding--mobile");
|
|
233
|
+
}
|
|
234
|
+
get hasGriddingTablet() {
|
|
235
|
+
return this.hasAttribute("has-gridding--tablet");
|
|
236
|
+
}
|
|
237
|
+
set hasGriddingTablet(t) {
|
|
238
|
+
t ? this.setAttribute("has-gridding--tablet", "") : this.removeAttribute("has-gridding--tablet");
|
|
239
|
+
}
|
|
240
|
+
get hasGriddingLaptop() {
|
|
241
|
+
return this.hasAttribute("has-gridding--laptop");
|
|
242
|
+
}
|
|
243
|
+
set hasGriddingLaptop(t) {
|
|
244
|
+
t ? this.setAttribute("has-gridding--laptop", "") : this.removeAttribute("has-gridding--laptop");
|
|
245
|
+
}
|
|
180
246
|
};
|
|
181
247
|
o.nativeName = "div";
|
|
182
|
-
let
|
|
183
|
-
customElements.get("px-banner") || customElements.define("px-banner",
|
|
248
|
+
let n = o;
|
|
249
|
+
customElements.get("px-banner") || customElements.define("px-banner", n);
|
|
184
250
|
export {
|
|
185
|
-
|
|
251
|
+
n as Banner
|
|
186
252
|
};
|