Skip to content

Commit 373a892

Browse files
harise01hselvaka
andauthored
Colour-coded nodes by year (#11)
* Colour-coded nodes by year * Improved functionality for extracting year * Fix formatting --------- Co-authored-by: hselvaka <hselvaka@uwaterloo.ca>
1 parent a891622 commit 373a892

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/components/CourseNode.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ export default function CourseNode({ data }: NodeProps<CourseNodeType>) {
88
const { selectedCourse, highlightedSet } = useExplorerStore();
99
const dimmed = selectedCourse !== null && !highlightedSet.has(data.code);
1010

11+
const year = data.code.match(/\d/)?.[0];
12+
13+
const borderColour =
14+
year === '1'
15+
? 'border-green-500'
16+
: year === '2'
17+
? 'border-blue-500'
18+
: year === '3'
19+
? 'border-yellow-500'
20+
: year === '4'
21+
? 'border-red-500'
22+
: 'border-gray-300';
23+
1124
return (
1225
<div
13-
className="flex flex-col justify-center rounded border border-gray-300 bg-white px-3 py-2 shadow-sm transition-opacity duration-150"
26+
className={`flex flex-col justify-center rounded border ${borderColour} bg-white px-3 py-2 shadow-sm transition-opacity duration-150`}
1427
style={{ width: 180, height: 60, opacity: dimmed ? 0.25 : 1 }}
1528
>
1629
<Handle type="target" position={Position.Top} />

0 commit comments

Comments
 (0)