diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-01-14 15:47:00 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-01-14 15:47:00 +0100 |
| commit | 9d74e1679915cc0c5f56413879276fc43b093892 (patch) | |
| tree | 10c1582a70633cea261c30ca6007b9915c363bc3 | |
| parent | ca647a41364001b6f996715bd2313b44ac28a4d3 (diff) | |
| -rw-r--r-- | css.js | 19 | ||||
| -rw-r--r-- | index.js | 2 |
2 files changed, 14 insertions, 7 deletions
@@ -1,12 +1,19 @@ - -async function load_sheet(url) { - const response = await fetch(url); - const content = await response.text(); +async function load_text(content) { const sheet = new CSSStyleSheet(); await sheet.replace(content); return sheet; } -export async function css(base, ...urls) { - return await Promise.all(urls.map(url => load_sheet(new URL(url, base)))) +async function load_file(url) { + const response = await fetch(url); + const content = await response.text(); + return await load_text(content); +} + +export async function sheet(...contents) { + return await Promise.all(contents.map(text => load_text(text))); +} + +export async function file(base, ...urls) { + return await Promise.all(urls.map(url => load_file(new URL(url, base)))) } @@ -1,3 +1,3 @@ -export { css } from './css.js'; +export * as css from './css.js'; export * as theme from './theme.js'; export * as element from './element/index.js' |