import React, { useMemo } from "react"; import '../../fonts/roboto.css'; import { AriaProps } from '../types/aria'; type TypographyProps = AriaProps & { children: React.ReactNode; variant?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "label"; className?: string; color?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'on-primary' | 'on-secondary' | 'on-tertiary' | 'on-error' | 'scrim' | 'outline' | 'outline-variant' | string; align?: "left" | "center" | "right"; style?: React.CSSProperties; noWrap?: boolean; id?: string; size?: "small" | "medium" | "large" | "auto"; htmlFor?: string; }; export const Typography = ({ children, variant = "span", className, color = "", align, style, noWrap, id, size = "auto", htmlFor }: TypographyProps) => { const clr = useMemo(() => { if (color === 'primary') return 'var(--md-sys-color-primary)'; if (color === 'secondary') return 'var(--md-sys-color-secondary)'; if (color === 'tertiary') return 'var(--md-sys-color-tertiary)'; if (color === 'error') return 'var(--md-sys-color-error)'; if (color === 'on-primary') return 'var(--md-sys-color-on-primary)'; if (color === 'on-secondary') return 'var(--md-sys-color-on-secondary)'; if (color === 'on-tertiary') return 'var(--md-sys-color-on-tertiary)'; if (color === 'on-error') return 'var(--md-sys-color-on-error)'; if (color === 'on-surface') return 'var(--md-sys-color-on-surface)'; if (color === 'scrim') return 'var(--md-sys-color-scrim)'; if (color === 'outline') return 'var(--md-sys-color-outline)'; if (color === 'outline-variant') return 'var(--md-sys-color-outline-variant)'; return color; }, [color]); const sz = useMemo(() => { if (size === 'auto') { const sizes = { h1: 'large', h2: 'large', h3: 'medium', h4: 'medium', h5: 'small', h6: 'small', p: 'large', span: 'large', label: 'large', }; return sizes[variant as keyof typeof sizes]; }; if (size === 'small') return 'small'; if (size === 'medium') return 'medium'; if (size === 'large') return 'large'; }, [size]); if (variant === "h1") { return (
{children}
); } if (variant === "span") { return ( {children} ); } if (variant === "label") { return ( ); } return null; };