Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore: share page tweaks (#797)

Ameer Al Ashhabe2260f988709
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index 6892ecda8..1fe5635d2 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -230,7 +230,9 @@ export const Share = ({
</div>
<div className="hidden mt-4 lg:block">
- <Toolbar data={data} user={user} />
+ <div>
+ <Toolbar data={data} user={user} />
+ </div>
</div>
<div className="hidden mt-4 lg:block">
@@ -306,6 +308,6 @@ export const Share = ({
</div>
)}
</div>
- </div>
+ </div >
);
};
diff --git a/apps/web/app/s/[videoId]/_components/Sidebar.tsx b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
index 210ce41d1..0426dceaf 100644
--- a/apps/web/app/s/[videoId]/_components/Sidebar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
@@ -73,8 +73,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
}) => {
const isOwnerOrMember: boolean = Boolean(
user?.id === data.ownerId ||
- (data.organizationId &&
- data.organizationMembers?.includes(user?.id ?? ""))
+ (data.organizationId &&
+ data.organizationMembers?.includes(user?.id ?? ""))
);
const [activeTab, setActiveTab] = useState<TabType>("activity");
@@ -140,7 +140,9 @@ export const Sidebar: React.FC<SidebarProps> = ({
};
return (
- <div className="new-card-style overflow-hidden h-[calc(100vh-16rem)] lg:h-full flex flex-col lg:aspect-video">
+ <div
+ className="new-card-style overflow-hidden h-[calc(100vh-16rem)] lg:h-full flex flex-col lg:aspect-video"
+ >
<div className="flex-none">
<div className="flex border-b border-gray-200">
{tabs.map((tab) => (
@@ -180,7 +182,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
</div>
</div>
<div className="flex-1 min-h-0">
- <div className="h-full relative overflow-hidden">
+ <div className="overflow-hidden relative h-full">
<AnimatePresence initial={false} custom={direction}>
<TabContent
key={activeTab}
@@ -190,7 +192,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
animate="center"
exit="exit"
transition={tabTransition}
- className="absolute inset-0 overflow-auto"
+ className="overflow-auto absolute inset-0"
>
<div className="h-full">{renderTabContent()}</div>
</TabContent>
diff --git a/apps/web/app/s/[videoId]/_components/Toolbar.tsx b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
index fc76481ab..b85ae6b38 100644
--- a/apps/web/app/s/[videoId]/_components/Toolbar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
@@ -2,10 +2,13 @@
import { userSelectProps } from "@cap/database/auth/session";
import { videos } from "@cap/database/schema";
import { Button } from "@cap/ui";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useState } from "react";
import { toast } from "sonner";
import { AuthOverlay } from "./AuthOverlay";
import { useRouter } from "next/navigation";
+import { AnimatePresence, motion } from "motion/react";
+
+const MotionButton = motion(Button);
// million-ignore
export const Toolbar = ({
@@ -37,24 +40,8 @@ export const Toolbar = ({
checkForVideoElement();
- return () => {
- // Clean up any ongoing checks if component unmounts
- };
}, []);
- const [currentEmoji, setCurrentEmoji] = useState<{
- emoji: string;
- id: number;
- } | null>(null);
- const clearEmojiTimeout = useRef<NodeJS.Timeout | null>(null);
-
- useEffect(() => {
- return () => {
- if (clearEmojiTimeout.current) {
- clearTimeout(clearEmojiTimeout.current);
- }
- };
- }, []);
const getTimestamp = (): number => {
if (videoElement) {
@@ -65,11 +52,6 @@ export const Toolbar = ({
};
const handleEmojiClick = async (emoji: string) => {
- if (clearEmojiTimeout.current) {
- clearTimeout(clearEmojiTimeout.current);
- }
-
- setCurrentEmoji({ emoji, id: Date.now() });
const timestamp = getTimestamp();
@@ -138,17 +120,18 @@ export const Toolbar = ({
};
const Emoji = ({ label, emoji }: { label: string; emoji: string }) => (
- <div className="relative size-10">
- <button
- className="inline-flex relative justify-center items-center p-1 text-xl leading-6 align-middle bg-transparent rounded-full ease-in-out size-full font-emoji sm:text-2xl transition-bg-color duration-600 hover:bg-gray-200 active:bg-blue-500 active:duration-0"
+ <motion.div layout className="relative size-10">
+ <motion.button
+ layout
+ className="inline-flex relative justify-center items-center p-1 text-xl leading-6 align-middle bg-transparent rounded-full transition-colors ease-in-out size-full font-emoji sm:text-2xl duration-600 hover:bg-gray-200 active:bg-blue-500 active:duration-0"
role="img"
aria-label={label ? label : ""}
aria-hidden={label ? "false" : "true"}
onClick={() => handleEmojiClick(emoji)}
>
{emoji}
- </button>
- </div>
+ </motion.button>
+ </motion.div>
);
useEffect(() => {
@@ -196,85 +179,104 @@ export const Toolbar = ({
return (
<>
- <div className="mx-auto max-w-fit">
- <div
- className={`mx-auto !rounded-full transition-all new-card-style`}
- >
- <div className="flex">
- <div className="flex-grow p-1">
- {commentBoxOpen === true ? (
- <div className="flex justify-between items-center w-full">
- <input
- autoFocus
- type="text"
- value={comment}
- onChange={(e) => setComment(e.target.value)}
- placeholder="Add a comment"
- className="flex-grow px-3 h-full outline-none"
- maxLength={255}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.preventDefault();
- handleCommentSubmit();
- }
- if (e.key === "Escape") {
- setCommentBoxOpen(false);
- setComment("");
- }
- }}
+ <motion.div layout className="flex overflow-hidden p-2 mx-auto max-w-full bg-white rounded-full md:max-w-fit">
+ <AnimatePresence initial={false} mode="popLayout">
+ {commentBoxOpen ? (
+ <motion.div
+ layout
+ key="comment-box"
+ initial={{ scale: 0.90 }}
+ animate={{ scale: 1 }}
+ className="flex justify-between items-center w-full"
+ >
+ <motion.input
+ layout
+ autoFocus
+ type="text"
+ value={comment}
+ onChange={(e) => setComment(e.target.value)}
+ placeholder="Add a comment"
+ className="flex-grow px-3 h-full outline-none"
+ maxLength={255}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ handleCommentSubmit();
+ }
+ if (e.key === "Escape") {
+ setCommentBoxOpen(false);
+ setComment("");
+ }
+ }}
+ />
+ <motion.div layout="position" className="flex items-center space-x-2">
+ <MotionButton
+ disabled={comment.length === 0}
+ variant="primary"
+ size="sm"
+ layout="position"
+ onClick={() => {
+ handleCommentSubmit();
+ }}
+ >
+ {videoElement && getTimestamp() > 0
+ ? `Comment at ${getTimestamp().toFixed(2)}`
+ : "Comment"}
+ </MotionButton>
+ <MotionButton
+ variant="gray"
+ size="sm"
+ layout="position"
+ onClick={() => {
+ setCommentBoxOpen(false);
+ setComment("");
+ }}
+ >
+ Cancel
+ </MotionButton>
+ </motion.div>
+ </motion.div>
+ ) : (
+ <motion.div
+ layout
+ key="toolbar"
+ initial={{ scale: 0.90 }}
+ animate={{ scale: 1 }}
+ exit={{ scale: 0.90 }}
+ transition={{ duration: 0.2, ease: "easeInOut" }}
+ className="flex flex-col gap-2 items-center mx-auto w-full md:justify-center sm:grid sm:grid-flow-col md:w-fit min-h-[28px]"
+ >
+ {/* Emoji reactions row */}
+ <div className="flex gap-2 justify-evenly items-center w-full md:w-fit md:justify-center">
+ {REACTIONS.map((reaction) => (
+ <Emoji
+ key={reaction.emoji}
+ emoji={reaction.emoji}
+ label={reaction.label}
/>
- <div className="flex items-center space-x-2">
- <Button
- className="min-w-[160px]"
- disabled={comment.length === 0}
- variant="primary"
- size="sm"
- onClick={() => {
- handleCommentSubmit();
- }}
- >
- {videoElement && getTimestamp() > 0
- ? `Comment at ${getTimestamp().toFixed(2)}`
- : "Comment"}
- </Button>
- <Button
- className="min-w-[100px]"
- variant="white"
- size="sm"
- onClick={() => {
- setCommentBoxOpen(false);
- setComment("");
- }}
- >
- Cancel
- </Button>
- </div>
- </div>
- ) : (
- <div className="grid grid-flow-col gap-2 justify-center items-center w-fit">
- {REACTIONS.map((reaction) => (
- <Emoji
- key={reaction.emoji}
- emoji={reaction.emoji}
- label={reaction.label}
- />
- ))}
- <div className="w-[1px] bg-gray-200 h-[16px] mx-4" />
- <div className="flex items-center min-w-fit">
- <Button
- onClick={handleCommentClick}
- variant="dark"
- size="sm"
- >
- Comment (c)
- </Button>
- </div>
- </div>
- )}
- </div>
- </div>
- </div>
- </div>
+ ))}
+ </div>
+
+ {/* Separator - hidden on mobile, visible on desktop */}
+ <motion.div className="hidden sm:block w-px bg-gray-200 h-[16px] mx-4" />
+
+ {/* Comment button - full width on mobile, normal on desktop */}
+ <div className="ml-auto w-full sm:w-auto">
+ <MotionButton
+ onClick={handleCommentClick}
+ variant="dark"
+ layout="position"
+ kbd="c"
+ size="sm"
+ className="mx-auto w-fit"
+ >
+ Comment
+ </MotionButton>
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </motion.div>
<AuthOverlay
isOpen={showAuthOverlay}
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
index e07814884..b20a6bcdb 100644
--- a/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
+++ b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
@@ -435,8 +435,8 @@ function Analytics(props: {
const Comments = Object.assign(
(props: {
- comments: CommentType[]; // Changed from MaybePromise since parent resolves it
- setComments: React.Dispatch<React.SetStateAction<CommentType[]>>; // Added setComments prop
+ comments: CommentType[];
+ setComments: React.Dispatch<React.SetStateAction<CommentType[]>>;
user: typeof userSelectProps | null;
videoId: string;
onSeek?: (time: number) => void;
@@ -474,9 +474,13 @@ const Comments = Object.assign(
}
};
+ useEffect(() => {
+ setTimeout(scrollToBottom, 100);
+ }, [comments]);
+
+
const addOptimisticComment = (newComment: CommentType) => {
setOptimisticComments((prev) => [...prev, newComment]);
- setTimeout(scrollToBottom, 100);
};
const handleNewComment = async (content: string) => {
diff --git a/packages/ui/src/components/Button.tsx b/packages/ui/src/components/Button.tsx
index 7d69fd496..8f6b8bc0f 100644
--- a/packages/ui/src/components/Button.tsx
+++ b/packages/ui/src/components/Button.tsx
@@ -43,6 +43,7 @@ export interface ButtonProps
asChild?: boolean;
spinner?: boolean;
href?: string;
+ kbd?: string;
icon?: React.ReactNode;
}
@@ -55,6 +56,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
asChild = false,
spinner = false,
href,
+ kbd,
icon,
...props
},
@@ -94,6 +96,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
)}
{icon && icon}
{props.children}
+ {kbd && <kbd className="hidden justify-center items-center ml-1 text-xs rounded-full border md:flex size-5 bg-gray-11 border-gray-10">{kbd}</kbd>}
</Comp>
);
}