refactor(FE): Refactor PDF components to support custom styles

This commit is contained in:
rstubryan
2026-02-10 14:00:28 +07:00
parent 2af83bed8a
commit 59eb781a22
3 changed files with 29 additions and 23 deletions
@@ -1,5 +1,6 @@
import { Color } from '@/types/theme';
import { Text, StyleSheet } from '@react-pdf/renderer';
import type { Style } from '@react-pdf/types';
type TypographySize = 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'small' | 'label';
@@ -10,7 +11,7 @@ type PdfTypographyProps = {
size?: TypographySize;
variant?: TypographyVariant;
color?: string;
marginBottom?: number;
style?: Style;
};
const styles = StyleSheet.create({
@@ -66,17 +67,13 @@ export const PdfTypography = ({
size = 'p',
variant = 'default',
color,
marginBottom,
style,
}: PdfTypographyProps) => {
const sizeStyle = styles[size];
const textColor = color || variantColors[variant];
const customStyle = {
...(marginBottom !== undefined && { marginBottom }),
};
return (
<Text style={[sizeStyle, { color: textColor }, customStyle]}>
<Text style={[sizeStyle, { color: textColor }, ...(style ? [style] : [])]}>
{children}
</Text>
);