Skip to content

Commit 778a330

Browse files
committed
Show consistent session colors
1 parent ac9344c commit 778a330

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/app/(authenticated)/sessions/[id]/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import { PrizeTile } from "@/components/prize";
99
import AddToCalendarButton from "@/components/session/AddToCalendarButton";
1010
import { SessionService } from "@/services/SessionService";
1111
import { UserService } from "@/services/UserService";
12-
import { generateTimeInterval, isMember } from "@/utils/utils";
12+
import {
13+
generateTimeInterval,
14+
getSessionColorClassName,
15+
isMember,
16+
} from "@/utils/utils";
1317
import { CalendarClock, MapPin, Scan, Users } from "lucide-react";
1418
import { getServerSession } from "next-auth";
1519
import Image from "next/image";
@@ -58,7 +62,9 @@ export default async function Session({ params }: { params: SessionParams }) {
5862
{sinfoSession.place}
5963
</span>
6064
</div>
61-
<span className="bg-sinfo-secondary text-white rounded-md px-3 py-1 font-bold uppercase">
65+
<span
66+
className={`text-white rounded-md px-3 py-1 font-bold uppercase ${getSessionColorClassName(sinfoSession.kind)}`}
67+
>
6268
{sinfoSession.kind}
6369
</span>
6470
<ShowMore lines={5} className="font-light">

src/components/session/SessionTile.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import ListCard from "@/components/ListCard";
2-
import { generateTimeInterval } from "@/utils/utils";
2+
import { generateTimeInterval, getSessionColorClassName } from "@/utils/utils";
33

44
interface SesionTileProps {
55
session: SINFOSession;
66
onlyShowHours?: boolean;
77
}
88

9-
export function getLabelClassName(text: string): string {
10-
switch (text) {
11-
case "Presentation":
12-
return "!bg-sinfo-tertiary";
13-
case "Workshop":
14-
return "!bg-sinfo-quaternary";
15-
case "Keynote":
16-
default:
17-
return ""; // Use default label color
18-
}
19-
}
20-
219
export function SessionTile({
2210
session,
2311
onlyShowHours = false,
@@ -41,7 +29,7 @@ export function SessionTile({
4129
onlyHours: onlyShowHours,
4230
})}
4331
label={session.kind}
44-
labelExtraClassName={getLabelClassName(session.kind)}
32+
labelExtraClassName={getSessionColorClassName(session.kind)}
4533
link={`/sessions/${session.id}`}
4634
extraClassName={
4735
pastSession ? "!bg-neutral-200 hover:!bg-neutral-300" : ""

src/utils/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,15 @@ export function isToday(date: Date | string): boolean {
131131
date.getDate() === today.getDate()
132132
);
133133
}
134+
135+
export function getSessionColorClassName(sessionKind: string) {
136+
switch (sessionKind) {
137+
case "Presentation":
138+
return "!bg-sinfo-tertiary";
139+
case "Workshop":
140+
return "!bg-sinfo-quaternary";
141+
case "Keynote":
142+
default:
143+
return "!bg-sinfo-secondary";
144+
}
145+
}

0 commit comments

Comments
 (0)