UNPKG

@scalar/api-client

Version:

the open source API testing client

35 lines (34 loc) 934 B
import { themePresets as y, defaultFonts as S } from "@scalar/themes"; import { computed as T, toValue as a } from "vue"; const p = new Map(y.map((e) => [e.slug, e])), l = (e, s = "scalar-theme") => `<style id="scalar-theme" data-testid="${s}">${e}</style>`, o = (e, s) => { const r = (t) => `${t} ${S}`; if (p.has(e)) return r(p.get(e)?.theme ?? ""); const c = s.find((t) => t.slug === e); if (c) return r(c.theme); }, w = ({ fallbackThemeSlug: e, store: s, customThemes: r }) => ({ themeStyleTag: T(() => { const t = l(o("default", []), "default"), m = a(s), n = a(e); if (m === null) return t; const f = m.workspace["x-scalar-theme"], u = f === "none" ? n : f; if (!u) { const i = o(n, a(r)); return i ? l(i, n) : t; } const h = o(u, a(r)); if (h) return l(h, u); const d = o(n, a(r)); return d ? l(d, n) : t; }) }); export { w as useTheme };