Skip to content

Instantly share code, notes, and snippets.

@jongacnik
Created April 27, 2018 03:10
Show Gist options
  • Save jongacnik/b68be906550410c0ffe876b094d7bc96 to your computer and use it in GitHub Desktop.
Save jongacnik/b68be906550410c0ffe876b094d7bc96 to your computer and use it in GitHub Desktop.
var html = require('choo/html')
module.exports = (style, classname, svg) => {
style = style || ''
classname = classname || ''
var viewBox = [0,0,1,1]
if (require('../browser')) {
svg.style.display = 'block'
svg.style.position = 'absolute'
svg.style.top = 0
svg.style.left = 0
svg.style.width = '100%'
svg.style.height = '100%'
viewBox = svg.getAttribute('viewBox').split(' ')
}
return html`
<div style=${style} class="${classname}">
<canvas width="${viewBox[2]}" height="${viewBox[3]}"></canvas>
${svg}
</div>
`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment