Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit a9bbf4c

Browse files
Merge pull request #13 from muxinc/larger-timer-text
Larger timer text
2 parents 57078bd + afbc123 commit a9bbf4c

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

components/Timer.tsx

+21-10
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,29 @@ import moment from "moment";
77

88
import { useSpace } from "hooks/useSpace";
99

10-
const Display = styled.div`
10+
const Display = styled.div<{ isUrgent: boolean }>`
1111
position: absolute;
1212
display: flex;
13-
align-items: center;
13+
flex-direction: column;
14+
align-items: end;
1415
background-color: #383838;
1516
padding: 0.5em;
1617
top: 12px;
1718
right: 12px;
19+
font-size: 1.5em;
1820
font-variant-numeric: tabular-nums;
1921
color: white;
2022
user-select: none;
2123
border-radius: 3px;
24+
z-index: 200;
25+
26+
${(props) =>
27+
props.isUrgent &&
28+
`
29+
#countdown {
30+
color: red;
31+
}
32+
`}
2233
`;
2334

2435
const getClock = (diff: number) => {
@@ -33,10 +44,12 @@ const getClock = (diff: number) => {
3344

3445
const Timer = (): JSX.Element => {
3546
const { spaceEndsAt, leaveSpace } = useSpace();
47+
const diff = moment(spaceEndsAt).diff(moment());
3648
const [timeDisplay, setTimeDisplay] = useState<string>(
37-
spaceEndsAt ? getClock(moment(spaceEndsAt).diff(moment())) : "00:00"
49+
spaceEndsAt ? getClock(diff) : "00:00"
3850
);
3951
const router = useRouter();
52+
const twoMinutesleft = 120 >= Math.floor(diff / 1000);
4053

4154
useEffect(() => {
4255
const timer = setInterval(() => {
@@ -54,15 +67,13 @@ const Timer = (): JSX.Element => {
5467
}, [router, leaveSpace, spaceEndsAt]);
5568

5669
return (
57-
<Tooltip label="This temporary space will close after the timer expires.">
58-
<Display>
59-
<Box marginRight="6px">
60-
<MdTimer size="20px" />
61-
</Box>{" "}
62-
{timeDisplay}
70+
<Tooltip label="This demo space will close after the timer expires.">
71+
<Display isUrgent={twoMinutesleft}>
72+
<span>Time Left</span>
73+
<span id="countdown">{timeDisplay}</span>
6374
</Display>
6475
</Tooltip>
6576
);
6677
};
6778

68-
export default Timer;
79+
export default Timer;

0 commit comments

Comments
 (0)