mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-02-15 19:53:12 +00:00
use virtual-dom to implement functionality for invite form
This commit is contained in:
40
src/js/components/inviteForm.js
Normal file
40
src/js/components/inviteForm.js
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var {h} = require('virtual-dom');
|
||||
var classList = require('../util/classList');
|
||||
|
||||
function render(props, state) {
|
||||
var emailInput = h('input', {
|
||||
className: classList({
|
||||
'input': true,
|
||||
'has-success': state.submitted,
|
||||
'has-error': state.error
|
||||
}),
|
||||
type: 'text',
|
||||
name: 'email',
|
||||
placeholder: 'Email',
|
||||
value: state.email,
|
||||
onkeydown: props.onChange
|
||||
});
|
||||
|
||||
var submitButton = h('button', {
|
||||
className: 'btn btn__submit',
|
||||
type: 'submit',
|
||||
title: 'Lähetä',
|
||||
disabled: state.error || state.submitted
|
||||
}, '⏎');
|
||||
|
||||
return h('form', {
|
||||
className: classList({
|
||||
'invite-form': true,
|
||||
'has-success': state.submitted,
|
||||
'has-error': state.error
|
||||
}),
|
||||
onsubmit: props.onSubmit
|
||||
}, [
|
||||
emailInput,
|
||||
submitButton
|
||||
]);
|
||||
}
|
||||
|
||||
module.exports = render;
|
||||
Reference in New Issue
Block a user