Skip to content

Commit ff0fcf6

Browse files
committed
what am i even doing
1 parent 0347f4e commit ff0fcf6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/Promo.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FunctionComponent } from 'preact';
2+
import { useEffect, useState } from 'preact/compat';
23

34
const dayLeftString = (days: number): string => {
45
if (days === 0) {
@@ -10,15 +11,29 @@ const dayLeftString = (days: number): string => {
1011
}
1112
};
1213

13-
const Promo: FunctionComponent = () => {
14+
const computeDaysLeft = () => {
1415
const now = Date.now();
15-
const daysLeft = Math.floor((1752735600000 - now) / (86400 * 1000));
16+
return Math.floor((1752735600000 - now) / 86_400_000);
17+
};
18+
19+
const Promo: FunctionComponent = () => {
20+
const [daysLeft, setDaysLeft] = useState(computeDaysLeft);
21+
useEffect(() => {
22+
const intervalId = setInterval(
23+
() => setDaysLeft(computeDaysLeft()),
24+
60_000
25+
);
26+
return () => clearInterval(intervalId);
27+
}, []);
1628
if (daysLeft < 0) {
1729
return null;
1830
} else {
1931
return (
2032
<p class="votenote">
21-
<strong>{dayLeftString(daysLeft)}</strong> Please consider{' '}
33+
<strong class={daysLeft < 2 ? 'verystrong' : undefined}>
34+
{dayLeftString(daysLeft)}
35+
</strong>
36+
{' Please consider '}
2237
<a target="_blank" href="https://www.youtube.com/shorts/4h8mYt6qnlw">
2338
voting for Jaspinko in the GeoGuessr Remix challenge
2439
</a>

src/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
--main-bg-color: #222;
6060
--main-text-color: #ffe;
6161
--error-color: #e77;
62+
--secondary-text-color: #cca;
6263
font-family: 'Inter', sans-serif;
6364
font-optical-sizing: auto;
6465
font-weight: 300;
@@ -101,6 +102,10 @@ b {
101102
font-weight: 550;
102103
}
103104

105+
strong.verystrong {
106+
font-weight: 800;
107+
}
108+
104109
.selector {
105110
display: flex;
106111
flex-direction: row;
@@ -121,7 +126,7 @@ b {
121126

122127
.hint {
123128
font-size: 0.75em;
124-
color: #cca;
129+
color: var(--secondary-text-color);
125130
}
126131

127132
#game-params input:not([type]),

0 commit comments

Comments
 (0)