Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: dashboard flicker & improvements (#1022)

Ameer Al Ashhab1580be22b45e
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Refer.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Refer.tsx
index a7572753c..aae32a2be 100644
--- a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Refer.tsx
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Refer.tsx
@@ -53,6 +53,7 @@ const ReferIcon = forwardRef<ReferIconHandle, ReferIconProps>(
onAnimationComplete={() => setIsAnimating(false)}
{...props}
>
+ <title>Box</title>
<path
strokeLinecap="round"
strokeLinejoin="round"
diff --git a/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx b/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
index f2c2ff9cd..baed0f219 100644
--- a/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
+++ b/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
@@ -1,180 +1,37 @@
"use client";
-import { buildEnv } from "@cap/env";
-import {
- Avatar,
- Command,
- CommandGroup,
- CommandItem,
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@cap/ui";
-import { faBell, faMoon, faSun } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useClickAway } from "@uidotdev/usehooks";
-import clsx from "clsx";
-import { AnimatePresence } from "framer-motion";
-import { MoreVertical } from "lucide-react";
-import Image from "next/image";
-import Link from "next/link";
import { usePathname } from "next/navigation";
-import { signOut } from "next-auth/react";
-import type React from "react";
-import {
- cloneElement,
- type MutableRefObject,
- memo,
- useMemo,
- useRef,
- useState,
-} from "react";
-import Notifications from "@/app/(org)/dashboard/_components/Notifications";
-import { UpgradeModal } from "@/components/UpgradeModal";
-import { useDashboardContext, useTheme } from "../Contexts";
+import { useState } from "react";
+import { useDashboardContext } from "../Contexts";
import { MembersDialog } from "../spaces/[spaceId]/components/MembersDialog";
-import {
- ArrowUpIcon,
- DownloadIcon,
- HomeIcon,
- LogoutIcon,
- MessageCircleMoreIcon,
- ReferIcon,
- SettingsGearIcon,
-} from "./AnimatedIcons";
-import type { DownloadIconHandle } from "./AnimatedIcons/Download";
-import type { ReferIconHandle } from "./AnimatedIcons/Refer";
+import Top from "./Navbar/Top";
export default function DashboardInner({
children,
}: {
children: React.ReactNode;
}) {
- const pathname = usePathname();
- const { activeOrganization, activeSpace, anyNewNotifications } =
- useDashboardContext();
+ const { activeOrganization } = useDashboardContext();
const [membersDialogOpen, setMembersDialogOpen] = useState(false);
+ const isSharedCapsPage = usePathname() === "/dashboard/shared-caps";
- const titles: Record<string, string> = {
- "/dashboard/caps": "Caps",
- "/dashboard/shared-caps": "Shared Caps",
- "/dashboard/settings/organization": "Organization Settings",
- "/dashboard/settings/account": "Account Settings",
- "/dashboard/spaces": "Spaces",
- "/dashboard/spaces/browse": "Browse Spaces",
- };
-
- const title = activeSpace ? activeSpace.name : titles[pathname] || "";
- const { theme, setThemeHandler } = useTheme();
- const [toggleNotifications, setToggleNotifications] = useState(false);
- const bellRef = useRef<HTMLDivElement>(null);
- const notificationsRef: MutableRefObject<HTMLDivElement> = useClickAway(
- (e) => {
- if (bellRef.current && !bellRef.current.contains(e.target as Node)) {
- setToggleNotifications(false);
- }
- },
- );
- const isSharedCapsPage = pathname === "/dashboard/shared-caps";
return (
<div className="flex overflow-hidden w-full flex-col flex-1 md:mt-0 mt-[126px]">
- {/* NavBar */}
- <div
- className={clsx(
- "flex fixed z-40 justify-between items-center py-3 pr-2 pl-5 w-full md:relative mt-[60px] md:mt-0 md:py-[19px] lg:pl-0 lg:pr-5",
- "top-0 bg-gray-1 md:mt-0",
- )}
- >
- <div className="flex flex-col gap-0.5">
- {activeSpace && <span className="text-xs text-gray-11">Space</span>}
- <div className="flex gap-1.5 items-center">
- {activeSpace &&
- (activeSpace.iconUrl ? (
- <Image
- src={activeSpace?.iconUrl}
- alt={activeSpace?.name || "Space"}
- width={20}
- height={20}
- className="rounded-full"
- />
- ) : (
- <Avatar
- letterClass="text-xs"
- className="relative flex-shrink-0 size-5"
- name={activeSpace?.name}
- />
- ))}
- <p className="relative text-lg truncate text-gray-12 lg:text-2xl">
- {title}
- </p>
- </div>
- </div>
- <div className="flex gap-4 items-center">
- {buildEnv.NEXT_PUBLIC_IS_CAP && <ReferButton />}
- <div
- data-state={toggleNotifications ? "open" : "closed"}
- ref={bellRef}
- onClick={() => {
- setToggleNotifications(!toggleNotifications);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
- e.preventDefault();
- setToggleNotifications(!toggleNotifications);
- }
- }}
- tabIndex={0}
- role="button"
- aria-label={`Notifications${
- anyNewNotifications ? " (new notifications available)" : ""
- }`}
- aria-expanded={toggleNotifications}
- className="hidden relative justify-center data-[state=open]:hover:bg-gray-5 items-center bg-gray-3
- rounded-full transition-colors cursor-pointer lg:flex
- hover:bg-gray-5 data-[state=open]:bg-gray-5
- focus:outline-none
- size-9"
- >
- {anyNewNotifications && (
- <div className="absolute right-0 top-1 z-10">
- <div className="relative">
- <div className="absolute inset-0 w-2 h-2 bg-red-400 rounded-full opacity-75 animate-ping" />
- <div className="relative w-2 h-2 bg-red-400 rounded-full" />
- </div>
- </div>
- )}
- <FontAwesomeIcon className="text-gray-12 size-3.5" icon={faBell} />
- <AnimatePresence>
- {toggleNotifications && <Notifications ref={notificationsRef} />}
- </AnimatePresence>
- </div>
- <div
- onClick={() => {
- if (document.startViewTransition) {
- document.startViewTransition(() => {
- setThemeHandler(theme === "light" ? "dark" : "light");
- });
- } else {
- setThemeHandler(theme === "light" ? "dark" : "light");
- }
- }}
- className="hidden justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 lg:flex hover:bg-gray-5 size-9"
- >
- <FontAwesomeIcon
- className="text-gray-12 size-3.5 view-transition-theme-icon"
- icon={theme === "dark" ? faMoon : faSun}
- />
- </div>
- <User />
- </div>
- </div>
- {/*End of NavBar*/}
+ <Top />
<main
className={
- "flex overscroll-contain flex-col flex-1 p-5 h-full border border-b-0 custom-scroll bg-gray-2 border-gray-3 lg:rounded-tl-2xl lg:p-8"
+ "flex relative flex-col flex-1 h-full [grid-area:main] bg-gray-1"
}
>
- <div className="flex flex-col flex-1 gap-4 min-h-fit">{children}</div>
+ {/* Top cap: renders rounded corner and top/side borders without affecting scroller */}
+ <div
+ aria-hidden
+ className="h-0 rounded-tl-xl border border-b-0 pointer-events-none lg:h-2 bg-gray-2 border-gray-3"
+ />
+ {/* Scrolling content area shares border/background; top border removed to meet cap */}
+ <div className="flex overflow-hidden overflow-y-auto overscroll-contain flex-col flex-1 p-5 h-full border border-t-0 bg-gray-2 border-gray-3 lg:p-8">
+ <div className="flex flex-col flex-1 gap-4 min-h-fit">{children}</div>
+ </div>
</main>
{isSharedCapsPage && activeOrganization?.members && (
<MembersDialog
@@ -187,201 +44,3 @@ export default function DashboardInner({
</div>
);
}
-
-const User = () => {
- const [menuOpen, setMenuOpen] = useState(false);
- const [upgradeModalOpen, setUpgradeModalOpen] = useState(false);
- const { user, isSubscribed } = useDashboardContext();
-
- const menuItems = useMemo(
- () => [
- {
- name: "Homepage",
- icon: <HomeIcon />,
- href: "/home",
- onClick: () => setMenuOpen(false),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: true,
- },
- {
- name: "Upgrade to Pro",
- icon: <ArrowUpIcon />,
- onClick: () => {
- setMenuOpen(false);
- setUpgradeModalOpen(true);
- },
- iconClassName: "text-amber-400 group-hover:text-amber-500",
- showCondition: !isSubscribed && buildEnv.NEXT_PUBLIC_IS_CAP,
- },
- {
- name: "Earn 40% Referral",
- icon: <ReferIcon />,
- href: "/dashboard/refer",
- onClick: () => setMenuOpen(false),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: buildEnv.NEXT_PUBLIC_IS_CAP,
- },
- {
- name: "Settings",
- icon: <SettingsGearIcon />,
- href: "/dashboard/settings/account",
- onClick: () => setMenuOpen(false),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: true,
- },
- {
- name: "Chat Support",
- icon: <MessageCircleMoreIcon />,
- onClick: () => window.open("https://cap.link/discord", "_blank"),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: true,
- },
- {
- name: "Download App",
- icon: <DownloadIcon />,
- onClick: () => window.open("https://cap.so/download", "_blank"),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: true,
- },
- {
- name: "Sign Out",
- icon: <LogoutIcon />,
- onClick: () => signOut(),
- iconClassName: "text-gray-11 group-hover:text-gray-12",
- showCondition: true,
- },
- ],
- [],
- );
-
- return (
- <>
- <UpgradeModal
- open={upgradeModalOpen}
- onOpenChange={setUpgradeModalOpen}
- />
- <Popover open={menuOpen} onOpenChange={setMenuOpen}>
- <PopoverTrigger asChild>
- <div
- data-state={menuOpen ? "open" : "closed"}
- className="flex gap-2 justify-between items-center p-2 rounded-xl border data-[state=open]:border-gray-3 data-[state=open]:bg-gray-3 border-transparent transition-colors cursor-pointer group lg:gap-6 hover:border-gray-3"
- >
- <div className="flex items-center">
- {user.image ? (
- <Image
- src={user.image}
- alt={user.name ?? "User"}
- width={24}
- height={24}
- className="rounded-full"
- />
- ) : (
- <Avatar
- letterClass="text-xs lg:text-md"
- name={user.name ?? "User"}
- className="size-[24px] text-gray-12"
- />
- )}
- <span className="ml-2 text-sm truncate lg:ml-2 lg:text-md text-gray-12">
- {user.name ?? "User"}
- </span>
- </div>
- <MoreVertical
- data-state={menuOpen ? "open" : "closed"}
- className="w-5 h-5 data-[state=open]:text-gray-12 transition-colors text-gray-10 group-hover:text-gray-12"
- />
- </div>
- </PopoverTrigger>
- <PopoverContent className="p-1 w-48">
- <Command>
- <CommandGroup>
- {menuItems
- .filter((item) => item.showCondition)
- .map((item, index) => (
- <MenuItem
- key={index.toString()}
- icon={item.icon}
- name={item.name}
- href={item.href ?? "#"}
- onClick={item.onClick}
- iconClassName={item.iconClassName}
- />
- ))}
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </>
- );
-};
-
-interface Props {
- icon: React.ReactElement;
- name: string;
- href?: string;
- onClick: () => void;
- iconClassName?: string;
-}
-
-const MenuItem = memo(({ icon, name, href, onClick, iconClassName }: Props) => {
- const iconRef = useRef<DownloadIconHandle>(null);
- return (
- <CommandItem
- key={name}
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={onClick}
- onMouseEnter={() => {
- iconRef.current?.startAnimation();
- }}
- onMouseLeave={() => {
- iconRef.current?.stopAnimation();
- }}
- >
- <Link
- className="flex gap-2 items-center w-full"
- href={href ?? "#"}
- onClick={onClick}
- >
- <div className="flex-shrink-0 flex items-center justify-center w-3.5 h-3.5">
- {cloneElement(icon, {
- ref: iconRef,
- className: iconClassName,
- size: 14,
- })}
- </div>
- <p className={clsx("text-sm text-gray-12")}>{name}</p>
- </Link>
- </CommandItem>
- );
-});
-
-const ReferButton = () => {
- const iconRef = useRef<ReferIconHandle>(null);
-
- return (
- <Link href="/dashboard/refer" className="hidden relative lg:block">
- {/* Red notification dot with pulse animation */}
- <div className="absolute right-0 top-1 z-10">
- <div className="relative">
- <div className="absolute inset-0 w-2 h-2 bg-red-400 rounded-full opacity-75 animate-ping" />
- <div className="relative w-2 h-2 bg-red-400 rounded-full" />
- </div>
- </div>
-
- <div
- onMouseEnter={() => {
- iconRef.current?.startAnimation();
- }}
- onMouseLeave={() => {
- iconRef.current?.stopAnimation();
- }}
- className="flex justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 hover:bg-gray-5 size-9"
- >
- {cloneElement(<ReferIcon />, {
- ref: iconRef,
- className: "text-gray-12 size-3.5",
- })}
- </div>
- </Link>
- );
-};
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx
index 00daa6b14..e683f4dd3 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx
@@ -31,10 +31,10 @@ export const DesktopNav = () => {
}, [toggleSidebarCollapsed]);
return (
- <motion.div
+ <motion.aside
initial={false}
animate={{
- width: sidebarCollapsed ? 70 : 230,
+ width: sidebarCollapsed ? 70 : 220,
transition: {
duration: 0.6,
type: "spring",
@@ -42,10 +42,10 @@ export const DesktopNav = () => {
},
}}
className={clsx(
- "hidden relative z-50 h-full will-change-[width] lg:flex group bg-gray-1",
+ "hidden relative z-50 flex-1 h-full [grid-area:sidebar] will-change-[width] lg:flex group bg-gray-1",
)}
>
- <div className="flex flex-col w-full max-w-[220px] mx-auto h-full">
+ <div className="flex flex-col mx-auto w-full h-full">
<div className="flex justify-start items-center px-3 pt-5 mb-3.5 w-full truncate min-h-8">
<Link href="/dashboard">
<Logo
@@ -80,7 +80,7 @@ export const DesktopNav = () => {
</Button>
</Tooltip>
</div>
- </motion.div>
+ </motion.aside>
);
};
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx
new file mode 100644
index 000000000..6944e1bca
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx
@@ -0,0 +1,369 @@
+"use client";
+
+import { buildEnv } from "@cap/env";
+import {
+ Avatar,
+ Command,
+ CommandGroup,
+ CommandItem,
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@cap/ui";
+import { faBell, faMoon, faSun } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useClickAway } from "@uidotdev/usehooks";
+import clsx from "clsx";
+import { AnimatePresence } from "framer-motion";
+import { MoreVertical } from "lucide-react";
+import Image from "next/image";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { signOut } from "next-auth/react";
+import {
+ cloneElement,
+ type MutableRefObject,
+ memo,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import Notifications from "@/app/(org)/dashboard/_components/Notifications";
+import { UpgradeModal } from "@/components/UpgradeModal";
+import { useDashboardContext, useTheme } from "../../Contexts";
+import {
+ ArrowUpIcon,
+ DownloadIcon,
+ HomeIcon,
+ LogoutIcon,
+ MessageCircleMoreIcon,
+ ReferIcon,
+ SettingsGearIcon,
+} from "../AnimatedIcons";
+import { type DownloadIconHandle } from "../AnimatedIcons/Download";
+import { type ReferIconHandle } from "../AnimatedIcons/Refer";
+
+const Top = () => {
+ const { activeSpace, anyNewNotifications } = useDashboardContext();
+ const [toggleNotifications, setToggleNotifications] = useState(false);
+ const bellRef = useRef<HTMLDivElement>(null);
+ const { theme, setThemeHandler } = useTheme();
+
+ const pathname = usePathname();
+
+ const titles: Record<string, string> = {
+ "/dashboard/caps": "Caps",
+ "/dashboard/folder": "Caps",
+ "/dashboard/shared-caps": "Shared Caps",
+ "/dashboard/settings/organization": "Organization Settings",
+ "/dashboard/settings/account": "Account Settings",
+ "/dashboard/spaces": "Spaces",
+ "/dashboard/spaces/browse": "Browse Spaces",
+ };
+
+ const title = activeSpace
+ ? activeSpace.name
+ : pathname.includes("/dashboard/folder")
+ ? "Caps"
+ : titles[pathname] || "";
+
+ const notificationsRef: MutableRefObject<HTMLDivElement> = useClickAway(
+ (e) => {
+ if (bellRef.current && !bellRef.current.contains(e.target as Node)) {
+ setToggleNotifications(false);
+ }
+ },
+ );
+
+ return (
+ <div
+ className={clsx(
+ "flex fixed z-40 justify-between items-center py-3 pr-2 pl-5 w-full md:relative mt-[60px] lg:mt-0 lg:py-[19px] lg:pl-0 lg:pr-5",
+ "top-0 bg-gray-1",
+ )}
+ >
+ <div className="flex flex-col gap-0.5">
+ {activeSpace && <span className="text-xs text-gray-11">Space</span>}
+ <div className="flex gap-1.5 items-center">
+ {activeSpace &&
+ (activeSpace.iconUrl ? (
+ <Image
+ src={activeSpace?.iconUrl}
+ alt={activeSpace?.name || "Space"}
+ width={20}
+ height={20}
+ className="rounded-full"
+ />
+ ) : (
+ <Avatar
+ letterClass="text-xs"
+ className="relative flex-shrink-0 size-5"
+ name={activeSpace?.name}
+ />
+ ))}
+ <p className="relative text-lg truncate text-gray-12 lg:text-2xl">
+ {title}
+ </p>
+ </div>
+ </div>
+ <div className="flex gap-4 items-center">
+ {buildEnv.NEXT_PUBLIC_IS_CAP && <ReferButton />}
+ <div
+ data-state={toggleNotifications ? "open" : "closed"}
+ ref={bellRef}
+ onClick={() => {
+ setToggleNotifications(!toggleNotifications);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ setToggleNotifications(!toggleNotifications);
+ }
+ }}
+ tabIndex={0}
+ role="button"
+ aria-label={`Notifications${
+ anyNewNotifications ? " (new notifications available)" : ""
+ }`}
+ aria-expanded={toggleNotifications}
+ className="hidden relative justify-center data-[state=open]:hover:bg-gray-5 items-center bg-gray-3
+ rounded-full transition-colors cursor-pointer lg:flex
+ hover:bg-gray-5 data-[state=open]:bg-gray-5
+ focus:outline-none
+ size-9"
+ >
+ {anyNewNotifications && (
+ <div className="absolute right-0 top-1 z-10">
+ <div className="relative">
+ <div className="absolute inset-0 w-2 h-2 bg-red-400 rounded-full opacity-75 animate-ping" />
+ <div className="relative w-2 h-2 bg-red-400 rounded-full" />
+ </div>
+ </div>
+ )}
+ <FontAwesomeIcon className="text-gray-12 size-3.5" icon={faBell} />
+ <AnimatePresence>
+ {toggleNotifications && <Notifications ref={notificationsRef} />}
+ </AnimatePresence>
+ </div>
+ <div
+ onClick={() => {
+ if (document.startViewTransition) {
+ document.startViewTransition(() => {
+ setThemeHandler(theme === "light" ? "dark" : "light");
+ });
+ } else {
+ setThemeHandler(theme === "light" ? "dark" : "light");
+ }
+ }}
+ className="hidden justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 lg:flex hover:bg-gray-5 size-9"
+ >
+ <FontAwesomeIcon
+ className="text-gray-12 size-3.5 view-transition-theme-icon"
+ icon={theme === "dark" ? faMoon : faSun}
+ />
+ </div>
+ <User />
+ </div>
+ </div>
+ );
+};
+
+const User = () => {
+ const [menuOpen, setMenuOpen] = useState(false);
+ const [upgradeModalOpen, setUpgradeModalOpen] = useState(false);
+ const { user, isSubscribed } = useDashboardContext();
+
+ const menuItems = useMemo(
+ () => [
+ {
+ name: "Homepage",
+ icon: <HomeIcon />,
+ href: "/home",
+ onClick: () => setMenuOpen(false),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Upgrade to Pro",
+ icon: <ArrowUpIcon />,
+ onClick: () => {
+ setMenuOpen(false);
+ setUpgradeModalOpen(true);
+ },
+ iconClassName: "text-amber-400 group-hover:text-amber-500",
+ showCondition: !isSubscribed && buildEnv.NEXT_PUBLIC_IS_CAP,
+ },
+ {
+ name: "Earn 40% Referral",
+ icon: <ReferIcon />,
+ href: "/dashboard/refer",
+ onClick: () => setMenuOpen(false),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: buildEnv.NEXT_PUBLIC_IS_CAP,
+ },
+ {
+ name: "Settings",
+ icon: <SettingsGearIcon />,
+ href: "/dashboard/settings/account",
+ onClick: () => setMenuOpen(false),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Chat Support",
+ icon: <MessageCircleMoreIcon />,
+ onClick: () => window.open("https://cap.link/discord", "_blank"),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Download App",
+ icon: <DownloadIcon />,
+ onClick: () => window.open("https://cap.so/download", "_blank"),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Sign Out",
+ icon: <LogoutIcon />,
+ onClick: () => signOut(),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ ],
+ [],
+ );
+
+ return (
+ <>
+ <UpgradeModal
+ open={upgradeModalOpen}
+ onOpenChange={setUpgradeModalOpen}
+ />
+ <Popover open={menuOpen} onOpenChange={setMenuOpen}>
+ <PopoverTrigger asChild>
+ <div
+ data-state={menuOpen ? "open" : "closed"}
+ className="flex gap-2 justify-between items-center p-2 rounded-xl border data-[state=open]:border-gray-3 data-[state=open]:bg-gray-3 border-transparent transition-colors cursor-pointer group lg:gap-6 hover:border-gray-3"
+ >
+ <div className="flex items-center">
+ {user.image ? (
+ <Image
+ src={user.image}
+ alt={user.name ?? "User"}
+ width={24}
+ height={24}
+ className="rounded-full"
+ />
+ ) : (
+ <Avatar
+ letterClass="text-xs lg:text-md"
+ name={user.name ?? "User"}
+ className="size-[24px] text-gray-12"
+ />
+ )}
+ <span className="ml-2 text-sm truncate lg:ml-2 lg:text-md text-gray-12">
+ {user.name ?? "User"}
+ </span>
+ </div>
+ <MoreVertical
+ data-state={menuOpen ? "open" : "closed"}
+ className="w-5 h-5 data-[state=open]:text-gray-12 transition-colors text-gray-10 group-hover:text-gray-12"
+ />
+ </div>
+ </PopoverTrigger>
+ <PopoverContent className="p-1 w-48">
+ <Command>
+ <CommandGroup>
+ {menuItems
+ .filter((item) => item.showCondition)
+ .map((item, index) => (
+ <MenuItem
+ key={index.toString()}
+ icon={item.icon}
+ name={item.name}
+ href={item.href ?? "#"}
+ onClick={item.onClick}
+ iconClassName={item.iconClassName}
+ />
+ ))}
+ </CommandGroup>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ </>
+ );
+};
+
+interface Props {
+ icon: React.ReactElement;
+ name: string;
+ href?: string;
+ onClick: () => void;
+ iconClassName?: string;
+}
+
+const MenuItem = memo(({ icon, name, href, onClick, iconClassName }: Props) => {
+ const iconRef = useRef<DownloadIconHandle>(null);
+ return (
+ <CommandItem
+ key={name}
+ className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
+ onSelect={onClick}
+ onMouseEnter={() => {
+ iconRef.current?.startAnimation();
+ }}
+ onMouseLeave={() => {
+ iconRef.current?.stopAnimation();
+ }}
+ >
+ <Link
+ className="flex gap-2 items-center w-full"
+ href={href ?? "#"}
+ onClick={onClick}
+ >
+ <div className="flex-shrink-0 flex items-center justify-center w-3.5 h-3.5">
+ {cloneElement(icon, {
+ ref: iconRef,
+ className: iconClassName,
+ size: 14,
+ })}
+ </div>
+ <p className={clsx("text-sm text-gray-12")}>{name}</p>
+ </Link>
+ </CommandItem>
+ );
+});
+
+const ReferButton = () => {
+ const iconRef = useRef<ReferIconHandle>(null);
+
+ return (
+ <Link href="/dashboard/refer" className="hidden relative lg:block">
+ {/* Red notification dot with pulse animation */}
+ <div className="absolute right-0 top-1 z-10">
+ <div className="relative">
+ <div className="absolute inset-0 w-2 h-2 bg-red-400 rounded-full opacity-75 animate-ping" />
+ <div className="relative w-2 h-2 bg-red-400 rounded-full" />
+ </div>
+ </div>
+
+ <div
+ onMouseEnter={() => {
+ iconRef.current?.startAnimation();
+ }}
+ onMouseLeave={() => {
+ iconRef.current?.stopAnimation();
+ }}
+ className="flex justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 hover:bg-gray-5 size-9"
+ >
+ {cloneElement(<ReferIcon />, {
+ ref: iconRef,
+ className: "text-gray-12 size-3.5",
+ })}
+ </div>
+ </Link>
+ );
+};
+
+export default Top;
diff --git a/apps/web/app/(org)/dashboard/caps/components/Folder.tsx b/apps/web/app/(org)/dashboard/caps/components/Folder.tsx
index 2cdf34c3d..b70e62fcf 100644
--- a/apps/web/app/(org)/dashboard/caps/components/Folder.tsx
+++ b/apps/web/app/(org)/dashboard/caps/components/Folder.tsx
@@ -319,7 +319,7 @@ const FolderCard = ({
onDragLeave={handleDragLeave}
onDrop={handleDrop}
className={clsx(
- "flex justify-between items-center px-4 py-4 w-full h-auto rounded-lg border transition-colors duration-200 cursor-pointer bg-gray-3 hover:bg-gray-4 hover:border-gray-6",
+ "flex justify-between items-center px-4 py-4 w-full h-auto rounded-lg border transition-all duration-200 cursor-pointer bg-gray-3 hover:bg-gray-4 hover:border-gray-6",
isDragOver ? "border-blue-10 bg-gray-4" : "border-gray-5",
isMovingVideo && "opacity-70",
)}
@@ -331,6 +331,7 @@ const FolderCard = ({
/>
<div
onClick={(e) => {
+ e.preventDefault();
e.stopPropagation();
}}
className="flex flex-col justify-center h-10"
@@ -347,11 +348,11 @@ const FolderCard = ({
await updateFolderNameHandler();
}
}}
- onKeyDown={(e) => {
+ onKeyDown={async (e) => {
if (e.key === "Enter") {
setIsRenaming(false);
if (updateName.trim() !== name) {
- updateFolderNameHandler();
+ await updateFolderNameHandler();
}
}
}}
@@ -359,15 +360,17 @@ const FolderCard = ({
focus:ring-0 focus:border-none text-gray-12 text-[15px] max-w-[116px] truncate p-0 m-0 h-[22px] leading-[22px] overflow-hidden font-normal tracking-normal"
/>
) : (
- <p
+ <div
onClick={(e) => {
+ e.preventDefault();
e.stopPropagation();
setIsRenaming(true);
}}
- className="text-[15px] truncate text-gray-12 w-full max-w-[116px] m-0 p-0 h-[22px] leading-[22px] font-normal tracking-normal"
>
- {updateName}
- </p>
+ <p className="text-[15px] truncate text-gray-12 w-full max-w-[116px] m-0 p-0 h-[22px] leading-[22px] font-normal tracking-normal">
+ {updateName}
+ </p>
+ </div>
)}
<p className="text-sm truncate text-gray-10 w-fit">{`${videoCount} ${
videoCount === 1 ? "video" : "videos"
diff --git a/apps/web/app/(org)/dashboard/layout.tsx b/apps/web/app/(org)/dashboard/layout.tsx
index 6d5abb32d..3a4f21038 100644
--- a/apps/web/app/(org)/dashboard/layout.tsx
+++ b/apps/web/app/(org)/dashboard/layout.tsx
@@ -79,11 +79,9 @@ export default async function DashboardLayout({
anyNewNotifications={anyNewNotifications}
userPreferences={userPreferences}
>
- <div className="grid grid-cols-[auto,1fr] bg-gray-1 grid-rows-[auto,1fr] h-dvh min-h-dvh">
- <aside className="hidden z-10 col-span-1 row-span-2 w-full lg:flex">
- <DesktopNav />
- </aside>
- <div className="flex col-span-2 row-span-2 h-full md:col-span-1 focus:outline-none">
+ <div className="dashboard-grid">
+ <DesktopNav />
+ <div className="flex h-full [grid-area:main] focus:outline-none">
<MobileNav />
<DashboardInner>{children}</DashboardInner>
</div>
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index c33360d42..2dfb1d7ab 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -52,6 +52,17 @@ html {
background-color: #f2f2f2;
}
+.dashboard-grid {
+ display: grid;
+ grid-template-columns: auto 1fr 1fr;
+ grid-template-areas:
+ "sidebar main main"
+ "sidebar main main";
+ height: 100dvh;
+ width: 100vw;
+ min-height: 100dvh;
+}
+
.left-perspective {
transform: scale(1.2) rotateX(47deg) rotateY(31deg) rotate(324deg);
}
@@ -66,9 +77,8 @@ html {
border-radius: 10px;
}
-/* Handle */
::-webkit-scrollbar-thumb {
- background: rgb(116, 116, 116);
+ background: var(--gray-7);
border-radius: 10px;
}
@@ -291,6 +301,15 @@ a.bg-primary:hover {
mask-composite: exclude;
}
+@media all and (max-width: 1024px) {
+ .dashboard-grid {
+ grid-template-columns: 1fr;
+ grid-template-areas:
+ "main"
+ "main";
+ }
+}
+
@media (prefers-color-scheme: dark) {
body,
html {