Skip to content

Commit 8e7b32a

Browse files
committed
Add fixes
1 parent fec834b commit 8e7b32a

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

src/components/resources/Sidebar/Sidebar.model.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
export interface SidebarItem {
2-
title: string;
3-
path?: string;
4-
children?: SidebarItem[];
5-
}
6-
7-
export interface SidebarItemGroup {
82
title: string;
93
path?: string;
104
icon?: string;
115
color?: string;
126
children?: SidebarItem[];
137
}
14-
158
export interface SidebarItemProps {
169
item: SidebarItem;
1710
depth: number;

src/components/resources/Sidebar/Sidebar.style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
}
5858

5959
.sidebar-content {
60-
max-height: 0;
60+
max-height: 0;
6161
overflow: hidden;
6262
transition: max-height 2s ease-in-out;
6363
}

src/components/resources/Sidebar/SidebarItem.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import "./Sidebar.style.scss";
22
import { useState, useEffect } from "react";
33
import { CircleIcon } from "../../core";
4-
import type { SidebarItemProps } from "./Sidebar.model";
5-
6-
interface RecursiveSidebarItemProps extends SidebarItemProps {
7-
children?: RecursiveSidebarItemProps[];
8-
}
4+
import type { SidebarItem, SidebarItemProps } from "./Sidebar.model";
95

106
export default function SidebarItem(props: SidebarItemProps) {
117
const [open, setOpen] = useState<boolean>(false);
128

13-
const checkActivePath = (item: RecursiveSidebarItemProps) => {
9+
const checkActivePath = (item: SidebarItem) => {
1410
if (props.item.path && window.location.pathname.includes(props.item.path)) {
1511
setOpen(true);
1612
} else if (item.children) {
@@ -35,9 +31,9 @@ export default function SidebarItem(props: SidebarItemProps) {
3531
<a href={props.item.path || "#"} className="sidebar-item plain">
3632
<div className="sidebar-title-container">
3733
<CircleIcon
38-
icon={props.item.icon}
34+
icon={props.item.icon || ""}
3935
size="size-small"
40-
colorSet={`${props.item.colorSet}-card`}
36+
colorSet={`${props.item.color || ""}-card`}
4137
/>
4238
<span>{props.item.title}</span>
4339
</div>
@@ -57,14 +53,14 @@ export default function SidebarItem(props: SidebarItemProps) {
5753
{/* if you have children, display a dropdown arrow */}
5854
{props.item.children ? (
5955
<button className="menu-down" onClick={() => setOpen(!open)}>
60-
<i className={`fa fa-chevron-${open ? "up" : "down"}`} />
56+
<i className={`fa fa-chevron-${open ? "up" : "down"}`} />
6157
</button>
6258
) : null}
6359
</div>
6460
</div>
6561

6662
{/* if you have children, display children */}
67-
{props.item.children && (
63+
{props.item.children ? (
6864
<div className={`sidebar-content ${open ? "open" : null}`}>
6965
{props.item.children.map((child, index) => (
7066
<SidebarItem
@@ -75,7 +71,7 @@ export default function SidebarItem(props: SidebarItemProps) {
7571
/>
7672
))}
7773
</div>
78-
)}
74+
): null}
7975
</>
8076
);
8177
}

src/components/resources/Sidebar/data/SidebarData.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"title": "Student Life",
44
"icon": "fa fa-home",
5-
"colorSet": "red",
5+
"color": "red",
66
"path": "/student-life",
77
"children": [
88
{
@@ -52,7 +52,7 @@
5252
{
5353
"title": "Academics",
5454
"icon": "fa fa-graduation-cap",
55-
"colorSet": "green",
55+
"color": "green",
5656
"path": "/academics",
5757
"children": [
5858
{
@@ -80,7 +80,7 @@
8080
{
8181
"title": "Careers",
8282
"icon": "fa fa-briefcase",
83-
"colorSet": "blue",
83+
"color": "blue",
8484
"path": "/careers",
8585
"children": [
8686
{
@@ -252,7 +252,7 @@
252252
{
253253
"title": "Self Learning",
254254
"icon": "fa fa-seedling",
255-
"colorSet": "orange",
255+
"color": "orange",
256256
"path": "/self-learning",
257257
"children": [
258258
{
@@ -264,7 +264,7 @@
264264
{
265265
"title": "Courses",
266266
"icon": "fa fa-book",
267-
"colorSet": "purple",
267+
"color": "purple",
268268
"path": "/courses",
269269
"children": [
270270
{
@@ -318,7 +318,7 @@
318318
{
319319
"title": "FAQs",
320320
"icon": "fa fa-lightbulb",
321-
"colorSet": "yellow",
321+
"color": "yellow",
322322
"path": "/faqs"
323323
}
324324
]

0 commit comments

Comments
 (0)