Skip to content

Commit 2523d96

Browse files
committed
chore(web): improve navigation accessibility
1 parent fee7fcd commit 2523d96

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

web/src/components/Navigation.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,36 @@ const Navigation = (props: Props) => {
6969
icon: <UserCircleIcon className="w-6 h-auto shrink-0" />,
7070
};
7171

72-
const navLinks: NavLinkItem[] = currentUser
72+
const primaryNavLinks: NavLinkItem[] = currentUser
7373
? [homeNavLink, exploreNavLink, attachmentsNavLink, inboxNavLink]
7474
: [exploreNavLink, signInNavLink];
75+
const inboxAriaLabel = unreadCount > 0 ? `${t("common.inbox")}, ${unreadCount} unread` : t("common.inbox");
7576

7677
return (
7778
<header className={cn("w-full h-full overflow-auto flex flex-col justify-between items-start gap-4", className)}>
7879
<div className="w-full px-1 py-1 flex flex-col justify-start items-start space-y-2 overflow-auto overflow-x-hidden shrink">
7980
<NavLink className="mb-3 cursor-default" to={currentUser ? Routes.ROOT : Routes.EXPLORE}>
8081
<MemosLogo collapsed={collapsed} />
8182
</NavLink>
82-
{navLinks.map((navLink) => (
83-
<NavLink
84-
className={({ isActive }) =>
85-
cn(
86-
"px-2 py-2 rounded-2xl border flex flex-row items-center text-lg text-sidebar-foreground transition-colors",
87-
collapsed ? "" : "w-full px-4",
88-
isActive
89-
? "bg-sidebar-accent text-sidebar-accent-foreground border-sidebar-accent-border drop-shadow"
90-
: "border-transparent hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:border-sidebar-accent-border opacity-80",
91-
)
92-
}
93-
key={navLink.id}
94-
to={navLink.path}
95-
id={navLink.id}
96-
viewTransition
97-
>
98-
{props.collapsed ? (
99-
<TooltipProvider>
83+
<TooltipProvider>
84+
{primaryNavLinks.map((navLink) => (
85+
<NavLink
86+
className={({ isActive }) =>
87+
cn(
88+
"px-2 py-2 rounded-2xl border flex flex-row items-center text-lg text-sidebar-foreground transition-colors",
89+
collapsed ? "" : "w-full px-4",
90+
isActive
91+
? "bg-sidebar-accent text-sidebar-accent-foreground border-sidebar-accent-border drop-shadow"
92+
: "border-transparent hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:border-sidebar-accent-border opacity-80",
93+
)
94+
}
95+
key={navLink.id}
96+
to={navLink.path}
97+
id={navLink.id}
98+
aria-label={navLink.id === "header-inbox" ? inboxAriaLabel : undefined}
99+
viewTransition
100+
>
101+
{props.collapsed ? (
100102
<Tooltip>
101103
<TooltipTrigger asChild>
102104
<div>{navLink.icon}</div>
@@ -105,13 +107,13 @@ const Navigation = (props: Props) => {
105107
<p>{navLink.title}</p>
106108
</TooltipContent>
107109
</Tooltip>
108-
</TooltipProvider>
109-
) : (
110-
navLink.icon
111-
)}
112-
{!props.collapsed && <span className="ml-3 truncate">{navLink.title}</span>}
113-
</NavLink>
114-
))}
110+
) : (
111+
navLink.icon
112+
)}
113+
{!props.collapsed && <span className="ml-3 truncate">{navLink.title}</span>}
114+
</NavLink>
115+
))}
116+
</TooltipProvider>
115117
</div>
116118
{currentUser && (
117119
<div className={cn("w-full flex flex-col justify-end", props.collapsed ? "items-center" : "items-start pl-3")}>

0 commit comments

Comments
 (0)