Skip to content

Commit be83fa4

Browse files
CopilotAdez017
andcommitted
Fix dashboard sidebar navigation and integrate LeaderBoard properly
Co-authored-by: Adez017 <[email protected]>
1 parent a498f27 commit be83fa4

File tree

5 files changed

+92
-3
lines changed

5 files changed

+92
-3
lines changed
File renamed without changes.
File renamed without changes.

src/components/navbar/NavbarIcon.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
11
import React from "react";
22
import { NAVBAR_CONFIG, type NavbarIconName } from "../../constants/navbarConfig";
33

4-
interface NavbarIconProps {
4+
// Legacy interface for dashboard usage
5+
interface DashboardNavbarIconProps {
6+
icon: React.ReactNode;
7+
text: string;
8+
active: boolean;
9+
onClick: () => void;
10+
}
11+
12+
// New interface for navbar usage
13+
interface ConfigNavbarIconProps {
514
name: NavbarIconName;
615
}
716

8-
export default function NavbarIcon({ name }: NavbarIconProps) {
17+
type NavbarIconProps = DashboardNavbarIconProps | ConfigNavbarIconProps;
18+
19+
// Type guard to check if props are for dashboard usage
20+
function isDashboardProps(props: NavbarIconProps): props is DashboardNavbarIconProps {
21+
return 'icon' in props && 'text' in props && 'active' in props && 'onClick' in props;
22+
}
23+
24+
export default function NavbarIcon(props: NavbarIconProps) {
25+
// Handle dashboard usage
26+
if (isDashboardProps(props)) {
27+
const { icon, text, active, onClick } = props;
28+
return (
29+
<div
30+
className={`navbar-icon-item ${active ? 'active' : ''}`}
31+
onClick={onClick}
32+
role="button"
33+
tabIndex={0}
34+
onKeyDown={(e) => {
35+
if (e.key === 'Enter' || e.key === ' ') {
36+
onClick();
37+
}
38+
}}
39+
>
40+
<span className="navbar-icon">
41+
{icon}
42+
</span>
43+
<span className="navbar-text">{text}</span>
44+
</div>
45+
);
46+
}
47+
48+
// Handle navbar config usage
49+
const { name } = props;
950
const IconComponent = NAVBAR_CONFIG[name];
1051

1152
if (!IconComponent) {

src/pages/dashboard/dashboard.css

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,54 @@
178178
gap: 8px;
179179
}
180180

181+
/* Navbar Icon Items for Dashboard */
182+
.navbar-icon-item {
183+
display: flex;
184+
align-items: center;
185+
padding: 12px 16px;
186+
border-radius: 8px;
187+
cursor: pointer;
188+
transition: all 0.2s ease;
189+
color: var(--ifm-color-content);
190+
font-weight: 500;
191+
text-decoration: none;
192+
position: relative;
193+
}
194+
195+
.navbar-icon-item:hover {
196+
background: var(--ifm-color-emphasis-100);
197+
color: var(--ifm-color-content);
198+
}
199+
200+
.navbar-icon-item.active {
201+
background: var(--ifm-color-primary-lightest);
202+
color: var(--ifm-color-primary);
203+
font-weight: 600;
204+
}
205+
206+
.navbar-icon-item.active::before {
207+
content: '';
208+
position: absolute;
209+
left: 0;
210+
top: 0;
211+
bottom: 0;
212+
width: 3px;
213+
background: var(--ifm-color-primary);
214+
border-radius: 0 2px 2px 0;
215+
}
216+
217+
.navbar-icon {
218+
margin-right: 12px;
219+
display: flex;
220+
align-items: center;
221+
font-size: 18px;
222+
}
223+
224+
.navbar-text {
225+
font-size: 14px;
226+
line-height: 1.4;
227+
}
228+
181229
/* Main Content */
182230
.dashboard-main-content {
183231
flex: 1;

src/pages/dashboard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
import NavbarIcon from "@site/src/components/navbar/NavbarIcon";
3535
import "@site/src/components/discussions/discussions.css";
3636
import "./dashboard.css";
37-
import LeaderBoard from "./LeaderBoard/leaderboard";
37+
import LeaderBoard from "@site/src/components/dashboard/LeaderBoard/leaderboard";
3838

3939
type DiscussionTab = "discussions" | "trending" | "unanswered";
4040
type SortOption = "most_popular" | "latest" | "oldest";

0 commit comments

Comments
 (0)