git ssb

0+

mixmix / patchbay-scry



Tree: d6ef2d8d03691e2b92bfa1599d8c4ad87ade87ae

Files: d6ef2d8d03691e2b92bfa1599d8c4ad87ade87ae / views / new-steps / invoke.js

1537 bytesRaw
1const { h, computed, resolve } = require('mutant')
2
3module.exports = function PickTimes ({ state, prev, next }) {
4 const nextBtn = computed(state, ({ title, closesAt }) => {
5 var opts = (!title || !closesAt)
6 ? { disabled: 'disabled' }
7 : { className: '-primary', 'ev-click': next }
8
9 return h('button', opts, 'Next')
10 })
11
12 return h('ScryNewInvoke', [
13 h('h1', 'Scry invocation'),
14 h('div.details', [
15 h('label.closes-at', 'Title'),
16 h('input',
17 {
18 placeholder: 'Name of gathering you\'re scrying for',
19 'ev-input': ev => {
20 state.title.set(ev.target.value)
21 }
22 },
23 state.title
24 ),
25 h('label.closes-at', 'Closes'),
26 h('div.closes-at', [
27 h('div.closes-at-helper', prettyTime(state.closesAt)),
28 h('button', { 'ev-click': () => shiftClosesAt(-6) }, '-'),
29 h('button', { 'ev-click': () => shiftClosesAt(+6) }, '+')
30 ])
31 ]),
32 h('div.actions', [
33 prev ? h('button', { 'ev-click': prev }, 'Cancel') : null,
34 next ? nextBtn : null
35 ])
36 ])
37
38 function prettyTime (obsTime) {
39 return computed(obsTime, d => {
40 const day = d.toDateString().slice(0, 10)
41 const time = d.toLocaleTimeString().slice(0, 5)
42 return `${day}, ${time}`
43 })
44 }
45
46 function shiftClosesAt (delta) {
47 const newClosesAt = new Date(resolve(state.closesAt))
48 newClosesAt.setHours(newClosesAt.getHours() + delta)
49 if (newClosesAt < new Date()) return
50
51 state.closesAt.set(newClosesAt)
52 }
53}
54

Built with git-ssb-web