feat(chore): add multiline support for templates props
This commit is contained in:
parent
62b85ce3c9
commit
a43f2c5c75
43
templates/Message.tsx
Normal file
43
templates/Message.tsx
Normal 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
|
18
types.ts
18
types.ts
|
@ -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
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue