import cx from 'classnames'; import type { FunctionalComponent, JSX } from 'preact'; import { useState } from 'preact/hooks'; import { Subheadline, Text } from '.'; interface ColorCardProps extends JSX.HTMLAttributes { class?: string; } interface Props extends JSX.HTMLAttributes { class?: string; color: string; title?: string; description?: string; } const ColorCard: FunctionalComponent = ({ class: className, children, ...props }) => { const classes = cx( 'absolute box-border h-[100vw] max-h-[200px] w-full max-w-[300px] rounded-25 bg-white shadow-book inline-start-0 block-start-0 [perspective:500px] [backface-visibility:hidden] dark:bg-black dark:border-[1px] dark:border-white/20', className ); return (
{children}
); }; export const ColorSwatch: FunctionalComponent = ({ class: className, color, title, description, ...props }) => { const [active, setActive] = useState(false); const classes = cx( 'h-[100vw] max-h-[200px] w-full max-w-[300px] [perspective:500px]', { 'cursor-pointer': description }, className ); const flipperClasses = cx( 'relative transition-transform duration-500 ease-in-out [transform-style:preserve-3d]', { '[transform:rotateY(180deg)]': active } ); const handleClick = () => { description && setActive(!active); }; return (
{title && ( {title} )} {color}
{description && ( {description} )}
); };