Last active
February 4, 2019 22:12
-
-
Save szympajka/03554a4727e353db8fe613518446ce91 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
import { createComponent, styled } from 'snabbdom-react-components' | |
const Box = styled.div`` | |
const Label = styled.label`` | |
const InputField = styled.input` | |
${(props, data) => { | |
data.attrs.type = 'text' | |
}} | |
` | |
const Input = (params) => createComponent({ | |
state: () => ({ value: params.value }), | |
onInput: (e, state, component) => component.setState({value: e.target.value}), | |
render(state, component) { | |
return Box([ | |
Label(params.label), | |
InputField({ | |
on: { | |
input: component.items.onInput | |
} | |
}) | |
]) | |
} | |
}) | |
/// | |
const newInput = Input({ .. .}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment