UNPKG

xtreme-ui

Version:

Collection of reusable components that can be used in web projects

25 lines (24 loc) 682 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(), r = s(t); let o = null; for (const n of r.ntc) (!o || n.distance < o.distance) && (o = n); return (o == null ? void 0 : o.name) || void 0; }; function p(e) { if (e) { for (const [t, r] of Object.entries(m)) if (e.h === r.h && e.s === r.s && e.l === r.l) return t; return f(e); } } const b = (e) => !!e && typeof e.h == "number" && typeof e.s == "number" && typeof e.l == "number"; export { p as getColorLabel, f as guessClosestColorName, b as isValidThemeColor };