Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Col, Row fixed tests and linter #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
lib
lib
.idea
coverage
4 changes: 2 additions & 2 deletions __tests__/renderEmail.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion examples/kitchenSink.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Box, Email, Image, Item, Span, A } from '../src/index'
import { Box, Email, Image, Item, Span, A, Row, Col } from '../src/index'

const css = `
@media only screen and (max-device-width: 480px) {
Expand All @@ -22,6 +22,12 @@ const email = (
</Item>
</Box>
</Item>
<Item>
<Row>
<Col>Column1</Col>
<Col>Column2</Col>
</Row>
</Item>
</Email>
)

Expand Down
1 change: 1 addition & 0 deletions src/components/A.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function A(props) {
download={props.download}
href={props.href}
target="_blank"
rel="noopener noreferrer"
style={{
color: props.color,
textDecoration: props.textDecoration,
Expand Down
40 changes: 40 additions & 0 deletions src/components/Col.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'
import PropTypes from 'prop-types'
import EmailPropTypes from '../PropTypes'
import includeDataProps from '../includeDataProps'

export default function Col(props) {
return (
<td
{...includeDataProps(props)}
className={props.className}
align={props.align}
valign={props.valign}
bgcolor={props.bgcolor}
colSpan={props.colSpan}
style={props.style}
>
{props.children}
</td>
)
}

Col.propTypes = {
className: PropTypes.string,
bgcolor: PropTypes.string,
colSpan: PropTypes.number,
align: PropTypes.oneOf(['left', 'center', 'right']),
valign: PropTypes.oneOf(['top', 'middle', 'bottom']),
style: EmailPropTypes.style,
children: PropTypes.node,
}

Col.defaultProps = {
colSpan: null,
children: null,
className: null,
bgcolor: null,
align: 'center',
valign: 'top',
style: null,
}
37 changes: 37 additions & 0 deletions src/components/Row.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react'
import PropTypes from 'prop-types'
import EmailPropTypes from '../PropTypes'
import includeDataProps from '../includeDataProps'

export default function Row(props) {
return (
<tr
{...includeDataProps(props)}
className={props.className}
align={props.align}
valign={props.valign}
bgcolor={props.bgcolor}
style={props.style}
>
{props.children}
</tr>
)
}

Row.propTypes = {
className: PropTypes.string,
bgcolor: PropTypes.string,
align: PropTypes.oneOf(['left', 'center', 'right']),
valign: PropTypes.oneOf(['top', 'middle', 'bottom']),
style: EmailPropTypes.style,
children: PropTypes.node,
}

Row.defaultProps = {
children: null,
className: null,
bgcolor: null,
align: 'center',
valign: 'top',
style: null,
}
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Box from './components/Box'
import Email from './components/Email'
import Image from './components/Image'
import Item from './components/Item'
import Row from './components/Row'
import Col from './components/Col'
import Span from './components/Span'
import A from './components/A'
import renderEmail from './renderEmail'
Expand All @@ -19,6 +21,8 @@ export {
Email,
Image,
Item,
Row,
Col,
Span,
A,
configStyleValidator,
Expand Down