Skip to content

Commit 99da9c3

Browse files
committed
(#96) Introduce DayOff component
1 parent a54bd43 commit 99da9c3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

ts/DayOff.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'moment-timezone';
2+
import * as dto from './dto';
3+
import * as html from './html';
4+
import * as moment from 'moment';
5+
import ComponentsArray from './ComponentsArray'
6+
import UiComponent from './UiComponent';
7+
8+
export default class DayOff implements UiComponent {
9+
constructor(private _state: dto.State,
10+
private _date: string) {
11+
}
12+
13+
appendTo(entry: HTMLElement | null): void {
14+
let datetime = moment.tz(`${this._date} 23:59`, this._state.timezone)
15+
16+
new html.Div(
17+
new ComponentsArray ([
18+
new html.H1(
19+
new html.Text("Day off")
20+
),
21+
new html.Div(
22+
new html.Text(
23+
datetime.utc().tz(moment.tz.guess()).format('ddd, ll')
24+
),
25+
{"class": "countdown"}
26+
)
27+
]),
28+
{"class": moment().diff(datetime, 'seconds') > 0 ? "event past" : "event"}
29+
).appendTo(entry);
30+
}
31+
}
32+

0 commit comments

Comments
 (0)