blob: fe8dcacf9efd5bea07da761054c2bf49382745e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import * as theme from '../theme.js'
import { create as create_element } from './index.js'
export class Container extends HTMLElement {
constructor(options) {
super();
this.body = this.attachShadow({ mode: 'closed' });
this.body.adoptedStyleSheets = (options?.css ?? []).concat(theme.css());
(options?.children ?? (() => []))().forEach(child => this.body.append(child))
}
static new(options) {
if (!this.__sfw_tag) {
this.__sfw_tag = this.__sfw_tag
?? 'sfw-' + this.name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
customElements.define(this.__sfw_tag, this);
}
return create_element(this.__sfw_tag, options);
}
}
|