The purpose of this repository is to automate the process of adjusting my brand colours. And also train my coding skills.
- Uses [CSS custom properties], with all of the color code properties
- Has source-maps, for easier debugging.
- Additional colors info available via
colors.json
. - Contains CLI written in TypeScript for automated tasks.
You can install this package with any Node.JS package of your choice:
pnpm install @xeho91/colors
If you use for example PostCSS, you can just import them with the following code:
@import "@xeho91/colors";
Each color has a name, and properties based on the color code used. I
prefer to use HSLA.
The properties are named with following format --<name>_<property>
.
Example:
:root {
--clairvoyant_alpha: 1;
--clairvoyant_hue: 297deg;
--clairvoyant_saturation: 84%;
--clairvoyant_lightness: 10%;
--clairvoyant_HSL: var(--clairvoyant_hue), var(--clairvoyant_saturation), var(--clairvoyant_lightness);
--clairvoyant_HSLA: hsla(var(--clairvoyant_HSL), var(--clairvoyant_alpha));
}
However, the variable to use it for coloring background, color or fill is named
with the following format --color-<name>
.
Example:
body {
color-background: var(--color-clairvoyant);
}
To make it darker, lighter, or whatever needs to be done, it can be used like this:
body {
color-background: hsla(
var(--clairvoyant_alpha),
var(--clairvoyant_hue),
calc(var(--clairvoyant_lightness) + 20%),
var(--clairvoyant_alpha)
);
}
It may be too verbose, but at least it gives the full control, without breaking the brand guidelines.
To make the more transparent, is possible to use it like this:
body {
color-background: hsla(var(--clairvoyant_HSL), 0.75);
}
NOTE: Requires Deno, until I am going to be able to compile or bundle.
At the moment due to the issues with upstream and swc
, I can't.
-
Install the package globally with Node.JS package of your choice.
I usepnpm
, so in my casepnpm install --global @xeho91/colors
. -
Inspect the code of installer script!
(Example from using Linux, and Zsh):cat "$(pnpm root --global)/@xeho91/colors/install.sh"
-
If nothing suspicious and you understand what's going on here, execute it.
"$(pnpm root --global)/@xeho91/colors/install.sh"
-
Edit the
colors.config.json
if needed. -
Use
xeho91-colors --help
to view available options and commands. -
If you're lazy, just use
xeho91-colors
and it will ask you what do you want to do.
- Generate the CSS output with desired color code variant (HSL, RGB, or HEX)
- Display the color's data for all of the colors or specific ones
- display them with some sorting options
- Adding/deleting new colors to the config
- Modifying existing colors in the config