-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce asset registration system (#9)
This PR introduces an asset registration system. This system streamlines synchronous asset URL resolution. This replaces the previous makeshift system that does the same thing, and unlike the previous system, supports arbitrary import nesting. This PR also contains a refactor of the onboarding email, to demonstrate this new system.
- Loading branch information
Showing
4 changed files
with
108 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
Body, | ||
Container, | ||
Head, | ||
Html, | ||
Img, | ||
Preview | ||
} from "@react-email/components"; | ||
import { getAsset, registerAsset, WATcloudURI } from "../../utils/watcloud-uri"; | ||
|
||
registerAsset('watcloud-logo', new WATcloudURI("watcloud://v1/sha256:393767e36d5387815c15d11c506c3c820de5db41723ffc062751673621dedb15?name=1024x512%20black%401x.png")) | ||
|
||
// Wrapper for WATcloud-themed emails | ||
export function WATcloudEmail({ | ||
previewText, | ||
children, | ||
}: { | ||
previewText: string, | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<Html> | ||
<Head /> | ||
<Preview>{previewText}</Preview> | ||
<Body style={{ backgroundColor: "#ffffff", margin: "auto", fontFamily: "sans-serif" }}> | ||
<Container style={{ border: "1px solid #eaeaea", borderRadius: "5px", margin: "40px auto", padding: "20px", maxWidth: "600px" }}> | ||
<Img src={getAsset('watcloud-logo').resolveFromCache()} alt="WATcloud Logo" style={{ display: "block", margin: "0 auto" }} height="100" /> | ||
{children} | ||
</Container> | ||
</Body> | ||
</Html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,7 @@ import { | |
} from "@react-email/components"; | ||
import dedent from "dedent-js"; | ||
import { z } from "zod"; | ||
import { WATcloudURI } from "../utils/watcloud-uri"; | ||
|
||
export const images = { | ||
'watcloud-logo': new WATcloudURI("watcloud://v1/sha256:393767e36d5387815c15d11c506c3c820de5db41723ffc062751673621dedb15?name=1024x512%20black%401x.png") | ||
} | ||
import { WATcloudEmail } from "./_common/watcloud-email"; | ||
|
||
const WATcloudOnboardingEmailProps = z.object({ | ||
name: z.string(), | ||
|
@@ -37,51 +33,44 @@ export const WATcloudOnboardingEmail = (props: WATcloudOnboardingEmailProps) => | |
) | ||
|
||
return ( | ||
<Html> | ||
<Head /> | ||
<Preview>{previewText}</Preview> | ||
<Body style={{ backgroundColor: "#ffffff", margin: "auto", fontFamily: "sans-serif" }}> | ||
<Container style={{ border: "1px solid #eaeaea", borderRadius: "5px", margin: "40px auto", padding: "20px", maxWidth: "600px" }}> | ||
<Img src={images['watcloud-logo'].resolveFromCache()} alt="WATcloud Logo" style={{ display: "block", margin: "0 auto" }} height="100" /> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px" }}> | ||
Hi {name}, | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
Welcome to WATcloud, WATonomous's compute cluster and infrastructure. We are excited to have you on board! | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
This email confirms that your access to WATcloud has been successfully updated. | ||
</Text> | ||
<Section style={{ marginTop: "20px", marginBottom: "20px" }}> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px" }}> | ||
Here's a list of services that you have access to: | ||
</Text> | ||
{accessInstructions} | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
Access instructions for each service can be found in the <Link href="https://cloud.watonomous.ca/docs/services" style={{ color: "#1e90ff", textDecoration: "none" }}>Services</Link> documentation. | ||
</Text> | ||
</Section> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
If you have any questions, please reach out to your <Link href="https://cloud.watonomous.ca/docs/services#watcloud-contact" style={{ color: "#1e90ff", textDecoration: "none" }}>WATcloud contact</Link> or the WATcloud team at <Link href={`mailto:[email protected]`} style={{ color: "#1e90ff", textDecoration: "none" }}>[email protected]</Link>. | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "20px" }}> | ||
Vroom vroom, | ||
</Text> | ||
<pre style={{ fontFamily: "Courier New, monospace" }}> | ||
{dedent(String.raw` | ||
<WATcloudEmail previewText={previewText}> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px" }}> | ||
Hi {name}, | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
Welcome to WATcloud, WATonomous's compute cluster and infrastructure. We are excited to have you on board! | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
This email confirms that your access to WATcloud has been successfully updated. | ||
</Text> | ||
<Section style={{ marginTop: "20px", marginBottom: "20px" }}> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px" }}> | ||
Here's a list of services that you have access to: | ||
</Text> | ||
{accessInstructions} | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
Access instructions for each service can be found in the <Link href="https://cloud.watonomous.ca/docs/services" style={{ color: "#1e90ff", textDecoration: "none" }}>Services</Link> documentation. | ||
</Text> | ||
</Section> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
If you have any questions, please reach out to your <Link href="https://cloud.watonomous.ca/docs/services#watcloud-contact" style={{ color: "#1e90ff", textDecoration: "none" }}>WATcloud contact</Link> or the WATcloud team at <Link href={`mailto:[email protected]`} style={{ color: "#1e90ff", textDecoration: "none" }}>[email protected]</Link>. | ||
</Text> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "20px" }}> | ||
Vroom vroom, | ||
</Text> | ||
<pre style={{ fontFamily: "Courier New, monospace" }}> | ||
{dedent(String.raw` | ||
_∩_ | ||
__|_|_ | ||
/|__|__\____ | ||
| | | ||
${"`"}.(o)-----(o).' | ||
`)} | ||
</pre> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
WATcloud Onboarding Bot 🤖 | ||
</Text> | ||
</Container> | ||
</Body> | ||
</Html> | ||
</pre> | ||
<Text style={{ color: "#000", fontSize: "14px", lineHeight: "24px", marginTop: "10px" }}> | ||
WATcloud Onboarding Bot 🤖 | ||
</Text> | ||
</WATcloudEmail> | ||
); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters