- XML としてパースする
- S タグの属性でスタイルを指定
- a: text-align
- c: color
- d: text-decoration
- f: font-family
- s: font-size
- w: font-weight
- ex:
<S w="bold" c="blue">blue-bold</S>
- D タグでタグ定義
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LitElement } from "lit" | |
export class StylitElement extends LitElement { | |
constructor() { | |
super() | |
this._cssss = new CSSStyleSheet() | |
this._style_num = 0 | |
} | |
style(template, ...values) { | |
const class_name = "c" + (this._style_num++).toString(36) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<meta charset="utf-8" /> | |
<script type="module"> | |
const addLog = (key) => { | |
const div = document.createElement("div") | |
div.textContent = `key: ${key}` | |
setTimeout(() => { | |
div.animate([ | |
{ height: div.clientHeight + "px" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs") | |
const { createCanvas } = require("canvas") | |
const alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
const chars = alphabets + alphabets.toLowerCase() + "1234567890" | |
for (const [index, char] of [...chars].entries()) { | |
const canvas = createCanvas(80, 80) | |
const ctx = canvas.getContext("2d") | |
ctx.font = "bold 70px serif" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ceil = (n, d) => Math.ceil(n * (10 ** d)) / (10 ** d) | |
export const round = (n, d) => Math.round(n * (10 ** d)) / (10 ** d) | |
export const floor = (n, d) => Math.floor(n * (10 ** d)) / (10 ** d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useContext, createContext } from "react" | |
const CounterContext = createContext() | |
const CounterProvider = CounterContext.Provider | |
const useCounter = () => useContext(CounterContext) | |
const useNewCounter = () => { | |
const [count, setCount] = useState(0) | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (fns, measure_count, effective_rate) => { | |
const data = [] | |
for (let i = 0; i < measure_count; i++) { | |
for (const [fn_index, fn] of fns.entries()) { | |
if (!data[fn_index]) { | |
data[fn_index] = [] | |
} | |
const start = performance.now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<meta charset="utf-8" /> | |
<script type="module"> | |
import { html, css, LitElement, createRef, ref } from "https://cdn.jsdelivr.net/gh/lit/[email protected]/all/lit-all.min.js" | |
import "https://unpkg.com/@fluentui/web-components" | |
const common_styles = css` | |
.btns { | |
display: flex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const name_to_url = {} | |
for (const script of document.querySelectorAll("script[data-module]")) { | |
name_to_url[script.dataset.module] = URL.createObjectURL(new Blob([script.innerHTML], { type: "text/javascript" })) | |
} | |
const importmap = document.createElement("script") | |
importmap.type = "importmap" | |
importmap.innerHTML = `{"imports": ${JSON.stringify(name_to_url)}}` | |
document.head.append(importmap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8" /> | |
<script type="module"> | |
import { html, render } from "https://cdn.skypack.dev/lit-html" | |
const lit = (root, template, init, actions) => { | |
let state = init | |
const update = async (fn, ...args) => { |