Skip to content

Instantly share code, notes, and snippets.

@cannap
Created May 3, 2017 19:45
Show Gist options
  • Save cannap/b8aa6a1bf1e49ee2064b3dabcb0414df to your computer and use it in GitHub Desktop.
Save cannap/b8aa6a1bf1e49ee2064b3dabcb0414df to your computer and use it in GitHub Desktop.
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