feat(chore): add multiline support for templates props

This commit is contained in:
Julien Oculi 2024-04-02 14:45:12 +02:00
parent 62b85ce3c9
commit a43f2c5c75
2 changed files with 60 additions and 1 deletions

43
templates/Message.tsx Normal file
View file

@ -0,0 +1,43 @@
import { Body, Html, Markdown, Preview, Section, Text } from 'jsx-email'
import type { Template } from '../types.ts'
function Message(
{ summary, body }: { summary?: string; body: string },
) {
return (
<Html lang='fr'>
<Preview>{summary}</Preview>
<Body style={{ backgroundColor: '#61dafb' }}>
<Markdown>{body}</Markdown>
<Section>
<Text>Coh@bit</Text>
</Section>
</Body>
</Html>
)
}
const template: Template = {
props: [
{
name: 'Résumé',
description: 'Résumé du mail.',
required: false,
multiline: false,
tag: 'summary',
},
{
name: 'Message',
description: 'Contenu du mail (markdown).',
required: true,
multiline: true,
tag: 'body',
},
],
name: 'message',
description: 'Message mail en markdown.',
builder: Message,
}
export default template
//summary <90c

View file

@ -1,4 +1,4 @@
import type { JSX } from 'preact' import type { FunctionComponent, JSX } from 'preact'
import type { Contact } from './src/contact.ts' import type { Contact } from './src/contact.ts'
export type Mail = { export type Mail = {
@ -12,3 +12,19 @@ export type Mail = {
attachments: string[] attachments: string[]
} }
} }
export type Template<
T extends FunctionComponent<P>,
P extends Record<string, unknown>,
> = {
name: string
description: string
builder: T
props: {
name: string
description: string
required: boolean
multiline: boolean
tag: P
}[]
}