qiita.rb
sdfdsfds
-----------------------
import tpl from './option-card.html?raw';
import localCss from './option-card.css?raw';
import commonCss from '../css/common.css?raw';
function sheet(c){const s=new CSSStyleSheet();s.replaceSync(c);return s;}
const shared=sheet(commonCss);
export class OptionCard extends HTMLElement{
_data=null;
constructor(){
super();
this.attachShadow({mode:'open'});
this.shadowRoot!.innerHTML=tpl;this.shadowRoot!.adoptedStyleSheets=[shared,sheet(localCss)];
}
set data(v){
this._data=v;this.render();
}
render(){
if(!this._data)return;
const r=this.shadowRoot!;
r.querySelector('.title').textContent=this._data.title;r.querySelector('.desc').textContent=this._data.desc;
}}
if(!customElements.get('option-card'))customElements.define('option-card',OptionCard);
export type OptionData = {title:string,desc:string};