Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Improve how sidebar looks (#533)

Ameer Al Ashhab969bb2d3fd17
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
index 4a4210f56..223aae982 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
@@ -38,10 +38,10 @@ export const AdminDesktopNav = () => {
<>
<motion.div
initial={{
- width: sidebarCollapsed ? "70px" : "250px",
+ width: sidebarCollapsed ? "70px" : "230px",
}}
animate={{
- width: sidebarCollapsed ? "70px" : "250px",
+ width: sidebarCollapsed ? "70px" : "230px",
transition: {
duration: 0.4,
type: "spring",
@@ -52,14 +52,12 @@ export const AdminDesktopNav = () => {
>
<div className="flex flex-col w-full max-w-[220px] mx-auto">
<div className="flex overflow-hidden flex-col flex-grow h-full">
- <div className="flex flex-col flex-shrink-0 items-start px-3 pt-5 w-full h-full justify-top">
+ <div className="flex flex-col items-center px-3 pt-5 w-full h-full justify-top">
<div className="flex justify-start items-center mb-3.5 w-full truncate min-h-8">
<Link href="/dashboard">
<Logo
- className={clsx(
- "flex-shrink-0 mx-auto w-[120px]",
- sidebarCollapsed ? "ml-1" : "ml-0"
- )}
+ hideLogoName={sidebarCollapsed}
+ className="mx-auto w-[120px] h-[40px]"
/>
</Link>
</div>
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
index bd3e9f36f..e230c0ecc 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
@@ -49,6 +49,7 @@ interface Props {
export const AdminNavItems = ({ toggleMobileNav }: Props) => {
const pathname = usePathname();
const [open, setOpen] = useState(false);
+ const [hoveredItem, setHoveredItem] = useState<string | null>(null);
const { user, sidebarCollapsed } =
useSharedContext();
@@ -90,7 +91,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
];
const navItemClass =
- "flex items-center justify-start py-2 px-3 rounded-2xl outline-none tracking-tight w-full overflow-hidden";
+ "flex items-center justify-start px-3 rounded-xl outline-none tracking-tight overflow-hidden";
const [dialogOpen, setDialogOpen] = useState(false);
const { organizationData: orgData, activeOrganization: activeOrg, isSubscribed: userIsSubscribed } =
@@ -110,9 +111,22 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
}
>
<PopoverTrigger asChild>
- <div
+ <motion.div
+ initial={{
+ width: sidebarCollapsed ? "40px" : "100%",
+ }}
+ animate={{
+ width: sidebarCollapsed ? "40px" : "100%",
+ }}
+ transition={{
+ type: "spring",
+ bounce: 0.2,
+ width: { type: "tween", duration: 0.2 },
+ }}
className={
- "px-3 py-2.5 w-full rounded-xl border cursor-pointer bg-gray-3 border-gray-4"
+ clsx(
+ "p-2.5 mt-2.5 rounded-xl border cursor-pointer bg-gray-4 border-gray-5",
+ )
}
>
<div
@@ -123,7 +137,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<div className="flex justify-between items-center w-full text-left">
<div className="flex items-center">
{activeOrg?.organization.iconUrl ? (
- <div className="overflow-hidden relative flex-shrink-0 rounded-full size-5">
+ <div className="overflow-hidden relative flex-shrink-0 rounded-full size-[18px]">
<Image
src={activeOrg.organization.iconUrl}
alt={activeOrg.organization.name || "Organization icon"}
@@ -134,7 +148,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
) : (
<Avatar
letterClass="text-gray-1 text-xs"
- className="relative flex-shrink-0 size-5"
+ className="relative flex-shrink-0 size-[18px]"
name={
activeOrg?.organization.name ??
"No organization found"
@@ -147,13 +161,13 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
</p>
</div>
{!sidebarCollapsed && (
- <ChevronDown className="w-5 h-auto text-gray-8" />
+ <ChevronDown data-state={open ? "open" : "closed"} className="w-5 h-auto transition-transform duration-200 text-gray-8 data-[state=open]:rotate-180" />
)}
</div>
</div>
<PopoverContent
className={clsx(
- "p-0 w-full min-w-[287px] md:min-w-fit md:w-[calc(100%-12px)] z-[120]",
+ "p-0 w-full min-w-[287px] md:min-w-fit z-[120]",
sidebarCollapsed ? "ml-3" : "mx-auto"
)}
>
@@ -220,7 +234,7 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
</CommandGroup>
</Command>
</PopoverContent>
- </div>
+ </motion.div>
</PopoverTrigger>
</Tooltip>
</Popover>
@@ -229,19 +243,20 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
aria-label="Sidebar"
>
<div
- className={clsx("mt-8 space-y-2.5", sidebarCollapsed ? "items-center" : "")}
+ className={clsx("mt-8", sidebarCollapsed ? "flex flex-col justify-center items-center" : "")}
>
{manageNavigation.map((item) => (
- <div key={item.name} className="flex relative justify-center">
- {pathname.includes(item.href) ? (
+ <div key={item.name} className="flex relative justify-center items-center w-full mb-2.5">
+ {/* Active indicator - always visible for active items */}
+ {pathname.includes(item.href) && (
<motion.div
initial={{
- width: sidebarCollapsed ? 40 : "100%",
- height: sidebarCollapsed ? 40 : "100%",
+ width: sidebarCollapsed ? 36 : "100%",
+ height: sidebarCollapsed ? 36 : "100%",
}}
animate={{
- width: sidebarCollapsed ? 40 : "100%",
- height: sidebarCollapsed ? 40 : "100%",
+ width: sidebarCollapsed ? 36 : "100%",
+ height: sidebarCollapsed ? 36 : "100%",
}}
transition={{
type: "spring",
@@ -252,10 +267,30 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
layoutId="underline"
id="underline"
className={clsx(
- "absolute inset-0 mx-auto rounded-xl shadow-sm border-gray-5 text-gray-8 border-[1px] shadow-gray-2"
+ "absolute rounded-xl shadow-sm bg-gray-3 border-gray-4 text-gray-8 border-[1px] shadow-gray-2",
+ sidebarCollapsed ? "inset-0 right-0 left-0 mx-auto w-9 h-9" : "inset-0 ml-[2px]"
+ )}
+ />
+ )}
+
+ {/* Hover indicator - only visible when hovering non-active items */}
+ {hoveredItem === item.name && !pathname.includes(item.href) && (
+ <motion.div
+ layoutId="hoverIndicator"
+ className={clsx(
+ "absolute rounded-xl border-gray-4 border-[1px] bg-gray-3/20",
+ sidebarCollapsed ? "inset-0 right-0 left-0 mx-auto w-9 h-9" : "inset-0 ml-[2px]"
)}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{
+ type: "spring",
+ bounce: 0.2,
+ duration: 0.2,
+ }}
/>
- ) : null}
+ )}
<Tooltip
content={item.name}
disable={sidebarCollapsed === false}
@@ -264,24 +299,27 @@ export const AdminNavItems = ({ toggleMobileNav }: Props) => {
<Link
passHref
onClick={() => toggleMobileNav?.()}
+ onMouseEnter={() => setHoveredItem(item.name)}
+ onMouseLeave={() => setHoveredItem(null)}
prefetch={false}
href={item.href}
className={classNames(
- "relative transition-opacity duration-200 hover:opacity-75 z-3",
+ "relative border border-transparent transition-opacity duration-200 z-3",
+ sidebarCollapsed ? "flex justify-center items-center w-full h-9" : "py-2 w-full",
navItemClass
)}
>
<FontAwesomeIcon
icon={item.icon as IconDefinition}
- className={classNames(
- "flex-shrink-0 w-5 h-5 transition-colors duration-200 stroke-[1.5px]",
- sidebarCollapsed ? "text-gray-12" : "text-gray-10"
+ className={clsx(
+ "flex-shrink-0 size-4 transition-colors duration-200 stroke-[1.5px]",
+ sidebarCollapsed ? "text-gray-12 mx-auto" : "text-gray-10"
)}
aria-hidden="true"
/>
- <span className="text-base ml-2.5 text-gray-12 truncate">
+ <p className={clsx("text-sm text-gray-12 truncate", sidebarCollapsed ? "hidden" : "ml-2.5")}>
{item.name}
- </span>
+ </p>
</Link>
</Tooltip>
</div>
diff --git a/apps/web/components/UsageButton.tsx b/apps/web/components/UsageButton.tsx
index 090ac11b3..cb218630c 100644
--- a/apps/web/components/UsageButton.tsx
+++ b/apps/web/components/UsageButton.tsx
@@ -40,13 +40,13 @@ export const UsageButton = ({
/>
<FontAwesomeIcon
className={clsx(
- "text-gray-50 drop-shadow-[0_0_2px_rgba(255,255,255,0.5)]",
+ "text-gray-50",
sidebarCollapsed ? "mr-0" : "mr-1"
)}
icon={faCheck}
/>
{sidebarCollapsed ? null : (
- <p className="text-gray-50 drop-shadow-[0_0_2px_rgba(255,255,255,0.5)]">
+ <p className="text-gray-50">
Cap Pro
</p>
)}
@@ -82,13 +82,13 @@ export const UsageButton = ({
/>
<FontAwesomeIcon
className={clsx(
- "text-gray-50 drop-shadow-[0_0_2px_rgba(255,255,255,0.5)]",
+ "text-gray-50",
sidebarCollapsed ? "mr-0" : "mr-1"
)}
icon={faArrowUp}
/>
{sidebarCollapsed ? null : (
- <p className="text-gray-50 drop-shadow-[0_0_2px_rgba(255,255,255,0.5)]">
+ <p className="text-base text-gray-50">
Upgrade to Pro
</p>
)}