/* eslint-disable formatjs/no-literal-string-in-jsx */ import copy from 'copy-to-clipboard' import { kebabify } from '../../generate/utils' import tableStyles from './tokens.module.css' type ThemeValue = { resolved: string | number alias?: string | number } type Theme = Record type ShadowProps = { theme: Theme } function copyToClipboard(text: string) { copy(text) } export function Shadow({ theme }: ShadowProps) { // Filter shadow tokens const shadowTokens: Theme = {} for (const [k, v] of Object.entries(theme)) { if (k.startsWith('BoxShadow-')) { shadowTokens[k] = v as ThemeValue } } // Sort by level const sortedTokens = Object.entries(shadowTokens).sort((a, b) => { const aLevel = parseInt(a[0].match(/\d+/)?.[0] || '0') const bLevel = parseInt(b[0].match(/\d+/)?.[0] || '0') return aLevel - bLevel }) return (
{sortedTokens.map(([k, v]) => { const shadowValue = typeof v.resolved === 'string' ? v.resolved : '' const level = k.match(/\d+/)?.[0] || '0' return ( ) })}
Token Level Value Visual representation
{ copyToClipboard(`var(--${kebabify(k)})`) }} title="Click to copy CSS variable" > {kebabify(k)} Level {level} { copyToClipboard(shadowValue) }} title="Click to copy" style={{ fontSize: '0.75rem', wordBreak: 'break-all', }} > {shadowValue}
) }