mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
refactor(FE): Refactor PDF components to support custom styles
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user