buster/apps/web/src/components/ui/typography/Paragraph.tsx

61 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-08-13 04:07:06 +08:00
import { cva, type VariantProps } from 'class-variance-authority';
import type React from 'react';
import { cn } from '@/lib/utils';
import { textColorVariants } from './variants';
const paragraphVariants = cva('', {
variants: {
size: {
base: 'text-base',
sm: 'text-sm',
xs: 'text-xs',
md: 'text-md',
2025-08-13 11:54:24 +08:00
lg: 'text-lg',
2025-08-13 04:07:06 +08:00
},
lineHeight: {
none: 'leading-[1]!',
sm: 'leading-1.5!',
base: 'leading-1.5!',
md: 'leading-[1.4]!',
2025-08-13 11:54:24 +08:00
lg: 'leading-[1.5]!',
},
},
2025-08-13 04:07:06 +08:00
});
type ParagraphProps = {
className?: string;
style?: React.CSSProperties;
onClick?: React.MouseEventHandler<HTMLHeadingElement>;
children: React.ReactNode;
onCopy?: React.ClipboardEventHandler<HTMLHeadingElement>;
} & VariantProps<typeof textColorVariants> &
VariantProps<typeof paragraphVariants>;
export const Paragraph: React.FC<ParagraphProps> = ({
onClick,
variant = 'default',
size = 'base',
children,
className,
style,
lineHeight = 'base',
2025-08-13 11:54:24 +08:00
onCopy,
2025-08-13 04:07:06 +08:00
}) => {
return (
<p
className={cn(
paragraphVariants({ size, lineHeight }),
textColorVariants({ variant }),
className
)}
style={style}
onCopy={onCopy}
2025-08-13 11:54:24 +08:00
onClick={onClick}
>
2025-08-13 04:07:06 +08:00
{children}
</p>
);
};
export default Paragraph;