/*! Strand UI | MIT License | dillingerstaffing.com */ import type { JSX } from "preact"; import { forwardRef } from "preact/compat"; import { cx, styled } from "../../internal/index.js"; /** Auto-filling grid of colour swatches. */ export const SwatchGrid = styled("div", "strand-swatch-grid", "SwatchGrid"); export type SwatchGridProps = JSX.HTMLAttributes; export interface SwatchProps extends JSX.HTMLAttributes { /** Token name, e.g. "blue-primary". */ name: string; /** Hex value, e.g. "#3B8EF6". */ hex: string; /** Background colour. */ background: string; /** Text colour. */ color: string; } /** One colour specimen with its name and hex. */ export const Swatch = forwardRef( ({ name, hex, background, color, className = "", style, ...rest }, ref) => (
) }} {...rest} > {name} {hex}
), ); Swatch.displayName = "Swatch";