UNPKG

react-fa-picker

Version:

A reusable React Icon Picker component, bundled with its own Tailwind CSS build.

24 lines (21 loc) 608 B
import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } // utils/color.ts /** * Given a hex color like "#a1b2c3", returns true if it's light. */ export function isLight(hex: string): boolean { // strip “#” const c = hex.replace(/^#/, ""); // parse r/g/b const num = parseInt(c, 16); const r = (num >> 16) & 0xff; const g = (num >> 8) & 0xff; const b = num & 0xff; // per ITU-R BT.601 const brightness = (r * 299 + g * 587 + b * 114) / 1000; return brightness > 128; }