UNPKG

@hiimjustin000/colors-css

Version:

Get all the colors that are included in CSS.

37 lines (36 loc) 1.02 kB
const chalk = require("chalk"); const convert = require("color-convert"); const Colors = require("."); const colors = require("./colors.json"); const colorTypes = [ "hex", "rgb", "hsl", "hsv", "hwb", "cmyk", "xyz", "lab", "lch", "keyword", "ansi16", "ansi256", "hcg", "apple" ]; function cli(argv) { if (!argv[0]) return console.log([ "Format: colors (hex/keyword)", "", "List of CSS (keyword) colors:", Object.keys(colors).join(", ") ].join("\n")); let color = Colors.color(argv[0]); let colorMessage = []; for (const colorType of colorTypes) { colorMessage.push(`${colorType.toUpperCase()}: ${chalk.hex(convert[colorType].hex ? convert[colorType].hex(color[colorType]) : color.hex)(color[colorType] instanceof Array ? color[colorType].join(", ") : color[colorType])}`); } console.log(colorMessage.join("\n")); } module.exports = cli;