Skip to content
Open
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
8 changes: 5 additions & 3 deletions packages/heml-elements/src/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ const {
const breakpoint = 600

export default createElement('column', {
attrs: [ 'small', 'large' ],
attrs: [ 'small', 'large', 'align' ],
parent: [ 'row' ],
defaultAttrs: { small: 12, large: 12 },
defaultAttrs: { small: 12, large: 12, align: 'left' },
containsText: true,

rules: {
'.column': [ { '@pseudo': 'root' }, { display: transforms.trueHide(undefined, true) }, background, box, padding, border, borderRadius, 'vertical-align' ]
},

render (attrs, contents) {
const { align } = attrs
const small = parseInt(attrs.small, 10)
const large = parseInt(attrs.large, 10)
const largeWidth = `${Math.round((100 * large) / 12)}%`
attrs.class += ` column col-sm-${small}`

delete attrs.large
delete attrs.small
delete attrs.align

return ([
<td {...attrs} width={largeWidth} style={`width: ${largeWidth};`} align='left' valign='top'>
<td {...attrs} width={largeWidth} style={`width: ${largeWidth};`} align={align} valign='top'>
{contents.length === 0 ? '&nbsp;' : contents}
</td>,
small === large ? '' : (<Style for='column' heml-embed>{`
Expand Down