Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit d35198e

Browse files
committed
fix: higlight current period
1 parent 5b9171b commit d35198e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timetabl-app",
3-
"version": "1.0.8-beta",
3+
"version": "1.0.9-beta",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/components/DTTPeriod/DTTPeriod.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { Period } from "../Period";
88
export const DTTPeriod = ({
99
period,
1010
isLoaded,
11-
date,
11+
active,
1212
}: {
1313
period: TimetablPeriod;
1414
isLoaded: boolean;
15-
date?: string;
15+
active: boolean;
1616
}) => {
1717
const {
1818
showTimesInsteadOfRooms,
@@ -28,11 +28,7 @@ export const DTTPeriod = ({
2828

2929
return (
3030
<Period
31-
active={
32-
(DateTime.fromISO(`${date}T${period.time}`) < DateTime.now() &&
33-
DateTime.now() < DateTime.fromISO(`${date}T${period.endTime}`)) ??
34-
false
35-
}
31+
active={active}
3632
colour={
3733
period.room &&
3834
{

src/routes/Main/Home/Home.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ const HomeView = ({
6262

6363
const [countdown, setCountdown] = useState("");
6464

65+
const activeIndex = periods.findIndex(
66+
({ time, endTime }: { time: string; endTime: string }) =>
67+
(DateTime.fromISO(`${date}T${time}`) < DateTime.now() &&
68+
DateTime.now() < DateTime.fromISO(`${date}T${endTime}`)) ??
69+
false
70+
);
71+
6572
return (
6673
<LayoutGroup>
6774
<Flex direction={"column"} align="center" gap={1.5}>
@@ -129,6 +136,7 @@ const HomeView = ({
129136
{periods.length ? (
130137
periods.map((period, index) => (
131138
<DTTPeriod
139+
active={activeIndex === index}
132140
period={period}
133141
key={period.key ?? index + 100}
134142
isLoaded={isLoaded}

0 commit comments

Comments
 (0)