Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip

ameer24686546233fde3a
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
index 9522c52cf..b70d26679 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminDesktopNav.tsx
@@ -1,6 +1,8 @@
"use client";
+import { Tooltip } from "@/components/Tooltip";
import { Logo } from "@cap/ui";
import clsx from "clsx";
+import { motion } from "framer-motion";
import { ChevronLeft, ChevronRight } from "lucide-react";
import Link from "next/link";
import { useState } from "react";
@@ -17,21 +19,30 @@ export const AdminDesktopNav = () => {
return (
<>
- <div
+ <motion.div
+ initial={{
+ width: collapsed ? "70px" : "250px",
+ }}
+ animate={{
+ width: collapsed ? "70px" : "250px",
+ transition: {
+ duration: 0.4,
+ type: "spring",
+ bounce: 0.25
+ },
+ }}
className={clsx(
- "hidden h-full transition-all duration-300 lg:flex lg:flex-shrink-0 group",
- collapsed ? "w-[70px]" : "w-[250px]",
+ "hidden h-full lg:flex lg:flex-shrink-0 group",
"relative"
)}
>
<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 w-full h-full justify-top">
- <div className="flex justify-center w-full h-[10vh] items-center">
+ <div className="truncate items-center flex justify-center w-full h-[10vh]">
<Link href="/dashboard">
<Logo
- hideLogoName={collapsed}
- className={collapsed ? "w-8" : "w-24"}
+ className={clsx("flex-shrink-0 mx-auto w-[120px]", collapsed ? "ml-1" : "ml-0")}
/>
</Link>
</div>
@@ -40,18 +51,20 @@ export const AdminDesktopNav = () => {
</div>
{/* Collapse toggle button - moved outside the overflow container */}
- <button
- onClick={toggleCollapse}
- className="absolute right-[-12px] hover:border-gray-500 top-[50%] transform -translate-y-1/2 bg-white rounded-full p-1 border border-gray-200 hover:bg-gray-50 transition-colors z-10"
- >
- {collapsed ? (
+ <Tooltip kbd={['⌘', 'S']} position="right" content="Toggle collapse">
+ <button
+ onClick={toggleCollapse}
+ className="absolute right-[-12px] hover:border-gray-400 top-[50%] transform -translate-y-1/2 bg-gray-50 rounded-full p-1 border border-gray-200 hover:bg-gray-50 transition-colors z-10"
+ >
+ {collapsed ? (
<ChevronRight size={16} className="text-gray-500" />
) : (
<ChevronLeft size={16} className="text-gray-500" />
)}
</button>
+ </Tooltip>
</div>
- </div>
+ </motion.div>
</>
);
};
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminMobileNav.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminMobileNav.tsx
index dbe643bbb..7a304e153 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminMobileNav.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminMobileNav.tsx
@@ -1,92 +1,61 @@
"use client";
-import { Fragment, useState } from "react";
-import { X, Menu } from "lucide-react";
import { LogoBadge } from "@cap/ui";
+import { useClickAway } from "@uidotdev/usehooks";
+import { AnimatePresence, motion } from "framer-motion";
+import { Menu, X } from "lucide-react";
import Link from "next/link";
-import { Dialog, Transition } from "@headlessui/react";
+import { MutableRefObject, useState } from "react";
import { AdminNavItems } from "./AdminNavItems";
export const AdminMobileNav = () => {
const [sidebarOpen, setSidebarOpen] = useState(false);
+ const sidebarRef: MutableRefObject<HTMLDivElement> = useClickAway(() =>
+ setSidebarOpen(false)
+ );
return (
<>
- <Transition.Root show={sidebarOpen} as={Fragment}>
- <Dialog
- as="div"
- static
- className="fixed inset-0 flex z-50 lg:hidden"
- open={sidebarOpen}
- onClose={setSidebarOpen}
- >
- <Transition.Child
- as={Fragment}
- enter="transition-opacity ease-linear duration-300"
- enterFrom="opacity-0"
- enterTo="opacity-100"
- leave="transition-opacity ease-linear duration-300"
- leaveFrom="opacity-100"
- leaveTo="opacity-0"
+ <AnimatePresence mode="wait">
+ {sidebarOpen && (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ className="flex fixed inset-0 z-50 lg:hidden bg-gray-200/50"
>
- <Dialog.Overlay className="fixed inset-0 bg-gray-600 bg-opacity-75" />
- </Transition.Child>
- <Transition.Child
- as={Fragment}
- enter="transition ease-in-out duration-300 transform"
- enterFrom="-translate-x-full"
- enterTo="translate-x-0"
- leave="transition ease-in-out duration-300 transform"
- leaveFrom="translate-x-0"
- leaveTo="-translate-x-full"
- >
- <div className="relative flex-1 flex flex-col max-w-xs w-[275px] pt-5 pb-4 px-4 bg-gray-50">
- <Transition.Child
- as={Fragment}
- enter="ease-in-out duration-300"
- enterFrom="opacity-0"
- enterTo="opacity-100"
- leave="ease-in-out duration-300"
- leaveFrom="opacity-100"
- leaveTo="opacity-0"
+ <motion.div
+ ref={sidebarRef}
+ initial={{ x: "100%" }}
+ animate={{
+ x: 0,
+ transition: { duration: 0.3, bounce: 0.2, type: "spring" },
+ }}
+ exit={{ x: "100%" }}
+ className="relative flex-1 flex flex-col ml-auto max-w-xs w-[275px] pt-5 pb-4 px-4 bg-gray-50"
+ >
+ <div
+ className="flex justify-end items-center mb-6 w-full rounded-full"
+ onClick={() => setSidebarOpen(false)}
>
- <div className="absolute top-0 right-0 -mr-12 pt-2">
- <button
- className="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
- onClick={() => setSidebarOpen(false)}
- >
- <span className="sr-only">Close sidebar</span>
- <X className="h-6 w-6 text-black" aria-hidden="true" />
- </button>
- </div>
- </Transition.Child>
- <div className="flex-shrink-0 flex items-center px-4">
- <Link href="/dashboard" className="block">
- <LogoBadge className="h-8 w-auto block" />
- </Link>
+ <X className="text-gray-500 size-7" aria-hidden="true" />
</div>
- <AdminNavItems />
- </div>
- </Transition.Child>
- <div className="flex-shrink-0 w-14" aria-hidden="true">
- {/* Dummy element to force sidebar to shrink to fit close icon */}
- </div>
- </Dialog>
- </Transition.Root>
- <div className="relative z-10 flex-shrink-0 flex h-16 bg-gray-50 border-b-2 border-gray-100 lg:border-none lg:hidden">
+ <AdminNavItems />
+ </motion.div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ <div className="flex fixed z-10 justify-between w-full h-16 bg-gray-50 border-b lg:border-none lg:hidden">
+ <div className="flex flex-shrink-0 items-center px-4 h-full lg:hidden">
+ <Link className="block" href="/dashboard">
+ <LogoBadge className="block w-auto h-8" />
+ </Link>
+ </div>
<button
- className="px-4 border-r-2 focus:outline-none focus:ring-2 text-white focus:ring-inset focus:ring-cyan-500 lg:hidden"
+ className="flex flex-col gap-2 justify-center items-center px-5 text-white border-l lg:hidden"
onClick={() => setSidebarOpen(true)}
>
- <span className="sr-only">Open sidebar</span>
- <Menu className="h-6 w-6 text-black" aria-hidden="true" />
+ <Menu className="text-gray-500 size-7" aria-hidden="true" />
</button>
- <div className="flex justify-center lg:justify-end w-full px-6">
- <div className="flex-shrink-0 flex lg:hidden items-center px-4">
- <Link className="block" href="/inbox">
- <LogoBadge className="w-auto h-8 block" />
- </Link>
- </div>
- </div>
</div>
</>
);
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
index 93f4b3632..49c6a9ea1 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
@@ -11,12 +11,13 @@ import {
PopoverTrigger,
} from "@cap/ui";
import { classNames } from "@cap/utils";
-import { Building, Check, ChevronDown, Plus, Share2 } from "lucide-react";
+import { Check, ChevronDown, Plus } from "lucide-react";
import Link from "next/link";
-import { usePathname, useRouter } from "next/navigation";
+import { usePathname } from "next/navigation";
import { useState } from "react";
import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";
+import { Avatar } from "@/app/s/[videoId]/_components/tabs/Activity";
import { NewSpace } from "@/components/forms/NewSpace";
import { Tooltip } from "@/components/Tooltip";
import { UsageButton } from "@/components/UsageButton";
@@ -27,73 +28,45 @@ import {
DialogHeader,
DialogTitle,
} from "@cap/ui";
+import {
+ faBuilding,
+ faDownload,
+ faRecordVinyl,
+ faShareNodes,
+ IconDefinition,
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import { updateActiveSpace } from "./server";
-const Clapperboard = ({ className }: { className: string }) => (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 18 15"
- className={className}
- >
- <path
- stroke="#8991A3"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.667"
- d="M1.5 5.833h15m-15 0v5a2.5 2.5 0 002.5 2.5h10a2.5 2.5 0 002.5-2.5v-5m-15 0V4.167a2.5 2.5 0 012.5-2.5h10a2.5 2.5 0 012.5 2.5v1.666M5.583 2.083l-.666 3.334m4.416-3.334l-.666 3.334m4.416-3.334l-.666 3.334"
- ></path>
- </svg>
-);
-
-const Download = ({ className }: { className: string }) => (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 16 15"
- className={className}
- >
- <path
- stroke="#8991A3"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="1.667"
- d="M14.667 10v1.667a2.5 2.5 0 01-2.5 2.5H3.833a2.5 2.5 0 01-2.5-2.5V10M8 9.583V.833m0 8.75L5.083 6.667M8 9.583l2.917-2.916"
- ></path>
- </svg>
-);
-
export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {
const pathname = usePathname();
const [open, setOpen] = useState(false);
const { spaceData, activeSpace, user, isSubscribed } = useSharedContext();
- const [menuOpen, setMenuOpen] = useState(false);
- const router = useRouter();
const manageNavigation = [
{
name: "My Caps",
href: `/dashboard/caps`,
- icon: Clapperboard,
+ icon: faRecordVinyl,
subNav: [],
},
{
name: "Shared Caps",
href: `/dashboard/shared-caps`,
- icon: Share2,
+ icon: faShareNodes,
subNav: [],
},
{
name: "Download App",
href: `/download`,
- icon: Download,
+ icon: faDownload,
subNav: [],
},
{
name: "Workspace",
href: `/dashboard/settings/workspace`,
- icon: Building,
+ icon: faBuilding,
subNav: [],
},
...(user.email.endsWith("@cap.so")
@@ -101,7 +74,7 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {
{
name: "Admin",
href: "/dashboard/admin",
- icon: Building, // Using Building icon as a fallback
+ icon: faBuilding, // Using Building icon as a fallback
subNav: [],
},
]
@@ -115,63 +88,73 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {
return (
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
- <div className="px-3 py-2.5 w-full rounded-2xl border border-gray-200">
- <Popover open={open} onOpenChange={setOpen}>
- <PopoverTrigger asChild>
- <div
- className="flex justify-between items-center cursor-pointer"
- role="combobox"
- aria-expanded={open}
- >
- <div className="flex items-center w-full text-left">
- <div>
- <p className="text-sm font-medium">
- {activeSpace?.space.name ?? "No space found"}
- </p>
+ <Tooltip
+ disable={collapsed === false}
+ position="right"
+ content={activeSpace?.space.name ?? "No space found"}
+ >
+ <div className="p-3 w-full rounded-xl border border-gray-200">
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <div
+ className="flex justify-between items-center cursor-pointer"
+ role="combobox"
+ aria-expanded={open}
+ >
+ <div className="flex justify-between items-center w-full text-left">
+ <div className="flex items-center">
+ <Avatar
+ className="flex-shrink-0 size-5"
+ name={activeSpace?.space.name ?? "No space found"}
+ />
+ <p className="ml-2.5 text-sm font-medium truncate">
+ {activeSpace?.space.name ?? "No space found"}
+ </p>
+ </div>
+ {!collapsed && (
+ <ChevronDown className="w-[20px] h-auto text-gray-400" />
+ )}
</div>
</div>
- <div>
- <ChevronDown className="w-[20px] h-auto text-gray-400" />
- </div>
- </div>
- </PopoverTrigger>
- <PopoverContent className="z-10 p-0 mt-2 w-[calc(100%-10%)] mx-auto bg-white">
- <Command>
- <CommandInput placeholder="Search spaces..." />
- <CommandEmpty>No spaces found</CommandEmpty>
- <CommandGroup>
- {spaceData?.map((space) => {
- const isSelected = activeSpace?.space.id === space.space.id;
- return (
- <CommandItem
- key={space.space.name + "-space"}
- onSelect={async () => {
- await updateActiveSpace(space.space.id);
- setOpen(false);
- }}
- >
- {space.space.name}
- <Check
- size={18}
- className={classNames(
- "ml-auto",
- isSelected ? "opacity-100" : "opacity-0"
- )}
- />
+ </PopoverTrigger>
+ <PopoverContent className="z-[60] p-0 mt-2 w-[calc(100%-12px)] mx-auto bg-white">
+ <Command>
+ <CommandInput placeholder="Search spaces..." />
+ <CommandEmpty>No spaces found</CommandEmpty>
+ <CommandGroup>
+ {spaceData?.map((space) => {
+ const isSelected = activeSpace?.space.id === space.space.id;
+ return (
+ <CommandItem
+ key={space.space.name + "-space"}
+ onSelect={async () => {
+ await updateActiveSpace(space.space.id);
+ setOpen(false);
+ }}
+ >
+ {space.space.name}
+ <Check
+ size={18}
+ className={classNames(
+ "ml-auto",
+ isSelected ? "opacity-100" : "opacity-0"
+ )}
+ />
+ </CommandItem>
+ );
+ })}
+ <DialogTrigger className="w-full">
+ <CommandItem className="bg-gray-100 rounded-lg border border-gray-200 aria-selected:bg-gray-200">
+ <Plus className="mr-1 w-4 h-auto" />
+ <span className="text-sm">Add new space</span>
</CommandItem>
- );
- })}
- <DialogTrigger className="w-full">
- <CommandItem className="bg-gray-100 rounded-lg border border-gray-200 aria-selected:bg-gray-200">
- <Plus className="mr-1 w-4 h-auto" />
- <span className="text-sm">Add new space</span>
- </CommandItem>
- </DialogTrigger>
- </CommandGroup>
- </Command>
- </PopoverContent>
- </Popover>
- </div>
+ </DialogTrigger>
+ </CommandGroup>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ </div>
+ </Tooltip>
<nav
className="flex flex-col justify-between w-full h-full"
aria-label="Sidebar"
@@ -180,42 +163,46 @@ export const AdminNavItems = ({ collapsed }: { collapsed?: boolean }) => {
className={clsx("mt-8 space-y-2.5", collapsed ? "items-center" : "")}
>
{manageNavigation.map((item) => (
- <div key={item.name}>
- <div className="flex justify-center">
- <Tooltip content={item.name} disable={collapsed === false}>
- <Link
- passHref
- prefetch={false}
- href={item.href}
+ <div key={item.name} className="flex justify-center">
+ <Tooltip
+ content={item.name}
+ disable={collapsed === false}
+ position="right"
+ >
+ <Link
+ passHref
+ prefetch={false}
+ href={item.href}
+ className={classNames(
+ pathname.includes(item.href)
+ ? "bg-white text-gray-400 border-[1px] border-gray-200 shadow-sm shadow-gray-200"
+ : "hover:opacity-75",
+ navItemClass
+ )}
+ >
+ <FontAwesomeIcon
+ icon={item.icon as IconDefinition}
className={classNames(
- pathname.includes(item.href)
- ? "bg-white text-gray-400 border-[1px] border-gray-200 shadow-[0_1.5px_3px_0px] shadow-gray-200"
- : "hover:opacity-75",
- navItemClass
+ "flex-shrink-0 w-5 h-5 stroke-[1.5px] text-gray-400"
)}
- >
- <item.icon
- className={classNames(
- "flex-shrink-0 w-5 h-5 stroke-[1.5px]"
- )}
- aria-hidden="true"
- />
- <span className="text-base ml-2.5 text-gray-400 truncate">
- {item.name}
- </span>
- </Link>
- </Tooltip>
- </div>
+ aria-hidden="true"
+ />
+ <span className="text-base ml-2.5 text-gray-400 truncate">
+ {item.name}
+ </span>
+ </Link>
+ </Tooltip>
</div>
))}
</div>
- <div className="mt-auto">
- <div className="pb-5 mb-3 w-full">
- <UsageButton
- collapsed={collapsed ?? false}
- subscribed={isSubscribed}
- />
- </div>
+ <div className="pb-0 w-full lg:pb-5">
+ <UsageButton
+ collapsed={collapsed ?? false}
+ subscribed={isSubscribed}
+ />
+ <p className="mt-4 text-xs text-center text-gray-400 truncate">
+ © Cap Software, Inc. {new Date().getFullYear()}.
+ </p>
</div>
</nav>
<DialogContent>
diff --git a/apps/web/app/dashboard/_components/DashboardInner.tsx b/apps/web/app/dashboard/_components/DashboardInner.tsx
index 970778f8a..6203b1e0b 100644
--- a/apps/web/app/dashboard/_components/DashboardInner.tsx
+++ b/apps/web/app/dashboard/_components/DashboardInner.tsx
@@ -28,17 +28,21 @@ export default function DashboardInner({
emptyComponent?: React.ReactNode;
}) {
return (
- <>
- <div className="h-[100vh] flex flex-col items-between gap-5 pt-5">
- <div className="h-[5vh] w-full justify-between flex items-center pr-8">
- <p className="text-xl text-gray-500">{title}</p>
- <User />
- </div>
- <div className="flex flex-grow h-[90vh] bg-gray-100 rounded-tl-2xl p-8 border-[1px] border-gray-200">
- {emptyCondition ? emptyComponent : children}
- </div>
+ <div className="flex flex-col gap-5 pt-5 min-h-screen">
+ {/* Top Bar */}
+ <div className="h-[8vh] lg:h-[5vh] border-b lg:border-0 border-gray-200 w-full mt-4 lg:mt-0 fixed top-12 lg:top-0 bg-gray-50 z-10 lg:relative flex items-center justify-between px-5 lg:pr-8 lg:pl-0">
+ <p className="text-xl text-gray-500">{title}</p>
+ <User />
+ </div>
+ {/* Content Area */}
+ <div className="flex overflow-auto flex-col flex-1 p-5 pb-5 bg-gray-100 border border-gray-200 mt-[120px] lg:mt-0 lg:rounded-tl-2xl lg:p-8">
+ {emptyCondition ? (
+ emptyComponent
+ ) : (
+ <div className="flex flex-col gap-4">{children}</div>
+ )}
</div>
- </>
+ </div>
);
}
@@ -48,14 +52,16 @@ const User = () => {
return (
<Popover open={menuOpen} onOpenChange={setMenuOpen}>
<PopoverTrigger asChild>
- <div className="flex gap-6 justify-between items-center p-2 rounded-lg transition-colors cursor-pointer hover:bg-gray-100">
+ <div className="flex gap-2 justify-between items-center p-2 rounded-lg transition-colors cursor-pointer lg:gap-6 hover:bg-gray-100">
<div className="flex items-center">
<Avatar
- letterClass="text-md"
+ letterClass="text-xs lg:text-md"
name={user.name ?? "User"}
- className="size-[36px]"
+ className="size-[24px] lg:size-[36px]"
/>
- <span className="ml-3 text-md">{user.name ?? "User"}</span>
+ <span className="ml-2 text-sm lg:ml-3 lg:text-md">
+ {user.name ?? "User"}
+ </span>
</div>
<MoreVertical className="w-5 h-5 text-gray-400 group-hover:text-gray-500" />
</div>
diff --git a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
index e0602875b..a8536650e 100644
--- a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
+++ b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
@@ -31,7 +31,7 @@ export default function DynamicSharedLayout({
<Context.Provider value={{ spaceData, activeSpace, user, isSubscribed }}>
<div className="flex h-screen min-h-full dashboard-layout">
<AdminDesktopNav />
- <div className="overflow-auto flex-1 focus:outline-none">
+ <div className="flex-1 focus:outline-none">
<AdminMobileNav />
<main className="w-full min-h-screen">{children}</main>
</div>
diff --git a/apps/web/app/dashboard/caps/Caps.tsx b/apps/web/app/dashboard/caps/Caps.tsx
index 894837514..c583d6121 100644
--- a/apps/web/app/dashboard/caps/Caps.tsx
+++ b/apps/web/app/dashboard/caps/Caps.tsx
@@ -86,8 +86,8 @@ export const Caps = ({
emptyCondition={data.length === 0}
emptyComponent={<EmptyCapState userName={user?.name || ""} />}
>
- <div className="flex flex-col w-full h-full">
- <div className="grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-4">
+ <div className="flex flex-col w-full">
+ <div className="grid grid-cols-1 gap-4 sm:gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{data.map((cap) => (
<CapCard
key={cap.id}
diff --git a/apps/web/app/dashboard/caps/components/CapCard.tsx b/apps/web/app/dashboard/caps/components/CapCard.tsx
index 33f159cee..c11c2b1c5 100644
--- a/apps/web/app/dashboard/caps/components/CapCard.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCard.tsx
@@ -1,18 +1,20 @@
-import { useState } from "react";
-import { VideoThumbnail } from "@/components/VideoThumbnail";
-import { CapCardActions } from "@/app/dashboard/caps/components/CapCardActions";
+import { editDate } from "@/actions/videos/edit-date";
+import { editTitle } from "@/actions/videos/edit-title";
+import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";
import { CapCardAnalytics } from "@/app/dashboard/caps/components/CapCardAnalytics";
-import { toast } from "react-hot-toast";
-import moment from "moment";
-import { Tooltip } from "react-tooltip";
-import { ChevronDown } from "lucide-react";
import { SharingDialog } from "@/app/dashboard/caps/components/SharingDialog";
-import { useRouter } from "next/navigation";
-import { clientEnv, NODE_ENV } from "@cap/env";
-import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";
+import { Tooltip } from "@/components/Tooltip";
+import { VideoThumbnail } from "@/components/VideoThumbnail";
import { VideoMetadata } from "@cap/database/types";
-import { editDate } from "@/actions/videos/edit-date";
-import { editTitle } from "@/actions/videos/edit-title";
+import { clientEnv, NODE_ENV } from "@cap/env";
+import { Button } from "@cap/ui";
+import { faLink, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import moment from "moment";
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { toast } from "react-hot-toast";
interface CapCardProps {
cap: {
@@ -89,34 +91,6 @@ export const CapCard: React.FC<CapCardProps> = ({
const isOwner = userId === cap.ownerId;
- const renderSharedStatus = () => {
- const baseClassName =
- "text-gray-400 text-sm cursor-pointer flex items-center";
- if (isOwner) {
- if (cap.sharedSpaces.length === 0) {
- return (
- <span
- className={baseClassName}
- onClick={() => setIsSharingDialogOpen(true)}
- >
- Not shared <ChevronDown className="ml-1" size={16} />
- </span>
- );
- } else {
- return (
- <span
- className={baseClassName}
- onClick={() => setIsSharingDialogOpen(true)}
- >
- Shared <ChevronDown className="ml-1" size={16} />
- </span>
- );
- }
- } else {
- return <span className={baseClassName}>Shared with you</span>;
- }
- };
-
const handleSharingUpdated = (updatedSharedSpaces: string[]) => {
setSharedSpaces(
userSpaces.filter((space) => updatedSharedSpaces.includes(space.id))
@@ -183,95 +157,7 @@ export const CapCard: React.FC<CapCardProps> = ({
};
return (
- <div
- className="rounded-xl border-[1px] border-gray-200 relative"
- style={{ boxShadow: "0px 8px 16px rgba(18, 22, 31, 0.04)" }}
- >
- <CapCardActions capId={cap.id} onDelete={onDelete} />
- <a
- className="group block"
- href={
- activeSpace?.space.customDomain
- ? `https://${activeSpace.space.customDomain}/s/${cap.id}`
- : clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
- ? `https://cap.link/${cap.id}`
- : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
- }
- >
- <VideoThumbnail
- userId={cap.ownerId}
- videoId={cap.id}
- alt={`${cap.name} Thumbnail`}
- />
- </a>
- <div className="flex flex-col p-4">
- <div className="mb-1">
- <div>
- <span className="text-[0.875rem] leading-[1.25rem] text-gray-400">
- {isOwner ? cap.ownerName : cap.sharedSpaces[0]?.name}
- </span>
- </div>
- <div>
- <span>{renderSharedStatus()}</span>
- </div>
- </div>
- {isEditing ? (
- <textarea
- rows={1}
- value={title}
- onChange={(e) => setTitle(e.target.value)}
- onBlur={handleTitleBlur}
- onKeyDown={handleTitleKeyDown}
- autoFocus
- className="text-[0.875rem] leading-[1.25rem] text-gray-500 font-medium box-border mb-1"
- />
- ) : (
- <p
- className="text-[0.875rem] leading-[1.25rem] text-gray-500 font-medium mb-1"
- onClick={() => {
- if (userId === cap.ownerId) {
- setIsEditing(true);
- }
- }}
- >
- {title}
- </p>
- )}
- <p className="mb-1">
- {isDateEditing ? (
- <div className="flex items-center">
- <input
- type="text"
- value={dateValue}
- onChange={handleDateChange}
- onBlur={handleDateBlur}
- onKeyDown={handleDateKeyDown}
- autoFocus
- className="text-[0.875rem] leading-[1.25rem] text-gray-400 bg-transparent focus:outline-none"
- placeholder="YYYY-MM-DD HH:mm:ss"
- />
- </div>
- ) : (
- <span
- className="text-[0.875rem] leading-[1.25rem] text-gray-400 cursor-pointer flex items-center"
- onClick={handleDateClick}
- data-tooltip-id={cap.id + "_createdAt"}
- data-tooltip-content={`Cap created at ${effectiveDate}`}
- >
- {showFullDate
- ? moment(effectiveDate).format("YYYY-MM-DD HH:mm:ss")
- : moment(effectiveDate).fromNow()}
- </span>
- )}
- <Tooltip className="z-50" id={cap.id + "_createdAt"} />
- </p>
- <CapCardAnalytics
- capId={cap.id}
- displayCount={displayCount}
- totalComments={cap.totalComments}
- totalReactions={cap.totalReactions}
- />
- </div>
+ <>
<SharingDialog
isOpen={isSharingDialogOpen}
onClose={() => setIsSharingDialogOpen(false)}
@@ -281,6 +167,113 @@ export const CapCard: React.FC<CapCardProps> = ({
userSpaces={userSpaces}
onSharingUpdated={handleSharingUpdated}
/>
- </div>
+ <div className="relative rounded-2xl flex flex-col gap-4 w-full h-full p-4 border-gray-200 bg-gray-50 border-[1px]">
+ <Link
+ className="block group"
+ href={
+ activeSpace?.space.customDomain
+ ? `https://${activeSpace.space.customDomain}/s/${cap.id}`
+ : clientEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
+ ? `https://cap.link/${cap.id}`
+ : `${clientEnv.NEXT_PUBLIC_WEB_URL}/s/${cap.id}`
+ }
+ >
+ <VideoThumbnail
+ userId={cap.ownerId}
+ videoId={cap.id}
+ alt={`${cap.name} Thumbnail`}
+ />
+ </Link>
+ <div className="flex flex-col flex-grow gap-3 w-full">
+ <div>
+ {isEditing ? (
+ <textarea
+ rows={1}
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ onBlur={handleTitleBlur}
+ onKeyDown={handleTitleKeyDown}
+ autoFocus
+ className="text-md truncate leading-[1.25rem] text-gray-500 font-medium box-border mb-1"
+ />
+ ) : (
+ <p
+ className="text-md truncate leading-[1.25rem] text-gray-500 font-medium mb-1"
+ onClick={() => {
+ if (userId === cap.ownerId) {
+ setIsEditing(true);
+ }
+ }}
+ >
+ {title}
+ </p>
+ )}
+ <p className="mb-1">
+ {isDateEditing ? (
+ <div className="flex items-center">
+ <input
+ type="text"
+ value={dateValue}
+ onChange={handleDateChange}
+ onBlur={handleDateBlur}
+ onKeyDown={handleDateKeyDown}
+ autoFocus
+ className="text-sm truncate leading-[1.25rem] text-gray-400 bg-transparent focus:outline-none"
+ placeholder="YYYY-MM-DD HH:mm:ss"
+ />
+ </div>
+ ) : (
+ <Tooltip content={`Cap created at ${effectiveDate}`}>
+ <span
+ className="text-sm truncate leading-[1.25rem] text-gray-400 cursor-pointer flex items-center"
+ onClick={handleDateClick}
+ >
+ {showFullDate
+ ? moment(effectiveDate).format("YYYY-MM-DD HH:mm:ss")
+ : moment(effectiveDate).fromNow()}
+ </span>
+ </Tooltip>
+ )}
+ </p>
+ </div>
+ <CapCardAnalytics
+ capId={cap.id}
+ displayCount={displayCount}
+ totalComments={cap.totalComments}
+ totalReactions={cap.totalReactions}
+ />
+ </div>
+ <div className="flex flex-wrap gap-3 items-center mt-auto w-full">
+ <Button
+ onClick={() => setIsSharingDialogOpen(true)}
+ className="flex-1 h-10 rounded-xl"
+ variant="white"
+ size="sm"
+ >
+ <FontAwesomeIcon
+ className="mr-1 text-gray-400 size-4"
+ icon={faLink}
+ />
+ {isOwner
+ ? cap.sharedSpaces.length === 0
+ ? "Not shared"
+ : "Shared"
+ : "Shared with you"}
+ </Button>
+ <Button
+ onClick={() => onDelete(cap.id)}
+ className="flex-1 h-10 rounded-xl"
+ variant="white"
+ size="sm"
+ >
+ <FontAwesomeIcon
+ className="mr-1 text-gray-400 size-4"
+ icon={faTrash}
+ />
+ Delete
+ </Button>
+ </div>
+ </div>
+ </>
);
};
diff --git a/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx b/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
index 33666b500..53e0fbb7c 100644
--- a/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
+++ b/apps/web/app/dashboard/caps/components/CapCardAnalytics.tsx
@@ -1,5 +1,6 @@
-import { EyeIcon, MessageSquareIcon, SmileIcon } from "lucide-react";
-import { Tooltip } from "react-tooltip";
+import { Tooltip } from "@/components/Tooltip";
+import { faComment, faEye, faSmile } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
interface CapCardAnalyticsProps {
capId: string;
@@ -15,40 +16,25 @@ export const CapCardAnalytics: React.FC<CapCardAnalyticsProps> = ({
totalReactions,
}) => {
return (
- <div className="flex items-center space-x-3 text-sm text-gray-60">
- <div
- className="flex items-center"
- data-tooltip-id={capId + "_analytics"}
- data-tooltip-content={`${displayCount} unique views via your shareable Cap.link.`}
- >
- <EyeIcon className="w-4 h-4 mr-1 text-gray-400" />
- <span className="text-[0.875rem] leading-[1.25rem] text-gray-400">
- {displayCount ?? "-"}
- </span>
- <Tooltip id={capId + "_analytics"} />
- </div>
- <div
- className="flex items-center"
- data-tooltip-id={capId + "_comments"}
- data-tooltip-content={`${totalComments} comments`}
- >
- <MessageSquareIcon className="w-4 h-4 mr-1 text-gray-400" />
- <span className="text-[0.875rem] leading-[1.25rem] text-gray-400">
- {totalComments}
- </span>
- <Tooltip id={capId + "_comments"} />
- </div>
- <div
- className="flex items-center"
- data-tooltip-id={capId + "_reactions"}
- data-tooltip-content={`${totalReactions} reactions`}
- >
- <SmileIcon className="w-4 h-4 mr-1 text-gray-400" />
- <span className="text-[0.875rem] leading-[1.25rem] text-gray-400">
- {totalReactions}
- </span>
- <Tooltip id={capId + "_reactions"} />
- </div>
+ <div className="flex flex-wrap gap-5 items-center text-sm text-gray-60">
+ <Tooltip content={`${displayCount} unique views`}>
+ <div className="flex flex-col gap-1 items-center">
+ <FontAwesomeIcon className="text-gray-400 size-4" icon={faEye} />
+ <span className="text-sm text-gray-500">{displayCount ?? "-"}</span>
+ </div>
+ </Tooltip>
+ <Tooltip content={`${totalComments} comments`}>
+ <div className="flex flex-col gap-1 items-center">
+ <FontAwesomeIcon className="text-gray-400 size-4" icon={faComment} />
+ <span className="text-sm text-gray-500">{totalComments}</span>
+ </div>
+ </Tooltip>
+ <Tooltip content={`${totalReactions} reactions`}>
+ <div className="flex flex-col gap-1 items-center">
+ <FontAwesomeIcon className="text-gray-400 size-4" icon={faSmile} />
+ <span className="text-sm text-gray-500">{totalReactions}</span>
+ </div>
+ </Tooltip>
</div>
);
};
diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx
index ccd898d19..9c24901ca 100644
--- a/apps/web/app/dashboard/layout.tsx
+++ b/apps/web/app/dashboard/layout.tsx
@@ -1,15 +1,15 @@
import DynamicSharedLayout from "@/app/dashboard/_components/DynamicSharedLayout";
-import { getCurrentUser } from "@cap/database/auth/session";
-import { redirect } from "next/navigation";
import { DashboardTemplate } from "@/components/templates/DashboardTemplate";
import { db } from "@cap/database";
+import { getCurrentUser } from "@cap/database/auth/session";
import {
+ spaceInvites,
spaceMembers,
spaces,
- spaceInvites,
users,
} from "@cap/database/schema";
-import { eq, inArray, or, and, count, sql } from "drizzle-orm";
+import { count, eq, inArray, or, sql } from "drizzle-orm";
+import { redirect } from "next/navigation";
export type Space = {
space: typeof spaces.$inferSelect;
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index dc4d54c9b..2031a5c02 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -110,6 +110,71 @@ a.bg-primary:hover {
animation: animatedyaxis 6s ease infinite forwards;
}
+.TooltipContent[data-side="left"] {
+ animation: slideLeft 0.2s ease-out;
+}
+
+.TooltipContent[data-side="right"] {
+ animation: slideRight 0.2s ease-out;
+}
+
+.TooltipContent[data-side="top"] {
+ animation: slideUp 0.2s ease-out;
+}
+
+.TooltipContent[data-side="bottom"] {
+ animation: slideDown 0.2s ease-out;
+}
+
+.TooltipContent {
+ transform-origin: var(--radix-tooltip-content-transform-origin);
+}
+
+@keyframes slideRight {
+ from {
+ opacity: 0;
+ transform: translateX(-10px);
+ }
+ to {
+ transform: translateX(0px);
+ opacity: 1;
+ }
+}
+
+@keyframes slideLeft {
+ from {
+ opacity: 0;
+ transform: translateX(10px);
+ }
+ to {
+ transform: translateX(0px);
+ opacity: 1;
+ }
+}
+
+@keyframes slideUp {
+ from {
+ opacity: 0;
+ transform: translateY(-5px);
+ }
+ to {
+ transform: translateY(0px);
+ opacity: 1;
+ }
+}
+
+@keyframes slideDown {
+ from {
+ opacity: 0;
+ transform: translateY(5px);
+ }
+ to {
+ transform: translateY(0px);
+ opacity: 1;
+ }
+}
+
+
.button-gradient-border::before {
content: '';
position: absolute;
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 73c117d2b..84bf36070 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -96,7 +96,7 @@ export default async function RootLayout({
email={user?.email ?? ""}
>
<Toaster />
- <main className="overflow-hidden w-full">
+ <main className="overflow-x-hidden w-full">
<Navbar auth={user ? true : false} />
{children}
<Footer />
diff --git a/apps/web/components/Tooltip.tsx b/apps/web/components/Tooltip.tsx
index e3cc6d9b3..cbfc5a38e 100644
--- a/apps/web/components/Tooltip.tsx
+++ b/apps/web/components/Tooltip.tsx
@@ -1,5 +1,6 @@
"use client";
+import { detectPlatform } from "@/utils/platform";
import { classNames } from "@cap/utils";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import * as React from "react";
@@ -9,30 +10,43 @@ const Tooltip = ({
content,
className,
position = "top",
+ kbd,
disable,
}: {
children: React.ReactNode;
content: string;
className?: string;
position?: "top" | "bottom" | "left" | "right";
+ kbd?: string[];
disable?: boolean;
}) => {
+ if (disable) {
+ return <>{children}</>;
+ }
return (
<TooltipPrimitive.Root>
- <TooltipPrimitive.Trigger disabled={disable} asChild>
+ <TooltipPrimitive.Trigger asChild>
{children}
</TooltipPrimitive.Trigger>
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
side={position}
className={classNames(
- "select-none rounded bg-white px-[15px] py-2.5 text-[15px] leading-none text-violet11 shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade",
+ "select-none rounded-lg flex items-center gap-2 TooltipContent bg-gray-50 border border-gray-200 px-3 py-2 text-xs leading-none shadow-sm shadow-gray-300/50 data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade",
className
)}
sideOffset={5}
>
{content}
- <TooltipPrimitive.Arrow className="fill-white" />
+ {kbd && (
+ <div className="flex gap-1 items-center">
+ {kbd.map((key, index) => (
+ <div className="flex justify-center items-center bg-gray-100 rounded-md border border-gray-300 shadow-sm size-5 shadow-gray-300/50" key={index}>
+ <kbd className="text-xs text-gray-400">{key}</kbd>
+ </div>
+ ))}
+ </div>
+ )}
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
</TooltipPrimitive.Root>
diff --git a/apps/web/components/UsageButton.tsx b/apps/web/components/UsageButton.tsx
index 0c650bf27..2cfdd460f 100644
--- a/apps/web/components/UsageButton.tsx
+++ b/apps/web/components/UsageButton.tsx
@@ -13,7 +13,7 @@ export const UsageButton = ({
collapsed: boolean;
}) => {
return (
- <Tooltip content={subscribed ? "Cap Pro" : "Upgrade to Pro"}>
+ <Tooltip position="right" content={subscribed ? "Cap Pro" : "Upgrade to Pro"}>
<Link
className="flex justify-center mx-auto w-full"
href={subscribed ? "/dashboard/settings/workspace" : "/pricing"}
diff --git a/apps/web/components/VideoThumbnail.tsx b/apps/web/components/VideoThumbnail.tsx
index b5196e34a..a3c087df2 100644
--- a/apps/web/components/VideoThumbnail.tsx
+++ b/apps/web/components/VideoThumbnail.tsx
@@ -1,11 +1,13 @@
import { LogoSpinner } from "@cap/ui";
+import clsx from "clsx";
import Image from "next/image";
-import { useEffect, useState, memo } from "react";
+import { memo, useEffect, useState } from "react";
interface VideoThumbnailProps {
userId: string;
videoId: string;
alt: string;
+ imageClass?: string;
}
function generateRandomGrayScaleColor() {
@@ -18,7 +20,7 @@ function generateRandomGrayScaleColor() {
}
export const VideoThumbnail: React.FC<VideoThumbnailProps> = memo(
- ({ userId, videoId, alt }) => {
+ ({ userId, videoId, alt, imageClass }) => {
const [imageUrls, setImageUrls] = useState({ screen: "" });
const [loading, setLoading] = useState(true);
const [failed, setFailed] = useState(false);
@@ -47,9 +49,9 @@ export const VideoThumbnail: React.FC<VideoThumbnailProps> = memo(
return (
<div
- className={`aspect-video relative overflow-hidden rounded-tr-lg rounded-tl-lg bg-black`}
+ className={`overflow-hidden relative mx-auto w-full bg-black rounded-2xl max-h-[175px] aspect-video`}
>
- <div className="absolute top-0 left-0 flex items-center justify-center w-full h-full z-10">
+ <div className="flex absolute top-0 left-0 z-10 justify-center items-center w-full h-full">
{failed ? (
<div
className="w-full h-full"
@@ -57,17 +59,17 @@ export const VideoThumbnail: React.FC<VideoThumbnailProps> = memo(
></div>
) : (
loading === true && (
- <LogoSpinner className="w-5 md:w-8 h-auto animate-spin" />
+ <LogoSpinner className="w-5 h-auto animate-spin md:w-8" />
)
)}
</div>
{imageUrls.screen && (
<Image
src={imageUrls.screen}
- alt={alt}
layout="fill"
+ alt={alt}
objectFit="cover"
- className="group-hover:scale-[1.02] transition-all w-full h-full"
+ className={clsx("w-full h-full", imageClass)}
onLoad={() => setLoading(false)}
onError={() => {
setFailed(true);
@@ -75,7 +77,6 @@ export const VideoThumbnail: React.FC<VideoThumbnailProps> = memo(
}}
/>
)}
- <div className="bg-black opacity-0 z-10 absolute top-0 left-0 w-full h-full group-hover:opacity-50 transition-all"></div>
</div>
);
}
diff --git a/packages/ui/src/components/Button.tsx b/packages/ui/src/components/Button.tsx
index a46f3fcd0..922d63f41 100644
--- a/packages/ui/src/components/Button.tsx
+++ b/packages/ui/src/components/Button.tsx
@@ -20,15 +20,15 @@ const buttonVariants = cva(
destructive:
"bg-red-300 text-gray-50 hover:bg-red-400 disabled:bg-red-200 border-red-300",
white:
- "bg-gray-50 text-gray-500 hover:bg-gray-200 border disabled:bg-gray-100 border-gray-200",
+ "bg-gray-50 text-gray-500 hover:bg-gray-100 border disabled:bg-gray-100 border-gray-200",
gray: "bg-gray-200 text-gray-500 hover:bg-gray-200 disabled:bg-gray-100 border-transparent",
dark: "bg-gradient-to-t from-[#0f0f0f] to-[#404040] shadow-[0_0_0_1px] hover:brightness-110 shadow-[#383838] text-gray-50 hover:bg-[#383838] disabled:bg-[#383838] border-transparent",
radialblue:
"text-gray-50 disabled:bg-gray-100 border-0 [background:radial-gradient(90%_100%_at_15%_12%,#9BC4FF_0%,#3588FF_100%)] border-transparent hover:opacity-80",
},
size: {
- xs: "text-[0.75rem] px-[0.5rem] ",
- sm: "text-[0.875rem] h-[40px] px-[0.75rem]",
+ xs: "text-[0.75rem] h-[32px] px-[0.5rem] ",
+ sm: "text-sm h-[40px] px-[0.75rem]",
md: "text-sm px-[1rem] h-[48px]",
lg: "text-md h-[48px] px-[1.25em]",
},
diff --git a/packages/ui/src/components/icons/Logo.tsx b/packages/ui/src/components/icons/Logo.tsx
index 080567004..874b51b32 100644
--- a/packages/ui/src/components/icons/Logo.tsx
+++ b/packages/ui/src/components/icons/Logo.tsx
@@ -14,7 +14,7 @@ export const Logo = ({
const viewBoxDimensions = hideLogoName ? "0 0 40 40" : "0 0 120 40";
return (
- <div className="flex items-center space-x-1">
+ <div className="flex items-center">
<svg
viewBox={viewBoxDimensions}
xmlns="http://www.w3.org/2000/svg"