react-email 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const render: (component: React.ReactElement) => string;
package/build/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.render = void 0;
27
+ const ReactDomServer = __importStar(require("react-dom/server"));
28
+ const render = (component) => {
29
+ const docType = '<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
30
+ const markup = ReactDomServer.renderToStaticMarkup(component);
31
+ const html = `${docType}<html xmlns="http://www.w3.org/1999/xhtml">
32
+ <head>
33
+ <meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
34
+ </head>
35
+ <body>${markup}</body>
36
+ </html>`;
37
+ return html;
38
+ };
39
+ exports.render = render;
package/package.json CHANGED
@@ -1,11 +1,45 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "1.0.0",
4
- "description": "React component for making email templates.",
5
- "main": "index.js",
3
+ "version": "1.0.3",
4
+ "description": "",
5
+ "main": "build/index.js",
6
+ "typings": "build/index.d.ts",
7
+ "files": [
8
+ "build/"
9
+ ],
6
10
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "build": "tsc -p .",
12
+ "lint": "tslint -p tsconfig.json -c tslint.json",
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check",
16
+ "format": "prettier \"src/**/*.{js,ts,tsx}\" --write",
17
+ "prepublishOnly": "yarn run build"
8
18
  },
9
- "author": "Mehdi Namvar",
10
- "license": "ISC"
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/klotty/react-email.git"
22
+ },
23
+ "author": "",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/klotty/react-email/issues"
27
+ },
28
+ "homepage": "https://github.com/klotty/react-email#readme",
29
+ "dependencies": {
30
+ "react": "^18.2.0",
31
+ "react-dom": "^18.2.0"
32
+ },
33
+ "devDependencies": {
34
+ "@babel/preset-react": "7.18.6",
35
+ "@types/jest": "28.1.7",
36
+ "@types/node": "18.6.4",
37
+ "@types/react-dom": "18.0.6",
38
+ "babel-jest": "28.1.3",
39
+ "jest": "28.1.3",
40
+ "prettier": "2.7.1",
41
+ "ts-jest": "28.0.8",
42
+ "tslint": "6.1.3",
43
+ "typescript": "4.7.4"
44
+ }
11
45
  }
package/readme.md ADDED
@@ -0,0 +1,45 @@
1
+ # react-email
2
+
3
+ Convert React components into HTML email templates.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install react-email
9
+ # or
10
+ yarn add react-email
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Start by creating your email template as a React component.
16
+
17
+ ```jsx
18
+ import React from 'react'
19
+
20
+ export default function MyTemplate(props) {
21
+ const { firstName } = props
22
+
23
+ return (
24
+ <>
25
+ <h1>Welcome, {firstName}!</h1>
26
+ <p>Thanks for trying our product. We’re thrilled to have you on board.</p>
27
+ </>
28
+ )
29
+ }
30
+ ```
31
+
32
+ Then import the template component and render it.
33
+
34
+ ```js
35
+ import reactEmail from 'react-email'
36
+ import MyTemplate from '../components/MyTemplate'
37
+
38
+ const html = reactEmail.render(
39
+ <MyTemplate firstName="Jim" />
40
+ )
41
+ ```
42
+
43
+ ## License
44
+
45
+ MIT License