-
Notifications
You must be signed in to change notification settings - Fork 0
/
summer.jsx
111 lines (94 loc) · 2.67 KB
/
summer.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
/* eslint-disable react/react-in-jsx-scope */
// Imports
import { css } from 'uebersicht';
import { fetchCurrentDate, fetchCurrentTime } from './src/datetimeutils';
import { fetchCurrentWeather } from './src/weatherutils';
// 3P requires
const numberConverter = require("number-to-words");
// User Config
const userConfig = require("./user_config.json");
// Emotion styles
const container = css`
width: 50vw;
height: 50vh;
display: flex;
align-items: center;
margin-left: 50%;
margin-top: 20vh;
`;
const overlayBox = css`
z-index: 1;
width: 100%;
margin-top: 6vh;
color: white;
text-align: center;
`;
const day = css`
width: 100%;
padding-top: 5vh;
position: absolute;
color: #333;
font-family: "Tahu!";
font-size: 50vh;
text-align: center;
`;
const month = css`
font-family: "High Summit";
font-size: 16vh;
text-transform: capitalize;
`;
const weekday = css`
margin-top: -8vh;
font-family: "High Summit";
font-size: 5vh;
text-transform: lowercase;
`;
const timeStyle = css`
font-family: "Montserrat";
font-size: 1.6vh;
text-transform: uppercase;
margin-top: 4vh;
`;
const weatherStyle = css`
font-family: "Montserrat";
font-size: 1vh;
text-transform: uppercase;
`;
// Value in milliseconds. Dictates how often the widget state is refreshed.
export const refreshFrequency = 15000;
// Command to be executed at every {refreshInterval}.
export const command = () => {
return {
"time": fetchCurrentTime(),
"date": fetchCurrentDate(),
"weather": fetchCurrentWeather(userConfig["location"], userConfig["openweathermapApiKey"])
};
};
// Main render function to draw up the widget.
export const render = ({output, error}) => {
const {time, date, weather} = output;
return (
<div className={container}>
<div className={day}>
{date["day"]}
</div>
<div className={overlayBox}>
<div className={month}>
{date["month"]}
</div>
<div className={weekday}>
{date["weekday"]}
</div>
<div className={timeStyle}>
{numberConverter.toWords(time["hours"])} <b>{numberConverter.toWords(time["minutes"])}</b>
</div>
{ weather === undefined ?
(<div className={weatherStyle}>Fetching weather...</div>) :
(<div className={weatherStyle}>
{weather["temprature"]}°C | {weather["condition"]}
</div>)
}
</div>
</div>
);
};