Skip to content

Instantly share code, notes, and snippets.

@fuunnx
Last active March 10, 2017 09:44
Show Gist options
  • Save fuunnx/8c8c1153696955fa749ea697ae01e4c5 to your computer and use it in GitHub Desktop.
Save fuunnx/8c8c1153696955fa749ea697ae01e4c5 to your computer and use it in GitHub Desktop.
.Checkbox input {
width: 0;
height: 0;
opacity: 0;
}
.Checkbox input + label {
display: block;
width: 1rem;
height: 1rem;
background: grey;
}
.Checkbox input:checked + label {
background: black;
}
import {span, label, input} from '@cycle/DOM'
function Checkbox (sources) {
const id = sources.random.uuid()
return {
vNode: (selector = '', attributes = {}) => {
xs.of(
span(`.Checkbox${selector}`, {}, [
input(`#${id}${selector}`, {...attributes, attrs: {...(attributes.attrs || {}), type: 'checkbox'}}),
label({attrs: {for: id}),
])
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment