Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
some more ui stuff
ameer2468d4631f277a3a
diff --git a/Cargo.lock b/Cargo.lockindex 0476f577e..6675ba37b 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1171,7 +1171,7 @@ dependencies = [[[package]]name = "cap-desktop"-version = "0.3.78"+version = "0.3.79"dependencies = ["anyhow","async-stream",diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsxindex 6290a4cc5..0bd54ad09 100644--- a/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx@@ -64,14 +64,11 @@ const Top = () => {"/dashboard/spaces": "Spaces","/dashboard/spaces/browse": "Browse Spaces","/dashboard/analytics": "Analytics",- [`/dashboard/analytics/s/${params.id}`]: "Analytics: cap name",+ [`/dashboard/folder/${params.id}`]: "Caps",+ [`/dashboard/analytics/s/${params.id}`]: "Analytics: Cap video title",};- const title = activeSpace- ? activeSpace.name- : pathname.includes("/dashboard/folder")- ? "Caps"- : titles[pathname] || "";+ const title = activeSpace ? activeSpace.name : titles[pathname] || "";const notificationsRef: MutableRefObject<HTMLDivElement> = useClickAway((e) => {diff --git a/apps/web/app/(org)/dashboard/analytics/components/CompareDataDialog.tsx b/apps/web/app/(org)/dashboard/analytics/components/CompareDataDialog.tsxnew file mode 100644index 000000000..ffa1ba73f--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/CompareDataDialog.tsx@@ -0,0 +1,260 @@+import {+ Button,+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+} from "@cap/ui";+import { faChartSimple } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { LayoutGroup } from "motion/react";+import { useRef, useState } from "react";+import { CompareDataDroppable, type FilterValue } from "./CompareFilters";+import { FiltersList } from "./FiltersList";+import CompareVideos from "./VideoFilters";+import VideosPicker from "./VideosPicker";++export const CompareDataDialog = ({+ open,+ onOpenChange,+}: {+ open: boolean;+ onOpenChange: (open: boolean) => void;+}) => {+ const [droppedItems, setDroppedItems] = useState<{+ compare: string | null;+ compareTwo: string | null;+ }>({+ compare: null,+ compareTwo: null,+ });+ const [droppedVideos, setDroppedVideos] = useState<{+ video1: string | null;+ video2: string | null;+ }>({+ video1: null,+ video2: null,+ });+ const [isDragging, setIsDragging] = useState(false);+ const [isVideoDragging, setIsVideoDragging] = useState(false);+ const [currentDragValue, setCurrentDragValue] = useState<FilterValue | null>(+ null,+ );+ const [currentDragVideo, setCurrentDragVideo] = useState<string | null>(null);++ const FILTERS: readonly FilterValue[] = [+ "views",+ "comments",+ "reactions",+ "shares",+ "downloads",+ "uploads",+ "deletions",+ "creations",+ "edits",+ ] as const;++ const VIDEOS: readonly string[] = [+ "Video A",+ "Video B",+ "Video C",+ "Video D",+ ] as const;++ const [dragPosition, setDragPosition] = useState({ x: 0, y: 0 });+ const [videoDragPosition, setVideoDragPosition] = useState({ x: 0, y: 0 });++ const compareRef = useRef<HTMLDivElement>(null);+ const compareTwoRef = useRef<HTMLDivElement>(null);+ const video1Ref = useRef<HTMLDivElement>(null);+ const video2Ref = useRef<HTMLDivElement>(null);++ const handleDrop = (dropZoneId: "compare" | "compareTwo") => {+ if (currentDragValue) {+ setDroppedItems((prev) => ({+ ...prev,+ [dropZoneId]: currentDragValue,+ }));+ }+ };++ const handleRemoveItem = (dropZoneId: "compare" | "compareTwo") => {+ setDroppedItems((prev) => ({+ ...prev,+ [dropZoneId]: null,+ }));+ };++ const isFilterInUse = (value: string) => {+ return droppedItems.compare === value || droppedItems.compareTwo === value;+ };++ const checkDropZone = (x: number, y: number): string | null => {+ const zones = [+ { id: "compare", ref: compareRef },+ { id: "compareTwo", ref: compareTwoRef },+ ];++ for (const zone of zones) {+ if (zone.ref.current) {+ const rect = zone.ref.current.getBoundingClientRect();+ if (+ x >= rect.left &&+ x <= rect.right &&+ y >= rect.top &&+ y <= rect.bottom+ ) {+ return zone.id;+ }+ }+ }+ return null;+ };++ const handleVideoDrop = (dropZoneId: "video1" | "video2") => {+ if (currentDragVideo) {+ setDroppedVideos((prev) => ({+ ...prev,+ [dropZoneId]: currentDragVideo,+ }));+ }+ };++ const handleRemoveVideo = (dropZoneId: "video1" | "video2") => {+ setDroppedVideos((prev) => ({+ ...prev,+ [dropZoneId]: null,+ }));+ };++ const isVideoInUse = (videoId: string) => {+ return droppedVideos.video1 === videoId || droppedVideos.video2 === videoId;+ };++ const checkVideoDropZone = (x: number, y: number): string | null => {+ const zones = [+ { id: "video1", ref: video1Ref },+ { id: "video2", ref: video2Ref },+ ];++ for (const zone of zones) {+ if (zone.ref.current) {+ const rect = zone.ref.current.getBoundingClientRect();+ if (+ x >= rect.left &&+ x <= rect.right &&+ y >= rect.top &&+ y <= rect.bottom+ ) {+ return zone.id;+ }+ }+ }+ return null;+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-[766px]">+ <DialogHeader+ description="Visualize data comparisons between each other"+ icon={<FontAwesomeIcon icon={faChartSimple} />}+ >+ <DialogTitle>Compare data</DialogTitle>+ </DialogHeader>+ <LayoutGroup>+ <div className="flex flex-1 w-full h-full">+ <FiltersList+ filters={FILTERS}+ isFilterInUse={isFilterInUse}+ onFilterDragStart={(value) => {+ setIsDragging(true);+ setCurrentDragValue(value);+ }}+ onFilterDragEnd={(x, y) => {+ setIsDragging(false);+ const dropZone = checkDropZone(x, y);+ if (dropZone) {+ handleDrop(dropZone as "compare" | "compareTwo");+ }+ setCurrentDragValue(null);+ }}+ onFilterDrag={(x, y) => setDragPosition({ x, y })}+ />+ {/*Main side*/}+ <div className="flex flex-col flex-1 h-full">+ <div className="border-b border-gray-4 bg-gray-3">+ <p className="px-4 py-2 text-xs font-medium text-gray-12 will-change-auto">+ Analysis+ </p>+ </div>+ <div className="flex flex-col flex-1 gap-5 justify-between p-4">+ <div className="space-y-5">+ <div className="flex justify-evenly items-end px-4 py-3 w-full rounded-full border bg-gray-3 border-gray-5">+ <div className="flex flex-1 gap-2 items-center border-r border-gray-6">+ <p className="text-[13px] font-medium text-gray-11 will-change-auto">+ Compare+ </p>+ {/* biome-ignore lint: Static ID for drop zone identification */}+ <CompareDataDroppable+ id="compare"+ ref={compareRef}+ droppedValue={droppedItems.compare}+ onRemove={() => handleRemoveItem("compare")}+ isDragging={isDragging}+ dragPosition={dragPosition}+ />+ </div>+ <div className="flex flex-1 gap-2 justify-end items-center">+ <p className="text-[13px] font-medium text-gray-11 will-change-auto">+ with+ </p>+ {/* biome-ignore lint: Static ID for drop zone identification */}+ <CompareDataDroppable+ id="compareTwo"+ ref={compareTwoRef}+ droppedValue={droppedItems.compareTwo}+ onRemove={() => handleRemoveItem("compareTwo")}+ isDragging={isDragging}+ dragPosition={dragPosition}+ />+ </div>+ </div>+ <VideosPicker+ droppedVideos={droppedVideos}+ onRemoveVideo={handleRemoveVideo}+ isDragging={isVideoDragging}+ dragPosition={videoDragPosition}+ video1Ref={video1Ref}+ video2Ref={video2Ref}+ />+ </div>+ <Button className="w-full" size="sm" variant="dark">+ Compare+ </Button>+ </div>+ </div>+ {/*Videos Picker*/}+ <CompareVideos+ videos={VIDEOS}+ isVideoInUse={isVideoInUse}+ onVideoDragStart={(videoId) => {+ setIsVideoDragging(true);+ setCurrentDragVideo(videoId);+ }}+ onVideoDragEnd={(x, y) => {+ setIsVideoDragging(false);+ const dropZone = checkVideoDropZone(x, y);+ if (dropZone) {+ handleVideoDrop(dropZone as "video1" | "video2");+ }+ setCurrentDragVideo(null);+ }}+ onVideoDrag={(x, y) => setVideoDragPosition({ x, y })}+ />+ </div>+ </LayoutGroup>+ </DialogContent>+ </Dialog>+ );+};diff --git a/apps/web/app/(org)/dashboard/analytics/components/CompareFilters.tsx b/apps/web/app/(org)/dashboard/analytics/components/CompareFilters.tsxnew file mode 100644index 000000000..fa5c35609--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/CompareFilters.tsx@@ -0,0 +1,193 @@+"use client";++import { faXmark } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import clsx from "clsx";+import { motion, useDragControls, useMotionValue } from "motion/react";+import React, { useEffect, useRef, useState } from "react";++const filterColorMap = {+ views: "bg-blue-300",+ comments: "bg-green-300",+ reactions: "bg-red-300",+ shares: "bg-yellow-300",+ downloads: "bg-purple-300",+ uploads: "bg-pink-300",+ deletions: "bg-gray-300",+ creations: "bg-orange-300",+ edits: "bg-teal-300",+} as const;++const labelMap = {+ views: "Views",+ comments: "Comments",+ reactions: "Reactions",+ shares: "Shares",+ downloads: "Downloads",+ uploads: "Uploads",+ deletions: "Deletions",+ creations: "Creations",+ edits: "Edits",+} as const;++export type FilterValue = keyof typeof filterColorMap;++interface CompareDataFilterItemProps {+ label: string;+ value: FilterValue;+ isInUse: boolean;+ onDragStart: () => void;+ onDragEnd: (x: number, y: number) => void;+ onDrag: (x: number, y: number) => void;+}++export const CompareDataFilterItem = ({+ label,+ value,+ isInUse,+ onDragStart,+ onDragEnd,+ onDrag,+}: CompareDataFilterItemProps) => {+ const controls = useDragControls();+ const x = useMotionValue(0);+ const y = useMotionValue(0);+ const elementRef = useRef<HTMLDivElement>(null);++ const handleDragEnd = () => {+ if (elementRef.current) {+ const rect = elementRef.current.getBoundingClientRect();+ const centerX = rect.left + rect.width / 2;+ const centerY = rect.top + rect.height / 2;+ onDragEnd(centerX, centerY);+ }+ };++ const handleDrag = () => {+ if (elementRef.current) {+ const rect = elementRef.current.getBoundingClientRect();+ const centerX = rect.left + rect.width / 2;+ const centerY = rect.top + rect.height / 2;+ onDrag(centerX, centerY);+ }+ };++ if (isInUse) {+ return null;+ }++ return (+ <motion.div+ ref={elementRef}+ layoutId={`filter-${value}`}+ drag+ dragControls={controls}+ dragSnapToOrigin+ onPointerDown={(e) => controls.start(e)}+ onDragStart={onDragStart}+ onDrag={handleDrag}+ style={{+ x,+ y,+ touchAction: "none",+ }}+ layout="position"+ initial={{ opacity: 0, scale: 0.8 }}+ animate={{ opacity: 1, scale: 1, x: 0, y: 0 }}+ exit={{ opacity: 0, scale: 0.8 }}+ transition={{+ layout: {+ type: "spring",+ stiffness: 600,+ damping: 35,+ mass: 0.8,+ },+ opacity: { duration: 0.15, ease: "easeInOut" },+ scale: { duration: 0.15, ease: "easeInOut" },+ x: { type: "spring", stiffness: 600, damping: 35 },+ y: { type: "spring", stiffness: 600, damping: 35 },+ }}+ onDragEnd={handleDragEnd}+ className={clsx(+ "flex-1 px-2 h-6 rounded-full cursor-grab active:cursor-grabbing max-w-fit min-w-fit",+ filterColorMap[value as keyof typeof filterColorMap] ?? "bg-gray-5",+ )}+ >+ <p className="text-[11px] font-medium text-black">{label}</p>+ </motion.div>+ );+};++interface CompareDataDroppableProps {+ id: string;+ droppedValue: string | null;+ onRemove: () => void;+ isDragging: boolean;+ dragPosition: { x: number; y: number };+}++export const CompareDataDroppable = React.forwardRef<+ HTMLDivElement,+ CompareDataDroppableProps+>(({ droppedValue, onRemove, isDragging, dragPosition }, ref) => {+ const [isOver, setIsOver] = useState(false);++ useEffect(() => {+ if (!isDragging) {+ setIsOver(false);+ return;+ }++ const checkIsOver = () => {+ if (ref && typeof ref !== "function" && ref.current) {+ const rect = ref.current.getBoundingClientRect();+ const over =+ dragPosition.x >= rect.left &&+ dragPosition.x <= rect.right &&+ dragPosition.y >= rect.top &&+ dragPosition.y <= rect.bottom;+ setIsOver(over);+ }+ };++ checkIsOver();+ }, [isDragging, dragPosition, ref]);++ return (+ <div+ ref={ref}+ className={clsx(+ "h-6 w-[100px] transition-all border rounded-full file:flex items-center",+ isDragging && !isOver && !droppedValue+ ? "bg-gray-5 border-gray-11"+ : isOver && isDragging+ ? "bg-transparent border-blue-500"+ : !droppedValue+ ? "border-dashed border-gray-7"+ : "border-transparent",+ )}+ >+ {droppedValue && (+ <div+ className={clsx(+ "flex items-center justify-between gap-1.5 px-2 h-6 rounded-full",+ filterColorMap[droppedValue as keyof typeof filterColorMap] ??+ "bg-gray-5",+ )}+ >+ <p className="text-[11px] font-medium text-black">+ {labelMap[droppedValue as keyof typeof labelMap] ?? droppedValue}+ </p>+ <button+ type="button"+ onClick={onRemove}+ className="flex justify-center items-center h-full text-black transition-colors cursor-pointer hover:text-gray-700"+ aria-label="Remove filter"+ >+ <FontAwesomeIcon icon={faXmark} className="text-black size-3" />+ </button>+ </div>+ )}+ </div>+ );+});diff --git a/apps/web/app/(org)/dashboard/analytics/components/FiltersList.tsx b/apps/web/app/(org)/dashboard/analytics/components/FiltersList.tsxnew file mode 100644index 000000000..54302d0f1--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/FiltersList.tsx@@ -0,0 +1,57 @@+"use client";++import { AnimatePresence, motion } from "motion/react";+import { CompareDataFilterItem, type FilterValue } from "./CompareFilters";++interface FiltersListProps {+ filters: readonly FilterValue[];+ isFilterInUse: (value: FilterValue) => boolean;+ onFilterDragStart: (value: FilterValue) => void;+ onFilterDragEnd: (x: number, y: number) => void;+ onFilterDrag: (x: number, y: number) => void;+}++const FILTER_LABELS: Record<FilterValue, string> = {+ views: "Views",+ comments: "Comments",+ reactions: "Reactions",+ shares: "Shares",+ downloads: "Downloads",+ uploads: "Uploads",+ deletions: "Deletions",+ creations: "Creations",+ edits: "Edits",+};++export const FiltersList = ({+ filters,+ isFilterInUse,+ onFilterDragStart,+ onFilterDragEnd,+ onFilterDrag,+}: FiltersListProps) => {+ return (+ <div className="max-w-[172px] w-full border-r border-gray-4 flex-1">+ <div className="border-b border-gray-4 bg-gray-3">+ <p className="px-4 py-2 text-xs font-medium text-gray-12 will-change-auto">+ Filters+ </p>+ </div>+ <motion.div layout className="flex p-4 flex-wrap gap-1.5 h-fit w-full">+ <AnimatePresence mode="popLayout">+ {filters.map((filter) => (+ <CompareDataFilterItem+ key={filter}+ label={FILTER_LABELS[filter]}+ value={filter}+ isInUse={isFilterInUse(filter)}+ onDragStart={() => onFilterDragStart(filter)}+ onDragEnd={onFilterDragEnd}+ onDrag={onFilterDrag}+ />+ ))}+ </AnimatePresence>+ </motion.div>+ </div>+ );+};diff --git a/apps/web/app/(org)/dashboard/analytics/components/Header.tsx b/apps/web/app/(org)/dashboard/analytics/components/Header.tsxindex 56775a4e0..637302b3e 100644--- a/apps/web/app/(org)/dashboard/analytics/components/Header.tsx+++ b/apps/web/app/(org)/dashboard/analytics/components/Header.tsx@@ -1,32 +1,48 @@"use client";-import { Select } from "@cap/ui";+import { Button, Select } from "@cap/ui";+import { useState } from "react";+import { CompareDataDialog } from "./CompareDataDialog";export default function Header() {+ const [openCompareDataDialog, setOpenCompareDataDialog] = useState(false);return (- <div className="flex gap-2 items-center">- <Select- variant="dark"- size="fit"- options={[- { value: "views", label: "Views" },- { value: "comments", label: "Comments" },- { value: "reactions", label: "Reactions" },- ]}- onValueChange={() => {}}- placeholder="Metric"+ <>+ <CompareDataDialog+ open={openCompareDataDialog}+ onOpenChange={setOpenCompareDataDialog}/>- <Select- variant="dark"- size="fit"- options={[- { value: "24_hours", label: "24 hours" },- { value: "7_days", label: "7 days" },- { value: "30_days", label: "30 days" },- ]}- onValueChange={() => {}}- placeholder="Time range"- />- </div>+ <div className="flex gap-2 items-center">+ <Select+ variant="dark"+ size="fit"+ options={[+ { value: "views", label: "Views" },+ { value: "comments", label: "Comments" },+ { value: "reactions", label: "Reactions" },+ ]}+ onValueChange={() => {}}+ placeholder="Metric"+ />+ <Select+ variant="dark"+ size="fit"+ options={[+ { value: "24_hours", label: "24 hours" },+ { value: "7_days", label: "7 days" },+ { value: "30_days", label: "30 days" },+ ]}+ onValueChange={() => {}}+ placeholder="Time range"+ />+ <Button+ size="sm"+ variant="white"+ onClick={() => setOpenCompareDataDialog(true)}+ >+ Compare data+ </Button>+ </div>+ </>);}diff --git a/apps/web/app/(org)/dashboard/analytics/components/OtherStats.tsx b/apps/web/app/(org)/dashboard/analytics/components/OtherStats.tsxindex d986c1c34..aff9033a7 100644--- a/apps/web/app/(org)/dashboard/analytics/components/OtherStats.tsx+++ b/apps/web/app/(org)/dashboard/analytics/components/OtherStats.tsx@@ -23,7 +23,7 @@ export interface OtherStatsData {browsers: BrowserRowData[];operatingSystems: OSRowData[];deviceTypes: DeviceRowData[];- topCaps: CapRowData[];+ topCaps?: CapRowData[] | null;}interface OtherStatsProps {@@ -97,20 +97,22 @@ export default function OtherStats({ data }: OtherStatsProps) {/></div></OtherStatBox>- <OtherStatBox- className="col-span-2"- title="Top Caps"- icon={faRecordVinyl}- >- <div className="flex flex-col flex-1 gap-5 justify-center w-full">- <TableCard- title="Caps"- columns={["Cap", "Views", "Comments", "Reactions", "Percentage"]}- rows={data.topCaps}- type="cap"- />- </div>- </OtherStatBox>+ {data.topCaps && (+ <OtherStatBox+ className="col-span-2"+ title="Top Caps"+ icon={faRecordVinyl}+ >+ <div className="flex flex-col flex-1 gap-5 justify-center w-full">+ <TableCard+ title="Caps"+ columns={["Cap", "Views", "Comments", "Reactions", "Percentage"]}+ rows={data.topCaps}+ type="cap"+ />+ </div>+ </OtherStatBox>+ )}</div>);}diff --git a/apps/web/app/(org)/dashboard/analytics/components/VideoComponents.tsx b/apps/web/app/(org)/dashboard/analytics/components/VideoComponents.tsxnew file mode 100644index 000000000..89d26f869--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/VideoComponents.tsx@@ -0,0 +1,161 @@+"use client";++import { faXmark } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import clsx from "clsx";+import { motion, useDragControls, useMotionValue } from "motion/react";+import React, { useEffect, useRef, useState } from "react";++export type VideoValue = string; // Can be video IDs in the future++interface DraggableVideoItemProps {+ videoId: string;+ isInUse: boolean;+ onDragStart: () => void;+ onDragEnd: (x: number, y: number) => void;+ onDrag: (x: number, y: number) => void;+}++export const DraggableVideoItem = ({+ videoId,+ isInUse,+ onDragStart,+ onDragEnd,+ onDrag,+}: DraggableVideoItemProps) => {+ const controls = useDragControls();+ const x = useMotionValue(0);+ const y = useMotionValue(0);+ const elementRef = useRef<HTMLDivElement>(null);++ const handleDragEnd = () => {+ if (elementRef.current) {+ const rect = elementRef.current.getBoundingClientRect();+ const centerX = rect.left + rect.width / 2;+ const centerY = rect.top + rect.height / 2;+ onDragEnd(centerX, centerY);+ }+ };++ const handleDrag = () => {+ if (elementRef.current) {+ const rect = elementRef.current.getBoundingClientRect();+ const centerX = rect.left + rect.width / 2;+ const centerY = rect.top + rect.height / 2;+ onDrag(centerX, centerY);+ }+ };++ if (isInUse) {+ return null;+ }++ return (+ <motion.div+ ref={elementRef}+ layoutId={`video-${videoId}`}+ drag+ dragControls={controls}+ dragSnapToOrigin+ onPointerDown={(e) => controls.start(e)}+ onDragStart={onDragStart}+ onDrag={handleDrag}+ style={{+ x,+ y,+ touchAction: "none",+ }}+ layout="position"+ initial={{ opacity: 0, scale: 0.9 }}+ animate={{ opacity: 1, scale: 1, x: 0, y: 0 }}+ exit={{ opacity: 0, scale: 0.9 }}+ transition={{+ layout: {+ type: "spring",+ stiffness: 600,+ damping: 35,+ mass: 0.8,+ },+ opacity: { duration: 0.15, ease: "easeInOut" },+ scale: { duration: 0.15, ease: "easeInOut" },+ x: { type: "spring", stiffness: 600, damping: 35 },+ y: { type: "spring", stiffness: 600, damping: 35 },+ }}+ onDragEnd={handleDragEnd}+ className="flex items-center justify-center w-full h-[64px] hover:bg-gray-5 hover:border-gray-7 transition-colors duration-200 rounded-lg bg-gray-4 border border-gray-6 cursor-grab active:cursor-grabbing"+ >+ <p className="text-xs text-gray-11">{videoId}</p>+ </motion.div>+ );+};++interface VideoDroppableProps {+ id: string;+ droppedValue: string | null;+ onRemove: () => void;+ isDragging: boolean;+ dragPosition: { x: number; y: number };+ label: string;+}++export const VideoDroppable = React.forwardRef<+ HTMLDivElement,+ VideoDroppableProps+>(({ droppedValue, onRemove, isDragging, dragPosition, label }, ref) => {+ const [isOver, setIsOver] = useState(false);++ useEffect(() => {+ if (!isDragging) {+ setIsOver(false);+ return;+ }++ const checkIsOver = () => {+ if (ref && typeof ref !== "function" && ref.current) {+ const rect = ref.current.getBoundingClientRect();+ const over =+ dragPosition.x >= rect.left &&+ dragPosition.x <= rect.right &&+ dragPosition.y >= rect.top &&+ dragPosition.y <= rect.bottom;+ setIsOver(over);+ }+ };++ checkIsOver();+ }, [isDragging, dragPosition, ref]);++ return (+ <div+ ref={ref}+ className={clsx(+ "flex flex-1 justify-center items-center h-20 rounded-xl border transition-all",+ isDragging && !isOver && !droppedValue+ ? "bg-gray-5 border-solid border-gray-11"+ : isOver && isDragging+ ? "bg-gray-4 border-blue-500 border-solid"+ : !droppedValue+ ? "border-dashed border-gray-6 bg-gray-3"+ : "border-solid border-gray-5 bg-gray-3",+ )}+ >+ {droppedValue ? (+ <div className="flex gap-2 justify-between items-center p-3 w-full h-full">+ <p className="text-xs text-gray-11">{droppedValue}</p>+ <button+ type="button"+ onClick={onRemove}+ className="flex justify-center items-center rounded-full transition-colors cursor-pointer size-6 bg-gray-5 text-gray-11 hover:bg-gray-6 hover:text-gray-12"+ aria-label="Remove video"+ >+ <FontAwesomeIcon icon={faXmark} className="size-3" />+ </button>+ </div>+ ) : (+ <p className="text-xs text-gray-11">{label}</p>+ )}+ </div>+ );+});++VideoDroppable.displayName = "VideoDroppable";diff --git a/apps/web/app/(org)/dashboard/analytics/components/VideoFilters.tsx b/apps/web/app/(org)/dashboard/analytics/components/VideoFilters.tsxnew file mode 100644index 000000000..5f63e5b9f--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/VideoFilters.tsx@@ -0,0 +1,44 @@+"use client";++import { AnimatePresence, motion } from "motion/react";+import { DraggableVideoItem } from "./VideoComponents";++interface VideoFiltersProps {+ videos: readonly string[];+ isVideoInUse: (videoId: string) => boolean;+ onVideoDragStart: (videoId: string) => void;+ onVideoDragEnd: (x: number, y: number) => void;+ onVideoDrag: (x: number, y: number) => void;+}++export default function VideoFilters({+ videos,+ isVideoInUse,+ onVideoDragStart,+ onVideoDragEnd,+ onVideoDrag,+}: VideoFiltersProps) {+ return (+ <div className="max-w-[160px] w-full border-l border-gray-4">+ <div className="border-b border-gray-4 bg-gray-3">+ <p className="px-4 py-2 text-xs font-medium text-gray-12 will-change-auto">+ Videos+ </p>+ </div>+ <motion.div layout className="grid grid-cols-2 gap-2 p-4 h-fit">+ <AnimatePresence mode="popLayout">+ {videos.map((videoId) => (+ <DraggableVideoItem+ key={videoId}+ videoId={videoId}+ isInUse={isVideoInUse(videoId)}+ onDragStart={() => onVideoDragStart(videoId)}+ onDragEnd={onVideoDragEnd}+ onDrag={onVideoDrag}+ />+ ))}+ </AnimatePresence>+ </motion.div>+ </div>+ );+}diff --git a/apps/web/app/(org)/dashboard/analytics/components/VideosPicker.tsx b/apps/web/app/(org)/dashboard/analytics/components/VideosPicker.tsxnew file mode 100644index 000000000..aac2c7176--- /dev/null+++ b/apps/web/app/(org)/dashboard/analytics/components/VideosPicker.tsx@@ -0,0 +1,55 @@+"use client";++import { faRightLeft } from "@fortawesome/free-solid-svg-icons";+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import type React from "react";+import { VideoDroppable } from "./VideoComponents";++interface VideosPickerProps {+ droppedVideos: {+ video1: string | null;+ video2: string | null;+ };+ onRemoveVideo: (slotId: "video1" | "video2") => void;+ isDragging: boolean;+ dragPosition: { x: number; y: number };+ video1Ref: React.RefObject<HTMLDivElement | null>;+ video2Ref: React.RefObject<HTMLDivElement | null>;+}++export default function VideosPicker({+ droppedVideos,+ onRemoveVideo,+ isDragging,+ dragPosition,+ video1Ref,+ video2Ref,+}: VideosPickerProps) {+ return (+ <div className="flex gap-4 items-center">+ {/* biome-ignore lint: Static ID for drop zone identification */}+ <VideoDroppable+ id="video1"+ ref={video1Ref}+ droppedValue={droppedVideos.video1}+ onRemove={() => onRemoveVideo("video1")}+ isDragging={isDragging}+ dragPosition={dragPosition}+ label="Video 1"+ />+ <div className="flex justify-center items-center rounded-full size-8 bg-gray-12">+ <FontAwesomeIcon icon={faRightLeft} className="size-2.5 text-gray-1" />+ </div>+ {/* biome-ignore lint: Static ID for drop zone identification */}+ <VideoDroppable+ id="video2"+ ref={video2Ref}+ droppedValue={droppedVideos.video2}+ onRemove={() => onRemoveVideo("video2")}+ isDragging={isDragging}+ dragPosition={dragPosition}+ label="Video 2"+ />+ </div>+ );+}diff --git a/apps/web/app/(org)/dashboard/analytics/s/[id]/page.tsx b/apps/web/app/(org)/dashboard/analytics/s/[id]/page.tsxindex 702eca87f..2ecb23c04 100644--- a/apps/web/app/(org)/dashboard/analytics/s/[id]/page.tsx+++ b/apps/web/app/(org)/dashboard/analytics/s/[id]/page.tsx@@ -1,4 +1,5 @@import Header from "../../components/Header";+import OtherStats, { type OtherStatsData } from "../../components/OtherStats";import StatsChart from "../../components/StatsChart";export default function AnalyticsPage() {@@ -13,6 +14,124 @@ export default function AnalyticsPage() {}}defaultSelectedBox="views"/>+ <OtherStats data={mockData} /></div>);}++const mockData: OtherStatsData = {+ countries: [+ {+ countryCode: "US",+ name: "United States",+ views: "8,452",+ comments: "100",+ reactions: "100",+ percentage: "34.2%",+ },+ {+ countryCode: "GB",+ name: "United Kingdom",+ views: "3,891",+ comments: "100",+ reactions: "100",+ percentage: "15.7%",+ },+ {+ countryCode: "CA",+ name: "Canada",+ views: "2,764",+ comments: "100",+ reactions: "100",+ percentage: "11.2%",+ },+ {+ countryCode: "DE",+ name: "Germany",+ views: "2,143",+ comments: "100",+ reactions: "100",+ percentage: "8.7%",+ },+ {+ countryCode: "FR",+ name: "France",+ views: "1,876",+ comments: "100",+ reactions: "100",+ percentage: "7.6%",+ },+ {+ countryCode: "AU",+ name: "Australia",+ views: "1,542",+ comments: "100",+ reactions: "100",+ percentage: "6.2%",+ },+ ],+ cities: [+ {+ countryCode: "US",+ name: "New York",+ views: "3,421",+ comments: "100",+ reactions: "100",+ percentage: "18.7%",+ },+ {+ countryCode: "US",+ name: "Los Angeles",+ views: "2,876",+ comments: "100",+ reactions: "100",+ percentage: "15.7%",+ },+ {+ countryCode: "GB",+ name: "London",+ views: "2,145",+ comments: "100",+ reactions: "100",+ percentage: "11.7%",+ },+ {+ countryCode: "CA",+ name: "Toronto",+ views: "1,892",+ comments: "100",+ reactions: "100",+ percentage: "10.3%",+ },+ ],+ browsers: [+ {+ browser: "google-chrome",+ name: "Chrome",+ views: "8,452",+ comments: "100",+ reactions: "100",+ percentage: "34.2%",+ },+ ],+ operatingSystems: [+ {+ os: "windows",+ name: "Windows",+ views: "8,452",+ comments: "100",+ reactions: "100",+ percentage: "34.2%",+ },+ ],+ deviceTypes: [+ {+ device: "desktop",+ name: "Desktop",+ views: "8,452",+ comments: "100",+ reactions: "100",+ percentage: "34.2%",+ },+ ],+};diff --git a/apps/web/package.json b/apps/web/package.jsonindex b471f866a..e35a5c9a8 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -26,6 +26,8 @@"@cap/web-backend": "workspace:*","@cap/web-domain": "workspace:*","@deepgram/sdk": "^3.3.4",+ "@dnd-kit/core": "^6.3.1",+ "@dnd-kit/utilities": "^3.2.2","@dub/analytics": "^0.0.27","@effect/cluster": "^0.50.4","@effect/experimental": "^0.56.0",diff --git a/packages/ui/src/components/Button.tsx b/packages/ui/src/components/Button.tsxindex 3e64fc3c3..0ea1c1448 100644--- a/packages/ui/src/components/Button.tsx+++ b/packages/ui/src/components/Button.tsx@@ -21,7 +21,7 @@ const buttonVariants = cva(outline:"border border-gray-4 hover:border-gray-5 hover:bg-gray-3 text-gray-12 disabled:bg-gray-8",white:- "bg-gray-1 border border-gray-5 text-gray-12 hover:bg-gray-3 disabled:bg-gray-8",+ "bg-gray-3 border border-gray-5 hover:border-gray-6 text-gray-12 hover:bg-gray-6 disabled:bg-gray-8",ghost: "hover:bg-white/20 hover:text-white",gray: "bg-gray-5 hover:bg-gray-7 border gray-button-border gray-button-shadow text-gray-12 disabled:border-gray-7 disabled:bg-gray-8 disabled:text-gray-11",dark: "bg-gray-12 dark-button-shadow hover:bg-gray-11 border dark-button-border text-gray-1 disabled:cursor-not-allowed disabled:text-gray-10 disabled:bg-gray-7 disabled:border-gray-8",diff --git a/packages/ui/src/components/Select.tsx b/packages/ui/src/components/Select.tsxindex 8c38dc006..0840309ce 100644--- a/packages/ui/src/components/Select.tsx+++ b/packages/ui/src/components/Select.tsx@@ -11,7 +11,7 @@ const SelectVariantContext = React.createContext<SelectVariant>("default");const selectTriggerVariants = cva(cx(- "font-medium flex px-4 py-2 transition-all duration-200 text-[13px] outline-0",+ "font-medium flex px-4 py-2 transition-all duration-200 text-sm outline-0","rounded-xl border-[1px] items-center justify-between gap-2 whitespace-nowrap","disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-gray-3 disabled:text-gray-9","ring-0 ring-gray-12 ring-offset-0 data-[state=open]:ring-offset-2 ring-offset-gray-1 data-[state=open]:ring-1",@@ -122,7 +122,7 @@ function Select({{...props}><SelectTrigger variant={variant} size={size} className={className}>- <SelectValue placeholder={placeholder} />+ <SelectValue className="text-sm" placeholder={placeholder} /></SelectTrigger><SelectContent className="mt-2" variant={variant}>{options.map((option) => (@@ -223,7 +223,7 @@ function SelectLabel({return (<SelectPrimitive.Labeldata-slot="select-label"- className={cx("text-gray-10 px-3 py-1.5 text-xs", className)}+ className={cx("text-gray-10 px-3 py-1.5 text-sm", className)}{...props}/>);diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a696b8595..3ac2a81c1 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -19,7 +19,7 @@ importers:version: 0.44.0dotenv-cli:specifier: latest- version: 10.0.0+ version: 11.0.0tsdown:specifier: ^0.15.6version: 0.15.6([email protected])@@ -471,6 +471,12 @@ importers:'@deepgram/sdk':specifier: ^3.3.4version: 3.13.0([email protected])+ '@dnd-kit/core':+ specifier: ^6.3.1+ '@dnd-kit/utilities':+ specifier: ^3.2.2+ version: 3.2.2([email protected])'@dub/analytics':specifier: ^0.0.27version: 0.0.27@@ -1051,7 +1057,7 @@ importers:version: 19.1.9(@types/[email protected])dotenv-cli:specifier: latest- version: 10.0.0+ version: 11.0.0drizzle-kit:specifier: 0.31.0version: 0.31.0@@ -2230,6 +2236,22 @@ packages:resolution: {integrity: sha512-KrkT6qO5NxqNfy68sBl6CTSoJ4SNDIS5iQArkibhlbGU4LaDukZ3q2HIkh8aUKDio6o4itU4xDR7t82Y2eP1Bg==}engines: {node: '>=14'}+ '@dnd-kit/[email protected]':+ resolution: {integrity: sha512-2P+YgaXF+gRsIihwwY1gCsQSYnu9Zyj2py8kY5fFvUM1qm2WA2u639R6YNVfU4GWr+ZM5mqEsfHZZLoRONbemw==}+ peerDependencies:+ react: '>=16.8.0'++ '@dnd-kit/[email protected]':+ resolution: {integrity: sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==}+ peerDependencies:+ react: '>=16.8.0'+ react-dom: '>=16.8.0'++ '@dnd-kit/[email protected]':+ resolution: {integrity: sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg==}+ peerDependencies:+ react: '>=16.8.0'+'@drizzle-team/[email protected]':resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==}@@ -6518,10 +6540,10 @@ packages:react-dom:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-Vp1xN+h7BKQ6k+zE2LHExfE65yL2d2q9TiVrIHJ2O7dukVkd5UYBOS9CLVenidgfbFRzt2hUQPLLKhTjJLwMmA==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-ipGNG3YeYnSsnnWyKJKQUv6On8OIK8Vk7Pr51rA4BDH8Jw1zI5ulSd2zTCu6iCCH2G26KrMoXaoZ49rrJ1XEdw==}peerDependencies:- storybook: ^10.0.0-rc.2+ storybook: ^10.1.0-alpha.0vite: ^5.0.0 || ^6.0.0 || ^7.0.0'@storybook/[email protected]':@@ -6532,12 +6554,12 @@ packages:prettier:optional: true- '@storybook/[email protected]':- resolution: {integrity: sha512-GCAlUdEbcdwaDT4JL8N/Dv0w3ZMNf80tdiFC26PMK+UZBBd9DKyEJfDTd2NLSzDXEG1DGRUKJymDec8ocFFqxQ==}+ '@storybook/[email protected]':+ resolution: {integrity: sha512-UKvA8vmGf7De9YCMsR5FRZ5J4jlTKwebheCopni3nCTn744Y9k2JmucdzfBTXIwwEl6SSuAnNc6eIKzUdSM0KQ==}peerDependencies:esbuild: '*'rollup: '*'- storybook: ^10.0.0-rc.2+ storybook: ^10.1.0-alpha.0vite: '*'webpack: '*'peerDependenciesMeta:@@ -9104,10 +9126,18 @@ packages:resolution: {integrity: sha512-lnOnttzfrzkRx2echxJHQRB6vOAMSCzzZg79IxpC00tU42wZPuZkQxNNrrwVAxaQZIIh001l4PxVlCrBxngBzA==}hasBin: true+ resolution: {integrity: sha512-r5pA8idbk7GFWuHEU7trSTflWcdBpQEK+Aw17UrSHjS6CReuhrrPcyC3zcQBPQvhArRHnBo/h6eLH1fkCvNlww==}+ hasBin: true+resolution: {integrity: sha512-zIHwmZPRshsCdpMDyVsqGmgyP0yT8GAgXUnkdAoJisxvf33k7yO6OuoKmcTGuXPWSsm8Oh88nZicRLA9Y0rUeA==}engines: {node: '>=12'}+ resolution: {integrity: sha512-uc47g4b+4k/M/SeaW1y4OApx+mtLWl92l5LMPP0GNXctZqELk+YGgOPIIC5elYmUH4OuoK3JLhuRUYegeySiFA==}+ engines: {node: '>=12'}+resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}engines: {node: '>=12'}@@ -16782,6 +16812,24 @@ snapshots:gonzales-pe: 4.3.0node-source-walk: 6.0.2+ '@dnd-kit/[email protected]([email protected])':+ dependencies:+ react: 19.1.1+ tslib: 2.8.1++ dependencies:+ '@dnd-kit/accessibility': 3.1.1([email protected])+ '@dnd-kit/utilities': 3.2.2([email protected])+ react: 19.1.1+ react-dom: 19.1.1([email protected])+ tslib: 2.8.1++ '@dnd-kit/[email protected]([email protected])':+ dependencies:+ react: 19.1.1+ tslib: 2.8.1+'@drizzle-team/[email protected]': {}'@dub/[email protected]':@@ -21212,9 +21260,9 @@ snapshots:react: 19.1.1react-dom: 19.1.1([email protected])- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':dependencies:- '@storybook/csf-plugin': 10.0.0-rc.2([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))+ '@storybook/csf-plugin': 10.1.0-alpha.0([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))storybook: 8.6.12([email protected])ts-dedent: 2.2.0@@ -21244,7 +21292,7 @@ snapshots:- supports-color- utf-8-validate- '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':+ '@storybook/[email protected]([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))':dependencies:storybook: 8.6.12([email protected])unplugin: 2.3.10@@ -24114,10 +24162,21 @@ snapshots:dotenv-expand: 11.0.7minimist: 1.2.8+ dependencies:+ cross-spawn: 7.0.6+ dotenv: 17.2.1+ dotenv-expand: 12.0.3+ minimist: 1.2.8+dependencies:dotenv: 16.5.0+ dependencies:+ dotenv: 16.5.0+@@ -29959,7 +30018,7 @@ snapshots:[email protected](@storybook/[email protected]([email protected]([email protected])))([email protected])([email protected])([email protected])([email protected]([email protected]))([email protected](@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected])):dependencies:- '@storybook/builder-vite': 10.0.0-rc.2([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))+ '@storybook/builder-vite': 10.1.0-alpha.0([email protected])([email protected])([email protected]([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]))'@storybook/types': 9.0.0-alpha.1([email protected]([email protected]))magic-string: 0.30.17solid-js: 1.9.6