Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Share page sidebar styling

Richie McIlroye6a82616c7a6
diff --git a/apps/web/app/s/[videoId]/_components/Sidebar.tsx b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
index c2b879ad5..26317c6c6 100644
--- a/apps/web/app/s/[videoId]/_components/Sidebar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
@@ -7,6 +7,7 @@ import { Settings } from "./tabs/Settings";
import { comments as commentsSchema, videos } from "@cap/database/schema";
import { userSelectProps } from "@cap/database/auth/session";
import { classNames } from "@cap/utils";
+import { AnimatePresence, motion } from "framer-motion";
type TabType = "activity" | "transcript" | "settings";
@@ -34,6 +35,30 @@ interface SidebarProps {
videoId: string;
}
+const TabContent = motion.div;
+
+const tabVariants = {
+ enter: (direction: number) => ({
+ x: direction > 0 ? 1000 : -1000,
+ opacity: 0,
+ }),
+ center: {
+ zIndex: 1,
+ x: 0,
+ opacity: 1,
+ },
+ exit: (direction: number) => ({
+ zIndex: 0,
+ x: direction < 0 ? 1000 : -1000,
+ opacity: 0,
+ }),
+};
+
+const tabTransition = {
+ x: { type: "spring", stiffness: 300, damping: 30 },
+ opacity: { duration: 0.2 },
+};
+
export const Sidebar: React.FC<SidebarProps> = ({
data,
user,
@@ -48,12 +73,22 @@ export const Sidebar: React.FC<SidebarProps> = ({
);
const [activeTab, setActiveTab] = useState<TabType>("activity");
+ const [[page, direction], setPage] = useState([0, 0]);
const tabs = [
{ id: "activity", label: "Comments" },
{ id: "transcript", label: "Transcript" },
];
+ const paginate = (newDirection: number, tabId: TabType) => {
+ const currentIndex = tabs.findIndex((tab) => tab.id === activeTab);
+ const newIndex = tabs.findIndex((tab) => tab.id === tabId);
+ const direction = newIndex > currentIndex ? 1 : -1;
+
+ setPage([page + direction, direction]);
+ setActiveTab(tabId);
+ };
+
const renderTabContent = () => {
switch (activeTab) {
case "activity":
@@ -83,21 +118,55 @@ export const Sidebar: React.FC<SidebarProps> = ({
{tabs.map((tab) => (
<button
key={tab.id}
- onClick={() => setActiveTab(tab.id as TabType)}
+ onClick={() =>
+ paginate(tab.id === activeTab ? 0 : 1, tab.id as TabType)
+ }
className={classNames(
- "flex-1 px-6 py-3 text-sm font-medium text-gray-600 hover:text-gray-900 relative",
- activeTab === tab.id && "text-gray-900"
+ "flex-1 px-6 py-3 text-sm font-medium relative transition-colors duration-200",
+ "hover:bg-gray-100",
+ activeTab === tab.id ? "bg-gray-100" : ""
)}
>
- {tab.label}
+ <span
+ className={classNames(
+ "relative z-10",
+ activeTab === tab.id ? "text-gray-500" : "text-gray-400"
+ )}
+ >
+ {tab.label}
+ </span>
{activeTab === tab.id && (
- <div className="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-500" />
+ <motion.div
+ layoutId="activeTab"
+ className="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-500"
+ initial={false}
+ transition={{
+ type: "spring",
+ stiffness: 500,
+ damping: 30,
+ }}
+ />
)}
</button>
))}
</div>
</div>
- <div className="flex-1 min-h-0">{renderTabContent()}</div>
+ <div className="flex-1 min-h-0 relative">
+ <AnimatePresence initial={false} custom={direction}>
+ <TabContent
+ key={activeTab}
+ custom={direction}
+ variants={tabVariants}
+ initial="enter"
+ animate="center"
+ exit="exit"
+ transition={tabTransition}
+ className="absolute inset-0"
+ >
+ {renderTabContent()}
+ </TabContent>
+ </AnimatePresence>
+ </div>
</div>
);
};
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
index e02d02baa..5409ce539 100644
--- a/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
+++ b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
@@ -62,7 +62,7 @@ const CommentInput: React.FC<CommentInputProps> = ({
autoFocus = false,
}) => {
const [content, setContent] = useState("");
- const inputRef = useRef<HTMLInputElement>(null);
+ const inputRef = useRef<HTMLTextAreaElement>(null);
useEffect(() => {
if (autoFocus && inputRef.current) {
@@ -78,7 +78,7 @@ const CommentInput: React.FC<CommentInputProps> = ({
}
};
- const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
handleSubmit();
@@ -89,9 +89,8 @@ const CommentInput: React.FC<CommentInputProps> = ({
<div className="flex items-start space-x-3">
<div className="flex-1">
<div className="bg-gray-100 rounded-lg p-4">
- <input
+ <textarea
ref={inputRef}
- type="text"
value={content}
onChange={(e) => setContent(e.target.value)}
onKeyDown={handleKeyDown}
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
index 5c2e69410..8b3daac1b 100644
--- a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
+++ b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
@@ -236,8 +236,10 @@ export const Transcript: React.FC<TranscriptProps> = ({ data, onSeek }) => {
return (
<div className="flex items-center justify-center h-full text-gray-500">
<div className="text-center">
- <MessageSquare className="w-8 h-8 mx-auto mb-2 text-gray-400" />
- <p>No transcript available</p>
+ <MessageSquare className="w-8 h-8 mx-auto mb-2 text-gray-300" />
+ <p className="text-sm text-gray-500 font-medium">
+ No transcript available
+ </p>
</div>
</div>
);