UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

1 lines 657 B
{"version":3,"file":"safeReadableColor.mjs","names":[],"sources":["../../src/utils/safeReadableColor.ts"],"sourcesContent":["import { cssVar } from 'antd-style';\nimport { readableColor } from 'polished';\n\nexport const safeReadableColor = (bgColor: string, fallbackColor?: string): string => {\n try {\n return readableColor(bgColor);\n } catch {\n if (bgColor.startsWith('var(')) return `contrast-color(${bgColor})`;\n return fallbackColor || cssVar.colorText;\n }\n};\n"],"mappings":";;;AAGA,MAAa,qBAAqB,SAAiB,kBAAmC;CACpF,IAAI;EACF,OAAO,cAAc,OAAO;CAC9B,QAAQ;EACN,IAAI,QAAQ,WAAW,MAAM,GAAG,OAAO,kBAAkB,QAAQ;EACjE,OAAO,iBAAiB,OAAO;CACjC;AACF"}