Skip to content

Commit d1c38f7

Browse files
committed
chore: upgrade email subproject
1 parent ba8ac37 commit d1c38f7

20 files changed

+2621
-9142
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.java-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.0
1+
17.0

email/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.react-email
2+
node_modules
23
out

email/HACKING.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ of the output HTML files, and you'll see for yourself why it's such a big deal t
1111

1212
React Email exposes a handful of primitives documented on their [website](https://react.email/docs/introduction).
1313
If you need real world examples, they provide a bunch of great examples based on real-world emails written using
14-
React Email [here](https://demo.react.email/preview/stack-overflow-tips).
14+
React Email [here](https://demo.react.email/preview/newsletters/stack-overflow-tips).
15+
16+
They also provide a handful of components [here](https://react.email/components)
1517

1618
### Preview and build
1719
While working on emails, you can use `npm run dev` to spin up a dev server and have a live preview of the emails in
@@ -37,17 +39,19 @@ fine to send and what isn't; basically the [Can I Use](https://caniuse.com/) of
3739
This also applies to the layout; always prefer React Email's `Container`, `Row` and `Column` elements for layout.
3840
They'll get turned into ugly HTML tables to do the layout - just like in the good ol' HTML days...
3941

40-
## Base layout
41-
The base layout is available in `components/Layout.tsx`. All components should use it, as it'll include the base
42-
Tailwind configuration and all the main elements.
42+
## Layouts
43+
The core shell of emails is provided by `components/layouts/LayoutCore.tsx`. It is not expected to be used as-is, but
44+
instead to serve as a shared base for more complete layouts such as `ClassicLayout.tsx`. All emails should use a layout,
45+
or at least must use the core layout as it contains important building blocks for emails to work properly.
4346

44-
The layout takes 2 properties:
47+
The classic layout (`ClassicLayout.tsx`) takes 3 properties:
4548
- `subject` (required): displayed in the header of the email and be used to construct the actual email subject
4649
- `sendReason` (required): important for anti-spam laws and must reflect the reason why a given email is sent
4750
- Is it because they have an account? Is it because they enabled notifications? ...
4851
- `extra` (optional): displayed at the very bottom, useful to insert an unsubscribe link if necessary
4952

50-
These three properties are generally expected to receive output from the `t()` function documented below.
53+
These three properties are generally expected to receive output from the `t()` function documented below. The core
54+
layout only requires the subject.
5155

5256
## Utility components
5357
This is note is left here for the lack of a better section: whenever you need a dynamic properties (e.g. href that
@@ -58,7 +62,8 @@ takes the value of a variable), you can prefix your attribute with `data-th-` an
5862
<a data-th-href="${link}">Click here!</a>
5963
```
6064

61-
A few base components with default styles are available in `components/parts`, such as buttons.
65+
A few low-level base components with default styles are available in `components/atoms`, such as buttons.
66+
Shared parts are found in `components/parts`.
6267

6368
### `<LocalizedText />` and `t()`
6469
Most if not all text in emails are expected to be wrapped in `<LocalizedText />` (or `t()` when more appropriate).
@@ -175,5 +180,13 @@ The following global variables are available:
175180
- `instanceQualifier`: Either "Tolgee" for Tolgee Cloud, or the domain name used for the instance
176181
- `instanceUrl`: Base URL of the instance
177182

178-
They still need to be passed as demo values except for localized strings where a default value is provided.
183+
They still need to be passed as demo values, except for localized strings as a default value is provided then.
179184
The default value can be overridden.
185+
186+
## Tips & tricks
187+
How the social icons were generated:
188+
- Get SVG from https://simpleicons.org/
189+
- Write to `[file].svg`
190+
- Add `width="16" height="16" fill="#a0a0a0"` to the `<svg>` tag
191+
- Convert SVG to PNG
192+
- Drink a deserved coffee

email/components/For.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

email/components/If.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

email/components/ImgResource.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
1515
*/
1616

1717
import * as React from 'react';
18-
import { join, extname } from 'path';
19-
import { readFileSync, readdirSync } from 'fs';
18+
import { extname, join } from 'path';
19+
import { readdirSync, readFileSync } from 'fs';
2020
import { Img, ImgProps } from '@react-email/components';
2121

2222
let root = __dirname;
@@ -28,20 +28,20 @@ const RESOURCES_FOLDER = join(root, 'resources');
2828

2929
type Props = Omit<ImgProps, 'src'> & {
3030
resourceName: string;
31+
src?: string;
3132
};
3233

3334
export default function ImgResource(props: Props) {
3435
const file = join(RESOURCES_FOLDER, props.resourceName);
3536

36-
const newProps = { ...props } as ImgProps & Props;
37+
const newProps = { ...props } as Props;
3738
delete newProps.resourceName;
3839
delete newProps.src;
3940

4041
if (process.env.NODE_ENV === 'production') {
4142
// Resources will be copied during final assembly.
42-
newProps[
43-
'data-th-src'
44-
] = `\${instanceUrl} + '/static/emails/${props.resourceName}'`;
43+
newProps['data-th-src'] =
44+
`\${instanceUrl} + '/static/emails/${props.resourceName}'`;
4545
} else {
4646
const blob = readFileSync(file);
4747
const ext = extname(file).slice(1);

email/components/Layout.tsx

Lines changed: 0 additions & 226 deletions
This file was deleted.

email/components/LocalizedText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

email/components/Var.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

email/components/parts/TolgeeButton.ts renamed to email/components/atoms/TolgeeButton.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ import * as React from 'react';
1818
import { Button, ButtonProps } from '@react-email/components';
1919

2020
const BUTTON_CLASSES =
21-
'bg-brand text-white font-bold px-[16px] py-[8px] rounded';
21+
'bg-brand text-white font-bold px-[16px] py-[8px] rounded cursor-pointer';
2222

2323
export default function TolgeeButton(props: ButtonProps) {
2424
const className = props.className

email/components/parts/TolgeeLink.ts renamed to email/components/atoms/TolgeeLink.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (C) 2023 Tolgee s.r.o. and contributors
2+
* Copyright (C) 2024 Tolgee s.r.o. and contributors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)