@busy-bee/emails
v4.1.124
Published
This library is for creating reusable, testable components and email templates using React.
Downloads
303
Readme
Overview
This library is for creating reusable, testable components and email templates using React.
Develop
Setup
- Open a terminal
- Clone git repository
- Go into repository dir
- Install root dependencies
npm install
- Start storybook
npm run storybook
ornpm start
Storybook
Check this page to read more about storybook: https://storybook.js.org/
Folder structure
.circleci
: CircleCI configuration..storybook
: Storybook configuration.src
_snapshots_
: Snapshot files for test.components
: Small components like header, footer, dashboard.customComponents
: Email layout components.emailComponents
: Rendered HTML email files.emailStrings
: String files of rendered HTML emails fromemailComponents
folder. This is the final result that will be returned.
Dependencies
Adding a new email
- Create a folder and create a new index.js and stories.js file in
EmailComponents
folder. If there's any components already created incomponents
folder, use them. Or create your own component. Main style guide and variables are in the/styleGuide.js
file. - Once you created email, import it from
EmailStrings
folder. - Create an test file in the same folder.
- Add an export function to
src/index.js
file. npm test
to check if it's all good.
Test
- Functional test:
npm test
Publish
npm version major | minor | patch
to update version.git push --tags
and then the CircleCI will kindly test, build, and publish the package for you.- If you didn't receive any error message, then hooray! Skull your beer! 🍺
Usage
- Install npm package via npm:
npm install @busy-bee/emails
- Import an email rendering function
import { stringOfResetPasswordEmail } from @busy-bee/emails
- Send appropriate data when you execute a function. Props are mandatory, Options are optional.
- If the data/props is appropriate, you'll get a string of rendered email as return. Otherwise, you're get a ruthless error as return.
Test email rendering https://testi.at
Examples
import { stringOfResetPasswordEmail } from @busy-bee/emails;
const props = {
firstName: 'Caroline',
passwordToken: 'https://resetpassword.com/'
};
stringOfResetPasswordEmail(props);