-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockSubTitle.js
79 lines (58 loc) · 4.02 KB
/
blockSubTitle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { twind, cssom, observe, install } from "@twind/core";
import "construct-style-sheets-polyfill";
import config from "../../twind.config.js";
// ╭───────────────────────────────────────────────────────╮
// │ Add the template │
// ╰───────────────────────────────────────────────────────╯
const template = document.createElement('template');
// ╭───────────────────────────────────────────────────────╮
// │ INCLUDES / LINKS / SCRIPTS │
// ╰───────────────────────────────────────────────────────╯
let html = /* html */`
`;
// ╭───────────────────────────────────────────────────────╮
// │ STYLESHEET │
// ╰───────────────────────────────────────────────────────╯
html += /* html */`
<style>
</style>
`;
// ╭───────────────────────────────────────────────────────╮
// │ TEMPLATE │
// ╰───────────────────────────────────────────────────────╯
html += /* html */`
<div id="blockSubTitle" class="text-3xl md:text-6xl mx-10 mt-10 mb-10 font-semibold text-center">
<h2 class="text-3xl md:text-6xl mx-10 mt-10 mb-10">
<slot name="title"></slot>
</h2>
<h3 class="text-xl md:text-3xl text-stone-500">
<slot name="subheading"></slot>
</h3>
</div>
`;
// ╭───────────────────────────────────────────────────────╮
// │ ADD TO TEMPLATE │
// ╰───────────────────────────────────────────────────────╯
template.innerHTML = html
// ╭───────────────────────────────────────────────────────╮
// │ DEFINE WEBCOMPONENT │
// ╰───────────────────────────────────────────────────────╯
class SubTitle extends HTMLElement {
constructor() {
// SETUP
super();
const clone = template.content.cloneNode(true);
this.attachShadow({ mode: "open" });
this.shadowRoot.appendChild(clone);
// TWIND Setup
const sheet = cssom(new CSSStyleSheet());
const tw = twind(config, sheet);
const theshadowRoot = this.shadowRoot;
theshadowRoot.adoptedStyleSheets = [sheet.target];
observe(tw, theshadowRoot);
}
// ╭───────────────────────────────────────────────────────╮
// │ GETTERS / SETTERS │
// ╰───────────────────────────────────────────────────────╯
}
customElements.define("ldnpk-blocksubtitle", SubTitle);