Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): add developer section to dashboard navigation
Richie McIlroy7e0e3872ea44
diff --git a/apps/web/app/(org)/dashboard/Contexts.tsx b/apps/web/app/(org)/dashboard/Contexts.tsxindex 5ae70ee82..faa2a7f13 100644--- a/apps/web/app/(org)/dashboard/Contexts.tsx+++ b/apps/web/app/(org)/dashboard/Contexts.tsx@@ -12,6 +12,7 @@ import type {Spaces,UserPreferences,} from "./dashboard-data";+import type { DeveloperApp } from "./developers/developer-data";type SharedContext = {organizationData: Organization[] | null;@@ -31,6 +32,9 @@ type SharedContext = {setUpgradeModalOpen: (open: boolean) => void;referClickedState: boolean;setReferClickedStateHandler: (referClicked: boolean) => void;+ isDeveloperSection: boolean;+ developerApps: DeveloperApp[] | null;+ setDeveloperApps: (apps: DeveloperApp[] | null) => void;};type ITheme = "light" | "dark";@@ -83,7 +87,11 @@ export function DashboardContexts({);const [upgradeModalOpen, setUpgradeModalOpen] = useState(false);const [referClickedState, setReferClickedState] = useState(referClicked);+ const [developerApps, setDeveloperApps] = useState<DeveloperApp[] | null>(+ null,+ );const pathname = usePathname();+ const isDeveloperSection = pathname.startsWith("/dashboard/developers");// Calculate user's spaces (both owned and member of)const userSpaces =@@ -176,6 +184,9 @@ export function DashboardContexts({setUpgradeModalOpen,referClickedState,setReferClickedStateHandler,+ isDeveloperSection,+ developerApps,+ setDeveloperApps,}}>{children}diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Code.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Code.tsxnew file mode 100644index 000000000..5204730a5--- /dev/null+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Code.tsx@@ -0,0 +1,105 @@+"use client";++import { motion, useAnimation } from "motion/react";+import type { HTMLAttributes } from "react";+import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";+import { cn } from "@/lib/utils";++export interface CodeIconHandle {+ startAnimation: () => void;+ stopAnimation: () => void;+}++interface CodeIconProps extends HTMLAttributes<HTMLDivElement> {+ size?: number;+}++const CodeIcon = forwardRef<CodeIconHandle, CodeIconProps>(+ ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {+ const controls = useAnimation();+ const isControlledRef = useRef(false);++ useImperativeHandle(ref, () => {+ isControlledRef.current = true;++ return {+ startAnimation: () => controls.start("animate"),+ stopAnimation: () => controls.start("normal"),+ };+ });++ const handleMouseEnter = useCallback(+ (e: React.MouseEvent<HTMLDivElement>) => {+ if (!isControlledRef.current) {+ controls.start("animate");+ } else {+ onMouseEnter?.(e);+ }+ },+ [controls, onMouseEnter],+ );++ const handleMouseLeave = useCallback(+ (e: React.MouseEvent<HTMLDivElement>) => {+ if (!isControlledRef.current) {+ controls.start("normal");+ } else {+ onMouseLeave?.(e);+ }+ },+ [controls, onMouseLeave],+ );++ return (+ <div+ className={cn(className)}+ onMouseEnter={handleMouseEnter}+ onMouseLeave={handleMouseLeave}+ {...props}+ >+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width={size}+ height={size}+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"+ >+ <motion.polyline+ points="16 18 22 12 16 6"+ variants={{+ normal: { x: 0 },+ animate: { x: 2 },+ }}+ transition={{+ type: "spring",+ stiffness: 300,+ damping: 15,+ }}+ animate={controls}+ />+ <motion.polyline+ points="8 6 2 12 8 18"+ variants={{+ normal: { x: 0 },+ animate: { x: -2 },+ }}+ transition={{+ type: "spring",+ stiffness: 300,+ damping: 15,+ }}+ animate={controls}+ />+ </svg>+ </div>+ );+ },+);++CodeIcon.displayName = "CodeIcon";++export default CodeIcon;diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/index.ts b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/index.tsindex a78bba9d4..f3570be3a 100644--- a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/index.ts+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/index.ts@@ -4,6 +4,7 @@ import ChartLineIcon from "./ChartLine";import MessageCircleMoreIcon from "./Chat";import ChatIcon from "./Chat";import ClapIcon from "./Clap";+import CodeIcon from "./Code";import CogIcon from "./Cog";import DownloadIcon from "./Download";import HomeIcon from "./Home";@@ -18,6 +19,7 @@ export {ArrowUpIcon,CapIcon,MessageCircleMoreIcon,+ CodeIcon,CogIcon,DownloadIcon,HomeIcon,diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsxindex 62551931b..0d43dcfcc 100644--- a/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Desktop.tsx@@ -3,15 +3,17 @@ import { Button, Logo } from "@cap/ui";import clsx from "clsx";import { motion } from "framer-motion";import { useDetectPlatform } from "hooks/useDetectPlatform";-import { ChevronRight } from "lucide-react";+import { ArrowLeft, ChevronRight } from "lucide-react";import Link from "next/link";import { useEffect } from "react";import { Tooltip } from "@/components/Tooltip";import { useDashboardContext } from "../../Contexts";+import { DeveloperSidebarContent } from "../../developers/_components/DeveloperSidebarContent";import AdminNavItems from "./Items";export const DesktopNav = () => {- const { toggleSidebarCollapsed, sidebarCollapsed } = useDashboardContext();+ const { toggleSidebarCollapsed, sidebarCollapsed, isDeveloperSection } =+ useDashboardContext();const { platform } = useDetectPlatform();const cmdSymbol = platform === "macos" ? "⌘" : "Ctrl";@@ -47,16 +49,33 @@ export const DesktopNav = () => {><div className="flex flex-col mx-auto w-full h-full"><div className="flex justify-between items-center px-3 pt-5 mb-3.5 w-full truncate min-h-8">- <Link href="/dashboard">- <Logo- hideLogoName={sidebarCollapsed}- viewBoxDimensions={sidebarCollapsed ? "0 0 40 40" : "0 0 120 40"}+ {isDeveloperSection ? (+ <Link+ href="/dashboard/caps"className={clsx(- "w-[120px] h-[40px]",- sidebarCollapsed ? "mx-auto" : "",+ "flex items-center gap-2 text-gray-11 hover:text-gray-12 transition-colors",+ sidebarCollapsed ? "justify-center" : "",)}- />- </Link>+ >+ <ArrowLeft size={sidebarCollapsed ? 18 : 16} />+ {!sidebarCollapsed && (+ <span className="text-sm font-medium">Dashboard</span>+ )}+ </Link>+ ) : (+ <Link href="/dashboard">+ <Logo+ hideLogoName={sidebarCollapsed}+ viewBoxDimensions={+ sidebarCollapsed ? "0 0 40 40" : "0 0 120 40"+ }+ className={clsx(+ "w-[120px] h-[40px]",+ sidebarCollapsed ? "mx-auto" : "",+ )}+ />+ </Link>+ )}<Tooltipkbd={[cmdSymbol, "Shift", "S"]}position="right"@@ -82,7 +101,11 @@ export const DesktopNav = () => {</div><div className="flex overflow-y-auto flex-col flex-grow"><div className="flex flex-col px-3 h-full">- <AdminNavItems />+ {isDeveloperSection ? (+ <DeveloperSidebarContent />+ ) : (+ <AdminNavItems />+ )}</div></div></div>diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsxindex 160105bbc..a4e6d8fcc 100644--- a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx@@ -38,6 +38,7 @@ import { useDashboardContext } from "../../Contexts";import {CapIcon,ChartLineIcon,+ CodeIcon,CogIcon,ImportIcon,RecordIcon,@@ -90,6 +91,18 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {icon: <CogIcon />,subNav: [],},+ ...(buildEnv.NEXT_PUBLIC_IS_CAP+ ? [+ {+ name: "Developers",+ href: `/dashboard/developers`,+ ownerOnly: true,+ matchChildren: true,+ icon: <CodeIcon />,+ subNav: [] as { name: string; href: string }[],+ },+ ]+ : []),];const [dialogOpen, setDialogOpen] = useState(false);diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsxindex 6af7c64f0..c634a876c 100644--- a/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx@@ -47,7 +47,8 @@ import type { DownloadIconHandle } from "../AnimatedIcons/Download";import type { ReferIconHandle } from "../AnimatedIcons/Refer";const Top = () => {- const { activeSpace, anyNewNotifications } = useDashboardContext();+ const { activeSpace, anyNewNotifications, isDeveloperSection } =+ useDashboardContext();const [toggleNotifications, setToggleNotifications] = useState(false);const bellRef = useRef<HTMLDivElement>(null);const { theme, setThemeHandler } = useTheme();@@ -68,6 +69,10 @@ const Top = () => {"/dashboard/analytics": "Analytics",[`/dashboard/folder/${params.id}`]: "Caps",[`/dashboard/analytics/s/${params.id}`]: "Analytics: Cap video title",+ "/dashboard/developers": "Developers",+ "/dashboard/developers/apps": "Developer Apps",+ "/dashboard/developers/usage": "Developer Usage",+ "/dashboard/developers/credits": "Developer Credits",};const title = activeSpace ? activeSpace.name : titles[pathname] || "";@@ -160,20 +165,22 @@ const Top = () => {{toggleNotifications && <Notifications ref={notificationsRef} />}</AnimatePresence></div>- <div- onClick={() => {- if (document.startViewTransition) {- document.startViewTransition(() => {+ {!isDeveloperSection && (+ <div+ onClick={() => {+ if (document.startViewTransition) {+ document.startViewTransition(() => {+ setThemeHandler(theme === "light" ? "dark" : "light");+ });+ } else {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"- >- <ThemeToggleIcon />- </div>+ }+ }}+ className="hidden justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 lg:flex hover:bg-gray-5 size-9"+ >+ <ThemeToggleIcon />+ </div>+ )}<User /></div></div>