Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(dashboard): pin sidebar footer and add scroll fade affordance
Richie McIlroy6873fc0e9785
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsxindex ed19a9507..6cb52d2f0 100644--- a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx@@ -29,7 +29,15 @@ import { motion } from "framer-motion";import { Check, ChevronDown, Plus } from "lucide-react";import Link from "next/link";import { usePathname, useRouter } from "next/navigation";-import { cloneElement, type RefObject, useRef, useState } from "react";+import {+ cloneElement,+ type RefObject,+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from "react";import { NewOrganization } from "@/components/forms/NewOrganization";import { SignedImageUrl } from "@/components/SignedImageUrl";import { Tooltip } from "@/components/Tooltip";@@ -136,6 +144,35 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {const [_openAIDialog, _setOpenAIDialog] = useState(false);const router = useRouter();+ const scrollRef = useRef<HTMLDivElement>(null);+ const contentRef = useRef<HTMLDivElement>(null);+ const [canScrollUp, setCanScrollUp] = useState(false);+ const [canScrollDown, setCanScrollDown] = useState(false);++ const updateScrollFades = useCallback(() => {+ const el = scrollRef.current;+ if (!el) return;+ const maxScroll = el.scrollHeight - el.clientHeight;+ setCanScrollUp(el.scrollTop > 1);+ setCanScrollDown(el.scrollTop < maxScroll - 1);+ }, []);++ useEffect(() => {+ const el = scrollRef.current;+ if (!el) return;+ updateScrollFades();+ const observer = new ResizeObserver(() => updateScrollFades());+ observer.observe(el);+ if (contentRef.current) observer.observe(contentRef.current);+ return () => observer.disconnect();+ }, [updateScrollFades]);++ const scrollFadeMask = useMemo(() => {+ const top = canScrollUp ? "transparent" : "#000";+ const bottom = canScrollDown ? "transparent" : "#000";+ return `linear-gradient(to bottom, ${top} 0, #000 20px, #000 calc(100% - 44px), ${bottom} 100%)`;+ }, [canScrollUp, canScrollDown]);+const isPathActive = (path: string, matchChildren: boolean = false) => {if (matchChildren) {return pathname === path || pathname.startsWith(`${path}/`);@@ -150,246 +187,268 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {return (<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>- <Popover open={open} onOpenChange={setOpen}>- <Tooltip- disable={open || sidebarCollapsed === false}- position="right"- content={activeOrg?.organization.name ?? "No organization found"}- >- <PopoverTrigger suppressHydrationWarning asChild>- <motion.div- transition={{- type: "easeInOut",- duration: 0.2,- }}- className={clsx(- "mt-1.5 mx-auto rounded-xl cursor-pointer bg-gray-3",- sidebarCollapsed ? "w-fit px-2 py-0.5" : "w-full p-2.5",- )}+ <div className="flex flex-col flex-1 w-full min-h-0">+ <div className="shrink-0">+ <Popover open={open} onOpenChange={setOpen}>+ <Tooltip+ disable={open || sidebarCollapsed === false}+ position="right"+ content={activeOrg?.organization.name ?? "No organization found"}>- <div- className={clsx(- "flex flex-col items-center cursor-pointer",- sidebarCollapsed ? "justify-center" : "justify-between",- )}- role="combobox"- aria-expanded={open}- tabIndex={0}- >- <div+ <PopoverTrigger suppressHydrationWarning asChild>+ <motion.div+ transition={{+ type: "easeInOut",+ duration: 0.2,+ }}className={clsx(- "flex items-center",- sidebarCollapsed- ? "justify-center w-fit"- : "justify-between gap-2.5 w-full",+ "mt-1.5 mx-auto rounded-xl cursor-pointer bg-gray-3",+ sidebarCollapsed ? "w-fit px-2 py-0.5" : "w-full p-2.5",)}>- <div className="flex items-center">- <SignedImageUrl- image={activeOrg?.organization.iconUrl}- name={- activeOrg?.organization.name ?? "No organization found"- }- letterClass={clsx(- sidebarCollapsed ? "text-sm" : "text-[13px]",- )}+ <div+ className={clsx(+ "flex flex-col items-center cursor-pointer",+ sidebarCollapsed ? "justify-center" : "justify-between",+ )}+ role="combobox"+ aria-expanded={open}+ tabIndex={0}+ >+ <divclassName={clsx(- "relative flex-shrink-0 mx-auto",- sidebarCollapsed ? "size-6" : "size-7",+ "flex items-center",+ sidebarCollapsed+ ? "justify-center w-fit"+ : "justify-between gap-2.5 w-full",)}- />- </div>- <div className="flex flex-col flex-1 items-center h-10">- <div className="flex justify-between items-center w-full">- {!sidebarCollapsed && (- <p className="text-sm truncate leading-0 text-gray-12">- {activeOrg?.organization.name ??- "No organization found"}- </p>- )}- {!sidebarCollapsed && (- <ChevronDown- data-state={open ? "open" : "closed"}- className="size-4 transition-transform duration-200 text-gray-10 data-[state=open]:rotate-180"- />- )}- </div>- {!sidebarCollapsed && (- <Link- href={- isDomainSetupVerified- ? `https://${activeOrg.organization.customDomain}`- : "/dashboard/settings/organization"- }- rel={- isDomainSetupVerified- ? "noopener noreferrer"- : undefined- }- target={isDomainSetupVerified ? "_blank" : "_self"}- className="flex truncate w-full overflow-hidden flex-1 gap-1.5 items-center self-start"- >- <FontAwesomeIcon- icon={isDomainSetupVerified ? faLink : faCircleInfo}- className="duration-200 size-3 text-gray-10"- />- <p className="w-full text-[11px] flex-1 duration-200 truncate leading-0 text-gray-11">- {isDomainSetupVerified- ? activeOrg?.organization.customDomain- : "No custom domain set"}- </p>- </Link>- )}- </div>- </div>- </div>- <PopoverContent- className={clsx(- "p-0 w-full min-w-[287px] md:min-w-fit z-[120]",- sidebarCollapsed ? "ml-3" : "mx-auto",- )}- >- <Command>- <CommandInput placeholder="Search organizations..." />- <CommandEmpty>No organizations found</CommandEmpty>- <CommandGroup>- {orgData?.map((organization) => {- const isSelected =- activeOrg?.organization.id ===- organization.organization.id;- return (- <CommandItem+ >+ <div className="flex items-center">+ <SignedImageUrl+ image={activeOrg?.organization.iconUrl}+ name={+ activeOrg?.organization.name ??+ "No organization found"+ }+ letterClass={clsx(+ sidebarCollapsed ? "text-sm" : "text-[13px]",+ )}className={clsx(- "rounded-lg transition-colors duration-300 group",- isSelected- ? "pointer-events-none"- : "text-gray-10 hover:text-gray-12 hover:bg-gray-6",+ "relative flex-shrink-0 mx-auto",+ sidebarCollapsed ? "size-6" : "size-7",)}- key={`${organization.organization.name}-organization-${organization.organization.id}`}- onSelect={async () => {- await updateActiveOrganization(- organization.organization.id,- );- setOpen(false);- router.push("/dashboard/caps");- }}- >- <div className="flex gap-2 items-center w-full">- <SignedImageUrl- image={organization.organization.iconUrl}- name={organization.organization.name}- letterClass="text-xs"- className="relative flex-shrink-0 size-5"+ />+ </div>+ <div className="flex flex-col flex-1 items-center h-10">+ <div className="flex justify-between items-center w-full">+ {!sidebarCollapsed && (+ <p className="text-sm truncate leading-0 text-gray-12">+ {activeOrg?.organization.name ??+ "No organization found"}+ </p>+ )}+ {!sidebarCollapsed && (+ <ChevronDown+ data-state={open ? "open" : "closed"}+ className="size-4 transition-transform duration-200 text-gray-10 data-[state=open]:rotate-180"/>- <p+ )}+ </div>+ {!sidebarCollapsed && (+ <Link+ href={+ isDomainSetupVerified+ ? `https://${activeOrg.organization.customDomain}`+ : "/dashboard/settings/organization"+ }+ rel={+ isDomainSetupVerified+ ? "noopener noreferrer"+ : undefined+ }+ target={isDomainSetupVerified ? "_blank" : "_self"}+ className="flex truncate w-full overflow-hidden flex-1 gap-1.5 items-center self-start"+ >+ <FontAwesomeIcon+ icon={+ isDomainSetupVerified ? faLink : faCircleInfo+ }+ className="duration-200 size-3 text-gray-10"+ />+ <p className="w-full text-[11px] flex-1 duration-200 truncate leading-0 text-gray-11">+ {isDomainSetupVerified+ ? activeOrg?.organization.customDomain+ : "No custom domain set"}+ </p>+ </Link>+ )}+ </div>+ </div>+ </div>+ <PopoverContent+ className={clsx(+ "p-0 w-full min-w-[287px] md:min-w-fit z-[120]",+ sidebarCollapsed ? "ml-3" : "mx-auto",+ )}+ >+ <Command>+ <CommandInput placeholder="Search organizations..." />+ <CommandEmpty>No organizations found</CommandEmpty>+ <CommandGroup>+ {orgData?.map((organization) => {+ const isSelected =+ activeOrg?.organization.id ===+ organization.organization.id;+ return (+ <CommandItemclassName={clsx(- "flex-1 text-sm transition-colors duration-200 group-hover:text-gray-12",- isSelected ? "text-gray-12" : "text-gray-10",+ "rounded-lg transition-colors duration-300 group",+ isSelected+ ? "pointer-events-none"+ : "text-gray-10 hover:text-gray-12 hover:bg-gray-6",)}+ key={`${organization.organization.name}-organization-${organization.organization.id}`}+ onSelect={async () => {+ await updateActiveOrganization(+ organization.organization.id,+ );+ setOpen(false);+ router.push("/dashboard/caps");+ }}>- {organization.organization.name}- </p>- </div>- {isSelected && (- <Check- size={18}- className={"ml-auto text-gray-12"}- />- )}- </CommandItem>- );- })}- <DialogTrigger asChild>- <Button- variant="dark"- size="sm"- className="flex gap-1 items-center my-2 w-[90%] mx-auto text-sm"- >- <Plus className="w-3.5 h-auto" />- New organization- </Button>- </DialogTrigger>- </CommandGroup>- </Command>- </PopoverContent>- </motion.div>- </PopoverTrigger>- </Tooltip>- </Popover>- <MemberAvatars />- <nav- className="flex flex-col justify-between w-full h-full"- aria-label="Sidebar"- >- <div- className={clsx(- "mt-5",- sidebarCollapsed ? "flex flex-col justify-center items-center" : "",- )}+ <div className="flex gap-2 items-center w-full">+ <SignedImageUrl+ image={organization.organization.iconUrl}+ name={organization.organization.name}+ letterClass="text-xs"+ className="relative flex-shrink-0 size-5"+ />+ <p+ className={clsx(+ "flex-1 text-sm transition-colors duration-200 group-hover:text-gray-12",+ isSelected+ ? "text-gray-12"+ : "text-gray-10",+ )}+ >+ {organization.organization.name}+ </p>+ </div>+ {isSelected && (+ <Check+ size={18}+ className={"ml-auto text-gray-12"}+ />+ )}+ </CommandItem>+ );+ })}+ <DialogTrigger asChild>+ <Button+ variant="dark"+ size="sm"+ className="flex gap-1 items-center my-2 w-[90%] mx-auto text-sm"+ >+ <Plus className="w-3.5 h-auto" />+ New organization+ </Button>+ </DialogTrigger>+ </CommandGroup>+ </Command>+ </PopoverContent>+ </motion.div>+ </PopoverTrigger>+ </Tooltip>+ </Popover>+ <MemberAvatars />+ </div>+ <nav+ className="flex flex-col flex-1 w-full min-h-0"+ aria-label="Sidebar">- {manageNavigation- .filter((item) => !item.ownerOnly || isOwner)- .filter((item) => !item.adminOnly || canViewSettings)- .map((item) => (- <div- key={item.name}- className="flex relative justify-center items-center mb-1.5 w-full"- >- {isPathActive(item.href, item.matchChildren ?? false) && (- <motion.div- animate={{- width: sidebarCollapsed ? 36 : "100%",- }}- transition={{- layout: {- type: "tween",- duration: 0.15,- },- width: {- type: "tween",- duration: 0.05,- },- }}- layoutId="navlinks"- className="absolute h-[36px] w-full rounded-xl pointer-events-none bg-gray-3"- />- )}+ <div+ ref={scrollRef}+ onScroll={updateScrollFades}+ className="overflow-y-auto flex-1 min-h-0"+ style={{+ scrollbarWidth: "none",+ msOverflowStyle: "none",+ maskImage: scrollFadeMask,+ WebkitMaskImage: scrollFadeMask,+ }}+ >+ <div+ ref={contentRef}+ className={clsx(+ "pt-5",+ sidebarCollapsed ? "flex flex-col items-center" : "",+ )}+ >+ {manageNavigation+ .filter((item) => !item.ownerOnly || isOwner)+ .filter((item) => !item.adminOnly || canViewSettings)+ .map((item) => (+ <div+ key={item.name}+ className="flex relative justify-center items-center mb-1.5 w-full"+ >+ {isPathActive(item.href, item.matchChildren ?? false) && (+ <motion.div+ animate={{+ width: sidebarCollapsed ? 36 : "100%",+ }}+ transition={{+ layout: {+ type: "tween",+ duration: 0.15,+ },+ width: {+ type: "tween",+ duration: 0.05,+ },+ }}+ layoutId="navlinks"+ className="absolute h-[36px] w-full rounded-xl pointer-events-none bg-gray-3"+ />+ )}- <NavItem- name={item.name}- href={item.href}- icon={item.icon}- sidebarCollapsed={sidebarCollapsed}- toggleMobileNav={toggleMobileNav}- isPathActive={isPathActive}- extraText={item.extraText}- matchChildren={item.matchChildren ?? false}- />- </div>- ))}+ <NavItem+ name={item.name}+ href={item.href}+ icon={item.icon}+ sidebarCollapsed={sidebarCollapsed}+ toggleMobileNav={toggleMobileNav}+ isPathActive={isPathActive}+ extraText={item.extraText}+ matchChildren={item.matchChildren ?? false}+ />+ </div>+ ))}- <SpacesList toggleMobileNav={() => toggleMobileNav?.()} />- </div>- <div className="pb-4 mt-auto w-full">- <UsageButton- toggleMobileNav={() => toggleMobileNav?.()}- subscribed={user.isPro}- />- {buildEnv.NEXT_PUBLIC_IS_CAP && (- <div className="flex justify-center items-center mt-2">- <Link- href="/dashboard/refer"- className="text-sm underline text-gray-10 hover:text-gray-12"- >- Earn 40% Referral- </Link>+ <SpacesList toggleMobileNav={() => toggleMobileNav?.()} /></div>- )}- <p className="mt-2 text-xs text-center truncate text-gray-10">- Cap Software, Inc. {new Date().getFullYear()}.- </p>- </div>- </nav>+ </div>+ <div className="pt-2 pb-4 w-full shrink-0">+ <UsageButton+ toggleMobileNav={() => toggleMobileNav?.()}+ subscribed={user.isPro}+ />+ {buildEnv.NEXT_PUBLIC_IS_CAP && (+ <div className="flex justify-center items-center mt-2">+ <Link+ href="/dashboard/refer"+ className="text-sm underline text-gray-10 hover:text-gray-12"+ >+ Earn 40% Referral+ </Link>+ </div>+ )}+ <p className="mt-2 text-xs text-center truncate text-gray-10">+ Cap Software, Inc. {new Date().getFullYear()}.+ </p>+ </div>+ </nav>+ </div><DialogContent className="p-0 w-full max-w-md rounded-xl bg-gray-2"><DialogHeadericon={<FontAwesomeIcon icon={faBuilding} />}