Skip to content

Commit f4d8f55

Browse files
committed
feat: add italic and underline text styles to template builder
Add italic and underline toggle options for text blocks in the template builder, matching the existing bold toggle functionality.
1 parent d113e6f commit f4d8f55

7 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/renderer/src/components/template-builder/BlockPreview.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export const BlockPreview = ({ block }: BlockPreviewProps) => {
5555
<div
5656
className={cn(
5757
'mt-1 text-sm text-muted-foreground truncate max-w-md',
58-
block.props.bold && 'font-semibold'
58+
block.props.bold && 'font-semibold',
59+
block.props.italic && 'italic',
60+
block.props.underline && 'underline'
5961
)}
6062
dangerouslySetInnerHTML={{
6163
__html: block.props.content.substring(0, 100)

src/renderer/src/components/template-builder/LivePreview.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ export const LivePreview = ({ templateStructure }: LivePreviewProps) => {
101101
.preview-content .bold {
102102
font-weight: 700;
103103
}
104+
.preview-content .italic {
105+
font-style: italic;
106+
}
107+
.preview-content .underline {
108+
text-decoration: underline;
109+
}
104110
.preview-content .pt-1 {
105111
padding-top: 2pt;
106112
}

src/renderer/src/components/template-builder/properties/TextProperties.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ export const TextProperties = ({ block, onUpdate }: TextPropertiesProps) => {
8888
onCheckedChange={(checked) => updateProps({ bold: checked })}
8989
/>
9090
</div>
91+
92+
<div className="flex items-center justify-between">
93+
<Label htmlFor="italic" className="text-sm">
94+
Italic
95+
</Label>
96+
<Switch
97+
id="italic"
98+
checked={block.props.italic}
99+
onCheckedChange={(checked) => updateProps({ italic: checked })}
100+
/>
101+
</div>
102+
103+
<div className="flex items-center justify-between">
104+
<Label htmlFor="underline" className="text-sm">
105+
Underline
106+
</Label>
107+
<Switch
108+
id="underline"
109+
checked={block.props.underline}
110+
onCheckedChange={(checked) => updateProps({ underline: checked })}
111+
/>
112+
</div>
91113
</div>
92114
)
93115
}

src/renderer/src/lib/template-renderer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ const renderText = (block: TextBlock, context: TemplateContext): string => {
117117
const fontSizeClass = `text-${props.fontSize || 'base'}`
118118
const alignmentStyle = `text-align: ${props.alignment || 'left'}`
119119
const boldClass = props.bold ? 'bold' : ''
120+
const italicClass = props.italic ? 'italic' : ''
121+
const underlineClass = props.underline ? 'underline' : ''
120122

121-
return `<div class="${fontSizeClass} ${boldClass} keep-together" style="${alignmentStyle}">${content}</div>`
123+
return `<div class="${fontSizeClass} ${boldClass} ${italicClass} ${underlineClass} keep-together" style="${alignmentStyle}">${content}</div>`
122124
}
123125

124126
// Render data field block

src/renderer/src/styles/screen.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ body {
175175
font-style: italic;
176176
}
177177

178+
.underline {
179+
text-decoration: underline;
180+
}
181+
178182
.text-center {
179183
text-align: center;
180184
}

src/shared/constants/template-fields.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ export const BLOCK_DEFINITIONS: BlockDefinition[] = [
279279
content: '',
280280
alignment: 'left',
281281
fontSize: 'base',
282-
bold: false
282+
bold: false,
283+
italic: false,
284+
underline: false
283285
}
284286
},
285287
{

src/shared/types/template-blocks.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface TextBlockProps {
2929
alignment: 'left' | 'center' | 'right'
3030
fontSize: 'sm' | 'base' | 'lg' | 'xl' | '2xl'
3131
bold: boolean
32+
italic: boolean
33+
underline: boolean
3234
}
3335

3436
export interface TextBlock extends BaseBlock {

0 commit comments

Comments
 (0)