deno.land / x / nano_jsx@v0.1.0 / ui / _helpers.ts

نووسراو ببینە
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
import { h } from '../core.ts'
// https://gist.github.com/renancouto/4675192export const lightenColor = (color: string, percent: number) => { const num = parseInt(color.replace('#', ''), 16), amt = Math.round(2.55 * percent), R = (num >> 16) + amt, B = ((num >> 8) & 0x00ff) + amt, G = (num & 0x0000ff) + amt return `#${( 0x1000000 + (R < 255 ? (R < 1 ? 0 : R) : 255) * 0x10000 + (B < 255 ? (B < 1 ? 0 : B) : 255) * 0x100 + (G < 255 ? (G < 1 ? 0 : G) : 255) ) .toString(16) .slice(1)}`}
export const addStylesToHead = (styles: string, hash: string) => { const el = document.querySelector(`[data-css-hash*="${hash}"]`) if (!el) { const styleElement = h('style', { 'data-css-hash': hash }, styles) document.head.appendChild(styleElement) }}
nano_jsx

Version Info

Tagged at
8 months ago