Created
May 3, 2017 19:45
-
-
Save cannap/b8aa6a1bf1e49ee2064b3dabcb0414df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Container = { | |
functional: true, | |
render (h, { data, children }) { | |
var containerClass = 'container' | |
if (data.attrs && Object.keys(data.attrs).toString() === 'fluid') { | |
containerClass = `${containerClass}-fluid` | |
} | |
return h( | |
'div', | |
{ | |
class: containerClass | |
}, | |
children | |
) | |
} | |
} | |
const Row = { | |
functional: true, | |
render (h, { data, children }) { | |
return h('div', { class: { row: true } }, children) | |
} | |
} | |
const Col = { | |
functional: true, | |
render (h, { data, children }) { | |
var classList = null | |
if (data.attrs) { | |
classList = Object.keys(data.attrs).map(c => { | |
// Bootstrap 4 removed xs prefix | |
if (parseInt(c)) return `col-${c}` | |
return `col-${c.substring(0, 2)}-${c.substring(2)}` | |
}) | |
} | |
return h('div', { class: classList }, children) | |
} | |
} | |
export default { | |
Container, | |
Row, | |
Col | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment