Giter Club home page Giter Club logo

react-html-email's Introduction

react-html-email

โš ๏ธ Currently Unmaintained

react-html-email is presently unmaintained. As React has matured, it is no longer as necessary to use a separate library to generate email-specific markup. I'd encourage you to look at more recent CSS-in-JS and style inlining component libraries as the basis for building your own email design system, though these components can serve as a useful starting point.

I think the future of this project would be a generic set of design components for email templates -- something akin to Chakra UI for email. If you'd be interested in taking ownership of this project and tackling that, drop me a line at [email protected].


Build Status Coverage Status npm npm

Modern HTML emails are a tangle of archaic HTML and inline styles. This library encapsulates the cruft into simple React components and helps avoid common pitfalls.

react-html-email provides a set of components for a standard 600px table layout (inspired by HTML Email Boilerplate). React's Supported Tags and Attributes are extended to include a few deprecated attributes useful for legacy clients. In addition, a style prop validator is included which uses Campaign Monitor's CSS Support Guide to check for potential compatibility issues across email clients.

Installation

$ npm install react-html-email

Usage

To render a simple email:

import { Email, Item, Span, A, renderEmail } from 'react-html-email'

const emailHTML = renderEmail(
  <Email title="Hello World!">
    <Item align="center">
      <Span fontSize={20}>
        This is an example email made with:
        <A href="https://github.com/chromakode/react-html-email">react-html-email</A>.
      </Span>
    </Item>
  </Email>
)

You can find more examples in the examples directory of the repo.

API

renderEmail(emailComponent)

Render an email component to an HTML string. Adds an XHTML 1.0 Strict doctype, as per HTML Email Boilerplate.

configStyleValidator(config)

By default, inline styles passed to the style prop will be validated against Campaign Monitor's CSS Support Guide. Here are the default settings, which can be overridden using configStyleValidator:

ReactHTMLEmail.configStyleValidator({
  // When strict, incompatible style properties will result in an error.
  strict: true,

  // Whether to warn when compatibility notes for a style property exist.
  warn: true,

  // Platforms to consider for compatibility checks.
  platforms: [
    'gmail',
    'gmail-android',
    'apple-mail',
    'apple-ios',
    'yahoo-mail',
    'outlook',
    'outlook-legacy',
    'outlook-web',
  ],
})

PropTypes.style

A PropTypes validator for checking email inline style compatibility. Used by default in the components below. Exported for use in your own components.

Components

Components in react-html-email include defaults for basic style properties, so that client styles are reset and normalized. Every component accepts a style prop which overrides the reset styles.

<Email>

An HTML document with a centered 600px <table> inside <table> container based on HTML Email Boilerplate.

It's necessary to always include a title prop for some clients' "open in browser" feature.

See MailChimp's HTML guide for how this works.

<Box>

A simplification of the <table> element, the workhorse of an HTML email design. <Box>es contain a vertical stack of <Item>s. Use them to create visual structure, filled buttons, and spacing.

<Item>

A subsection of a <Box>, essentially a <tr><td> unit.

<Span>

Use to assign styles to text.

It can be handy to create an object containing your default text styles for reuse. For example:

const textDefaults = {
  fontFamily: 'Verdana',
  fontSize: 42,
  fontWeight: 'bold',
  color: 'orange',
}

[...]

<Span {...textDefaults}>Congratulations!</Span>
<Span {...textDefaults}>You won a free cruise!</Span>

<A>

Use to format links. Requires an href prop. Always sets target="_blank" and defaults to underline. To remove the underline, set textDecoration="none".

<Image>

An image, without any pesky borders, outlines, or underlines by default. Requires a src prop, and width and height to be set. You can override the default styles (such as adding a border) using the style prop.

Head CSS and Media Queries

You can pass a string prop headCSS to your <Email> component. You can see it in our kitchenSink.jsx example.

Mailchimp attributes

If you're using Mailchimp and need to add their custom mc:edit attributes to your markup, we recommend using the mailchimpify module.

License

MIT

react-html-email's People

Contributors

benediktvaldez avatar chromakode avatar joewestcott avatar laurent-skim-it avatar lulalachen avatar martinbethann avatar mikemclin avatar roilan avatar ryanscottaudio avatar taylorwinfield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-html-email's Issues

Capability to add media queries

Referring to Email Boilerplate template I'd like to be able to do mobile targetting such as HDI images.

Looking at Email component there doesn't appear to be anything at present to allow for the injection? Perhaps I'm missing something?

Extending to this, I would also like to be able to do some of the more quirky things like @font-face as well.

Keep package simple

Is it possible to separate the injectReactEmailAttributes functionality from the other stuff? This is really the only feature I need, but I'm not sure if it's as simple as copy pasta. Furthermore I don't believe it's wise to set the head in react/jsx. Email head elements can get really complex so it should just be a string IMO. This would allow for something like:

import * as React from 'react';
import {StaticRouter} from "react-router";
import {renderToStaticMarkup} from "react-dom/server";
import {createLocation} from 'history';
import Logo from "./components/Logo";
import head from "./head";
import injectReactEmailAttributes from "./inject-react-email-attributes":

injectReactEmailAttributes();
export default function(locals:Utils.Locals){
    const location = createLocation(locals.path);
    return `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">`
        + `<html data-editor-version="2" class="sg-campaigns" xmlns="http://www.w3.org/1999/xhtml">`
        + head
        + `<body>`
        + renderToStaticMarkup(
            <StaticRouter location={location} context={locals}>
                <Logo />
            </StaticRouter>
        )
        + `</body></html>`;

unsupported props warning even when downgrading to 1.2.0

Warning: Unknown props `bgcolor`, `border`, `align`, `valign` on <table> tag. Remove these props from the element

I keep getting this message, also passing any of those props has no effect to Box or Email component.
I am using react 15 in my project so I downgraded the library but still meeting those issues.

Multiple tds per tr

Give your API components, I don't see a way to create multiple items in a single row. What if I'd like to have 2 boxes of equal size, side by side. Should I fall back to divs or just render raw tds with width="50%"?

Thoughts on conditional comments

Im curious if you've given thought on how to handle the very common conditional comments for IE that are found in many email templates? I've been reading about the React/comment issue for a while and have not found anything useful for server side rendering.

Install issues:

Thanks for this project,

Using:
React 15.0.2, Webpack, Babel 6.8.0,

When I run:
import ReactHTMLEmail from 'react-html-email'
ReactHTMLEmail.injectReactEmailAttributes();

I get:
client:47 .//react-html-email/lib/supportMatrix.json
Module parse failed: /Projects/SMS/sms-app-factory/af-secure/node_modules/react-html-email/lib/supportMatrix.json Unexpected token (1:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:12)
at Parser.pp.raise (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:920:13)
at Parser.pp.unexpected (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1483:8)
at Parser.pp.semicolon (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1462:73)
at Parser.pp.parseExpressionStatement (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1976:8)
at Parser.pp.parseStatement (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1754:188)
at Parser.pp.parseBlock (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1991:21)
at Parser.pp.parseStatement (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1735:19)
at Parser.pp.parseTopLevel (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1648:21)
at Parser.parse (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:1616:17)
at Object.parse (/Projects/SMS/sms-app-factory/af-secure/node_modules/acorn/dist/acorn.js:882:44)
@ ./
/react-html-email/lib/StyleValidator.js 13:21-52

is there a full example

Hello i couldnt create with this example becouse it doesnt make any sence.
I have made a component according the example and that gave me just a page that is writen download source code.. etc.

import React from 'react'

import {
render
} from 'react-dom';
//import { Email, Item, Span, A, renderEmail } from 'react-html-email'
import { Box, Email, Image, Item, Span, A } from 'react-html-email'

//import eml from './XEmail'

const css = @media only screen and (max-device-width: 480px) { font-size: 20px !important; }.trim()

const sourceURL = 'https://raw.githubusercontent.com/chromakode/react-html-email/master/examples/kitchenSink.js'

export const Connect = () => (


Hello, world!


<Box cellSpacing={20} width="100%" style={{ borderTop: '3px solid black' }}>

Generated by react-html-email
react
Source code




)

export default Connect

Where do static files end up?

Noob here.

I'm just looking for the output from this program. Here's my setup:

  • In the examples/ folder, I have added a file called simple.jsx, which contains the example given in the readme.

  • When I run 'npm run prepare' I get:

[email protected] prepare /home/t42/Documents/programming/Projects/...
npm run compile
[email protected] compile /home/.../Documents/programming/Projects/...
babel -d lib/ src/ && cp -v src/supportMatrix.json lib/

src/PropTypes.js -> lib/PropTypes.js
src/StyleValidator.js -> lib/StyleValidator.js
src/components/A.jsx -> lib/components/A.js
src/components/Box.jsx -> lib/components/Box.js
src/components/Email.jsx -> lib/components/Email.js
src/components/Image.jsx -> lib/components/Image.js
src/components/Item.jsx -> lib/components/Item.js
src/components/Span.jsx -> lib/components/Span.js
src/includeDataProps.js -> lib/includeDataProps.js
src/index.js -> lib/index.js
src/renderEmail.js -> lib/renderEmail.js
'src/supportMatrix.json' -> 'lib/supportMatrix.json'

...which makes it look like lib/ is the output directory.

  • if I run 'npm run prepare examples/' I get:

[email protected] prepare /home/t42/Documents/programming/Projects/...
npm run compile "examples/"

[email protected] compile /home/t42/Documents/programming/Projects/...
babel -d lib/ src/ && cp -v src/supportMatrix.json lib/ "examples/"

src/PropTypes.js -> lib/PropTypes.js
src/StyleValidator.js -> lib/StyleValidator.js
src/components/A.jsx -> lib/components/A.js
src/components/Box.jsx -> lib/components/Box.js
src/components/Email.jsx -> lib/components/Email.js
src/components/Image.jsx -> lib/components/Image.js
src/components/Item.jsx -> lib/components/Item.js
src/components/Span.jsx -> lib/components/Span.js
src/includeDataProps.js -> lib/includeDataProps.js
src/index.js -> lib/index.js
src/renderEmail.js -> lib/renderEmail.js
'src/supportMatrix.json' -> 'examples/supportMatrix.json'
cp: -r not specified; omitting directory 'lib/'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] compile: babel -d lib/ src/ && cp -v src/supportMatrix.json lib/ "examples/"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/.../.npm/_logs/2020-06-22T16_18_33_140Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] prepare: npm run compile "examples/"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I'm sure this is a simple misunderstanding on my part, but what should I be doing to have Babel compile my component to a static html file without crashing?

Thanks

Include 'dowload' attribute on <A> component

Hi, is it possible to include this attribute?

Like <A href="..." download="my-file.pdf" />

So the user can click the link and download the pdf on the link, instead of open it.

Thanks

Can't build with webpack 3.10

Hi @chromakode , I have installed and tested your library.
The HTML email I receive is working. Thanks a lot for sharing your work.

I am trying to build for production with webpack and It seems that you are not transpiling your module to es2015 module.

ERROR in main.43150ac1b07aa1b9d40e.js from UglifyJs
Unexpected token: punc (() [main.43150ac1b07aa1b9d40e.js:171807,7]

That looks like to be a problem : https://github.com/chromakode/react-html-email/blob/master/.babelrc#L5

I have made and published this version that correct the plugin for browsers:

version

  • node 9.2.0
  • npm 5.6.0

[BUG] Default example kitchenSink.jsx does not display well in default Galaxy S6 email client.

Dear everyone,

I have tested with my Galaxy S6 edge default mail client and I was surprised to see that my template was not working well.

I have then tested with the default and found it to be a non working example:

image

The content does not display as in thunderbird:

image

I have reduced the amount of the example code and noticed that it was still present when I only have:

<Email title="Test Email" headCSS={css}>
  <Span fontSize={15}>Hello, world!</Span>
</Email>

It generates the following HTML (from thunderbird sourcecode)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.=
org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang=3D"en" xmlns=3D"http://www.=
w3.org/1999/xhtml"><head><meta http-equiv=3D"Content-Type" =
content=3D"text/html; charset=3Dutf-8"/><meta name=3D"viewport" =
content=3D"width=3Ddevice-width, initial-scale=3D1.0"/><title>Test =
Email</title></head><body style=3D"width:100%;margin:0;padding:0;-webkit-te=
xt-size-adjust:100%;-ms-text-size-adjust:100%"><table width=3D"100%" =
height=3D"100%" cellPadding=3D"0" cellSpacing=3D"0" border=3D"0" =
align=3D"left" valign=3D"top"><tbody><tr><td align=3D"center" =
valign=3D"top"><table width=3D"600" align=3D"center" cellPadding=3D"0" =
cellSpacing=3D"0" border=3D"0" valign=3D"top"><tbody><span =
style=3D"font-family:sans-serif;font-size:15px;line-height:15px;color:#000"=
>Hello, world!</span></tbody></table></td></tr></tbody></table></body></htm=
l>
  • Why does it generate two tables just for that simple email? it looks really dumb but I must be missing something.

If I keep just the <Span> the text can display well

<Span fontSize={15}>Hello, world!</Span>

But then the source code looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.=
org/TR/xhtml1/DTD/xhtml1-strict.dtd"><span style=3D"font-family:sans-serif;=
font-size:15px;line-height:15px;color:#000">Hello, world!=
</span>

I also see this guys fixing height issues for some other mail client: https://github.com/impossibleventures/react-html-email/commit/bc24f3a02be2c20ab9a5768c117e986691d159cb

This package seems to not be ready for production, is anyone aware of this? How should we fix it?

Unnecessary padding warning

Style property padding supplied to Item, in outlook: padding for p, div and a tags is not supported

The Item component adds the padding to a <td /> so this warning seems unnecessary. Can we only give it when the padding is added to a p, div, or a tag?

Setting multiple <style> blocks

Is there a way to set multiple <style> blocks in the head. I am trying to use a custom web font, which is not really supported in gmail so I'd like to put gmail safe styles in one block and gmail unsafe blocks in another. Apparently if gmail encounters anything it doesn't like in the style block it will remove the whole thing.

Thanks.

Row & Column components

Create row & column components for multi column layouts.

I can do this. Will open a PR when I have some time.

Webpack build error

Hi,
I am using this package.
When I build my react project with webpack, it gets an error.

node_modules/eslint-config-airbnb/rules/react.js:
        Configuration for rule "react/jsx-boolean-value" is invalid:
        Value "never,[object Object]" should NOT have more than 1 items.

<Email /> bodyStyle props

Hello
I found that I needed to pass styles into <body /> tag when I was using <Email /> component
and I'm wondering if you might open a new prop bodyStyle to handle styling body.

Thanks for this great email library

All the Best

When to use <Box>?

I keep getting this error anytime I use box inside < Email >

<table> cannot appear as a child of <tbody>. See MyReactComponent > Email > Box > tbody > Box > table.

inject border attribute

i want border attribute in box component

but react did not support inline border attribute

so border attribute add to injectReactEmailAttributes.js

export const emailAttributes = {
  Properties: {
    'xmlns': DOMProperty.MUST_USE_ATTRIBUTE,
    'align': DOMProperty.MUST_USE_ATTRIBUTE,
    'valign': DOMProperty.MUST_USE_ATTRIBUTE,
    'bgcolor': DOMProperty.MUST_USE_ATTRIBUTE,
    'border': DOMProperty.MUST_USE_ATTRIBUTE,
  },
}

Test with enzyme: mount

I want to do testing using mount in enzyme, and I can see many warning due to improper generated code behind that.

Would be nice to have a browser support without any warning.

react-html-email fails to compile when building

I have an app built with create-react-app. When i run the build command i get this error:
image

Here is my package.json

{
  "name": "enjoy-copenhagen",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.17.1",
    "bootstrap": "4.0.0-beta.2",
    "classnames": "^2.2.5",
    "currency-formatter": "^1.3.1",
    "draft-js": "^0.10.4",
    "firebase": "^4.6.2",
    "font-awesome": "^4.7.0",
    "money": "^0.2.0",
    "node-sass-chokidar": "0.0.3",
    "npm-run-all": "^4.1.2",
    "rand-token": "^0.4.0",
    "react": "^16.1.1",
    "react-dom": "^16.1.1",
    "react-draft-wysiwyg": "^1.12.2",
    "react-dropzone": "^4.2.3",
    "react-html-email": "^3.0.0",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^4.0.8",
    "react-scripts": "1.0.17",
    "reactstrap": "5.0.0-alpha.4",
    "redux": "^3.7.2",
    "redux-form": "^7.1.2",
    "redux-i18n": "^1.5.10",
    "redux-thunk": "^2.2.0",
    "simple-line-icons": "^2.4.1",
    "react-star-ratings": "^1.3.0",
    "react-image-gallery": "^0.8.6"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build-js": "react-scripts build",
    "build": "npm-run-all build-css build-js",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "redux-devtools-extension": "^2.13.2"
  }
}

I also attached the debug log 2018-01-14T15_07_27_354Z-debug.log

Can anyone tell me how i can fix this?

TypeError: Cannot read property 'getCurrentStack' of undefined

hello, I got the error TypeError: Cannot read property 'getCurrentStack' of undefined when render, Do you know where i use in a wrong way?

export const getResEmailData = (dataArr) => {
  if(!dataArr) return '';
  return renderEmail(<Email title="email">{dataArr && dataArr.map((item, index) => {
    if(Array.isArray(item)){
      return <Item key={index}>{item.map(partOfline => handleEmailItem(partOfline))}</Item>
    }
    return <Item key={index}>{handleEmailItem(item)}</Item>
  }
    )}</Email>)
}
const handleEmailItem = (line) => {
  switch (line.tag) {
    case RICH_CONTENT_TYPE.img:
      return <Image src={line.src} />
    case RICH_CONTENT_TYPE.text:
      return <Span>{line.text}</Span>
    case RICH_CONTENT_TYPE.title:
      return <Span>{`<h${line.level}>${line.text}</h${line.level}>`}</Span>
    case RICH_CONTENT_TYPE.a:
      return <A href={line.href}>{line.text}</A>
    default:
      break;
  }
}
react-dom-server.browser.development.js:2560 Uncaught (in promise) TypeError: Cannot read property 'getCurrentStack' of undefined
    at pushCurrentDebugStack (react-dom-server.browser.development.js:2560)
    at ReactDOMServerRenderer.read (react-dom-server.browser.development.js:3155)
    at Object.renderToStaticMarkup (react-dom-server.browser.development.js:3660)

Warnings in console of production

I have a series of errors coming from some padding on a span, and some other minor warnings. However, I am fine with those styles not being rendered.

Could we add a config variable that would disable the warnings in production?

ClassName on Item

I was hoping to have ClassName added to the Item component. I see it listed as a prop but it will not render on the element like it does with Box.

Thank you!

Latest React PropTypes is deprecated - use npm Proptype package

I just installed and am using this awesome package and noticed that I'm getting a react warning about proptypes:

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

I took a look at the code and it looks like the native React.PropTypes is being used. Any way you could update this to use the npm prop-type package now? React is deprecating this in the near future.

Let me know when you can. Thanks! -Chris

Responsive table

Hello,
How we can add media queries for table ?
I see

const css = `
@media only screen and (max-width: 480px) {
  table{
    width:50px;
  }
}`.trim()

And headCSS={css} but I can't select the ONLY table with width="600px", and I can't add className for this.
screen shot 2016-11-02 at 12 36 52

Any suggestion ?

Best regards,

Email shows all the html tags and etc

Below is my mail body.

const emailHTML = renderEmail(

hello world


)

Below is the e-mail I get.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><p>hello world</p>

What could be the issue? Can someone please help me? Thank you!

TypeScript declarations

Hey, I'd love to use this lib on a new project I'm starting, but I'll be using TypeScript and so will need some types for your lib.

Since I'll be writing them anyway, would you accept a pull request to include the types with your library?

Your kitchenSink.jsx doesn't work, should it?

Appears import should be 'react-html-email', and some others.

I just pasted into a brand new create-react-app, and doesn't seem to work.

Looking to render emails from various sources.

thanks

Error: Cannot find module 'react/lib/DOMProperty'

Error: Cannot find module 'react/lib/DOMProperty'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/react-html-email/lib/injectReactEmailAttributes.js:11:20)

[SOLVED] Layout issue - <Box> won't center

Need help centering in a template where the is 600px and centered, tried few ways, nothing works, my best attempt is below:

import React from "react";
import { Box, Email, Item, Span, A, renderEmail } from "react-html-email"; // note we added renderEmail to this import statement

// added our const that holds a string of css (it is worth noting that we can also do inline jss styles as well)
const css = `
body {
  background-color: #244a74;
  text-align: center;
}
@media only screen and (max-device-width: 480px) {
  font-size: 20px !important;
}

.container{
  width:600px;
  margin:0 auto;
  background: rgba(255,255,255,0.9)
}

`.trim();

const TeacherStudioCreatedTemplate = () => {
  const textDefaults = {
    fontFamily: "Verdana",
    fontSize: 42,
    fontWeight: "bold",
    color: "orange"
  };

  return (
    <Email title="Title" headCSS={css}>
      <Box className="container">
          <Item>
            <Span {...textDefaults}>
              text
            </Span>
        </Item>
      </Box>
    </Email>
  );
};

Can I use it for server-side-rendering?

Currently, I am trying to use reactHtmlEmail with my Keystone project(A node cms)

I'm using express-react-views as my express engine.

and sending email using express-react-views as my email render engine as well.
and using html-to-text to convert HTML to the text string.

I did not use renderEmail API to render components that react-html-email provides.

So, I wonder how to the SSR and Have I done it right?

Problem with React 15.3.0

Hello

thanks for your library!

If you generate email with your sample app

It seems there is problem with react 15.3.0

W20160819-08:49:36.187(2)? (STDERR) Warning: Unknown props bgcolor, border, align, valign on

tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop
W20160819-08:49:36.188(2)? (STDERR) in table (created by Box)
W20160819-08:49:36.189(2)? (STDERR) in Box (created by Email)
W20160819-08:49:36.189(2)? (STDERR) in body (created by Email)
W20160819-08:49:36.189(2)? (STDERR) in html (created by Email)
W20160819-08:49:36.190(2)? (STDERR) in Email
W20160819-08:49:36.196(2)? (STDERR) Warning: validateDOMNesting(...):
cannot appear as a child of . See Email > Box > tbody > Box > table.

Can you check it please ?
Thank you

Using a number for width and height doesn't give us responsive images

Using a number for the width and height props forces you to know your image before hand.

If you supplied a string and then just passed it to the styles for the Image component it should render correctly even if you do '50%'. If I pass in styles from the Image component it even works but it gives a warning for prop types and it says you shouldn't assign width and height to div elements.

If you think its a good idea to make a change I can give it a go ๐Ÿ‘

Warnings log even though warn is set to false

Here's my configuration:

import ReactHTMLEmail from 'react-html-email';

ReactHTMLEmail.injectReactEmailAttributes();
ReactHTMLEmail.configStyleValidator({
  strict: true,
  warn: false,
  platforms: [
    'gmail',
    'gmail-android',
    'apple-mail',
    'apple-ios',
  ],
});

Then here's the warning I get even though warn is set to false:

Warning: Failed prop type: Style property `border-radius` supplied to `A` unsupported in: gmail-android.
    in A (created by CTA)
    in CTA
    in tbody (created by Box)
    in table (created by Box)
    in Box (created by Email)
    in td (created by Item)
    in tr (created by Item)
    in Item (created by Email)
    in tbody (created by Box)
    in table (created by Box)
    in Box (created by Email)
    in body (created by Email)
    in html (created by Email)
    in Email

Am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.