Files
jindengchen-ai-report/cool-unix/cool/utils/tailwind.ts

29 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-11-13 10:36:23 +08:00
/**
* Tailwind class text-red, text-red-500, text-sky
* @param className class
* @returns
*/
export function hasTextColor(className: string): boolean {
if (className == "") return false;
const regex =
/\btext-(primary|surface|red|blue|green|yellow|purple|pink|indigo|gray|grey|black|white|orange|amber|lime|emerald|teal|cyan|sky|violet|fuchsia|rose|slate|zinc|neutral|stone)(?:-\d+)?\b/;
return regex.test(className);
}
/**
* Tailwind class
* text-xs, text-sm, text-base, text-lg, text-xl, text-[22px]text-[22rpx]
* @param className class
* @returns
*/
export function hasTextSize(className: string): boolean {
if (className == "") return false;
const regex =
/\btext-(xs|sm|md|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl|\[\d+[a-zA-Z%]*\])\b/;
return regex.test(className);
}