mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import type { I18n } from '@lingui/core';
|
|
import { I18nProvider } from '@lingui/react';
|
|
import * as ReactEmail from '@react-email/render';
|
|
|
|
import config from '@hanzo/esign-tailwind-config';
|
|
|
|
import { Tailwind } from './components';
|
|
import { BrandingProvider, type BrandingSettings } from './providers/branding';
|
|
|
|
export type RenderOptions = ReactEmail.Options & {
|
|
branding?: BrandingSettings;
|
|
i18n?: I18n;
|
|
};
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
const colors = (config.theme?.extend?.colors || {}) as Record<string, string>;
|
|
|
|
export const render = async (element: React.ReactNode, options?: RenderOptions) => {
|
|
const { branding, ...otherOptions } = options ?? {};
|
|
|
|
return ReactEmail.render(
|
|
<BrandingProvider branding={branding}>
|
|
<Tailwind
|
|
config={{
|
|
theme: {
|
|
extend: {
|
|
colors,
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
{element}
|
|
</Tailwind>
|
|
</BrandingProvider>,
|
|
otherOptions,
|
|
);
|
|
};
|
|
|
|
export const renderWithI18N = async (element: React.ReactNode, options?: RenderOptions) => {
|
|
const { branding, i18n, ...otherOptions } = options ?? {};
|
|
|
|
if (!i18n) {
|
|
throw new Error('i18n is required');
|
|
}
|
|
|
|
return ReactEmail.render(
|
|
<I18nProvider i18n={i18n}>
|
|
<BrandingProvider branding={branding}>
|
|
<Tailwind
|
|
config={{
|
|
theme: {
|
|
extend: {
|
|
colors,
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
{element}
|
|
</Tailwind>
|
|
</BrandingProvider>
|
|
</I18nProvider>,
|
|
otherOptions,
|
|
);
|
|
};
|