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: {
|
2025-10-01 23:34:10 +08:00
|
|
|
none: 'leading-[1]',
|
2025-08-13 04:07:06 +08:00
|
|
|
sm: 'leading-1.5!',
|
2025-10-01 23:34:10 +08:00
|
|
|
base: 'leading-1.5',
|
|
|
|
md: 'leading-[1.4]',
|
|
|
|
lg: 'leading-[1.5]',
|
2025-08-13 11:54:24 +08:00
|
|
|
},
|
|
|
|
},
|
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;
|