Skip to content

Commit

Permalink
fix(web): Improve SidebarItem tap target accessibility (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trugamr authored Sep 29, 2024
1 parent 36fb5a4 commit 8fe1927
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
8 changes: 4 additions & 4 deletions apps/web/components/dashboard/sidebar/AllLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ export default function AllLists({
logo={<span className="text-lg">📋</span>}
name="All Lists"
path={`/dashboard/lists`}
className="py-0.5"
linkClassName="py-0.5"
/>
<SidebarItem
logo={<span className="text-lg">⭐️</span>}
name="Favourites"
path={`/dashboard/favourites`}
className="py-0.5"
linkClassName="py-0.5"
/>
<SidebarItem
logo={<span className="text-lg">🗄️</span>}
name="Archive"
path={`/dashboard/archive`}
className="py-0.5"
linkClassName="py-0.5"
/>

{
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function AllLists({
</Button>
</ListOptions>
}
className="group py-0.5"
linkClassName="group py-0.5"
style={{ marginLeft: `${level * 1}rem` }}
/>
)}
Expand Down
26 changes: 18 additions & 8 deletions apps/web/components/dashboard/sidebar/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function SidebarItem({
logo,
path,
className,
linkClassName,
style,
collapseButton,
right = null,
Expand All @@ -19,27 +20,36 @@ export default function SidebarItem({
path: string;
style?: React.CSSProperties;
className?: string;
linkClassName?: string;
right?: React.ReactNode;
collapseButton?: React.ReactNode;
}) {
const currentPath = usePathname();
return (
<li
className={cn(
"relative rounded-lg px-3 py-2 hover:bg-accent",
"relative rounded-lg hover:bg-accent",
path == currentPath ? "bg-accent/50" : "",
className,
)}
style={style}
>
{collapseButton}
<div className="flex justify-between">
<Link href={path} className="flex w-full gap-x-2">
{logo}
<span className="my-auto"> {name} </span>
</Link>
{right}
</div>
<Link
href={path}
className={cn(
"flex w-full items-center rounded-[inherit] px-3 py-2",
linkClassName,
)}
>
<div className="flex w-full justify-between">
<div className="flex items-center gap-x-2">
{logo}
<span>{name}</span>
</div>
{right}
</div>
</Link>
</li>
);
}

0 comments on commit 8fe1927

Please sign in to comment.