Skip to content

Commit

Permalink
fix: html language and direction in emails (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-dalmet authored Jul 29, 2024
1 parent 8edad0d commit 4efbee7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/emails/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ import { ReactNode } from 'react';
import { Body, Head, Html, Preview } from '@react-email/components';

import { styles } from '@/emails/styles';
import { AVAILABLE_LANGUAGES } from '@/lib/i18n/constants';

interface LayoutProps {
preview: string;
children: ReactNode;
language: string;
}

export const Layout = ({ preview, children }: LayoutProps) => {
export const Layout = ({ preview, children, language }: LayoutProps) => {
return (
<Html>
<Html
lang={language}
dir={
AVAILABLE_LANGUAGES.find(({ key }) => key === language)?.dir ?? 'ltr'
}
>
<Head>
<meta name="viewport" content="width=device-width" />
</Head>
Expand Down
5 changes: 4 additions & 1 deletion src/emails/templates/delete-account-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const EmailDeleteAccountCode = ({
}: EmailDeleteAccountCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:deleteAccountCode.preview')}>
<Layout
preview={i18n.t('emails:deleteAccountCode.preview')}
language={language}
>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:deleteAccountCode.title')}
Expand Down
5 changes: 4 additions & 1 deletion src/emails/templates/email-address-change.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const EmailAddressChange = ({
}: EmailAddressChangeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:emailAddressChange.preview')}>
<Layout
preview={i18n.t('emails:emailAddressChange.preview')}
language={language}
>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:emailAddressChange.title')}
Expand Down
2 changes: 1 addition & 1 deletion src/emails/templates/login-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const EmailLoginCode = ({
}: EmailLoginCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:loginCode.preview')}>
<Layout preview={i18n.t('emails:loginCode.preview')} language={language}>
<Container style={styles.container}>
<Heading style={styles.h1}>{i18n.t('emails:loginCode.title')}</Heading>
<Section style={styles.section}>
Expand Down
5 changes: 4 additions & 1 deletion src/emails/templates/login-not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ type EmailLoginNotFoundProps = {
export const EmailLoginNotFound = ({ language }: EmailLoginNotFoundProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:loginNotFound.preview')}>
<Layout
preview={i18n.t('emails:loginNotFound.preview')}
language={language}
>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:loginNotFound.title')}
Expand Down
2 changes: 1 addition & 1 deletion src/emails/templates/register-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const EmailRegisterCode = ({
}: EmailRegisterCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:registerCode.preview')}>
<Layout preview={i18n.t('emails:registerCode.preview')} language={language}>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:registerCode.title')}
Expand Down

0 comments on commit 4efbee7

Please sign in to comment.