Fork from @arco-design/color
Committed to
ESMfirst, invitesimilar tools, you can skip dependency pre-bundling
ArcoDesign Color Utils.
For a given color, a gradient swatch containing ten colors is generated with an algorithm. This works for both light and dark modes.
npm i @vrx-arco/theme-colorsimport { generate, getPresetColors } from '@vrx-arco/theme-colors';
console.log(generate('#123456'));
console.log(getPresetColors());
// {
// red: {...},
// orangered: {...},
// orange: {...},
// gold: {...},
// yellow: {...},
// lime: {...},
// green: {...},
// cyan: {...},
// blue: {...},
// arcoblue: {...},
// purple: {...},
// pinkpurple: {...},
// magenta: {...},
// gray: {...}
// }Index (starting from 1) of the gradient colors to be generated.
Whether to generate color array containing the ten colors.
Whether to generate colors for dark mode.
Color format.
Contains 14 preset sets of colors.
redorangeredorangegoldyellowlimegreencyanbluearcobluepurplepinkpurplemagentagray
const { red } = getPresetColors();
console.log(red.light);
console.log(red.dark);
console.log(red.primary);For a given color, get the r, g, b value in string
getRgbStr('#F53F3F') // 245,63,63The generated color palette is different from @arco-design/color
- In order to achieve pure ESM, the color parsing tool is replaced by
@ctrl/tinycolorused in ant-design and element. There are slight differences in precision in color calculation, and slight differences in the actual generated colors, but the difference is not big in actual display. - In subsequent versions, the
colorpackage used by the original project@arco-design/colormay be rewritten to keep the returned data consistent