git ssb

0+

mixmix / patchbay-scry



Tree: 6071577daff8cc01e7241b5799fb112902aec545

Files: 6071577daff8cc01e7241b5799fb112902aec545 / views / new-steps / pick-times.js

1506 bytesRaw
1const { h, computed } = require('mutant')
2const DayPicker = require('../component/day-picker.js')
3const TimePicker = require('../component/time-picker.js')
4
5module.exports = function PickTimes ({ state, prev, next }) {
6 const nextBtn = computed(state, ({ days, times }) => {
7 var opts = (!days.length || !times.length)
8 ? { disabled: 'disabled' }
9 : { className: '-primary', 'ev-click': next }
10
11 return h('button', opts, 'Scry')
12 })
13
14 return h('ScryNewPickTimes', [
15 DayPicker(state),
16 computed(state.days, days => {
17 if (!days.length) {
18 return h('div.time-picker-pristine', [
19 h('label', 'Dates and Times'),
20 h('div.instruction', 'Select one or multiple dates')
21 ])
22 }
23
24 return h('div.time-picker', [
25 h('label', `Same times for all dates (${days.length})`),
26 TimePicker(state),
27 h('div.timezone', [
28 h('label', 'Timezone of your scry is'),
29 h('div.zone', [
30 getTimezone(),
31 h('span', ['(UTC ', getTimezoneOffset(), ')'])
32 ])
33 ])
34 ])
35 }),
36 h('div.actions', [
37 prev ? h('button', { 'ev-click': prev }, 'Back') : null,
38 next ? nextBtn : null
39 ])
40 ])
41}
42
43// functions
44
45function getTimezone () {
46 try {
47 return Intl.DateTimeFormat().resolvedOptions().timeZone
48 } catch (e) {
49 return '??'
50 }
51}
52
53function getTimezoneOffset () {
54 const offset = new Date().getTimezoneOffset() / -60
55 return offset > 0 ? `+${offset}` : offset
56}
57

Built with git-ssb-web