UNPKG

xtreme-ui

Version:

Collection of reusable components that can be used in web projects

22 lines (21 loc) 642 B
import s from "color-namer"; import { colord as l } from "colord"; import { ThemeColorsPreset as m } from "../constants/theme.js"; const f = (e) => { const t = l(e).toHex(), o = s(t); let r = null; for (const n of o.ntc) (!r || n.distance < r.distance) && (r = n); return r?.name || void 0; }; function p(e) { if (e) { for (const [t, o] of Object.entries(m)) if (e.h === o.h && e.s === o.s && e.l === o.l) return t; return f(e); } } const c = (e) => !!e && typeof e.h == "number" && typeof e.s == "number" && typeof e.l == "number"; export { p as getColorLabel, f as guessClosestColorName, c as isValidThemeColor };