Home
Whatever is put inside ./src/pages/
folder is considered as a new email layout
The basic structure of a mail layout
// ./src/pages/WelcomeMail.jsx
import React from 'react';
import { EmailMain, Div } from '../EmailBuilder';
const WelcomeMail = () => {
return (
<EmailMain>
<Div>Hello</Div>
</EmailMain>
);
};
export default WelcomeMail;
configuration is stored in ./generator.config.js
file
file structure
// ./generator.config.js
export default {
outputExtension: 'html',
minify: false,
};
- outputExtension - output extension of final build files.
default: html
- minify- should email templates be minified
default: false
Email Builder uses Snowpack for the development server
use npm start
to start the dev server
The development routing is based on react-router so all pages should be added to ./src/add-routes-here.js
Put global resources in the public folder
use npm run build
to generate emails-based contents in the pages folder. generated pages will appear in
./build
folder
import { isProd } from '../utils';
value is true for build and false for development
Email builder provides a variety of components ./src/EmailBuilder
import {
EmailMain,
Div,
Image,
Link,
Paragraph as P,
List,
ListItem,
RawHTML,
DataList,
} from '../EmailBuilder';
Main email layout
Props:
- styles - inline css - type:
Object
, default:{}
- bodyStyles - inline css for body tag - type:
Object
, default:{}
- title - page title - type:
String
, default: - googleFont - google font href - type:
String
, default:https://fonts.googleapis.com/css?family=IBM+Plex+Sans:200,300,400,400i,500,600,700&display=swap
<div>
tag with style reset
Props:
- styles - inline css - type:
Object
, default:{}
<img>
tag with extra features
Props:
- styles - inline css - type:
Object
, default:{}
- src - img src tag
- prodSrc - production src, applicable if isProd - type:
String
, default:
<a>
with style reset
Props:
- styles - inline css - type:
Object
, default:{}
<p>
tag with style reset
Props:
- styles - inline css - type:
Object
, default:{}
a tag that can act either as <ul>
or <ol>
Props:
- styles - inline css - type:
Object
, default:{}
- type - can be either 'ol' or 'ul' - type:
String
, default:ul
<li>
tag with style reset
Props:
- styles - inline css - type:
Object
, default:{}
treat the value as raw HTML
example
import React from 'react';
import { Div, RawHTML } from '../EmailBuilder';
const text = `<p>
<b>Lorem Ipsum</b> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>`;
const Welcome = () => {
return (
<Div>
<RawHTML>{text}</RawHTML>
</Div>
);
};
export default Welcome;
data list based on <List>
tag
Props:
- styles - inline css - type:
Object
, default:{}
- type - can be either 'ol' or 'ul' - type:
String
, default:ul
- listItemStyles - inline css for list items - type:
Object
, default:{}
- keyField - - unique data key field - type:
String
, default:id
- data - list data - type:
Array
, default:[]
- id - type:
String
, isRequired if now keyField is selected - description - type:
String, ReactElement
, default: - styles - inline css for a perticular data list item - type:
Object
, default:{}
- isRawHTML - weather to treat the string as raw HTML, helpful if you have
<b>
tags - type:Boolean
, default:false
- id - type:
example
import React from 'react';
import {
Div
DataList,
} from '../EmailBuilder';
const dataListData = [
{
id: '1',
description: 'one',
},
{
id: '2',
description: 'two',
},
{
id: '3',
description: (
<>
<b>Three</b> Three
</>
),
},
{
id: '4',
description: '<b>Four</b>',
isRawHTML: true,
},
];
const Welcome = () => {
return (
<Div>
<DataList data={dataListData} />
</Div>
);
};
export default Welcome;