Files
typogenie/src/types.ts
2026-02-01 18:51:43 +02:00

184 lines
4.2 KiB
TypeScript

export type PaperSize = 'A4' | 'Letter';
export type StyleCategory = string;
export interface DocxBorder {
color: string;
space: number;
style: string; // 'single' | 'double' | 'dotted' | 'dashed'
size: number;
}
export interface DocxStyleConfig {
font: string;
size: number; // in pt
color: string;
bold?: boolean;
italic?: boolean;
underline?: boolean;
allCaps?: boolean;
smallCaps?: boolean;
tracking?: number; // Letter spacing
align?: 'left' | 'center' | 'right' | 'both'; // 'both' is justify
spacing?: { before: number; after: number; line: number };
border?: {
top?: DocxBorder;
bottom?: DocxBorder;
left?: DocxBorder;
right?: DocxBorder;
};
shading?: {
fill: string; // Hex color
color: string; // usually 'auto'
type: string; // usually 'clear' - maps to ShadingType
};
}
// New unified element styling (spacing values in points)
export interface ElementStyle {
font?: string;
size?: number;
color?: string;
background?: string;
bold?: boolean;
italic?: boolean;
underline?: boolean;
allCaps?: boolean;
align?: 'left' | 'center' | 'right' | 'both';
spacing?: { before: number; after: number; line: number };
indent?: number;
padding?: number;
border?: { color: string; width: number; style: string };
borderTop?: { color: string; width: number; style: string };
borderBottom?: { color: string; width: number; style: string };
borderLeft?: { color: string; width: number; style: string };
borderRight?: { color: string; width: number; style: string };
bullet?: string;
numbering?: string;
bulletSize?: number;
}
// Extended element style for DOCX export
export type TemplateElementStyle = ElementStyle;
// Font definitions
export interface FontConfig {
heading?: string;
body?: string;
code?: string;
}
// Color palette
export interface ColorPalette {
text?: string;
textSecondary?: string;
background?: string;
accent?: string;
border?: string;
codeBg?: string;
blockquoteBorder?: string;
}
// Page configuration
export interface PageConfig {
margins?: { top: number; bottom: number; left: number; right: number };
columns?: number;
gutter?: number;
header?: boolean;
footer?: boolean;
}
// Unified template structure (all Markdown elements)
export interface UnifiedTemplate {
typography?: {
fonts?: FontConfig;
colors?: ColorPalette;
};
elements?: {
h1?: ElementStyle;
h2?: ElementStyle;
h3?: ElementStyle;
h4?: ElementStyle;
h5?: ElementStyle;
h6?: ElementStyle;
p?: ElementStyle;
blockquote?: ElementStyle;
code?: ElementStyle;
pre?: ElementStyle;
ul?: ElementStyle;
ol?: ElementStyle;
li?: ElementStyle;
strong?: ElementStyle;
em?: ElementStyle;
a?: ElementStyle;
table?: ElementStyle;
th?: ElementStyle;
td?: ElementStyle;
hr?: ElementStyle;
img?: ElementStyle;
};
page?: PageConfig;
}
export interface StyleOption {
id: string;
name: string;
category: StyleCategory;
description: string;
vibe: string;
googleFontsImport: string;
// New unified template structure (optional, for new templates)
typography?: {
fonts?: FontConfig;
colors?: ColorPalette;
};
elements?: {
h1?: ElementStyle;
h2?: ElementStyle;
h3?: ElementStyle;
h4?: ElementStyle;
h5?: ElementStyle;
h6?: ElementStyle;
p?: ElementStyle;
blockquote?: ElementStyle;
code?: ElementStyle;
pre?: ElementStyle;
ul?: ElementStyle;
ol?: ElementStyle;
li?: ElementStyle;
strong?: ElementStyle;
em?: ElementStyle;
a?: ElementStyle;
table?: ElementStyle;
th?: ElementStyle;
td?: ElementStyle;
hr?: ElementStyle;
img?: ElementStyle;
};
page?: PageConfig;
// Legacy Word Export Configuration (auto-generated if unified structure provided)
wordConfig?: {
heading1: DocxStyleConfig;
heading2: DocxStyleConfig;
body: DocxStyleConfig;
accentColor: string;
};
// Legacy CSS for Web Preview (auto-generated if unified structure provided)
previewCss?: string;
}
export interface GenerationConfig {
styleId: string;
paperSize: PaperSize;
content: string;
}
export enum AppState {
UPLOAD = 'UPLOAD',
CONFIG = 'CONFIG',
GENERATING = 'GENERATING',
PREVIEW = 'PREVIEW',
ERROR = 'ERROR'
}