-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.jsx
130 lines (106 loc) · 2.65 KB
/
index.jsx
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
// eslint-disable-next-line import/no-unresolved
import React, {css, styled} from 'uebersicht'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
import timezone from 'dayjs/plugin/timezone'
import advancedFormat from 'dayjs/plugin/advancedFormat'
dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.extend(advancedFormat)
const list = [
{location: '🇺🇸 San Francisco', z: 'US/Pacific'},
{location: '🇺🇸 Salt Lake City', z: 'US/Mountain'},
{location: '🇺🇸 Austin', z: 'US/Central'},
{location: '🇺🇸 New York', z: 'US/Eastern'},
{location: '🇬🇧 London', z: 'Europe/London'},
{location: '🇩🇪 Ichenhausen', z: 'Europe/Berlin'},
{location: '🇮🇳 Bengaluru', z: 'Asia/Kolkata'},
{location: '🇦🇺 Sydney', z: 'Australia/Sydney'},
]
export const refreshFrequency = 1000 // Use ms (every seconds)
// eslint-disable-next-line no-unused-vars
export const command = dispatch => {}
export const render = () => {
const now = dayjs().local()
const items = list.map(item => {
const [date, time, tz] = now.tz(item.z).format('DD MMM_HH:mm_z').split('_')
return {
...item,
date,
time,
tz,
}
})
return items.map(item => (
<WorldClockContainer key={item.location}>
<City>{item.location}</City>
<TimeBlock>
<Time>{item.time}</Time>
<Info>
<Date>{item.date}</Date>
<Timezone>{item.tz}</Timezone>
</Info>
</TimeBlock>
</WorldClockContainer>
))
}
// Styling...
export const className = css`
font:
normal normal 400 1.96em/1.28 -apple-system,
Helvetica Neue;
transition: all 1s ease;
@media (prefers-color-scheme: light) {
color: #2f363d;
}
@media (prefers-color-scheme: dark) {
color: #ebebeb;
}
left: 1em;
top: 4em;
min-width: 200px;
`
const WorldClockContainer = styled('div')`
margin-bottom: 8px;
display: flex;
flex-direction: column;
`
const City = styled('div')`
font-size: 0.4em;
@media (prefers-color-scheme: light) {
opacity: 0.64;
}
@media (prefers-color-scheme: dark) {
opacity: 0.32;
}
flex-grow: 2;
`
const TimeBlock = styled('div')`
display: inline-flex;
flex-grow: 2;
flex-direction: row;
`
const Time = styled('div')`
font-size: 0.64em;
font-weight: 400;
flex-grow: 1;
`
const Info = styled('div')`
font-size: 0.32em;
@media (prefers-color-scheme: light) {
opacity: 0.64;
}
@media (prefers-color-scheme: dark) {
opacity: 0.32;
}
display: inline-flex;
justify-content: space-around;
flex-direction: column;
flex-grow: 10;
`
const Date = styled('span')`
font-weight: 100;
`
const Timezone = styled('span')`
font-weight: 100;
`