mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 01:01:49 +10:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import * as ReactEmail from '@react-email/render';
|
|
|
|
import { Tailwind } from './components';
|
|
import { BrandingProvider, type BrandingSettings } from './providers/branding';
|
|
|
|
// Todo:
|
|
// import config from '@documenso/tailwind-config';
|
|
|
|
export type RenderOptions = ReactEmail.Options & {
|
|
branding?: BrandingSettings;
|
|
};
|
|
|
|
export const render = (element: React.ReactNode, options?: RenderOptions) => {
|
|
const { branding, ...otherOptions } = options ?? {};
|
|
|
|
return ReactEmail.render(
|
|
<Tailwind
|
|
config={{
|
|
theme: {
|
|
extend: {
|
|
// colors: config.theme.extend.colors,
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
<BrandingProvider branding={branding}>{element}</BrandingProvider>
|
|
</Tailwind>,
|
|
otherOptions,
|
|
);
|
|
};
|
|
|
|
export const renderAsync = async (element: React.ReactNode, options?: RenderOptions) => {
|
|
const { branding, ...otherOptions } = options ?? {};
|
|
|
|
return await ReactEmail.renderAsync(
|
|
<Tailwind
|
|
config={{
|
|
theme: {
|
|
extend: {
|
|
// colors: config.theme.extend.colors,
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
<BrandingProvider branding={branding}>{element}</BrandingProvider>
|
|
</Tailwind>,
|
|
otherOptions,
|
|
);
|
|
};
|