Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix: smooth sidebar collapse/expand transition

Khuram Niaz2f1737dee8e7
diff --git a/src/app/globals.css b/src/app/globals.css
index 91b26d2..14ff6d3 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -145,7 +145,7 @@
/* Navlink */
.navlink {
- @apply relative flex items-center overflow-hidden transition-colors;
+ @apply relative flex items-center overflow-hidden transition-all duration-200 ease-in-out;
}
}
diff --git a/src/components/NavLink.tsx b/src/components/NavLink.tsx
index 6420d84..622b728 100644
--- a/src/components/NavLink.tsx
+++ b/src/components/NavLink.tsx
@@ -30,8 +30,7 @@ function NavLink({ label, Icon, route, pathname, expanded }: NavLinkProps) {
href={route}
aria-current={isActive ? "page" : undefined}
className={cn(
- "navlink w-full hover:text-foreground",
- expanded ? "h-10 justify-start gap-3 px-4" : "h-12 justify-center",
+ "navlink h-10 w-full hover:text-foreground",
isActive ? "text-foreground" : "text-muted-foreground",
isActive && expanded && "rounded-md bg-accent"
)}
@@ -42,25 +41,29 @@ function NavLink({ label, Icon, route, pathname, expanded }: NavLinkProps) {
className="absolute left-0 top-0 h-full w-0.5 bg-foreground"
/>
)}
- <Icon className="h-6 w-6 shrink-0" strokeWidth={1.5} />
- {/* Collapsed uses sr-only, not opacity: an in-flow hidden span still
- takes flex space and pushes the icon off-center in the rail. */}
- {expanded ? (
- <span className="truncate text-sm">{label}</span>
- ) : (
- <span className="sr-only">{label}</span>
- )}
+ {/* Fixed-width lead box (= collapsed rail width) so the icon sits at the
+ same spot in both states and never moves during the slide. */}
+ <span className="flex h-full w-14 shrink-0 items-center justify-center">
+ <Icon className="h-6 w-6 shrink-0" strokeWidth={1.5} />
+ </span>
+ <span
+ className={cn(
+ "truncate text-sm transition-opacity duration-200",
+ expanded ? "opacity-100 delay-100" : "opacity-0"
+ )}
+ >
+ {label}
+ </span>
</Link>
);
- if (expanded) {
- return link;
- }
-
+ // Always render the Tooltip wrapper so the <Link> keeps a stable position in
+ // the tree across expand/collapse — remounting it would reset the CSS
+ // transitions and make the toggle snap instead of animate.
return (
<Tooltip>
<TooltipTrigger asChild>{link}</TooltipTrigger>
- <TooltipContent side="right">{label}</TooltipContent>
+ {!expanded && <TooltipContent side="right">{label}</TooltipContent>}
</Tooltip>
);
}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index e994ce6..5f3dbe4 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -24,28 +24,27 @@ function Sidebar() {
: APP_CONSTANTS.SIDEBAR_WIDTH.collapsed.rail,
)}
>
- <div
- className={cn(
- "flex h-14 shrink-0 items-center gap-2 sm:mt-2",
- expanded ? "px-4" : "justify-center",
- )}
- >
- <Link
- href="/"
- className="group flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground md:h-8 md:w-8"
+ <div className="flex h-14 shrink-0 items-center overflow-hidden sm:mt-2">
+ <div className="flex w-14 shrink-0 items-center justify-center">
+ <Link
+ href="/"
+ className="group flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground md:h-8 md:w-8"
+ >
+ <Briefcase className="h-4 w-4 transition-transform group-hover:scale-110" />
+ <span className="sr-only">JobSync</span>
+ </Link>
+ </div>
+ <span
+ className={cn(
+ "truncate font-semibold transition-opacity duration-200",
+ expanded ? "opacity-100 delay-100" : "opacity-0",
+ )}
>
- <Briefcase className="h-4 w-4 transition-transform group-hover:scale-110" />
- <span className="sr-only">JobSync</span>
- </Link>
- {expanded && <span className="truncate font-semibold">JobSync</span>}
+ JobSync
+ </span>
</div>
- <nav
- className={cn(
- "flex flex-1 flex-col overflow-y-auto py-2",
- expanded ? "gap-0.5" : "gap-2",
- )}
- >
+ <nav className="flex flex-1 flex-col gap-1 overflow-y-auto py-2">
{SIDEBAR_LINKS.map((item) => {
// Only show dev-only items in development mode
if (item.devOnly && process.env.NODE_ENV !== "development") {
@@ -64,12 +63,7 @@ function Sidebar() {
})}
</nav>
- <div
- className={cn(
- "flex flex-col py-2",
- expanded ? "gap-0.5 border-t" : "gap-2",
- )}
- >
+ <div className="flex flex-col gap-1 border-t py-2">
<NavLink
label="Settings"
Icon={Settings}