Format using new prettier config
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
/** Converts a percentage scale value (0-100) to normalized scale (0-1) value. */
|
/** Converts a percentage scale value (0-100) to normalized scale (0-1) value. */
|
||||||
export function percentageToNormalized(value: number) {
|
export function percentageToNormalized(value: number) {
|
||||||
const normalized = value / 100;
|
const normalized = value / 100
|
||||||
return normalized;
|
return normalized
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts a normalized scale (0-1) value to a percentage scale (0-100) value. */
|
/** Converts a normalized scale (0-1) value to a percentage scale (0-100) value. */
|
||||||
export function normalizedToPercetage(value: number) {
|
export function normalizedToPercetage(value: number) {
|
||||||
const percentage = value * 100;
|
const percentage = value * 100
|
||||||
return percentage;
|
return percentage
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import bezier from "bezier-easing";
|
import bezier from "bezier-easing"
|
||||||
import { Curve } from "../ref/curves";
|
import { Curve } from "../ref/curves"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats our Curve data structure into a bezier easing function.
|
* Formats our Curve data structure into a bezier easing function.
|
||||||
@@ -8,14 +8,19 @@ import { Curve } from "../ref/curves";
|
|||||||
* @returns {EasingFunction} The formatted easing function.
|
* @returns {EasingFunction} The formatted easing function.
|
||||||
*/
|
*/
|
||||||
export function curve(curve: Curve, inverted?: Boolean) {
|
export function curve(curve: Curve, inverted?: Boolean) {
|
||||||
if (inverted) {
|
if (inverted) {
|
||||||
return bezier(
|
return bezier(
|
||||||
curve.value[3],
|
curve.value[3],
|
||||||
curve.value[2],
|
curve.value[2],
|
||||||
curve.value[1],
|
curve.value[1],
|
||||||
curve.value[0]
|
curve.value[0]
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return bezier(curve.value[0], curve.value[1], curve.value[2], curve.value[3]);
|
return bezier(
|
||||||
|
curve.value[0],
|
||||||
|
curve.value[1],
|
||||||
|
curve.value[2],
|
||||||
|
curve.value[3]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import bezier from "bezier-easing";
|
import bezier from "bezier-easing"
|
||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js"
|
||||||
import { Color, ColorFamily, ColorFamilyConfig, ColorScale } from "../types";
|
import { Color, ColorFamily, ColorFamilyConfig, ColorScale } from "../types"
|
||||||
import { percentageToNormalized } from "./convert";
|
import { percentageToNormalized } from "./convert"
|
||||||
import { curve } from "./curve";
|
import { curve } from "./curve"
|
||||||
|
|
||||||
// Re-export interface in a more standard format
|
// Re-export interface in a more standard format
|
||||||
export type EasingFunction = bezier.EasingFunction;
|
export type EasingFunction = bezier.EasingFunction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a color, outputs it in multiple formats, and returns a variety of useful metadata.
|
* Generates a color, outputs it in multiple formats, and returns a variety of useful metadata.
|
||||||
@@ -20,60 +20,60 @@ export type EasingFunction = bezier.EasingFunction;
|
|||||||
* @returns {Color} The generated color, with its calculated contrast against black and white, as well as its LCH values, RGBA array, hexadecimal representation, and a flag indicating if it is light or dark.
|
* @returns {Color} The generated color, with its calculated contrast against black and white, as well as its LCH values, RGBA array, hexadecimal representation, and a flag indicating if it is light or dark.
|
||||||
*/
|
*/
|
||||||
function generateColor(
|
function generateColor(
|
||||||
hueEasing: EasingFunction,
|
hueEasing: EasingFunction,
|
||||||
saturationEasing: EasingFunction,
|
saturationEasing: EasingFunction,
|
||||||
lightnessEasing: EasingFunction,
|
lightnessEasing: EasingFunction,
|
||||||
family: ColorFamilyConfig,
|
family: ColorFamilyConfig,
|
||||||
step: number,
|
step: number,
|
||||||
steps: number
|
steps: number
|
||||||
) {
|
) {
|
||||||
const { hue, saturation, lightness } = family.color;
|
const { hue, saturation, lightness } = family.color
|
||||||
|
|
||||||
const stepHue = hueEasing(step / steps) * (hue.end - hue.start) + hue.start;
|
const stepHue = hueEasing(step / steps) * (hue.end - hue.start) + hue.start
|
||||||
const stepSaturation =
|
const stepSaturation =
|
||||||
saturationEasing(step / steps) * (saturation.end - saturation.start) +
|
saturationEasing(step / steps) * (saturation.end - saturation.start) +
|
||||||
saturation.start;
|
saturation.start
|
||||||
const stepLightness =
|
const stepLightness =
|
||||||
lightnessEasing(step / steps) * (lightness.end - lightness.start) +
|
lightnessEasing(step / steps) * (lightness.end - lightness.start) +
|
||||||
lightness.start;
|
lightness.start
|
||||||
|
|
||||||
const color = chroma.hsl(
|
const color = chroma.hsl(
|
||||||
stepHue,
|
stepHue,
|
||||||
percentageToNormalized(stepSaturation),
|
percentageToNormalized(stepSaturation),
|
||||||
percentageToNormalized(stepLightness)
|
percentageToNormalized(stepLightness)
|
||||||
);
|
)
|
||||||
|
|
||||||
const contrast = {
|
const contrast = {
|
||||||
black: {
|
black: {
|
||||||
value: chroma.contrast(color, "black"),
|
value: chroma.contrast(color, "black"),
|
||||||
aaPass: chroma.contrast(color, "black") >= 4.5,
|
aaPass: chroma.contrast(color, "black") >= 4.5,
|
||||||
aaaPass: chroma.contrast(color, "black") >= 7,
|
aaaPass: chroma.contrast(color, "black") >= 7,
|
||||||
},
|
},
|
||||||
white: {
|
white: {
|
||||||
value: chroma.contrast(color, "white"),
|
value: chroma.contrast(color, "white"),
|
||||||
aaPass: chroma.contrast(color, "white") >= 4.5,
|
aaPass: chroma.contrast(color, "white") >= 4.5,
|
||||||
aaaPass: chroma.contrast(color, "white") >= 7,
|
aaaPass: chroma.contrast(color, "white") >= 7,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|
||||||
const lch = color.lch();
|
const lch = color.lch()
|
||||||
const rgba = color.rgba();
|
const rgba = color.rgba()
|
||||||
const hex = color.hex();
|
const hex = color.hex()
|
||||||
|
|
||||||
// 55 is a magic number. It's the lightness value at which we consider a color to be "light".
|
// 55 is a magic number. It's the lightness value at which we consider a color to be "light".
|
||||||
// It was picked by eye with some testing. We might want to use a more scientific approach in the future.
|
// It was picked by eye with some testing. We might want to use a more scientific approach in the future.
|
||||||
const isLight = lch[0] > 55;
|
const isLight = lch[0] > 55
|
||||||
|
|
||||||
const result: Color = {
|
const result: Color = {
|
||||||
step,
|
step,
|
||||||
lch,
|
lch,
|
||||||
hex,
|
hex,
|
||||||
rgba,
|
rgba,
|
||||||
contrast,
|
contrast,
|
||||||
isLight,
|
isLight,
|
||||||
};
|
}
|
||||||
|
|
||||||
return result;
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,50 +110,50 @@ function generateColor(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function generateColorScale(
|
export function generateColorScale(
|
||||||
config: ColorFamilyConfig,
|
config: ColorFamilyConfig,
|
||||||
inverted: Boolean = false
|
inverted: Boolean = false
|
||||||
) {
|
) {
|
||||||
const { hue, saturation, lightness } = config.color;
|
const { hue, saturation, lightness } = config.color
|
||||||
|
|
||||||
// 101 steps means we get values from 0-100
|
// 101 steps means we get values from 0-100
|
||||||
const NUM_STEPS = 101;
|
const NUM_STEPS = 101
|
||||||
|
|
||||||
const hueEasing = curve(hue.curve, inverted);
|
const hueEasing = curve(hue.curve, inverted)
|
||||||
const saturationEasing = curve(saturation.curve, inverted);
|
const saturationEasing = curve(saturation.curve, inverted)
|
||||||
const lightnessEasing = curve(lightness.curve, inverted);
|
const lightnessEasing = curve(lightness.curve, inverted)
|
||||||
|
|
||||||
let scale: ColorScale = {
|
let scale: ColorScale = {
|
||||||
colors: [],
|
colors: [],
|
||||||
values: [],
|
values: [],
|
||||||
};
|
}
|
||||||
|
|
||||||
for (let i = 0; i < NUM_STEPS; i++) {
|
for (let i = 0; i < NUM_STEPS; i++) {
|
||||||
const color = generateColor(
|
const color = generateColor(
|
||||||
hueEasing,
|
hueEasing,
|
||||||
saturationEasing,
|
saturationEasing,
|
||||||
lightnessEasing,
|
lightnessEasing,
|
||||||
config,
|
config,
|
||||||
i,
|
i,
|
||||||
NUM_STEPS
|
NUM_STEPS
|
||||||
);
|
)
|
||||||
|
|
||||||
scale.colors.push(color);
|
scale.colors.push(color)
|
||||||
scale.values.push(color.hex);
|
scale.values.push(color.hex)
|
||||||
}
|
}
|
||||||
|
|
||||||
return scale;
|
return scale
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generates a color family with a scale and an inverted scale. */
|
/** Generates a color family with a scale and an inverted scale. */
|
||||||
export function generateColorFamily(config: ColorFamilyConfig) {
|
export function generateColorFamily(config: ColorFamilyConfig) {
|
||||||
const scale = generateColorScale(config, false);
|
const scale = generateColorScale(config, false)
|
||||||
const invertedScale = generateColorScale(config, true);
|
const invertedScale = generateColorScale(config, true)
|
||||||
|
|
||||||
const family: ColorFamily = {
|
const family: ColorFamily = {
|
||||||
name: config.name,
|
name: config.name,
|
||||||
scale,
|
scale,
|
||||||
invertedScale,
|
invertedScale,
|
||||||
};
|
}
|
||||||
|
|
||||||
return family;
|
return family
|
||||||
}
|
}
|
||||||
|
|||||||
+344
-344
@@ -1,5 +1,5 @@
|
|||||||
import { generateColorFamily } from "../lib/generate";
|
import { generateColorFamily } from "../lib/generate"
|
||||||
import { curve } from "./curves";
|
import { curve } from "./curves"
|
||||||
|
|
||||||
// These are the source colors for the color scales in the system.
|
// These are the source colors for the color scales in the system.
|
||||||
// These should never directly be used directly in components or themes as they generate thousands of lines of code.
|
// These should never directly be used directly in components or themes as they generate thousands of lines of code.
|
||||||
@@ -10,436 +10,436 @@ import { curve } from "./curves";
|
|||||||
// Light Gray ======================================== //
|
// Light Gray ======================================== //
|
||||||
|
|
||||||
export const lightgray = generateColorFamily({
|
export const lightgray = generateColorFamily({
|
||||||
name: "lightgray",
|
name: "lightgray",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 210,
|
start: 210,
|
||||||
end: 210,
|
end: 210,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 10,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 50,
|
||||||
|
curve: curve.linear,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 10,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 50,
|
|
||||||
curve: curve.linear,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Light Dark ======================================== //
|
// Light Dark ======================================== //
|
||||||
|
|
||||||
export const darkgray = generateColorFamily({
|
export const darkgray = generateColorFamily({
|
||||||
name: "darkgray",
|
name: "darkgray",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 210,
|
start: 210,
|
||||||
end: 210,
|
end: 210,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 15,
|
||||||
|
end: 20,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 55,
|
||||||
|
end: 8,
|
||||||
|
curve: curve.linear,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 15,
|
|
||||||
end: 20,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 55,
|
|
||||||
end: 8,
|
|
||||||
curve: curve.linear,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Red ======================================== //
|
// Red ======================================== //
|
||||||
|
|
||||||
export const red = generateColorFamily({
|
export const red = generateColorFamily({
|
||||||
name: "red",
|
name: "red",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 95,
|
||||||
|
end: 75,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 25,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 95,
|
|
||||||
end: 75,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 25,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Sunset ======================================== //
|
// Sunset ======================================== //
|
||||||
|
|
||||||
export const sunset = generateColorFamily({
|
export const sunset = generateColorFamily({
|
||||||
name: "sunset",
|
name: "sunset",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 15,
|
start: 15,
|
||||||
end: 15,
|
end: 15,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 100,
|
||||||
|
end: 90,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 25,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 100,
|
|
||||||
end: 90,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 25,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Orange ======================================== //
|
// Orange ======================================== //
|
||||||
|
|
||||||
export const orange = generateColorFamily({
|
export const orange = generateColorFamily({
|
||||||
name: "orange",
|
name: "orange",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 25,
|
start: 25,
|
||||||
end: 25,
|
end: 25,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 100,
|
||||||
|
end: 95,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 20,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 100,
|
|
||||||
end: 95,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 20,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Amber ======================================== //
|
// Amber ======================================== //
|
||||||
|
|
||||||
export const amber = generateColorFamily({
|
export const amber = generateColorFamily({
|
||||||
name: "amber",
|
name: "amber",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 38,
|
start: 38,
|
||||||
end: 38,
|
end: 38,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 100,
|
||||||
|
end: 100,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 18,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 100,
|
|
||||||
end: 100,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 18,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Yellow ======================================== //
|
// Yellow ======================================== //
|
||||||
|
|
||||||
export const yellow = generateColorFamily({
|
export const yellow = generateColorFamily({
|
||||||
name: "yellow",
|
name: "yellow",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 48,
|
start: 48,
|
||||||
end: 48,
|
end: 48,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 90,
|
||||||
|
end: 100,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 90,
|
|
||||||
end: 100,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Lemon ======================================== //
|
// Lemon ======================================== //
|
||||||
|
|
||||||
export const lemon = generateColorFamily({
|
export const lemon = generateColorFamily({
|
||||||
name: "lemon",
|
name: "lemon",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 55,
|
start: 55,
|
||||||
end: 55,
|
end: 55,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 85,
|
||||||
|
end: 95,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 85,
|
|
||||||
end: 95,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Citron ======================================== //
|
// Citron ======================================== //
|
||||||
|
|
||||||
export const citron = generateColorFamily({
|
export const citron = generateColorFamily({
|
||||||
name: "citron",
|
name: "citron",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 70,
|
start: 70,
|
||||||
end: 70,
|
end: 70,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 85,
|
||||||
|
end: 90,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 85,
|
|
||||||
end: 90,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Lime ======================================== //
|
// Lime ======================================== //
|
||||||
|
|
||||||
export const lime = generateColorFamily({
|
export const lime = generateColorFamily({
|
||||||
name: "lime",
|
name: "lime",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 85,
|
start: 85,
|
||||||
end: 85,
|
end: 85,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 85,
|
||||||
|
end: 80,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 18,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 85,
|
|
||||||
end: 80,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 18,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Green ======================================== //
|
// Green ======================================== //
|
||||||
|
|
||||||
export const green = generateColorFamily({
|
export const green = generateColorFamily({
|
||||||
name: "green",
|
name: "green",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 108,
|
start: 108,
|
||||||
end: 108,
|
end: 108,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 60,
|
||||||
|
end: 70,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 18,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 60,
|
|
||||||
end: 70,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 18,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mint ======================================== //
|
// Mint ======================================== //
|
||||||
|
|
||||||
export const mint = generateColorFamily({
|
export const mint = generateColorFamily({
|
||||||
name: "mint",
|
name: "mint",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 142,
|
start: 142,
|
||||||
end: 142,
|
end: 142,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 60,
|
||||||
|
end: 75,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 20,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 60,
|
|
||||||
end: 75,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 20,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cyan ======================================== //
|
// Cyan ======================================== //
|
||||||
|
|
||||||
export const cyan = generateColorFamily({
|
export const cyan = generateColorFamily({
|
||||||
name: "cyan",
|
name: "cyan",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 179,
|
start: 179,
|
||||||
end: 179,
|
end: 179,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 70,
|
||||||
|
end: 80,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 20,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 70,
|
|
||||||
end: 80,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 20,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Sky ======================================== //
|
// Sky ======================================== //
|
||||||
|
|
||||||
export const sky = generateColorFamily({
|
export const sky = generateColorFamily({
|
||||||
name: "sky",
|
name: "sky",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 195,
|
start: 195,
|
||||||
end: 205,
|
end: 205,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 85,
|
||||||
|
end: 90,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 85,
|
|
||||||
end: 90,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Blue ======================================== //
|
// Blue ======================================== //
|
||||||
|
|
||||||
export const blue = generateColorFamily({
|
export const blue = generateColorFamily({
|
||||||
name: "blue",
|
name: "blue",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 218,
|
start: 218,
|
||||||
end: 218,
|
end: 218,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 85,
|
||||||
|
end: 70,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 15,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 85,
|
|
||||||
end: 70,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 15,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Indigo ======================================== //
|
// Indigo ======================================== //
|
||||||
|
|
||||||
export const indigo = generateColorFamily({
|
export const indigo = generateColorFamily({
|
||||||
name: "indigo",
|
name: "indigo",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 245,
|
start: 245,
|
||||||
end: 245,
|
end: 245,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 60,
|
||||||
|
end: 50,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 22,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 60,
|
|
||||||
end: 50,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 22,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Purple ======================================== //
|
// Purple ======================================== //
|
||||||
|
|
||||||
export const purple = generateColorFamily({
|
export const purple = generateColorFamily({
|
||||||
name: "purple",
|
name: "purple",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 260,
|
start: 260,
|
||||||
end: 270,
|
end: 270,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 65,
|
||||||
|
end: 55,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 20,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 65,
|
|
||||||
end: 55,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 20,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pink ======================================== //
|
// Pink ======================================== //
|
||||||
|
|
||||||
export const pink = generateColorFamily({
|
export const pink = generateColorFamily({
|
||||||
name: "pink",
|
name: "pink",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 320,
|
start: 320,
|
||||||
end: 330,
|
end: 330,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 70,
|
||||||
|
end: 65,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 32,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 70,
|
|
||||||
end: 65,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 32,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Rose ======================================== //
|
// Rose ======================================== //
|
||||||
|
|
||||||
export const rose = generateColorFamily({
|
export const rose = generateColorFamily({
|
||||||
name: "rose",
|
name: "rose",
|
||||||
color: {
|
color: {
|
||||||
hue: {
|
hue: {
|
||||||
start: 345,
|
start: 345,
|
||||||
end: 345,
|
end: 345,
|
||||||
curve: curve.linear,
|
curve: curve.linear,
|
||||||
|
},
|
||||||
|
saturation: {
|
||||||
|
start: 90,
|
||||||
|
end: 70,
|
||||||
|
curve: curve.saturation,
|
||||||
|
},
|
||||||
|
lightness: {
|
||||||
|
start: 97,
|
||||||
|
end: 32,
|
||||||
|
curve: curve.lightness,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
saturation: {
|
})
|
||||||
start: 90,
|
|
||||||
end: 70,
|
|
||||||
curve: curve.saturation,
|
|
||||||
},
|
|
||||||
lightness: {
|
|
||||||
start: 97,
|
|
||||||
end: 32,
|
|
||||||
curve: curve.lightness,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
export interface Curve {
|
export interface Curve {
|
||||||
name: string;
|
name: string
|
||||||
value: number[];
|
value: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Curves {
|
export interface Curves {
|
||||||
lightness: Curve;
|
lightness: Curve
|
||||||
saturation: Curve;
|
saturation: Curve
|
||||||
linear: Curve;
|
linear: Curve
|
||||||
}
|
}
|
||||||
|
|
||||||
export const curve: Curves = {
|
export const curve: Curves = {
|
||||||
lightness: {
|
lightness: {
|
||||||
name: "lightnessCurve",
|
name: "lightnessCurve",
|
||||||
value: [0.2, 0, 0.75, 1.0],
|
value: [0.2, 0, 0.75, 1.0],
|
||||||
},
|
},
|
||||||
saturation: {
|
saturation: {
|
||||||
name: "saturationCurve",
|
name: "saturationCurve",
|
||||||
value: [0.67, 0.6, 0.55, 1.0],
|
value: [0.67, 0.6, 0.55, 1.0],
|
||||||
},
|
},
|
||||||
linear: {
|
linear: {
|
||||||
name: "linear",
|
name: "linear",
|
||||||
value: [0.5, 0.5, 0.5, 0.5],
|
value: [0.5, 0.5, 0.5, 0.5],
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|||||||
+29
-29
@@ -1,32 +1,32 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js"
|
||||||
import * as colorFamily from "./ref/color";
|
import * as colorFamily from "./ref/color"
|
||||||
|
|
||||||
const color = {
|
const color = {
|
||||||
lightgray: chroma
|
lightgray: chroma
|
||||||
.scale(colorFamily.lightgray.scale.values)
|
.scale(colorFamily.lightgray.scale.values)
|
||||||
.mode("lch")
|
.mode("lch")
|
||||||
.colors(9),
|
.colors(9),
|
||||||
darkgray: chroma
|
darkgray: chroma
|
||||||
.scale(colorFamily.darkgray.scale.values)
|
.scale(colorFamily.darkgray.scale.values)
|
||||||
.mode("lch")
|
.mode("lch")
|
||||||
.colors(9),
|
.colors(9),
|
||||||
red: chroma.scale(colorFamily.red.scale.values).mode("lch").colors(9),
|
red: chroma.scale(colorFamily.red.scale.values).mode("lch").colors(9),
|
||||||
sunset: chroma.scale(colorFamily.sunset.scale.values).mode("lch").colors(9),
|
sunset: chroma.scale(colorFamily.sunset.scale.values).mode("lch").colors(9),
|
||||||
orange: chroma.scale(colorFamily.orange.scale.values).mode("lch").colors(9),
|
orange: chroma.scale(colorFamily.orange.scale.values).mode("lch").colors(9),
|
||||||
amber: chroma.scale(colorFamily.amber.scale.values).mode("lch").colors(9),
|
amber: chroma.scale(colorFamily.amber.scale.values).mode("lch").colors(9),
|
||||||
yellow: chroma.scale(colorFamily.yellow.scale.values).mode("lch").colors(9),
|
yellow: chroma.scale(colorFamily.yellow.scale.values).mode("lch").colors(9),
|
||||||
lemon: chroma.scale(colorFamily.lemon.scale.values).mode("lch").colors(9),
|
lemon: chroma.scale(colorFamily.lemon.scale.values).mode("lch").colors(9),
|
||||||
citron: chroma.scale(colorFamily.citron.scale.values).mode("lch").colors(9),
|
citron: chroma.scale(colorFamily.citron.scale.values).mode("lch").colors(9),
|
||||||
lime: chroma.scale(colorFamily.lime.scale.values).mode("lch").colors(9),
|
lime: chroma.scale(colorFamily.lime.scale.values).mode("lch").colors(9),
|
||||||
green: chroma.scale(colorFamily.green.scale.values).mode("lch").colors(9),
|
green: chroma.scale(colorFamily.green.scale.values).mode("lch").colors(9),
|
||||||
mint: chroma.scale(colorFamily.mint.scale.values).mode("lch").colors(9),
|
mint: chroma.scale(colorFamily.mint.scale.values).mode("lch").colors(9),
|
||||||
cyan: chroma.scale(colorFamily.cyan.scale.values).mode("lch").colors(9),
|
cyan: chroma.scale(colorFamily.cyan.scale.values).mode("lch").colors(9),
|
||||||
sky: chroma.scale(colorFamily.sky.scale.values).mode("lch").colors(9),
|
sky: chroma.scale(colorFamily.sky.scale.values).mode("lch").colors(9),
|
||||||
blue: chroma.scale(colorFamily.blue.scale.values).mode("lch").colors(9),
|
blue: chroma.scale(colorFamily.blue.scale.values).mode("lch").colors(9),
|
||||||
indigo: chroma.scale(colorFamily.indigo.scale.values).mode("lch").colors(9),
|
indigo: chroma.scale(colorFamily.indigo.scale.values).mode("lch").colors(9),
|
||||||
purple: chroma.scale(colorFamily.purple.scale.values).mode("lch").colors(9),
|
purple: chroma.scale(colorFamily.purple.scale.values).mode("lch").colors(9),
|
||||||
pink: chroma.scale(colorFamily.pink.scale.values).mode("lch").colors(9),
|
pink: chroma.scale(colorFamily.pink.scale.values).mode("lch").colors(9),
|
||||||
rose: chroma.scale(colorFamily.rose.scale.values).mode("lch").colors(9),
|
rose: chroma.scale(colorFamily.rose.scale.values).mode("lch").colors(9),
|
||||||
};
|
}
|
||||||
|
|
||||||
export { color };
|
export { color }
|
||||||
|
|||||||
+35
-36
@@ -1,10 +1,9 @@
|
|||||||
import { Color as ChromaColor } from "chroma-js";
|
import { Curve } from "./ref/curves"
|
||||||
import { Curve } from "./ref/curves";
|
|
||||||
|
|
||||||
export interface ColorAccessiblityValue {
|
export interface ColorAccessiblityValue {
|
||||||
value: number;
|
value: number
|
||||||
aaPass: boolean;
|
aaPass: boolean
|
||||||
aaaPass: boolean;
|
aaaPass: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,54 +13,54 @@ export interface ColorAccessiblityValue {
|
|||||||
* @note The goal is to align with WCAG3 accessibility standards as they become stabilized. See the [WCAG 3 Introduction](https://www.w3.org/WAI/standards-guidelines/wcag/wcag3-intro/) for more information.
|
* @note The goal is to align with WCAG3 accessibility standards as they become stabilized. See the [WCAG 3 Introduction](https://www.w3.org/WAI/standards-guidelines/wcag/wcag3-intro/) for more information.
|
||||||
*/
|
*/
|
||||||
export interface ColorAccessiblity {
|
export interface ColorAccessiblity {
|
||||||
black: ColorAccessiblityValue;
|
black: ColorAccessiblityValue
|
||||||
white: ColorAccessiblityValue;
|
white: ColorAccessiblityValue
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Color = {
|
export type Color = {
|
||||||
step: number;
|
step: number
|
||||||
contrast: ColorAccessiblity;
|
contrast: ColorAccessiblity
|
||||||
hex: string;
|
hex: string
|
||||||
lch: number[];
|
lch: number[]
|
||||||
rgba: number[];
|
rgba: number[]
|
||||||
isLight: boolean;
|
isLight: boolean
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface ColorScale {
|
export interface ColorScale {
|
||||||
colors: Color[];
|
colors: Color[]
|
||||||
// An array of hex values for each color in the scale
|
// An array of hex values for each color in the scale
|
||||||
values: string[];
|
values: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ColorFamily = {
|
export type ColorFamily = {
|
||||||
name: string;
|
name: string
|
||||||
scale: ColorScale;
|
scale: ColorScale
|
||||||
invertedScale: ColorScale;
|
invertedScale: ColorScale
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface ColorFamilyHue {
|
export interface ColorFamilyHue {
|
||||||
start: number;
|
start: number
|
||||||
end: number;
|
end: number
|
||||||
curve: Curve;
|
curve: Curve
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorFamilySaturation {
|
export interface ColorFamilySaturation {
|
||||||
start: number;
|
start: number
|
||||||
end: number;
|
end: number
|
||||||
curve: Curve;
|
curve: Curve
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorFamilyLightness {
|
export interface ColorFamilyLightness {
|
||||||
start: number;
|
start: number
|
||||||
end: number;
|
end: number
|
||||||
curve: Curve;
|
curve: Curve
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorFamilyConfig {
|
export interface ColorFamilyConfig {
|
||||||
name: string;
|
name: string
|
||||||
color: {
|
color: {
|
||||||
hue: ColorFamilyHue;
|
hue: ColorFamilyHue
|
||||||
saturation: ColorFamilySaturation;
|
saturation: ColorFamilySaturation
|
||||||
lightness: ColorFamilyLightness;
|
lightness: ColorFamilyLightness
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user