apphouse
Version:
Component library for React that uses observable state management and theme-able components.
22 lines (20 loc) • 656 B
text/typescript
import { Color } from "../Color";
import { Palette } from "../Palette";
export const getPaletteMatchingColorsByKey = (
palettes: Record<string, Palette>
): Record<string, Color[]> => {
const colorsBykeys: Record<string, Color[]> = {};
// first pass fills all possible color keys
Object.keys(palettes).forEach((paletteId) => {
const palette = palettes[paletteId];
const colors = palette.colors;
Object.keys(colors).forEach((key) => {
if (colorsBykeys[key]) {
colorsBykeys[key] = [...colorsBykeys[key], colors[key]];
} else {
colorsBykeys[key] = [colors[key]];
}
});
});
return colorsBykeys;
};