Skip to content

Commit 0c3d969

Browse files
committed
more styling
1 parent 8ffb3d6 commit 0c3d969

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-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: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1-
import React from 'react';
1+
import React, { useEffect, useRef } from 'react'
22

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

4972
{/* Prerequisite Graph Tree Section */}
5073
<div>
51-
<h3 className="text-2xl font-semibold text-[#2e2e4f] mb-0.5">Prerequisite Graph Tree</h3>
74+
<h3 className="text-2xl font-semibold text-[#2e2e4f] mb-0.5">
75+
Prerequisite Graph Tree
76+
</h3>
5277
<div className="mb-4 h-0.5 w-full bg-violet-500"></div>
53-
<div className="bg-indigo-300/50">
78+
<div
79+
className="bg-indigo-300/50 outline-none focus:outline-none focus:ring-2 focus:ring-violet-600 rounded-lg transition-shadow"
80+
ref={treeRef}
81+
onClick={handleTreeClick}
82+
tabIndex={0} // allows the div to receive focus
83+
>
5484
{prerequisiteTree}
5585
</div>
86+
5687
</div>
5788
{/* Reviews Section */}
5889
<div>

0 commit comments

Comments
 (0)