Last active
March 10, 2017 09:44
-
-
Save fuunnx/8c8c1153696955fa749ea697ae01e4c5 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
.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; | |
} |
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
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