-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
192 lines (170 loc) · 4.64 KB
/
index.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
const debug = require('debug')
const bel = require('bel')
const csjs = require('csjs-inject')
const { isBefore, getYear, getMonth, getDaysInMonth } = require('date-fns')
// widgets
const timelineDays = require('datdot-ui-timeline-days')
// const datepicker = require('datdot-ui-datepicker')
const tab = require('datdot-ui-tab')
const message_maker = require('message-maker')
var id = 0
module.exports = datdotui
function datdotui ({data}, parent_protocol) {
// -----------------------------------
const myaddress = `${__filename}-${id++}`
const inbox = {}
const outbox = {}
const recipients = {}
const names = {}
const message_id = to => (outbox[to] = 1 + (outbox[to]||0))
const {notify, address} = parent_protocol(myaddress, listen)
names[address] = recipients['parent'] = { name: 'parent', notify, address, make: message_maker(myaddress) }
notify(recipients['parent'].make({ to: address, type: 'ready', refs: {} }))
function make_protocol (name) {
return function protocol (address, notify) {
console.log('PROTOCOL INIT', { name, address })
names[address] = recipients[name] = { name, address, notify, make: message_maker(myaddress) }
return { notify: listen, address: myaddress }
}
}
function listen (msg) {
const { head, refs, type, data, meta } = msg // receive msg
inbox[head.join('/')] = msg // store msg
const [from] = head
console.log('DATEPICKER', { type, from, name: names[from].name, msg, data })
// handlers
}
// -----------------------------------
var counter = 0
const { jobs, plans } = data
// set init date
const date = new Date()
let year = getYear(date)
// get current month
let currentMonth = getMonth(date)
let currentDays = getDaysInMonth(date)
// get next month
let nextMonth = currentMonth+1
let nextDays = getDaysInMonth(new Date(year, nextMonth))
// store data
let state = {}
// SUB COMPONENTS
const timelinedays = timelineDays( {data: null, style: `${css['timeline-days']}` }, make_protocol(`timeline-${counter++}`) )
// const datepicker1 = datepicker({month1: [year, currentMonth, currentDays], month2: [year, nextMonth, nextDays] }, make_protocol(`datepicker-${counter++}`))
const weekday = bel`<section class=${css['calendar-weekday']} role="weekday"></section>`
const weekList= ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
weekList.map( w => weekday.append( bel`<div class=${css['calendar-week']} role="week">${w.slice(0 ,1)}</div>`))
const element = bel`
<div class=${css.wrap}>
<section class=${css["ui-widgets"]}>
<!--- ui-calendar-timeline-days start -->
<div class=${css.days}>
<h2 class=${css.title}>Timline days</h2>
<div class=${css['calendar-timeline-days']}>${timelinedays}</div>
</div>
<!--- // ui-calendar-timeline-days end -->
</section>
<div class=${css.terminal}> </div>
</div>`
const [, terminal] = element.children
return element
}
const css = csjs`
body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
background-color: #F2F2F2;
height: 100%;
}
button:active, button:focus {
outline: dotted 1px #c9c9c9;
}
.wrap {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 75vh 25vh;
min-width: 520px
}
.terminal {
background-color: #212121;
color: #f2f2f2;
font-size: 13px;
padding: 0 20px;
overflow-y: auto;
}
.terminal div {
margin: 10px 0;
}
.terminal div:last-child {
color: #FFF500;
font-weight: bold;
}
.ui-widgets {
padding: 20px;
overflow-y: auto;
}
.ui-widgets > div {
margin-bottom: 30px;
padding: 10px 20px 20px 20px;
background-color: #fff;
}
.ui-tab {
}
.ui-tab > nav {
margin-bottom: 20px;
}
.title {
color: #008dff;
}
.ui-calendar-header {
}
.custom-header {
background-color: #f2f2f2;
max-width: 25%;
min-width: 225px;
border-radius: 50px;
}
.custom-header > [class^="calendar-header"] {
grid-template-rows: 30px;
}
.custom-header > [class^="calendar-header"] h3 {
font-size: 16px;
}
.calendar-header-fullsize {
}
.days {
}
.calendar-timeline-days {
}
.timeline-days {
display: grid;
grid-template-rows: auto;
grid-template-columns: repeat(auto-fit, minmax(30px, auto));
justify-content: left;
align-items: center;
}
.calendar-section {
margin-top: 30px;
font-size: 12px;
}
.calendar-table-days {
max-width: 210px;
}
.calendar-days {
display: grid;
grid-template-rows: auto;
grid-template-columns: repeat(7, minmax(30px, auto));
justify-items: center;
}
.calendar-weekday {
display: grid;
grid-template-rows: auto;
grid-template-columns: repeat(7, 30px);
justify-items: center;
}
.calendar-week {
}
.ui-datepicker {
}
`