Skip to content

Commit a659334

Browse files
LSKprkexana
andauthored
Styling (#42)
* Course page merged with main * some styling changes * more styling * more styling --------- Co-authored-by: Kacper Lisik <lisik@kth.se> Co-authored-by: Dean Tsankov <deotsts@gmail.com>
1 parent cd991a8 commit a659334

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

my-app/src/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import "tailwindcss";
1+
@import "tailwindcss";

my-app/src/views/Components/CoursePagePopup.jsx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1-
import React from 'react';
1+
import React, { useEffect, useRef } from 'react'
22

33
function CoursePagePopup({ isOpen, onClose, course, prerequisiteTree }) {
4+
5+
const treeRef = useRef(null);
6+
useEffect(() => {
7+
const handleKeyDown = (event) => {
8+
if (event.key === 'Escape') {
9+
onClose();
10+
}
11+
};
12+
13+
if (isOpen) {
14+
window.addEventListener('keydown', handleKeyDown);
15+
}
16+
17+
return () => {
18+
window.removeEventListener('keydown', handleKeyDown);
19+
};
20+
}, [isOpen, onClose]);
21+
22+
const handleTreeClick = () => {
23+
if (treeRef.current) {
24+
treeRef.current.focus(); // gives it focus
25+
}
26+
};
27+
428
if (!isOpen || !course) return null; // Don't render if not open or course not selected
529
return (
630
<div
@@ -43,16 +67,26 @@ function CoursePagePopup({ isOpen, onClose, course, prerequisiteTree }) {
4367
className="text-lg leading-8 text-[#2e2e4f] font-semibold tracking-wide prose prose-slate max-w-full"
4468
dangerouslySetInnerHTML={{ __html: course.description }}
4569
/>
46-
70+
4771
</div>
4872

4973
{/* Prerequisite Graph Tree Section */}
5074
<div>
51-
<h3 className="text-2xl font-semibold text-[#2e2e4f] mb-0.5">Prerequisite Graph Tree</h3>
75+
76+
<h3 className="text-2xl font-semibold text-[#2e2e4f] mb-0.5">
77+
Prerequisite Graph Tree
78+
</h3>
5279
<div className="mb-4 h-0.5 w-full bg-violet-500"></div>
53-
<div className="bg-indigo-300/50">
80+
<div
81+
className="bg-indigo-300/50 outline-none focus:outline-none focus:ring-2 focus:ring-violet-600 rounded-lg transition-shadow"
82+
ref={treeRef}
83+
onClick={handleTreeClick}
84+
tabIndex={0} // allows the div to receive focus
85+
>
5486
{prerequisiteTree}
5587
</div>
88+
89+
5690
</div>
5791
{/* Reviews Section */}
5892
<div>

0 commit comments

Comments
 (0)