houdini/app/javascript/legacy/components/checkbox.js
2020-04-23 14:09:14 -05:00

15 lines
453 B
JavaScript

// License: LGPL-3.0-or-later
const h = require('flimflam/h')
const uuid = require('uuid')
// example:
// checkbox({name: 'anonymous', value: 'true', label: 'Donate anonymously?'})
module.exports = obj => {
const id = uuid.v1()
return h('div', [
h('input', {props: {type: 'checkbox', id, value: obj.value, name: obj.name}})
, h('label', {attrs: {for: id}}, [h('span.pl-1.sub.font-weight-1', obj.label ? obj.label : obj.value)])
])
}