Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Add mute + fullscreen

Richie McIlroy65cf151045b9
diff --git a/apps/web/app/share/[videoId]/_components/ShareVideo.tsx b/apps/web/app/share/[videoId]/_components/ShareVideo.tsx
index c149a0110..9390168fa 100644
--- a/apps/web/app/share/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/share/[videoId]/_components/ShareVideo.tsx
@@ -1,8 +1,8 @@
import { videos } from "@cap/database/schema";
import { VideoPlayer } from "./VideoPlayer";
import { useState, useCallback, useMemo, useEffect, useRef } from "react";
-import { Play, Pause, Maximize, VolumeX } from "lucide-react";
-import { LogoBadge } from "@cap/ui";
+import { Play, Pause, Maximize, VolumeX, Volume2 } from "lucide-react";
+import { LogoSpinner } from "@cap/ui";
const formatTime = (time: number) => {
const minutes = Math.floor(time / 60);
@@ -57,6 +57,24 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {
const handlePlayPauseClick = () => setIsPlaying(!isPlaying);
+ const handleMuteClick = () => {
+ if (!video1Ref.current || !video2Ref.current) return;
+
+ video1Ref.current.muted = !video1Ref.current.muted;
+ video2Ref.current.muted = !video2Ref.current.muted;
+ };
+
+ const handleFullscreenClick = () => {
+ const player = document.getElementById("player");
+ if (player) {
+ if (document.fullscreenElement) {
+ document.exitFullscreen();
+ } else {
+ player.requestFullscreen();
+ }
+ }
+ };
+
const watchedPercentage =
longestDuration > 0 ? (currentTime / longestDuration) * 100 : 0;
@@ -82,13 +100,6 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {
}
}, [isLoading]);
- const CapSpinner = () => {
- return (
- <div>
- <LogoBadge className="w-10 h-auto animate-spin opacity-50" />
- </div>
- );
- };
return (
<div
className="relative flex h-full w-full overflow-hidden shadow-lg rounded-lg group"
@@ -96,7 +107,7 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {
>
{isLoading && (
<div className="absolute top-0 left-0 flex items-center justify-center w-full h-full z-10">
- <CapSpinner />
+ <LogoSpinner className="w-10 h-auto animate-spin" />
</div>
)}
{isLoading === false && (
@@ -180,9 +191,13 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {
className=" inline-flex items-center text-sm font-medium transition ease-in-out duration-150 focus:outline-none border text-slate-100 border-transparent hover:text-white focus:border-white hover:bg-slate-100 hover:bg-opacity-10 active:bg-slate-100 active:bg-opacity-10 px-2 py-2 justify-center rounded-lg"
tabIndex={0}
type="button"
- data-state="closed"
+ onClick={handleMuteClick}
>
- <VolumeX className="w-auto h-6" />
+ {video1Ref?.current?.muted && video2Ref?.current?.muted ? (
+ <VolumeX className="w-auto h-6" />
+ ) : (
+ <Volume2 className="w-auto h-6" />
+ )}
</button>
</span>
<span className="inline-flex">
@@ -191,7 +206,7 @@ export const ShareVideo = ({ data }: { data: typeof videos.$inferSelect }) => {
className=" inline-flex items-center text-sm font-medium transition ease-in-out duration-150 focus:outline-none border text-slate-100 border-transparent hover:text-white focus:border-white hover:bg-slate-100 hover:bg-opacity-10 active:bg-slate-100 active:bg-opacity-10 px-2 py-2 justify-center rounded-lg"
tabIndex={0}
type="button"
- data-state="closed"
+ onClick={handleFullscreenClick}
>
<Maximize className="w-auto h-6" />
</button>
diff --git a/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx b/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx
index 23cbfbcb7..658689e48 100644
--- a/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx
+++ b/apps/web/app/share/[videoId]/_components/VideoPlayer.tsx
@@ -33,7 +33,7 @@ export const VideoPlayer = forwardRef<HTMLVideoElement, VideoPlayerProps>(
className="absolute top-0 left-0 rounded-lg w-full h-full object-cover"
preload="auto"
playsInline
- controls={false} // Controls handled by parent
+ controls={false}
/>
);
}
diff --git a/packages/ui/src/components/LogoSpinner.tsx b/packages/ui/src/components/LogoSpinner.tsx
new file mode 100644
index 000000000..40b78d957
--- /dev/null
+++ b/packages/ui/src/components/LogoSpinner.tsx
@@ -0,0 +1,74 @@
+export const LogoSpinner = ({ className }: { className: string }) => {
+ return (
+ <svg
+ className={className}
+ viewBox="0 0 269 269"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M218.623 0H50C22.3858 0 0 22.3858 0 50V218.623C0 246.237 22.3858 268.623 50 268.623H218.623C246.237 268.623 268.623 246.237 268.623 218.623V50C268.623 22.3858 246.237 0 218.623 0Z"
+ fill="url(#paint0_linear_275_61)"
+ />
+ <path
+ d="M134.646 240.418C193.061 240.418 240.416 193.063 240.416 134.648C240.416 76.2328 193.061 28.8779 134.646 28.8779C76.2308 28.8779 28.876 76.2328 28.876 134.648C28.876 193.063 76.2308 240.418 134.646 240.418Z"
+ fill="url(#paint1_radial_275_61)"
+ />
+ <path
+ d="M134.983 224.972C184.682 224.972 224.971 184.683 224.971 134.984C224.971 85.2844 184.682 44.9951 134.983 44.9951C85.2834 44.9951 44.9941 85.2844 44.9941 134.984C44.9941 184.683 85.2834 224.972 134.983 224.972Z"
+ fill="url(#paint2_linear_275_61)"
+ />
+ <path
+ d="M134.983 202.81C172.443 202.81 202.811 172.442 202.811 134.982C202.811 97.5225 172.443 67.1553 134.983 67.1553C97.5235 67.1553 67.1562 97.5225 67.1562 134.982C67.1562 172.442 97.5235 202.81 134.983 202.81Z"
+ fill="url(#paint3_radial_275_61)"
+ />
+ <defs>
+ <linearGradient
+ id="paint0_linear_275_61"
+ x1="134.311"
+ y1="0"
+ x2="134.311"
+ y2="268.623"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#A8DBF8" />
+ <stop offset="1" stopColor="#BCCBFF" />
+ </linearGradient>
+ <radialGradient
+ id="paint1_radial_275_61"
+ cx="0"
+ cy="0"
+ r="1"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(134.646 98.0059) rotate(107.38) scale(149.225 149.225)"
+ >
+ <stop offset="0.0625" stopColor="#84D3FF" />
+ <stop offset="0.411458" stopColor="#17ABFE" />
+ <stop offset="0.90625" stopColor="#0770D1" />
+ </radialGradient>
+ <linearGradient
+ id="paint2_linear_275_61"
+ x1="134.983"
+ y1="44.9947"
+ x2="134.983"
+ y2="224.972"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#BBE8FF" />
+ <stop offset="1" stopColor="#018FEF" />
+ </linearGradient>
+ <radialGradient
+ id="paint3_radial_275_61"
+ cx="0"
+ cy="0"
+ r="1"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(145.222 134.982) rotate(98.5836) scale(68.5955 68.5955)"
+ >
+ <stop stopColor="#7EC3FF" />
+ <stop offset="1" stopColor="#EAF5FF" />
+ </radialGradient>
+ </defs>
+ </svg>
+ );
+};
diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx
index c1e1cd6f5..d5de538de 100644
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@ -8,6 +8,7 @@ export * from "./components/icons/LogoBadge";
// Layout
export * from "./components/SkeletonPage";
+export * from "./components/LogoSpinner";
// UI
export * from "./components/Button";