/** @jsx jsx */ import { jsx, ThemeUICSSObject } from "theme-ui" import useColorUtils from "../hooks/useColorUtils" import useSpecimensConfig from "../hooks/useSpecimensConfig" import Badge from "./badge" import theme from "../theme" const swatchContentStyles: ThemeUICSSObject = { flexBasis: `50%`, display: `flex`, flexDirection: `column`, fontSize: theme.fontSizes[1], alignItems: `flex-start`, color: theme.colors.black, span: { mb: theme.space[2], }, } type ColorSwatchProps = { color: string name?: string minimal?: boolean className?: string prefix?: string } const ColorSwatch = ({ color, name = ``, minimal = false, className = ``, prefix = `` }: ColorSwatchProps) => { const { hex, RGB, CMYK, ratings } = useColorUtils(color) const specimensOptions = useSpecimensConfig() return (
{ratings.map((rating) => (
A
{rating.value ? `Pass` : `Fail`}
))}
{name && (
Name {prefix} {name}
)}
Hex {hex}
{!minimal && (
RGB {RGB}
)} {!minimal && specimensOptions.CMYK && (
CMYK {CMYK}
)}
) } export default ColorSwatch