// Generated with util/create-component.js
import React, { useMemo } from "react";
import { isValidSpecValue } from "../../utils/functions";
import {
ColorChipsProps,
COLOR_CHIPS,
COLOR_CHIP_PATTERN,
TCOLOR_OF_COLOR_CHIPS,
} from "./ColorChips.types";
const ColorChips = ({
colors,
chipHeight,
chipWidth,
direction = "row",
shape = "circle",
size = 6,
isWrapped = false,
wrapperClassName = "",
}: ColorChipsProps) => {
const refinedColors = useMemo(() => {
return colors
.split("/")
.filter((color) => isValidSpecValue(color))
.slice(0, size);
}, [colors, size]);
if (refinedColors.length < 2) {
return null;
}
return (
{refinedColors.map((color) => {
const colorHexValue = COLOR_CHIPS[color as TCOLOR_OF_COLOR_CHIPS];
if (color === "패턴") {
return (
);
}
if (color.indexOf("+") !== -1) {
const combinationColors = color.split("+");
return (
);
}
if (colorHexValue) {
return (
);
}
})}
);
};
export default ColorChips;
const ColorChipPattern = ({
width,
height,
shape = "circle",
isWrapped,
}: {
width: string;
height: string;
shape?: "circle" | "square";
isWrapped: boolean;
}) => {
return (
{COLOR_CHIP_PATTERN.map((color, index) => {
return (
);
})}
);
};
const ColorChipCombination = ({
colors,
direction,
width,
height,
shape = "circle",
isWrapped,
}: {
colors: string[];
direction: "row" | "column";
width: string;
height: string;
shape?: "circle" | "square";
isWrapped: boolean;
}) => {
return (
{colors.map((color) => {
const colorHexValue = COLOR_CHIPS[color as TCOLOR_OF_COLOR_CHIPS];
return (
);
})}
);
};