Skip to content

Commit

Permalink
Move react-email to preact
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmade committed May 6, 2024
1 parent 906f8fa commit 37e4864
Show file tree
Hide file tree
Showing 26 changed files with 64 additions and 437 deletions.
223 changes: 0 additions & 223 deletions packages/preact-async/CHANGELOG.md

This file was deleted.

11 changes: 3 additions & 8 deletions packages/preact-async/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,14 @@
"@quilted/react-signals": "workspace:^0.2.4"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"preact": "^10.21.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"preact": {
"optional": true
}
},
"devDependencies": {
"react": "workspace:@quilted/react@^18.2.0",
"react-dom": "workspace:@quilted/react-dom@^18.2.0"
"preact": "^10.21.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# `@quilted/react-email`
# `@quilted/preact-email`

React-friendly APIs for rendering emails and their metadata.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@quilted/react-email",
"name": "@quilted/preact-email",
"type": "module",
"version": "0.3.2",
"version": "0.1.0",
"description": "React-friendly APIs for rendering emails and their metadata",
"repository": {
"type": "git",
"url": "https://github.com/lemonmade/quilt.git",
"directory": "packages/react-email"
"directory": "packages/preact-email"
},
"publishConfig": {
"access": "public",
Expand Down Expand Up @@ -41,22 +41,18 @@
},
"dependencies": {
"preact-render-to-string": "^6.4.0",
"@quilted/preact-browser": "workspace:^0.1.0"
"@quilted/preact-browser": "workspace:^0.1.0",
"@quilted/preact-context": "workspace:^0.1.0"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
"preact": "^10.21.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"preact": {
"optional": true
}
},
"devDependencies": {
"react": "workspace:@quilted/react@^18.2.0",
"react-dom": "workspace:@quilted/react-dom@^18.2.0"
"preact": "^10.21.0"
}
}
4 changes: 4 additions & 0 deletions packages/preact-email/source/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {createOptionalContext} from '@quilted/preact-context';
import type {EmailManager} from './manager.ts';

export const EmailContext = createOptionalContext<EmailManager>();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useContext} from 'react';
import {useContext} from 'preact/hooks';

import {EmailContext} from '../context.ts';
import type {EmailManager} from '../manager.ts';
Expand Down
5 changes: 5 additions & 0 deletions packages/preact-email/source/hooks/send-bcc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {useEmailAction} from './email-action.ts';

export function useSendBCC(emails: string | string[] | undefined) {
return useEmailAction((email) => email.sendBCC(emails));
}
5 changes: 5 additions & 0 deletions packages/preact-email/source/hooks/send-cc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {useEmailAction} from './email-action.ts';

export function useSendCC(emails: string | string[] | undefined) {
return useEmailAction((email) => email.sendCC(emails));
}
File renamed without changes.
10 changes: 10 additions & 0 deletions packages/preact-email/source/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {EmailContext} from './context.ts';
export {EmailManager} from './manager.ts';
export type {Sender} from './types.ts';

export {usePlainTextContent} from './hooks/plain-text.ts';
export {useSendTo} from './hooks/send-to.ts';
export {useSendCC} from './hooks/send-cc.ts';
export {useSendBCC} from './hooks/send-bcc.ts';
export {useSender} from './hooks/sender.ts';
export {useSubject} from './hooks/subject.ts';
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export class EmailManager {
this.to = typeof emails === 'string' ? [emails] : emails;
}

sendCc(emails: string | string[] | undefined) {
sendCC(emails: string | string[] | undefined) {
this.cc = typeof emails === 'string' ? [emails] : emails;
}

sendBcc(emails: string | string[] | undefined) {
sendBCC(emails: string | string[] | undefined) {
this.bcc = typeof emails === 'string' ? [emails] : emails;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ReactElement} from 'react';
import type {VNode} from 'preact';
import {
renderToStringAsync,
renderToStaticMarkup,
Expand All @@ -18,7 +18,7 @@ import {
import {EmailContext} from './context.ts';
import {EmailManager} from './manager.ts';

export async function renderEmail(element: ReactElement<any>) {
export async function renderEmail(element: VNode<any>) {
const browser = new BrowserEmailResponse();
const email = new EmailManager();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"extends": "@quilted/typescript/tsconfig.project.json",
"compilerOptions": {
"rootDir": "source",
"outDir": "build/typescript"
"outDir": "build/typescript",
"jsxImportSource": "preact"
},
"include": ["source"],
"exclude": ["**/*.test.ts", "**/*.test.tsx"],
"references": [{"path": "../preact-browser"}]
"references": [{"path": "../preact-browser"}, {"path": "../preact-context"}]
}
Loading

0 comments on commit 37e4864

Please sign in to comment.