Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore(web): improve navigation accessibility

boojack2523d966f4be
diff --git a/web/src/components/Navigation.tsx b/web/src/components/Navigation.tsx
index 484f0837b..584eb5e2e 100644
--- a/web/src/components/Navigation.tsx
+++ b/web/src/components/Navigation.tsx
@@ -69,9 +69,10 @@ const Navigation = (props: Props) => {
icon: <UserCircleIcon className="w-6 h-auto shrink-0" />,
};
- const navLinks: NavLinkItem[] = currentUser
+ const primaryNavLinks: NavLinkItem[] = currentUser
? [homeNavLink, exploreNavLink, attachmentsNavLink, inboxNavLink]
: [exploreNavLink, signInNavLink];
+ const inboxAriaLabel = unreadCount > 0 ? `${t("common.inbox")}, ${unreadCount} unread` : t("common.inbox");
return (
<header className={cn("w-full h-full overflow-auto flex flex-col justify-between items-start gap-4", className)}>
@@ -79,24 +80,25 @@ const Navigation = (props: Props) => {
<NavLink className="mb-3 cursor-default" to={currentUser ? Routes.ROOT : Routes.EXPLORE}>
<MemosLogo collapsed={collapsed} />
</NavLink>
- {navLinks.map((navLink) => (
- <NavLink
- className={({ isActive }) =>
- cn(
- "px-2 py-2 rounded-2xl border flex flex-row items-center text-lg text-sidebar-foreground transition-colors",
- collapsed ? "" : "w-full px-4",
- isActive
- ? "bg-sidebar-accent text-sidebar-accent-foreground border-sidebar-accent-border drop-shadow"
- : "border-transparent hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:border-sidebar-accent-border opacity-80",
- )
- }
- key={navLink.id}
- to={navLink.path}
- id={navLink.id}
- viewTransition
- >
- {props.collapsed ? (
- <TooltipProvider>
+ <TooltipProvider>
+ {primaryNavLinks.map((navLink) => (
+ <NavLink
+ className={({ isActive }) =>
+ cn(
+ "px-2 py-2 rounded-2xl border flex flex-row items-center text-lg text-sidebar-foreground transition-colors",
+ collapsed ? "" : "w-full px-4",
+ isActive
+ ? "bg-sidebar-accent text-sidebar-accent-foreground border-sidebar-accent-border drop-shadow"
+ : "border-transparent hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:border-sidebar-accent-border opacity-80",
+ )
+ }
+ key={navLink.id}
+ to={navLink.path}
+ id={navLink.id}
+ aria-label={navLink.id === "header-inbox" ? inboxAriaLabel : undefined}
+ viewTransition
+ >
+ {props.collapsed ? (
<Tooltip>
<TooltipTrigger asChild>
<div>{navLink.icon}</div>
@@ -105,13 +107,13 @@ const Navigation = (props: Props) => {
<p>{navLink.title}</p>
</TooltipContent>
</Tooltip>
- </TooltipProvider>
- ) : (
- navLink.icon
- )}
- {!props.collapsed && <span className="ml-3 truncate">{navLink.title}</span>}
- </NavLink>
- ))}
+ ) : (
+ navLink.icon
+ )}
+ {!props.collapsed && <span className="ml-3 truncate">{navLink.title}</span>}
+ </NavLink>
+ ))}
+ </TooltipProvider>
</div>
{currentUser && (
<div className={cn("w-full flex flex-col justify-end", props.collapsed ? "items-center" : "items-start pl-3")}>