UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

59 lines (56 loc) 2.24 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { ElementType, ReactNode, ComponentPropsWithoutRef } from 'react'; /** * Base text component props */ type BaseTextProps = { /** Content to be displayed */ children?: ReactNode; /** Text size variant */ size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl'; /** Font weight variant */ weight?: 'hairline' | 'light' | 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold' | 'black'; /** Color variant - white for light backgrounds, black for dark backgrounds */ color?: string; /** Additional CSS classes to apply */ className?: string; }; /** * Polymorphic text component props that ensures type safety based on the 'as' prop */ type TextProps<T extends ElementType = 'p'> = BaseTextProps & { /** HTML tag to render */ as?: T; } & Omit<ComponentPropsWithoutRef<T>, keyof BaseTextProps>; /** * Text component for Analytica Ensino platforms * * A flexible polymorphic text component with multiple sizes, weights, and colors. * Automatically adapts to dark and light themes with full type safety. * * @param children - The content to display * @param size - The text size variant (2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl) * @param weight - The font weight variant (hairline, light, normal, medium, semibold, bold, extrabold, black) * @param color - The color variant - adapts to theme * @param as - The HTML tag to render - determines allowed attributes via TypeScript * @param className - Additional CSS classes * @param props - HTML attributes valid for the chosen tag only * @returns A styled text element with type-safe attributes * * @example * ```tsx * <Text size="lg" weight="bold" color="text-info-800"> * This is a large, bold text * </Text> * * <Text as="a" href="/link" target="_blank"> * Link with type-safe anchor attributes * </Text> * * <Text as="button" onClick={handleClick} disabled> * Button with type-safe button attributes * </Text> * ``` */ declare const Text: <T extends ElementType = "p">({ children, size, weight, color, as, className, ...props }: TextProps<T>) => react_jsx_runtime.JSX.Element; export { Text as default };