@proximus/lavender-sticky-container 1.0.0-alpha.2
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 +80 -0
- package/package.json +42 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AttributeBreakpointHandlerDelegate as a } from "@proximus/lavender-common";
|
|
2
|
+
const n = "#content{overflow:auto}#sticky-right{position:sticky;top:0;float:right;margin-top:var(--px-sticky-container-suffix-margin-desktop, var(--px-sticky-container-suffix-margin-all))}@media only screen and (max-width: 768px){#sticky-right{margin-top:var(--px-sticky-container-suffix-margin-mobile, var(--px-sticky-container-suffix-margin-all))}}@media only screen and (max-width: 1025px){#sticky-right{margin-top:var(--px-sticky-container-suffix-margin-laptop, var(--px-sticky-container-suffix-margin-all))}}#sticky-left{position:sticky;top:0;float:left;margin-top:var(--px-sticky-container-prefix-margin-desktop, var(--px-sticky-container-prefix-margin-all))}@media only screen and (max-width: 768px){#sticky-left{margin-top:var(--px-sticky-container-prefix-margin-mobile, var(--px-sticky-container-prefix-margin-all))}}@media only screen and (max-width: 1025px){#sticky-left{margin-top:var(--px-sticky-container-prefix-margin-laptop, var(--px-sticky-container-prefix-margin-all))}}#middle{position:relative;height:var(--px-sticky-container-middle-height, 100vh);width:100%;overflow:auto}.sticky-footer{position:sticky;bottom:0;width:100%}", r = new CSSStyleSheet();
|
|
3
|
+
r.replaceSync(n);
|
|
4
|
+
class o extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.prefixMarginTopBreakpointHandlerDelegate = new a(
|
|
7
|
+
this,
|
|
8
|
+
"prefix-margin",
|
|
9
|
+
(t) => t,
|
|
10
|
+
"--px-sticky-container-prefix-margin"
|
|
11
|
+
), this.suffixMarginTopBreakpointHandlerDelegate = new a(
|
|
12
|
+
this,
|
|
13
|
+
"suffix-margin",
|
|
14
|
+
(t) => t,
|
|
15
|
+
"--px-sticky-container-suffix-margin"
|
|
16
|
+
), this.template = `
|
|
17
|
+
<div id="header">
|
|
18
|
+
<slot name="header"></slot>
|
|
19
|
+
</div>
|
|
20
|
+
<div id="middle">
|
|
21
|
+
<div id="sticky-right">
|
|
22
|
+
<slot name="suffix"></slot>
|
|
23
|
+
</div>
|
|
24
|
+
<div id="sticky-left">
|
|
25
|
+
<slot name="prefix"></slot>
|
|
26
|
+
</div>
|
|
27
|
+
<div id="content">
|
|
28
|
+
<slot></slot>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="sticky-footer">
|
|
32
|
+
<slot name="footer"></slot>
|
|
33
|
+
</div>
|
|
34
|
+
`, this.adjustContentHeight = () => {
|
|
35
|
+
const t = this.$header.offsetHeight, i = this.$footer.offsetHeight;
|
|
36
|
+
this.$middle.style.setProperty(
|
|
37
|
+
"--px-sticky-container-middle-height",
|
|
38
|
+
`calc(100vh - ${t + i}px)`
|
|
39
|
+
);
|
|
40
|
+
}, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [r];
|
|
41
|
+
}
|
|
42
|
+
connectedCallback() {
|
|
43
|
+
this.adjustContentHeight(), window.addEventListener("resize", this.adjustContentHeight);
|
|
44
|
+
}
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
window.removeEventListener("resize", this.adjustContentHeight);
|
|
47
|
+
}
|
|
48
|
+
static get observedAttributes() {
|
|
49
|
+
return ["prefix-margin", "suffix-margin"];
|
|
50
|
+
}
|
|
51
|
+
attributeChangedCallback(t, i, e) {
|
|
52
|
+
if (i !== e)
|
|
53
|
+
switch (t) {
|
|
54
|
+
case "prefix-margin":
|
|
55
|
+
this.prefixMarginTopBreakpointHandlerDelegate.attributeChangedCallback(
|
|
56
|
+
t,
|
|
57
|
+
i,
|
|
58
|
+
e
|
|
59
|
+
);
|
|
60
|
+
break;
|
|
61
|
+
case "suffix-margin":
|
|
62
|
+
this.suffixMarginTopBreakpointHandlerDelegate.attributeChangedCallback(
|
|
63
|
+
t,
|
|
64
|
+
i,
|
|
65
|
+
e
|
|
66
|
+
);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get $header() {
|
|
71
|
+
return this.shadowRoot.querySelector("#header");
|
|
72
|
+
}
|
|
73
|
+
get $footer() {
|
|
74
|
+
return this.shadowRoot.querySelector(".sticky-footer");
|
|
75
|
+
}
|
|
76
|
+
get $middle() {
|
|
77
|
+
return this.shadowRoot.querySelector("#middle");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
customElements.get("px-sticky-container") || customElements.define("px-sticky-container", o);
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-sticky-container",
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
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": "c9887f61d33d87b3ecb76e177df729f02694dcca",
|
|
28
|
+
"lerna": {
|
|
29
|
+
"command": {
|
|
30
|
+
"publish": {
|
|
31
|
+
"assets": [
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"package.json",
|
|
34
|
+
"dist/*.js",
|
|
35
|
+
"dist/*.cjs",
|
|
36
|
+
"dist/css/**/*.css",
|
|
37
|
+
"dist/js/**/*.js"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|