import * as React from 'react' import { HStack, Stack, VStack, panda } from '../../styled-system/jsx' import { getContrastPairs, getContrastRatio } from '../lib/color' import * as context from '../lib/panda-context' import { Select } from './input' import { TestScore } from './test-score' import { TokenContent } from './token-content' import { TokenGroup } from './token-group' interface ColorSelectProps { title: string value: string colors: { label: string value: string }[] onChange: (value: string) => void } function ColorSelect(props: ColorSelectProps) { const { title, colors, onChange, value } = props return ( {title} ) } export default function ColorContrastChecker() { const colors = context.colors const [foreground, setForeGround] = React.useState('#000000') const [background, setBackground] = React.useState('#ffffff') const activeForeground = (colors.find((col) => col.label === foreground)?.value || foreground) as string const activeBackground = (colors.find((col) => col.label === background)?.value || background) as string const wcag = getContrastPairs(activeForeground, activeBackground) const constrastRatio = getContrastRatio(activeForeground, activeBackground) return ( example text showing contrast
{constrastRatio ? `${constrastRatio?.toFixed(2).replace(/[.,]00$/, '')}:1` : ':'} Contrast ratio {wcag && ( Normal Text Large Text )}
) }