Skip to content

Commit bd8a6a0

Browse files
committed
Use different approach to sinfo session colors
1 parent 64e3f63 commit bd8a6a0

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ 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 {
13-
generateTimeInterval,
14-
getSessionColorClassName,
15-
isMember,
16-
} from "@/utils/utils";
12+
import { generateTimeInterval, getSessionColor, isMember } from "@/utils/utils";
1713
import { CalendarClock, MapPin, Scan, Users } from "lucide-react";
1814
import { getServerSession } from "next-auth";
1915
import Image from "next/image";
@@ -63,7 +59,8 @@ export default async function Session({ params }: { params: SessionParams }) {
6359
</span>
6460
</div>
6561
<span
66-
className={`text-white rounded-md px-3 py-1 font-bold uppercase ${getSessionColorClassName(sinfoSession.kind)}`}
62+
className={`text-white rounded-md px-3 py-1 font-bold uppercase`}
63+
style={{ backgroundColor: getSessionColor(sinfoSession.kind) }}
6764
>
6865
{sinfoSession.kind}
6966
</span>

src/components/ListCard.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface ListCardProps {
1313
subtitle?: string;
1414
headtext?: string;
1515
label?: string;
16-
labelExtraClassName?: string;
16+
labelColor?: string;
1717
link?: string;
1818
linkProps?: LinkProps;
1919
extraClassName?: string;
@@ -41,7 +41,7 @@ export default function ListCard({
4141
subtitle,
4242
headtext,
4343
label,
44-
labelExtraClassName,
44+
labelColor,
4545
link,
4646
extraComponent,
4747
imgProps,
@@ -74,7 +74,8 @@ export default function ListCard({
7474
)}
7575
{label && (
7676
<span
77-
className={`bg-sinfo-secondary text-white rounded-md px-2 py-0.5 uppercase ${labelExtraClassName ?? ""}`}
77+
className={`bg-sinfo-secondary text-white rounded-md px-2 py-0.5 uppercase`}
78+
style={labelColor ? { backgroundColor: labelColor } : undefined}
7879
>
7980
{label}
8081
</span>

src/components/session/SessionTile.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ListCard from "@/components/ListCard";
2-
import { generateTimeInterval, getSessionColorClassName } from "@/utils/utils";
2+
import { generateTimeInterval, getSessionColor } from "@/utils/utils";
33

44
interface SesionTileProps {
55
session: SINFOSession;
@@ -29,7 +29,7 @@ export function SessionTile({
2929
onlyHours: onlyShowHours,
3030
})}
3131
label={session.kind}
32-
labelExtraClassName={getSessionColorClassName(session.kind)}
32+
labelColor={getSessionColor(session.kind)}
3333
link={`/sessions/${session.id}`}
3434
extraClassName={
3535
pastSession ? "!bg-neutral-200 hover:!bg-neutral-300" : ""

src/utils/utils.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import config from "../../tailwind.config";
2+
13
export function convertToAppRole(role: string): UserRole {
24
switch (role) {
35
case "company":
@@ -132,14 +134,15 @@ export function isToday(date: Date | string): boolean {
132134
);
133135
}
134136

135-
export function getSessionColorClassName(sessionKind: string) {
137+
export function getSessionColor(sessionKind: string) {
136138
switch (sessionKind) {
137139
case "Presentation":
138-
return "!bg-sinfo-tertiary";
140+
return config.theme.extend.colors.sinfo.tertiary;
139141
case "Workshop":
140-
return "!bg-sinfo-quaternary";
142+
return config.theme.extend.colors.sinfo.quaternary;
141143
case "Keynote":
144+
return config.theme.extend.colors.sinfo.secondary;
142145
default:
143-
return "!bg-sinfo-secondary";
146+
return "#000";
144147
}
145148
}

tailwind.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Config } from "tailwindcss";
22

3-
const config: Config = {
3+
const config = {
44
content: [
55
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
66
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
@@ -23,4 +23,5 @@ const config: Config = {
2323
},
2424
plugins: [],
2525
};
26-
export default config;
26+
27+
export default config satisfies Config;

0 commit comments

Comments
 (0)