Skip to content

API reference

Liam Cheneval edited this page May 17, 2023 · 4 revisions

Palette constructor class

creates a palette from a chosen color.

let palette = new Palette(color, bestPractice, highContrast);

Usage

  • color: Is a string. The color to make the palette from in HEX format.
  • bestPractice: Optional, true by default, is a boolean that when true, Kozy will find the closest best color to use (experimental).
  • highContrast: Optional, false by default, is a boolean that when true, Kozy will make the color pallette easier to read for disabled people. We recommend you to add a toggle somewhere on your site as Kozy can be really hard to read even for anyone.

Returns

{
  "baseColor": hexColor,
  "raw": {
    "v100": [h, s, l],
    "v90": [h, s, l],
    "v80": [h, s, l],
    "v70": [h, s, l],
    "v60": [h, s, l],
    "v50": [h, s, l],
    "v40": [h, s, l],
    "v30": [h, s, l],
    "v20": [h, s, l],
    "v10": [h, s, l],
    "v5": [h, s, l],
    "v1": [h, s, l],
  }
}
  • hexColor from baseColor is the inputted hexadecimal color.
  • [h, s, l] is an array of 3 integer corresponding to the hue, saturation and lightness of the color in HSL format.

Hex to Hsl

Convert hexadecimal (HEX) to hue, saturation lightness (HSL).

Usage

let hsl = hexToHsl(color);
  • color: Is a string. The color to make the palette from in HEX format.

Returns

[h, s, l]
  • [h, s, l] is an array of 3 integer corresponding to the hue, saturation and lightness of the color in HSL format.
Clone this wiki locally