Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Animated icons (#677)

Ameer Al Ashhab360a83e64224
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/ArrowUp.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/ArrowUp.tsx
new file mode 100644
index 000000000..316a029dd
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/ArrowUp.tsx
@@ -0,0 +1,111 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import type { Variants } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface ArrowUpIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface ArrowUpIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const pathVariants: Variants = {
+ normal: { d: 'm5 12 7-7 7 7', y: 0 },
+ animate: {
+ d: 'm5 12 7-7 7 7',
+ y: [0, 3, 0],
+ transition: {
+ duration: 0.4,
+ },
+ },
+};
+
+const secondPathVariants: Variants = {
+ normal: { d: 'M12 19V5' },
+ animate: {
+ d: ['M12 19V5', 'M12 19V10', 'M12 19V5'],
+ transition: {
+ duration: 0.4,
+ },
+ },
+};
+
+const ArrowUpIcon = forwardRef<ArrowUpIconHandle, ArrowUpIconProps>(
+ ({ 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.path
+ d="m5 12 7-7 7 7"
+ variants={pathVariants}
+ animate={controls}
+ />
+ <motion.path
+ d="M12 19V5"
+ variants={secondPathVariants}
+ animate={controls}
+ />
+ </svg>
+ </div>
+ );
+ }
+);
+
+ArrowUpIcon.displayName = 'ArrowUpIcon';
+
+export { ArrowUpIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cap.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cap.tsx
new file mode 100644
index 000000000..fce936b2c
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cap.tsx
@@ -0,0 +1,92 @@
+'use client';
+
+import { cn } from "@/lib/utils";
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface CapIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface CapIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const CapIcon = forwardRef<CapIconHandle, CapIconProps>(
+ ({ 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}
+ >
+ <motion.svg
+ width={size}
+ height={size}
+ transition={{ type: 'spring', stiffness: 50, damping: 10 }}
+ viewBox="0 0 32 32"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <motion.circle cx="16" cy="16" r="12" fill="none" stroke="currentColor" />
+ <motion.circle
+ initial={{
+ fill: "none",
+ opacity: 0.5,
+ }}
+ variants={{
+ normal: { fill: "none", opacity: 0.5 },
+ animate: { fill: "currentColor", opacity: [0.3, 1, 0.3, 1] },
+ }}
+ animate={controls}
+ transition={{ duration: 0.5, ease: "easeInOut" }}
+ cx="16" cy="16" r="8" fill="none" stroke="currentColor" />
+ </motion.svg>
+ </div>
+ );
+ }
+);
+
+CapIcon.displayName = 'CapIcon';
+
+export { CapIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Chat.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Chat.tsx
new file mode 100644
index 000000000..8d54164ac
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Chat.tsx
@@ -0,0 +1,124 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import type { Variants } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface MessageCircleMoreIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface MessageCircleMoreIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const dotVariants: Variants = {
+ normal: {
+ opacity: 1,
+ },
+ animate: (custom: number) => ({
+ opacity: [1, 0, 0, 1, 1, 0, 0, 1],
+ transition: {
+ opacity: {
+ times: [
+ 0,
+ 0.1,
+ 0.1 + custom * 0.1,
+ 0.1 + custom * 0.1 + 0.1,
+ 0.5,
+ 0.6,
+ 0.6 + custom * 0.1,
+ 0.6 + custom * 0.1 + 0.1,
+ ],
+ duration: 1.5,
+ },
+ },
+ }),
+};
+
+const MessageCircleMoreIcon = forwardRef<
+ MessageCircleMoreIconHandle,
+ MessageCircleMoreIconProps
+>(({ 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"
+ >
+ <path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z" />
+ <motion.path
+ d="M8 12h.01"
+ variants={dotVariants}
+ animate={controls}
+ custom={0}
+ />
+ <motion.path
+ d="M12 12h.01"
+ variants={dotVariants}
+ animate={controls}
+ custom={1}
+ />
+ <motion.path
+ d="M16 12h.01"
+ variants={dotVariants}
+ animate={controls}
+ custom={2}
+ />
+ </svg>
+ </div>
+ );
+});
+
+MessageCircleMoreIcon.displayName = 'MessageCircleMoreIcon';
+
+export { MessageCircleMoreIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cog.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cog.tsx
new file mode 100644
index 000000000..29893e850
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Cog.tsx
@@ -0,0 +1,102 @@
+'use client';
+
+import { cn } from "@/lib/utils";
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface CogIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface CogIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const CogIcon = forwardRef<CogIconHandle, CogIconProps>(
+ ({ 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}
+ >
+ <motion.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"
+ transition={{ type: 'spring', stiffness: 50, damping: 10 }}
+ variants={{
+ normal: {
+ rotate: 0,
+ },
+ animate: {
+ rotate: 180,
+ },
+ }}
+ animate={controls}
+ >
+ <path d="M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z" />
+ <path d="M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
+ <path d="M12 2v2" />
+ <path d="M12 22v-2" />
+ <path d="m17 20.66-1-1.73" />
+ <path d="M11 10.27 7 3.34" />
+ <path d="m20.66 17-1.73-1" />
+ <path d="m3.34 7 1.73 1" />
+ <path d="M14 12h8" />
+ <path d="M2 12h2" />
+ <path d="m20.66 7-1.73 1" />
+ <path d="m3.34 17 1.73-1" />
+ <path d="m17 3.34-1 1.73" />
+ <path d="m11 13.73-4 6.93" />
+ </motion.svg>
+ </div>
+ );
+ }
+);
+
+CogIcon.displayName = 'CogIcon';
+
+export { CogIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Download.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Download.tsx
new file mode 100644
index 000000000..83c1cda6a
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Download.tsx
@@ -0,0 +1,98 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import type { Variants } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface DownloadIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface DownloadIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const arrowVariants: Variants = {
+ normal: { y: 0 },
+ animate: {
+ y: 2,
+ transition: {
+ type: 'spring',
+ stiffness: 200,
+ damping: 10,
+ mass: 1,
+ },
+ },
+};
+
+const DownloadIcon = forwardRef<DownloadIconHandle, DownloadIconProps>(
+ ({ 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"
+ >
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
+ <motion.g variants={arrowVariants} animate={controls}>
+ <polyline points="7 10 12 15 17 10" />
+ <line x1="12" x2="12" y1="15" y2="3" />
+ </motion.g>
+ </svg>
+ </div>
+ );
+ }
+);
+
+DownloadIcon.displayName = 'DownloadIcon';
+
+export { DownloadIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Home.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Home.tsx
new file mode 100644
index 000000000..aff17afd7
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Home.tsx
@@ -0,0 +1,102 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import type { Transition, Variants } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface HomeIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface HomeIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const defaultTransition: Transition = {
+ duration: 0.6,
+ opacity: { duration: 0.2 },
+};
+
+const pathVariants: Variants = {
+ normal: {
+ pathLength: 1,
+ opacity: 1,
+ },
+ animate: {
+ opacity: [0, 1],
+ pathLength: [0, 1],
+ },
+};
+
+const HomeIcon = forwardRef<HomeIconHandle, HomeIconProps>(
+ ({ 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"
+ >
+ <path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
+ <motion.path
+ d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"
+ variants={pathVariants}
+ transition={defaultTransition}
+ animate={controls}
+ />
+ </svg>
+ </div>
+ );
+ }
+);
+
+HomeIcon.displayName = 'HomeIcon';
+
+export { HomeIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Layers.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Layers.tsx
new file mode 100644
index 000000000..e97e0937c
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Layers.tsx
@@ -0,0 +1,112 @@
+'use client';
+
+import { cn } from "@/lib/utils";
+import type { Transition } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface LayersIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface LayersIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const defaultTransition: Transition = {
+ type: 'spring',
+ stiffness: 100,
+ damping: 14,
+ mass: 1,
+};
+
+const LayersIcon = forwardRef<LayersIconHandle, LayersIconProps>(
+ ({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
+ const controls = useAnimation();
+ const isControlledRef = useRef(false);
+
+ useImperativeHandle(ref, () => {
+ isControlledRef.current = true;
+
+ return {
+ startAnimation: async () => {
+ await controls.start('firstState');
+ await controls.start('secondState');
+ },
+ stopAnimation: () => controls.start('normal'),
+ };
+ });
+
+ const handleMouseEnter = useCallback(
+ async (e: React.MouseEvent<HTMLDivElement>) => {
+ if (!isControlledRef.current) {
+ await controls.start('firstState');
+ await controls.start('secondState');
+ } 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"
+ >
+ <path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z" />
+ <motion.path
+ d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"
+ variants={{
+ normal: { y: 0 },
+ firstState: { y: -9 },
+ secondState: { y: 0 },
+ }}
+ animate={controls}
+ transition={defaultTransition}
+ />
+ <motion.path
+ d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"
+ variants={{
+ normal: { y: 0 },
+ firstState: { y: -5 },
+ secondState: { y: 0 },
+ }}
+ animate={controls}
+ transition={defaultTransition}
+ />
+ </svg>
+ </div>
+ );
+ }
+);
+
+LayersIcon.displayName = 'LayersIcon';
+
+export { LayersIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Logout.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Logout.tsx
new file mode 100644
index 000000000..a402ef155
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Logout.tsx
@@ -0,0 +1,103 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import type { Variants } from 'motion/react';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface LogoutIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface LogoutIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const pathVariants: Variants = {
+ animate: {
+ x: [0, -3, 0],
+ transition: {
+ duration: 0.4,
+ },
+ },
+};
+
+const LogoutIcon = forwardRef<LogoutIconHandle, LogoutIconProps>(
+ ({ 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"
+ >
+ <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
+ <motion.polyline
+ points="16 17 21 12 16 7"
+ variants={pathVariants}
+ animate={controls}
+ />
+ <motion.line
+ x1="21"
+ x2="9"
+ y1="12"
+ y2="12"
+ variants={pathVariants}
+ animate={controls}
+ />
+ </svg>
+ </div>
+ );
+ }
+);
+
+LogoutIcon.displayName = 'LogoutIcon';
+
+export { LogoutIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Settings.tsx b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Settings.tsx
new file mode 100644
index 000000000..17c71b0b3
--- /dev/null
+++ b/apps/web/app/(org)/dashboard/_components/AnimatedIcons/Settings.tsx
@@ -0,0 +1,92 @@
+'use client';
+
+import { cn } from '@/lib/utils';
+import { motion, useAnimation } from 'motion/react';
+import type { HTMLAttributes } from 'react';
+import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
+
+export interface SettingsGearIconHandle {
+ startAnimation: () => void;
+ stopAnimation: () => void;
+}
+
+interface SettingsGearIconProps extends HTMLAttributes<HTMLDivElement> {
+ size?: number;
+}
+
+const SettingsGearIcon = forwardRef<
+ SettingsGearIconHandle,
+ SettingsGearIconProps
+>(({ 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}
+ >
+ <motion.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"
+ transition={{ type: 'spring', stiffness: 50, damping: 10 }}
+ variants={{
+ normal: {
+ rotate: 0,
+ },
+ animate: {
+ rotate: 180,
+ },
+ }}
+ animate={controls}
+ >
+ <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
+ <circle cx="12" cy="12" r="3" />
+ </motion.svg>
+ </div>
+ );
+});
+
+SettingsGearIcon.displayName = 'SettingsGearIcon';
+
+export { SettingsGearIcon };
diff --git a/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx b/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
index 63fc8a482..ccf3c58dd 100644
--- a/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
+++ b/apps/web/app/(org)/dashboard/_components/DashboardInner.tsx
@@ -3,34 +3,37 @@
import { UpgradeModal } from "@/components/UpgradeModal";
import { buildEnv } from "@cap/env";
import {
+ Avatar,
Command,
CommandGroup,
CommandItem,
Popover,
PopoverContent,
PopoverTrigger,
- Avatar,
} from "@cap/ui";
+import {
+ faMoon,
+ faSun
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import { MoreVertical } from "lucide-react";
import { signOut } from "next-auth/react";
+import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
-import { useState } from "react";
-import {
- faMoon,
- faSun,
- faHome,
- faCrown,
- faGear,
- faMessage,
- faSignOut,
- faDownload,
-} from "@fortawesome/free-solid-svg-icons";
-import Image from "next/image";
-import { MembersDialog } from "../spaces/[spaceId]/components/MembersDialog";
+import React, { cloneElement, memo, useMemo, useRef, useState } from "react";
import { useDashboardContext, useTheme } from "../Contexts";
+import { MembersDialog } from "../spaces/[spaceId]/components/MembersDialog";
+import { ArrowUpIcon } from "./AnimatedIcons/ArrowUp";
+import { MessageCircleMoreIcon } from "./AnimatedIcons/Chat";
+import { DownloadIcon, DownloadIconHandle } from "./AnimatedIcons/Download";
+import { HomeIcon } from "./AnimatedIcons/Home";
+import { LogoutIcon } from "./AnimatedIcons/Logout";
+import { SettingsGearIcon } from "./AnimatedIcons/Settings";
+
+export const navItemClass =
+ "flex items-center justify-start rounded-xl outline-none tracking-tight overflow-hidden";
export default function DashboardInner({
children,
@@ -53,12 +56,11 @@ export default function DashboardInner({
const title = activeSpace ? activeSpace.name : titles[pathname] || "";
const { theme, setThemeHandler } = useTheme();
const isSharedCapsPage = pathname === "/dashboard/shared-caps";
-
return (
<div className="flex flex-col min-h-screen">
<div
className={clsx(
- "flex sticky z-50 justify-between items-center px-5 mt-10 w-full border-b",
+ "flex sticky z-40 justify-between items-center px-5 mt-10 w-full border-b",
"bg-gray-1 lg:bg-transparent min-h-16 lg:min-h-10 border-gray-3 lg:border-b-0 lg:pl-0 lg:pr-5 lg:top-0 lg:relative top-[64px] lg:mt-5 lg:h-8"
)}
>
@@ -130,6 +132,57 @@ const User = () => {
const [menuOpen, setMenuOpen] = useState(false);
const [upgradeModalOpen, setUpgradeModalOpen] = useState(false);
const { user, isSubscribed } = useDashboardContext();
+
+ const menuItems = useMemo(() => [
+ {
+ name: "Homepage",
+ icon: <HomeIcon />,
+ href: "/home",
+ onClick: () => setMenuOpen(false),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Upgrade to Pro",
+ icon: <ArrowUpIcon />,
+ onClick: () => {
+ setMenuOpen(false);
+ setUpgradeModalOpen(true);
+ },
+ iconClassName: "text-amber-400 group-hover:text-amber-500",
+ showCondition: !isSubscribed && buildEnv.NEXT_PUBLIC_IS_CAP,
+ },
+ {
+ name: "Settings",
+ icon: <SettingsGearIcon />,
+ href: "/dashboard/settings/account",
+ onClick: () => setMenuOpen(false),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Chat Support",
+ icon: <MessageCircleMoreIcon />,
+ onClick: () => window.open("https://cap.link/discord", "_blank"),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Download App",
+ icon: <DownloadIcon />,
+ onClick: () => window.open("https://cap.so/download", "_blank"),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ {
+ name: "Sign Out",
+ icon: <LogoutIcon />,
+ onClick: () => signOut(),
+ iconClassName: "text-gray-11 group-hover:text-gray-12",
+ showCondition: true,
+ },
+ ], []);
+
return (
<>
<UpgradeModal
@@ -171,101 +224,66 @@ const User = () => {
<PopoverContent className="p-1 w-48">
<Command>
<CommandGroup>
- <Link href="/home">
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() => {
- setMenuOpen(false);
- }}
- >
- <FontAwesomeIcon
- icon={faHome}
- className="mr-2 text-gray-11 transition-colors duration-300 size-3.5 group-hover:text-gray-12"
+ {menuItems
+ .filter((item) => item.showCondition)
+ .map((item, index) => (
+ <MenuItem
+ key={index}
+ icon={item.icon}
+ name={item.name}
+ href={item.href ?? "#"}
+ onClick={item.onClick}
+ iconClassName={item.iconClassName}
/>
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Homepage
- </span>
- </CommandItem>
- </Link>
- {!isSubscribed && buildEnv.NEXT_PUBLIC_IS_CAP && (
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() => {
- setMenuOpen(false);
- setUpgradeModalOpen(true);
- }}
- >
- <FontAwesomeIcon
- icon={faCrown}
- className="mr-2 text-amber-400 transition-colors duration-300 size-3.5 group-hover:text-amber-500"
- />
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Upgrade to Pro
- </span>
- </CommandItem>
- )}
- <Link href="/dashboard/settings/account">
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() => {
- setMenuOpen(false);
- }}
- >
- <FontAwesomeIcon
- icon={faGear}
- className="mr-2 text-gray-11 transition-colors duration-300 size-3.5 group-hover:text-gray-12"
- />
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Settings
- </span>
- </CommandItem>
- </Link>
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() =>
- window.open("https://cap.link/discord", "_blank")
- }
- >
- <FontAwesomeIcon
- icon={faMessage}
- className="mr-2 text-gray-11 transition-colors duration-300 size-3.5 group-hover:text-gray-12"
- />
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Chat Support
- </span>
- </CommandItem>
-
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() =>
- window.open("https://cap.so/download", "_blank")
- }
- >
- <FontAwesomeIcon
- icon={faDownload}
- className="mr-2 text-gray-11 transition-colors duration-300 size-3.5 group-hover:text-gray-12"
- />
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Download App
- </span>
- </CommandItem>
-
- <CommandItem
- className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
- onSelect={() => signOut()}
- >
- <FontAwesomeIcon
- icon={faSignOut}
- className="mr-2 text-gray-11 transition-colors duration-300 size-3.5 group-hover:text-gray-12"
- />
- <span className="text-[13px] transition-colors duration-300 text-gray-11 group-hover:text-gray-12">
- Sign Out
- </span>
- </CommandItem>
+ ))}
</CommandGroup>
</Command>
</PopoverContent>
</Popover>
</>
);
-};
+}
+
+interface Props {
+ icon: React.ReactElement;
+ name: string;
+ href?: string;
+ onClick: () => void;
+ iconClassName?: string;
+}
+
+const MenuItem = memo(({ icon, name, href, onClick, iconClassName }: Props) => {
+ const iconRef = useRef<DownloadIconHandle>(null);
+ return (
+ <CommandItem
+ key={name}
+ className="px-2 py-1.5 rounded-lg transition-colors duration-300 cursor-pointer hover:bg-gray-5 group"
+ onSelect={onClick}
+ onMouseEnter={() => {
+ iconRef.current?.startAnimation();
+ }}
+ onMouseLeave={() => {
+ iconRef.current?.stopAnimation();
+ }}
+ >
+ <Link
+ className="flex gap-2 items-center"
+ href={href ?? "#"}
+ onClick={onClick}
+ >
+ {cloneElement(icon, {
+ ref: iconRef,
+ className: iconClassName,
+ size: 14,
+ })}
+ <p
+ className={clsx(
+ "text-sm text-gray-12"
+ )}
+ >
+ {name}
+ </p>
+ </Link>
+ </CommandItem>
+ );
+});
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx
index ff2153f30..53e7e9336 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx
@@ -1,5 +1,10 @@
"use client";
+import { NewOrganization } from "@/components/forms/NewOrganization";
+import { Tooltip } from "@/components/Tooltip";
+import { UsageButton } from "@/components/UsageButton";
+import { buildEnv } from "@cap/env";
import {
+ Avatar,
Button,
Command,
CommandEmpty,
@@ -15,31 +20,23 @@ import {
Popover,
PopoverContent,
PopoverTrigger,
- Avatar,
} from "@cap/ui";
import { classNames } from "@cap/utils";
-import { Check, ChevronDown, Plus } from "lucide-react";
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-
-import { NewOrganization } from "@/components/forms/NewOrganization";
-import { Tooltip } from "@/components/Tooltip";
-import { UsageButton } from "@/components/UsageButton";
-import { buildEnv } from "@cap/env";
-import {
- faBuilding,
- faRecordVinyl,
- IconDefinition,
-} from "@fortawesome/free-solid-svg-icons";
+import { faBuilding } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
import { motion } from "framer-motion";
+import { Check, ChevronDown, Plus } from "lucide-react";
import Image from "next/image";
-
-import { useRef, useState } from "react";
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { cloneElement, useRef, useState } from "react";
+import { useDashboardContext } from "../../Contexts";
+import { CapIcon } from "../AnimatedIcons/Cap";
+import { CogIcon, CogIconHandle } from "../AnimatedIcons/Cog";
import { updateActiveOrganization } from "./server";
import SpacesList from "./SpacesList";
-import { useDashboardContext } from "../../Contexts";
+
interface Props {
toggleMobileNav?: () => void;
@@ -54,28 +51,29 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
const [hoveredItem, setHoveredItem] = useState<string | null>(null);
const { user, sidebarCollapsed } = useDashboardContext();
+
const manageNavigation = [
{
name: "My Caps",
href: `/dashboard/caps`,
- icon: faRecordVinyl,
+ icon: <CapIcon />,
subNav: [],
},
{
name: "Organization Settings",
href: `/dashboard/settings/organization`,
- icon: faBuilding,
+ icon: <CogIcon />,
subNav: [],
},
...(buildEnv.NEXT_PUBLIC_IS_CAP && user.email.endsWith("@cap.so")
? [
- {
- name: "Admin Dev",
- href: "/dashboard/admin",
- icon: faBuilding,
- subNav: [],
- },
- ]
+ {
+ name: "Admin Dev",
+ href: "/dashboard/admin",
+ icon: <CogIcon />,
+ subNav: [],
+ },
+ ]
: []),
];
@@ -306,49 +304,14 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
}}
/>
)}
- <Tooltip
- content={item.name}
- disable={sidebarCollapsed === false}
- position="right"
- >
- <Link
- passHref
- onClick={() => toggleMobileNav?.()}
- onMouseEnter={() => setHoveredItem(item.name)}
- onMouseLeave={() => setHoveredItem(null)}
- prefetch={false}
- href={item.href}
- className={classNames(
- "relative border border-transparent transition z-3",
- sidebarCollapsed
- ? "flex justify-center px-0 items-center w-full size-9"
- : "py-2 w-full px-3",
- isPathActive(item.href)
- ? "bg-transparent pointer-events-none"
- : "hover:bg-gray-2",
- navItemClass
- )}
- >
- <FontAwesomeIcon
- icon={item.icon as IconDefinition}
- className={clsx(
- "flex-shrink-0 transition-colors",
- sidebarCollapsed
- ? "text-gray-12 size-[18px] mx-auto"
- : "text-gray-10 size-3.5"
- )}
- aria-hidden="true"
- />
- <p
- className={clsx(
- "text-sm text-gray-12 truncate",
- sidebarCollapsed ? "hidden" : "ml-2.5"
- )}
- >
- {item.name}
- </p>
- </Link>
- </Tooltip>
+ <NavItem
+ name={item.name}
+ href={item.href}
+ icon={item.icon}
+ sidebarCollapsed={sidebarCollapsed}
+ toggleMobileNav={toggleMobileNav}
+ isPathActive={isPathActive}
+ />
</div>
))}
@@ -401,4 +364,64 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
);
};
+
+const NavItem = ({
+ name,
+ href,
+ icon,
+ sidebarCollapsed,
+ toggleMobileNav,
+ isPathActive,
+}: {
+ name: string;
+ href: string;
+ icon: React.ReactElement;
+ sidebarCollapsed: boolean;
+ toggleMobileNav?: () => void;
+ isPathActive: (path: string) => boolean;
+}) => {
+ const iconRef = useRef<CogIconHandle>(null);
+ return (
+ <Tooltip disable={!sidebarCollapsed} content={name} position="right">
+ <Link
+ href={href}
+ onClick={() => toggleMobileNav?.()}
+ onMouseEnter={() => {
+ iconRef.current?.startAnimation();
+ }}
+ onMouseLeave={() => {
+ iconRef.current?.stopAnimation();
+ }}
+ prefetch={false}
+ passHref
+ className={classNames(
+ "relative border border-transparent transition z-3",
+ sidebarCollapsed
+ ? "flex justify-center items-center px-0 w-full size-9"
+ : "px-3 py-2 w-full",
+ isPathActive(href)
+ ? "bg-transparent pointer-events-none"
+ : "hover:bg-gray-2",
+ navItemClass
+ )}
+ >
+ {cloneElement(icon, {
+ ref: iconRef,
+ className: clsx(sidebarCollapsed ? "text-gray-12 mx-auto" : "text-gray-10"),
+ size: sidebarCollapsed ? 18 : 16,
+ })}
+ <p
+ className={clsx(
+ "text-sm text-gray-12 truncate",
+ sidebarCollapsed ? "hidden" : "ml-2.5"
+ )}
+ >
+ {name}
+ </p>
+ </Link>
+ </Tooltip>
+ )
+}
+
+
export default AdminNavItems;
diff --git a/apps/web/app/(org)/dashboard/_components/Navbar/SpacesList.tsx b/apps/web/app/(org)/dashboard/_components/Navbar/SpacesList.tsx
index 7e0f45bcf..9066aacd6 100644
--- a/apps/web/app/(org)/dashboard/_components/Navbar/SpacesList.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Navbar/SpacesList.tsx
@@ -1,30 +1,30 @@
"use client";
-import { ChevronDown, ChevronUp } from "lucide-react";
-import Link from "next/link";
-import { useState } from "react";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { shareCap } from "@/actions/caps/share";
+import { deleteSpace } from "@/actions/organization/delete-space";
+import { Tooltip } from "@/components/Tooltip";
+import { Avatar, Button } from "@cap/ui";
import {
faLayerGroup,
faPlus,
faXmark,
} from "@fortawesome/free-solid-svg-icons";
-import { deleteSpace } from "@/actions/organization/delete-space";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import clsx from "clsx";
-import SpaceDialog from "./SpaceDialog";
-import { Button, Avatar } from "@cap/ui";
-import { ConfirmationDialog } from "../ConfirmationDialog";
-import { shareCap } from "@/actions/caps/share";
-import { toast } from "sonner";
-import { useParams, usePathname, useRouter } from "next/navigation";
-import { Tooltip } from "@/components/Tooltip";
import { motion } from "framer-motion";
-import { useMemo } from "react";
+import { ChevronDown, ChevronUp } from "lucide-react";
import Image from "next/image";
+import Link from "next/link";
+import { useParams, usePathname, useRouter } from "next/navigation";
+import { useMemo, useRef, useState } from "react";
+import { toast } from "sonner";
+import { ConfirmationDialog } from "../ConfirmationDialog";
+import SpaceDialog from "./SpaceDialog";
-import { navItemClass } from "./Items";
-import { Spaces } from "../../dashboard-data";
import { useDashboardContext } from "../../Contexts";
+import { Spaces } from "../../dashboard-data";
+import { LayersIcon, LayersIconHandle } from "../AnimatedIcons/Layers";
+import { navItemClass } from "./Items";
const SpacesList = ({ toggleMobileNav }: { toggleMobileNav?: () => void }) => {
const { spacesData, sidebarCollapsed, user } = useDashboardContext();
@@ -34,6 +34,7 @@ const SpacesList = ({ toggleMobileNav }: { toggleMobileNav?: () => void }) => {
const router = useRouter();
const params = useParams();
const pathname = usePathname();
+ const layersIconRef = useRef<LayersIconHandle>(null);
const [confirmOpen, setConfirmOpen] = useState(false);
const [pendingDeleteSpace, setPendingDeleteSpace] = useState<Spaces | null>(null);
@@ -168,6 +169,8 @@ const SpacesList = ({ toggleMobileNav }: { toggleMobileNav?: () => void }) => {
passHref
onClick={() => toggleMobileNav?.()}
prefetch={false}
+ onMouseEnter={() => layersIconRef.current?.startAnimation()}
+ onMouseLeave={() => layersIconRef.current?.stopAnimation()}
href="/dashboard/spaces/browse"
className={clsx(
"relative border border-transparent transition z-3",
@@ -180,16 +183,7 @@ const SpacesList = ({ toggleMobileNav }: { toggleMobileNav?: () => void }) => {
navItemClass
)}
>
- <FontAwesomeIcon
- icon={faLayerGroup}
- className={clsx(
- "flex-shrink-0 transition-colors",
- sidebarCollapsed
- ? "text-gray-12 size-[18px] mx-auto"
- : "text-gray-10 size-3.5"
- )}
- aria-hidden="true"
- />
+ <LayersIcon ref={layersIconRef} className={clsx(sidebarCollapsed ? "text-gray-12" : "text-gray-10")} size={sidebarCollapsed ? 18 : 14} />
<p
className={clsx(
"text-sm text-gray-12 truncate",
diff --git a/apps/web/lib/utils.ts b/apps/web/lib/utils.ts
index 106f843f6..ce328065b 100644
--- a/apps/web/lib/utils.ts
+++ b/apps/web/lib/utils.ts
@@ -1,3 +1,6 @@
+import { clsx, type ClassValue } from "clsx";
+import { twMerge } from "tailwind-merge";
+
/**
* Format a date string to a more readable format
* @param dateString - ISO 8601 date string
@@ -10,4 +13,8 @@ export function formatDate(dateString: string): string {
month: "long",
day: "numeric",
});
-}
\ No newline at end of file
+}
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}
diff --git a/apps/web/package.json b/apps/web/package.json
index b8d91eaf8..61eb0e9ac 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -53,7 +53,8 @@
"@virtual-grid/react": "^2.0.3",
"@workos-inc/node": "^7.34.0",
"aws-sdk": "^2.1530.0",
- "clsx": "^2.0.0",
+ "class-variance-authority": "^0.7.0",
+ "clsx": "^2.1.1",
"cookies-next": "^4.1.0",
"date-fns": "^3.2.0",
"dotenv": "^16.3.1",
@@ -70,6 +71,7 @@
"lodash": "^4.17.21",
"lucide-react": "^0.294.0",
"moment": "^2.30.1",
+ "motion": "^12.18.1",
"next": "14.2.3",
"next-auth": "^4.24.5",
"next-contentlayer2": "^0.5.3",
@@ -91,7 +93,8 @@
"server-only": "^0.0.1",
"sonner": "^2.0.3",
"subtitles-parser-vtt": "^0.1.0",
- "tailwind-merge": "^2.1.0",
+ "tailwind-merge": "^2.6.0",
+ "tailwindcss-animate": "^1.0.6",
"uuid": "^9.0.1",
"video.js": "^8.17.3",
"zod": "^3.24.4"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b114f37e6..ee4181d3a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -525,8 +525,11 @@ importers:
aws-sdk:
specifier: ^2.1530.0
version: 2.1692.0
+ class-variance-authority:
+ specifier: ^0.7.0
+ version: 0.7.1
clsx:
- specifier: ^2.0.0
+ specifier: ^2.1.1
version: 2.1.1
cookies-next:
specifier: ^4.1.0
@@ -576,6 +579,9 @@ importers:
moment:
specifier: ^2.30.1
version: 2.30.1
+ motion:
+ specifier: ^12.18.1
next:
specifier: 14.2.3
@@ -640,8 +646,11 @@ importers:
specifier: ^0.1.0
version: 0.1.0
tailwind-merge:
- specifier: ^2.1.0
+ specifier: ^2.6.0
version: 2.6.0
+ tailwindcss-animate:
+ specifier: ^1.0.6
uuid:
specifier: ^9.0.1
version: 9.0.1
@@ -8404,6 +8413,20 @@ packages:
react-dom:
optional: true
+ resolution: {integrity: sha512-6o4EDuRPLk4LSZ1kRnnEOurbQ86MklVk+Y1rFBUKiF+d2pCdvMjWVu0ZkyMVCTwl5UyTH2n/zJEJx+jvTYuxow==}
+ peerDependencies:
+ '@emotion/is-prop-valid': '*'
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@emotion/is-prop-valid':
+ optional: true
+ react:
+ optional: true
+ react-dom:
+ optional: true
+
resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==}
engines: {node: '>= 0.6'}
@@ -10048,9 +10071,29 @@ packages:
resolution: {integrity: sha512-g76KvA001z+atjfxczdRtw/RXOM3OMSdd1f4DL77qCTF/+avrRJiawSG4yDibEQ215sr9kpinSlX2pCTJ9zbhw==}
+ resolution: {integrity: sha512-dR/4EYT23Snd+eUSLrde63Ws3oXQtJNw/krgautvTfwrN/2cHfCZMdu6CeTxVfRRWREW3Fy1f5vobRDiBb/q+w==}
+
resolution: {integrity: sha512-49Kt+HKjtbJKLtgO/LKj9Ld+6vw9BjH5d9sc40R/kVyH8GLAXgT42M2NnuPcJNuA3s9ZfZBUcwIgpmZWGEE+hA==}
+ resolution: {integrity: sha512-az26YDU4WoDP0ueAkUtABLk2BIxe28d8NH1qWT8jPGhPyf44XTdDUh8pDk9OPphaSrR9McgpcJlgwSOIw/sfkA==}
+
+ resolution: {integrity: sha512-w1ns2hWQ4COhOvnZf4rg4mW0Pl36mzcShpgt0fSfI6qJxKUbi3kHho/HSKeJFRoY0TO1m5/7C8lG1+Li0uC9Fw==}
+ peerDependencies:
+ '@emotion/is-prop-valid': '*'
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@emotion/is-prop-valid':
+ optional: true
+ react:
+ optional: true
+ react-dom:
+ optional: true
+
resolution: {integrity: sha512-GcCH0fySxBurJtvr0dfhz0IxHZjc1RP+F+I8xw+LIwkU1a+7HJx8NCDiww1I5u4Hz6g4eR1JlGADEGJ9r4lSfA==}
@@ -21861,6 +21904,15 @@ snapshots:
react: 19.1.0
react-dom: 19.1.0([email protected])
+ dependencies:
+ motion-dom: 12.18.1
+ motion-utils: 12.18.1
+ tslib: 2.8.1
+ optionalDependencies:
+ react: 19.1.0
+ react-dom: 19.1.0([email protected])
+
@@ -23945,8 +23997,22 @@ snapshots:
dependencies:
motion-utils: 11.18.1
+ dependencies:
+ motion-utils: 12.18.1
+
+
+ dependencies:
+ tslib: 2.8.1
+ optionalDependencies:
+ react: 19.1.0
+ react-dom: 19.1.0([email protected])
+