✨ direct navigation and notification badges for messages and calendar icons
Browse files at this commit7362bb1ac71d2e466f05ca9c24e5cbcc109d8abfParent: 68d09e3- feat
- ✨ direct navigation and notification badges for messages and calendar icons
2 changed files +21 -25
src/components/layout/nav-items.tsmodified+3 -0
| @@ -13,6 +13,7 @@ import { | |||
| 13 | IconHelpCircle, | 13 | IconHelpCircle, |
| 14 | IconHomework, | 14 | IconHomework, |
| 15 | IconHome, | 15 | IconHome, |
| 16 | + IconMessage, | ||
| 16 | IconNote, | 17 | IconNote, |
| 17 | IconReportAnalytics, | 18 | IconReportAnalytics, |
| 18 | IconSchool, | 19 | IconSchool, |
| @@ -56,6 +57,7 @@ const NAV_GROUPS: NavGroup[] = [ | |||
| 56 | { to: "/homework", labelKey: "nav.homework", Icon: IconHomework }, | 57 | { to: "/homework", labelKey: "nav.homework", Icon: IconHomework }, |
| 57 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, | 58 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, |
| 58 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, | 59 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, |
| 60 | + { to: "/calendar", labelKey: "nav.calendar", Icon: IconCalendarDays }, | ||
| 59 | { to: "/marks", labelKey: "nav.marks", Icon: IconChart, exactRole: "student" }, | 61 | { to: "/marks", labelKey: "nav.marks", Icon: IconChart, exactRole: "student" }, |
| 60 | { to: "/attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, exactRole: "student" }, | 62 | { to: "/attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, exactRole: "student" }, |
| 61 | { to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student" }, | 63 | { to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student" }, |
| @@ -83,6 +85,7 @@ const NAV_GROUPS: NavGroup[] = [ | |||
| 83 | labelKey: "nav.group.community", | 85 | labelKey: "nav.group.community", |
| 84 | Icon: IconGlobe, | 86 | Icon: IconGlobe, |
| 85 | items: [ | 87 | items: [ |
| 88 | + { to: "/messages", labelKey: "nav.messages", Icon: IconMessage }, | ||
| 86 | { to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle }, | 89 | { to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle }, |
| 87 | ], | 90 | ], |
| 88 | }, | 91 | }, |
src/components/layout/right-nav.tsxmodified+18 -25
| @@ -1,5 +1,5 @@ | |||
| 1 | import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 1 | import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; |
| 2 | -import { useNavigate } from "@tanstack/solid-router"; | 2 | +import { useLocation, useNavigate } from "@tanstack/solid-router"; |
| 3 | import { getEvents } from "@/api/events"; | 3 | import { getEvents } from "@/api/events"; |
| 4 | import { getExams } from "@/api/exams"; | 4 | import { getExams } from "@/api/exams"; |
| 5 | import { getMessages, patchMessageById } from "@/api/messages"; | 5 | import { getMessages, patchMessageById } from "@/api/messages"; |
| @@ -29,8 +29,12 @@ const PAGE_SIZE = 5; | |||
| 29 | export function RightNav() { | 29 | export function RightNav() { |
| 30 | const t = useT(); | 30 | const t = useT(); |
| 31 | const navigate = useNavigate(); | 31 | const navigate = useNavigate(); |
| 32 | + const location = useLocation(); | ||
| 32 | const { locale } = usePreferences(); | 33 | const { locale } = usePreferences(); |
| 33 | 34 | ||
| 35 | + const isMessagesActive = () => location().pathname === "/messages"; | ||
| 36 | + const isCalendarActive = () => location().pathname === "/calendar"; | ||
| 37 | + | ||
| 34 | // Active drawer tab | 38 | // Active drawer tab |
| 35 | const [activeTab, setActiveTab] = createSignal<ActiveTab>(null); | 39 | const [activeTab, setActiveTab] = createSignal<ActiveTab>(null); |
| 36 | 40 | ||
| @@ -145,18 +149,6 @@ export function RightNav() { | |||
| 145 | return combinedCalendarItems().slice(start, start + PAGE_SIZE); | 149 | return combinedCalendarItems().slice(start, start + PAGE_SIZE); |
| 146 | }); | 150 | }); |
| 147 | 151 | ||
| 148 | - // Toggle drawer tabs | ||
| 149 | - const toggleTab = (tab: "messages" | "calendar") => { | ||
| 150 | - if (activeTab() === tab) { | ||
| 151 | - setActiveTab(null); | ||
| 152 | - } else { | ||
| 153 | - setActiveTab(tab); | ||
| 154 | - // Reset preview state when switching tabs | ||
| 155 | - setSelectedMessage(null); | ||
| 156 | - setSelectedCalItem(null); | ||
| 157 | - } | ||
| 158 | - }; | ||
| 159 | - | ||
| 160 | const closePanel = () => { | 152 | const closePanel = () => { |
| 161 | setActiveTab(null); | 153 | setActiveTab(null); |
| 162 | setSelectedMessage(null); | 154 | setSelectedMessage(null); |
| @@ -199,41 +191,42 @@ export function RightNav() { | |||
| 199 | class="sticky top-0 z-30 hidden h-screen w-14 shrink-0 flex-col items-center justify-between border-l border-black/[0.06] bg-sidebar py-3 text-sidebar-foreground dark:border-white/[0.08] dark:bg-[#070707] dark:text-white lg:flex" | 191 | class="sticky top-0 z-30 hidden h-screen w-14 shrink-0 flex-col items-center justify-between border-l border-black/[0.06] bg-sidebar py-3 text-sidebar-foreground dark:border-white/[0.08] dark:bg-[#070707] dark:text-white lg:flex" |
| 200 | > | 192 | > |
| 201 | <div class="flex flex-col items-center gap-3"> | 193 | <div class="flex flex-col items-center gap-3"> |
| 202 | - {/* Messages Icon Button */} | 194 | + {/* Messages Icon Button - Direct Page Navigation */} |
| 203 | <button | 195 | <button |
| 204 | type="button" | 196 | type="button" |
| 205 | - onClick={() => toggleTab("messages")} | 197 | + onClick={() => goTo("/messages")} |
| 206 | class={cn( | 198 | class={cn( |
| 207 | - "relative flex h-10 w-10 items-center justify-center rounded-xl transition-all duration-200", | 199 | + "relative flex h-10 w-10 items-center justify-center rounded-xl transition-all duration-200 cursor-pointer", |
| 208 | - activeTab() === "messages" | 200 | + isMessagesActive() |
| 209 | ? "bg-primary text-primary-foreground shadow-md scale-105" | 201 | ? "bg-primary text-primary-foreground shadow-md scale-105" |
| 210 | : "text-muted-foreground hover:bg-secondary hover:text-foreground dark:text-white/70 dark:hover:bg-white/[0.08] dark:hover:text-white" | 202 | : "text-muted-foreground hover:bg-secondary hover:text-foreground dark:text-white/70 dark:hover:bg-white/[0.08] dark:hover:text-white" |
| 211 | )} | 203 | )} |
| 212 | - title={t("rightPanel.messagesTitle")} | 204 | + title={t("nav.messages")} |
| 213 | - aria-label={t("rightPanel.messagesTitle")} | 205 | + aria-label={t("nav.messages")} |
| 214 | > | 206 | > |
| 215 | <IconMessage class="h-5 w-5" /> | 207 | <IconMessage class="h-5 w-5" /> |
| 216 | <Show when={unreadCount() > 0}> | 208 | <Show when={unreadCount() > 0}> |
| 217 | <span | 209 | <span |
| 218 | class="absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-rose-500 px-1 text-[9px] font-bold text-white shadow-xs animate-pulse ring-2 ring-sidebar dark:ring-[#070707]" | 210 | class="absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full bg-rose-500 px-1 text-[9px] font-bold text-white shadow-xs animate-pulse ring-2 ring-sidebar dark:ring-[#070707]" |
| 211 | + title={`${unreadCount()} ${t("rightPanel.unreadBadge")}`} | ||
| 219 | > | 212 | > |
| 220 | {unreadCount() > 9 ? "9+" : unreadCount()} | 213 | {unreadCount() > 9 ? "9+" : unreadCount()} |
| 221 | </span> | 214 | </span> |
| 222 | </Show> | 215 | </Show> |
| 223 | </button> | 216 | </button> |
| 224 | 217 | ||
| 225 | - {/* Calendar Icon Button with Overlapping Colored Indicators */} | 218 | + {/* Calendar Icon Button - Direct Page Navigation */} |
| 226 | <button | 219 | <button |
| 227 | type="button" | 220 | type="button" |
| 228 | - onClick={() => toggleTab("calendar")} | 221 | + onClick={() => goTo("/calendar")} |
| 229 | class={cn( | 222 | class={cn( |
| 230 | - "relative flex h-10 w-10 items-center justify-center rounded-xl transition-all duration-200", | 223 | + "relative flex h-10 w-10 items-center justify-center rounded-xl transition-all duration-200 cursor-pointer", |
| 231 | - activeTab() === "calendar" | 224 | + isCalendarActive() |
| 232 | ? "bg-primary text-primary-foreground shadow-md scale-105" | 225 | ? "bg-primary text-primary-foreground shadow-md scale-105" |
| 233 | : "text-muted-foreground hover:bg-secondary hover:text-foreground dark:text-white/70 dark:hover:bg-white/[0.08] dark:hover:text-white" | 226 | : "text-muted-foreground hover:bg-secondary hover:text-foreground dark:text-white/70 dark:hover:bg-white/[0.08] dark:hover:text-white" |
| 234 | )} | 227 | )} |
| 235 | - title={t("rightPanel.calendarTitle")} | 228 | + title={t("nav.calendar")} |
| 236 | - aria-label={t("rightPanel.calendarTitle")} | 229 | + aria-label={t("nav.calendar")} |
| 237 | > | 230 | > |
| 238 | <IconCalendarDays class="h-5 w-5" /> | 231 | <IconCalendarDays class="h-5 w-5" /> |
| 239 | 232 | ||