Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Share page copy to clipboard

Richie McIlroyd0137f40e313
diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
index 83264ec4d..c4afc690c 100644
--- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
@@ -5,7 +5,7 @@ import { userSelectProps } from "@cap/database/auth/session";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "react-hot-toast";
-import { LinkIcon, Loader2 } from "lucide-react";
+import { Copy, Loader2 } from "lucide-react";
import JSZip from "jszip";
import { saveAs } from "file-saver";
@@ -112,27 +112,6 @@ export const ShareHeader = ({
{title}
</h1>
)}
- <div>
- <button
- data-tooltip-id="clipboard"
- data-tooltip-content="Copy link to clipboard"
- className="bg-white p-2 w-8 h-8 rounded-lg flex items-center justify-center border hover:border-gray-300 transition-all"
- onClick={() => {
- if (process.env.NEXT_PUBLIC_IS_CAP) {
- navigator.clipboard.writeText(
- `https://cap.link/${data.id}`
- );
- } else {
- navigator.clipboard.writeText(
- `${process.env.NEXT_PUBLIC_URL}/s/${data.id}`
- );
- }
- toast.success("Link copied to clipboard!");
- }}
- >
- <LinkIcon className="w-5 h-5" />
- </button>
- </div>
</div>
<p className="text-gray-400 text-sm">
{moment(data.createdAt).fromNow()}
@@ -160,6 +139,31 @@ export const ShareHeader = ({
</Button>
</div>
)}
+ <Button
+ variant="gray"
+ className="hover:bg-gray-300"
+ onClick={() => {
+ if (
+ process.env.NEXT_PUBLIC_IS_CAP &&
+ process.env.NODE_ENV === "production"
+ ) {
+ navigator.clipboard.writeText(
+ `https://cap.link/${data.id}`
+ );
+ } else {
+ navigator.clipboard.writeText(
+ `${process.env.NEXT_PUBLIC_URL}/s/${data.id}`
+ );
+ }
+ toast.success("Link copied to clipboard!");
+ }}
+ >
+ {process.env.NEXT_PUBLIC_IS_CAP &&
+ process.env.NODE_ENV === "production"
+ ? `cap.link/${data.id}`
+ : `${process.env.NEXT_PUBLIC_URL}/s/${data.id}`}
+ <Copy className="ml-2 h-4 w-4" />
+ </Button>
{user !== null && (
<div className="hidden md:flex">
<Button
diff --git a/apps/web/app/s/[videoId]/_components/Sidebar.tsx b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
new file mode 100644
index 000000000..0519ecba6
--- /dev/null
+++ b/apps/web/app/s/[videoId]/_components/Sidebar.tsx
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/apps/web/app/s/[videoId]/_components/Toolbar.tsx b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
index 3dfcf5380..81d11cac1 100644
--- a/apps/web/app/s/[videoId]/_components/Toolbar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
@@ -162,6 +162,36 @@ export const Toolbar = ({
</div>
);
+ useEffect(() => {
+ const handleKeyPress = (e: KeyboardEvent) => {
+ // Only trigger if 'c' is pressed and comment box isn't already open
+ // Also check if user isn't typing in an input field
+ if (
+ e.key.toLowerCase() === "c" &&
+ !commentBoxOpen &&
+ !(
+ e.target instanceof HTMLInputElement ||
+ e.target instanceof HTMLTextAreaElement
+ )
+ ) {
+ e.preventDefault(); // Prevent the 'c' from being added to the input
+ if (!user) {
+ push(`/login?next=${window.location.pathname}`);
+ return;
+ }
+ if (videoElement) {
+ videoElement.pause();
+ }
+ setCommentBoxOpen(true);
+ }
+ };
+
+ window.addEventListener("keydown", handleKeyPress);
+ return () => {
+ window.removeEventListener("keydown", handleKeyPress);
+ };
+ }, [commentBoxOpen, user, push, videoElement]);
+
return (
<div
className={`${
@@ -174,7 +204,7 @@ export const Toolbar = ({
}`}
>
<div className="flex">
- <div className="flex-grow p-2">
+ <div className="flex-grow p-1">
{commentBoxOpen === true ? (
<div className="w-full flex items-center justify-between">
<input
@@ -206,7 +236,7 @@ export const Toolbar = ({
handleCommentSubmit();
}}
>
- {videoElement
+ {videoElement && getTimestamp() > 0
? `Comment at ${getTimestamp().toFixed(2)}`
: "Comment"}
</Button>
@@ -232,7 +262,7 @@ export const Toolbar = ({
label={reaction.label}
/>
))}
- <div className="w-[2px] bg-gray-200 h-full mx-2"></div>
+ <div className="w-[1px] bg-gray-200 h-[16px] mx-4"></div>
<div className="flex items-center">
<button
onClick={() => {
@@ -245,10 +275,11 @@ export const Toolbar = ({
}
setCommentBoxOpen(true);
}}
- className="font-medium bg-transparent py-1 px-2 relative transition-bg-color duration-600 flex justify-center items-center rounded-full ease-in-out hover:bg-gray-200 active:bg-gray-400 active:duration-0"
+ className="font-medium bg-gray-200 py-1 px-3 relative transition-bg-color duration-600 flex justify-center items-center rounded-full ease-in-out hover:bg-gray-200 active:bg-gray-400 active:duration-0"
>
- <MessageSquare className="w-[16px] sm:w-[22px] h-auto" />
- <span className="text-sm ml-1">Comment</span>
+ <span className="text-sm text-gray-500 font-medium">
+ Comment (c)
+ </span>
</button>
</div>
</div>
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
new file mode 100644
index 000000000..0519ecba6
--- /dev/null
+++ b/apps/web/app/s/[videoId]/_components/tabs/Activity.tsx
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Settings.tsx b/apps/web/app/s/[videoId]/_components/tabs/Settings.tsx
new file mode 100644
index 000000000..0519ecba6
--- /dev/null
+++ b/apps/web/app/s/[videoId]/_components/tabs/Settings.tsx
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
new file mode 100644
index 000000000..0519ecba6
--- /dev/null
+++ b/apps/web/app/s/[videoId]/_components/tabs/Transcript.tsx
@@ -0,0 +1 @@
+
\ No newline at end of file