component of web frontend
TRANSCRIPT
‣‣
‣‣
‣‣
‣
?
‣‣
‣
‣‣
‣
!
?
📱 ☁
‣‣
‣
‣‣
‣
?
"
‣
‣
‣
?
‣‣
‣
‣‣
‣
‣
"
‣‣
‣
‣‣
‣
?
‣‣
‣
‣‣
‣
?
‣‣
‣
‣‣
‣
😅
‣‣
‣‣
‣
/* style.css */ .className { color: green; }
import styles from "./style.css";
element.innerHTML = `<input class="${styles.className}">`;
import jss from 'jss';
const styles = jss.createStyleSheet({ className: { color: green } }).attach(); element.innerHTML = `<input class="${styles.className}">`;
‣‣
‣
‣‣
‣
<template> <style> :host { display: inline-block; } </style> <input type="checkbox"> </template> <script> class SwitchElement extends HTMLElement { constructor() { super(); const o = document.currentScript.ownerDocument; const t = o.querySelector('template'); this.attachShadow({ mode: 'open' }); this.shadowRoot.appendChild(t.content.cloneNode(true)); } } customElements.define('switch-element', SwitchElement); </script>
‣‣
‣‣
‣
‣‣
‣ 👈
‣‣
‣‣
‣
‣‣
‣‣
‣
‣‣
‣
‣
‣‣
‣
‣
‣
‣‣
‣
‣‣
‣
#
$
%
✨