-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathform.js
More file actions
30 lines (25 loc) · 856 Bytes
/
form.js
File metadata and controls
30 lines (25 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var defaults = require('json-schema-defaults')
var el = require('yo-yo')
var schema = require('./schema')
module.exports = function renderForm (state, actions) {
var obj = defaults(schema)
var keys = Object.keys(obj)
function field (key) {
var value = obj[key] ? obj[key] : ''
return el`
<div class="field">
<label for="${key}">${key}</label>
<input name=${key} class="field-text" type="text" value=${value}>
</div>
`
}
return el`
<div class="form">
<p>This site will create a fork of this repo on your account, create a branch for your submission, save your submission, then create a pull request on the source repository.</p>
<form onsubmit=${actions.onsubmit}>
${keys.map(field)}
<input type="submit" class="button" value="Save item">
</form>
</div>
`
}