onecart-ui
Version:
OneCart UI: Cross-platform design tokens + React & React Native components
52 lines (51 loc) • 2.27 kB
TypeScript
import React from "react";
export type BodySize = "xl" | "lg" | "md" | "sm";
export interface BaseTypographyProps {
/** Horizontal text alignment */
align?: "left" | "center" | "right";
/** Text color override; falls back to token color when undefined */
color?: string;
/** Enables single-line truncation with ellipsis */
truncate?: boolean;
/** Number of lines to clamp; when provided applies multi-line ellipsis styles */
lineClamp?: number;
/** Optional CSS class name for styling adjustments */
className?: string;
/** Inline style overrides (React style object or arbitrary record) */
style?: React.CSSProperties | Record<string, unknown>;
/** Web click handler; executes alongside `onPress` if both supplied. */
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
/** Platform‑agnostic press handler (used by mobile; also invoked on web clicks). */
onPress?: () => void;
/** Testing identifier exposed as data-testid */
testID?: string;
/** Inner content (string, nodes, or components) */
children?: React.ReactNode;
}
export interface BodyProps extends BaseTypographyProps {
/** Body size token (xl|lg|md|sm), default lg */
size?: BodySize;
/** Which HTML element to render, default p */
element?: keyof JSX.IntrinsicElements;
}
export type DisplaySize = "2xl" | "xl";
export interface DisplayProps extends BaseTypographyProps {
/** Display size (2xl|xl), default 2xl */
size?: DisplaySize;
/** HTML element to render (semantic override), default h1 */
element?: keyof JSX.IntrinsicElements;
}
export type HeadingSize = "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
export interface HeadingProps extends BaseTypographyProps {
/** Heading size controlling typography scale */
size?: HeadingSize;
/** Overrides the default mapped heading element */
element?: keyof JSX.IntrinsicElements;
}
export type UtilityVariant = "button" | "link" | "caption";
export interface UtilityProps extends BaseTypographyProps {
/** Visual style preset (button|link|caption), default button */
variant?: UtilityVariant;
/** Override rendered element; link variant defaults to <a>, others span */
element?: keyof JSX.IntrinsicElements;
}