Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip: Dynamic webcam record in web app

Richie McIlroy790d537d4f01
diff --git a/apps/desktop/src/components/recording/ActionButton.tsx b/apps/desktop/src/components/windows/inner/ActionButton.tsx
similarity index 98%
rename from apps/desktop/src/components/recording/ActionButton.tsx
rename to apps/desktop/src/components/windows/inner/ActionButton.tsx
index 5c771fc5c..69fd0dfd8 100644
--- a/apps/desktop/src/components/recording/ActionButton.tsx
+++ b/apps/desktop/src/components/windows/inner/ActionButton.tsx
@@ -1,5 +1,6 @@
import { ReactNode } from "react";
+// million-ignore
export const ActionButton = ({
handler,
icon,
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index bf0c494ec..1cc6645d2 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -6,7 +6,6 @@ import { Video } from "@/components/icons/Video";
import { Microphone } from "@/components/icons/Microphone";
import { Screen } from "@/components/icons/Screen";
import { Window } from "@/components/icons/Window";
-import { ActionButton } from "@/components/recording/ActionButton";
import { Button } from "@cap/ui";
import { Logo } from "@/components/icons/Logo";
import { emit } from "@tauri-apps/api/event";
@@ -17,6 +16,7 @@ import toast, { Toaster } from "react-hot-toast";
import { authFetch } from "@/utils/auth/helpers";
import { appDataDir, join } from "@tauri-apps/api/path";
import { open } from "@tauri-apps/api/shell";
+import { ActionButton } from "@/components/windows/inner/ActionButton";
declare global {
interface Window {
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
index 511a752b2..519f6f632 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
@@ -119,7 +119,7 @@ export const AdminNavItems = () => {
className="w-full flex flex-col justify-between h-full"
aria-label="Sidebar"
>
- <Button href="/dashboard/caps/new" className="w-full mb-4">
+ <Button href="/dashboard/record" className="w-full mb-4">
<Video className="flex-shrink-0 w-6 h-6" aria-hidden="true" />
<span className="ml-2.5 text-white">Record a Cap</span>
</Button>
diff --git a/apps/web/app/dashboard/record/Record.tsx b/apps/web/app/dashboard/record/Record.tsx
deleted file mode 100644
index 972a523ac..000000000
--- a/apps/web/app/dashboard/record/Record.tsx
+++ /dev/null
@@ -1,428 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import { users } from "@cap/database/schema";
-import {
- Mic,
- MicOff,
- Video,
- VideoOff,
- Monitor,
- CircleEllipsis,
- ChevronUp,
-} from "lucide-react";
-import { Rnd } from "react-rnd";
-
-export const Record = ({
- user,
-}: {
- user: typeof users.$inferSelect | null;
-}) => {
- const [isRecording, setIsRecording] = useState(false);
- const [audioDevices, setAudioDevices] = useState<MediaDeviceInfo[]>([]);
- const [videoDevices, setVideoDevices] = useState<MediaDeviceInfo[]>([]);
- const [selectedAudioDevice, setSelectedAudioDevice] = useState<string>();
- const [selectedVideoDevice, setSelectedVideoDevice] = useState<string>();
- const [showAudioOptions, setShowAudioOptions] = useState(false);
- const [showVideoOptions, setShowVideoOptions] = useState(false);
- const [screenStream, setScreenStream] = useState<MediaStream | null>(null);
- const [videoStream, setVideoStream] = useState<MediaStream | null>(null);
- const [combinedStream, setCombinedStream] = useState<MediaStream | null>(
- null
- );
- const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(
- null
- );
- const [recordedBlobs, setRecordedBlobs] = useState<Blob[]>([]);
-
- const buttonStyles =
- "w-full h-full flex flex-col items-center justify-center text-center space-y-1 py-2 pl-5 pr-7 group-hover:bg-[#2e2d32] rounded-xl";
-
- const getDevices = async () => {
- try {
- await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
- const devices = await navigator.mediaDevices.enumerateDevices();
- console.log("Devices:", devices);
- const audioDevices = devices.filter(
- (device) => device.kind === "audioinput"
- );
- const videoDevices = devices.filter(
- (device) => device.kind === "videoinput"
- );
- setAudioDevices(audioDevices);
- setVideoDevices(videoDevices);
- } catch (error) {
- console.error("Error accessing media devices:", error);
- }
- };
-
- const startScreenCapture = async () => {
- try {
- const stream = await navigator.mediaDevices.getDisplayMedia({
- video: true,
- });
- setScreenStream(stream);
- } catch (error) {
- console.error("Error capturing screen:", error);
- }
- };
-
- const startVideoCapture = async (deviceId?: string) => {
- try {
- const constraints: MediaStreamConstraints = {
- video: deviceId ? { deviceId } : true,
- audio: selectedAudioDevice ? { deviceId: selectedAudioDevice } : false,
- };
-
- const stream = await navigator.mediaDevices.getUserMedia(constraints);
- setVideoStream(stream);
- } catch (error) {
- console.error("Error capturing video:", error);
- }
- };
-
- const stopScreenCapture = () => {
- if (screenStream) {
- screenStream.getTracks().forEach((track) => track.stop());
- setScreenStream(null);
- }
- };
-
- const stopVideoCapture = () => {
- if (videoStream) {
- videoStream.getTracks().forEach((track) => track.stop());
- setVideoStream(null);
- }
- };
-
- const startRecording = async () => {
- if (screenStream && videoStream) {
- const combinedStream = new MediaStream();
- const canvas = document.createElement("canvas");
- const ctx = canvas.getContext("2d");
-
- const screenSize = screenStream.getVideoTracks()[0].getSettings();
- canvas.width = screenSize.width ?? 1280;
- canvas.height = screenSize.height ?? 720;
-
- let animationFrameId: number;
-
- const drawCanvas = () => {
- if (ctx) {
- ctx.drawImage(
- document.getElementById("screenPreview") as HTMLVideoElement,
- 0,
- 0,
- canvas.width,
- canvas.height
- );
-
- // Get the current position and size of the webcam preview
- const webcamPreview = document.getElementById(
- "webcamPreview"
- ) as HTMLVideoElement;
- const webcamRect = webcamPreview.getBoundingClientRect();
- const camWidth = webcamRect.width;
- const camHeight = webcamRect.height;
- const camX = webcamRect.left;
- const camY = webcamRect.top;
-
- // Calculate the aspect ratio of the video
- const videoWidth = webcamPreview.videoWidth;
- const videoHeight = webcamPreview.videoHeight;
- const aspectRatio = videoWidth / videoHeight;
-
- // Calculate the new dimensions based on the aspect ratio
- let newWidth = camWidth;
- let newHeight = camWidth / aspectRatio;
- if (newHeight > camHeight) {
- newWidth = camHeight * aspectRatio;
- newHeight = camHeight;
- }
-
- // Calculate the position to center the video
- const centerX = camX + (camWidth - newWidth) / 2;
- const centerY = camY + (camHeight - newHeight) / 2;
-
- // Set the position and size of the circular webcam preview on the canvas
- ctx.save();
- ctx.beginPath();
- ctx.arc(
- centerX + newWidth / 2,
- centerY + newHeight / 2,
- Math.min(newWidth, newHeight) / 2,
- 0,
- 2 * Math.PI
- );
- ctx.clip();
- ctx.drawImage(webcamPreview, centerX, centerY, newWidth, newHeight);
- ctx.restore();
- animationFrameId = requestAnimationFrame(drawCanvas);
- }
- };
-
- drawCanvas();
-
- const canvasStream = canvas.captureStream(30);
- canvasStream
- .getVideoTracks()
- .forEach((track) => combinedStream.addTrack(track));
-
- videoStream
- .getAudioTracks()
- .forEach((track) => combinedStream.addTrack(track));
-
- setCombinedStream(combinedStream);
-
- const options = { mimeType: "video/webm; codecs=vp9,opus" };
- const mediaRecorder = new MediaRecorder(combinedStream, options);
- const recordedChunks: Blob[] = [];
-
- mediaRecorder.ondataavailable = function (event) {
- if (event.data.size > 0) recordedChunks.push(event.data);
- };
-
- mediaRecorder.onstop = () => {
- cancelAnimationFrame(animationFrameId);
- const recordedBlob = new Blob(recordedChunks, { type: "video/webm" });
- console.log("Recorded Blob:", recordedBlob);
- setRecordedBlobs([recordedBlob]);
- };
-
- setIsRecording(true);
- mediaRecorder.start();
- setMediaRecorder(mediaRecorder);
- }
- };
-
- const stopRecording = () => {
- if (mediaRecorder && mediaRecorder.state === "recording") {
- setIsRecording(false);
- mediaRecorder.stop();
- }
- };
-
- useEffect(() => {
- getDevices();
- }, []);
-
- useEffect(() => {
- if (recordedBlobs.length > 0) {
- const recordedVideo = new Blob(recordedBlobs, { type: "video/webm" });
- const videoUrl = URL.createObjectURL(recordedVideo);
- const link = document.createElement("a");
- link.href = videoUrl;
- link.download = "recorded_video.webm";
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- URL.revokeObjectURL(videoUrl);
- setRecordedBlobs([]);
- }
- }, [recordedBlobs]);
-
- useEffect(() => {
- const storedAudioDevice = localStorage.getItem("selectedAudioDevice");
- const storedVideoDevice = localStorage.getItem("selectedVideoDevice");
- const storedScreenStream = localStorage.getItem("screenStream");
-
- if (storedAudioDevice) {
- setSelectedAudioDevice(storedAudioDevice);
- }
- if (storedVideoDevice) {
- setSelectedVideoDevice(storedVideoDevice);
- startVideoCapture(storedVideoDevice);
- }
- if (storedScreenStream === "true") {
- startScreenCapture();
- }
- }, []);
-
- useEffect(() => {
- if (selectedAudioDevice) {
- localStorage.setItem("selectedAudioDevice", selectedAudioDevice);
- } else {
- localStorage.removeItem("selectedAudioDevice");
- }
- if (selectedVideoDevice) {
- localStorage.setItem("selectedVideoDevice", selectedVideoDevice);
- } else {
- localStorage.removeItem("selectedVideoDevice");
- }
- if (screenStream) {
- localStorage.setItem("screenStream", "true");
- } else {
- localStorage.removeItem("screenStream");
- }
- }, [selectedAudioDevice, selectedVideoDevice, screenStream]);
-
- return (
- <div className="z-[1000000] absolute top-0 left-0 w-full h-full bg-black flex items-center justify-center">
- <div className="z-[1000001] absolute bottom-4 left-1/2 transform -translate-x-1/2 w-[90%] h-16 bg-[#212024] flex items-center justify-center rounded-full">
- <div className="w-full max-w-[650px] mx-auto flex justify-center items-center space-x-2">
- <div className="group flex items-center justify-center relative">
- <button
- className={buttonStyles}
- onClick={() => setShowAudioOptions(!showAudioOptions)}
- >
- {selectedAudioDevice ? (
- <Mic className="w-4 h-4 text-white" />
- ) : (
- <MicOff className="w-4 h-4 text-white" />
- )}
- <div className="text-white text-xs">
- {selectedAudioDevice ? "Mute audio" : "Unmute audio"}
- </div>
- </button>
- {showAudioOptions && (
- <div className="z-[1000002] absolute bottom-full left-0 bg-[#212024] w-full text-white rounded-md shadow-lg">
- {audioDevices.map((device) => (
- <button
- key={device.deviceId}
- className="block w-full px-4 py-2 text-left hover:bg-[#2e2d32]"
- onClick={() => {
- setSelectedAudioDevice(device.deviceId);
- setShowAudioOptions(false);
- }}
- >
- {device.label}
- </button>
- ))}
- </div>
- )}
- <button
- className="flex items-center justify-center absolute top-0 right-0 w-5 h-full hover:bg-[#424147] flex-grow rounded-tr-xl rounded-br-xl"
- onClick={() => setShowAudioOptions(!showAudioOptions)}
- >
- <ChevronUp className="w-2.5 h-2.5 text-white" />
- </button>
- </div>
- <div className="group flex items-center justify-center relative">
- <button
- className={buttonStyles}
- onClick={() => setShowVideoOptions(!showVideoOptions)}
- >
- {selectedVideoDevice ? (
- <Video className="w-4 h-4 text-white" />
- ) : (
- <VideoOff className="w-4 h-4 text-white" />
- )}
- <div className="text-white text-xs">
- {selectedVideoDevice ? "Stop camera" : "Show camera"}
- </div>
- </button>
- {showVideoOptions && (
- <div className="z-[1000002] absolute bottom-full left-0 bg-[#212024] w-full text-white rounded-md shadow-lg">
- {videoDevices.map((device) => (
- <button
- key={device.deviceId}
- className="block w-full px-4 py-2 text-left hover:bg-[#2e2d32]"
- onClick={() => {
- setSelectedVideoDevice(device.deviceId);
- startVideoCapture(device.deviceId);
- setShowVideoOptions(false);
- }}
- >
- {device.label}
- </button>
- ))}
- </div>
- )}
- <button
- className="flex items-center justify-center absolute top-0 right-0 w-5 h-full hover:bg-[#424147] flex-grow rounded-tr-xl rounded-br-xl"
- onClick={() => setShowVideoOptions(!showVideoOptions)}
- >
- <ChevronUp className="w-2.5 h-2.5 text-white" />
- </button>
- </div>
- <div className="group flex flex-col items-center justify-center">
- <button
- onClick={() => {
- isRecording ? stopRecording() : startRecording();
- }}
- className="px-4 cursor-pointer disabled:cursor-not-allowed group"
- >
- <div className="shadow-recording-button group-enabled:hover:shadow-recording-heavy-button w-12 h-12 rounded-full flex items-center justify-center border border-red-700/50 border-4 group-enabled:hover:border-red-700 duration-300 transition">
- <div className="bg-red-700 group-disabled:!bg-red-700/50 transition duration-500 group-enabled:hover:!bg-red-700 w-8 h-8 rounded-full" />
- </div>
- </button>
- </div>
- <div className="group flex items-center justify-center">
- <button
- className={buttonStyles + " pl-5 pr-5"}
- onClick={screenStream ? stopScreenCapture : startScreenCapture}
- >
- <Monitor className="w-4 h-4 text-white" />
- <div className="text-white text-xs">
- {screenStream ? "Stop screen" : "Show screen"}
- </div>
- </button>
- </div>
- <div className="group flex items-center justify-center">
- <button className={buttonStyles + " pl-5 pr-5"}>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="24"
- height="24"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- className="w-4 h-4 text-white"
- viewBox="0 0 24 24"
- >
- <circle cx="12" cy="12" r="1"></circle>
- <circle cx="19" cy="12" r="1"></circle>
- <circle cx="5" cy="12" r="1"></circle>
- </svg>
- <div className="text-white text-xs">More</div>
- </button>
- </div>
- </div>
- </div>
- {(screenStream || videoStream) && (
- <div className="aspect-video absolute top-8 left-0 w-full h-[calc(100%-8rem)] object-contain">
- <video
- id="screenPreview"
- ref={(video) => {
- if (video) {
- video.srcObject = screenStream;
- }
- }}
- autoPlay
- muted
- className="w-full h-full object-contain"
- />
- {videoStream && (
- <Rnd
- default={{
- x: 0,
- y: 0,
- width: 200,
- height: 200,
- }}
- bounds="parent"
- className="absolute bottom-8 left-8"
- lockAspectRatio={true}
- >
- <div className="w-full h-full rounded-full overflow-hidden">
- <video
- id="webcamPreview"
- ref={(video) => {
- if (video) {
- video.srcObject = videoStream;
- }
- }}
- autoPlay
- muted
- className="w-full h-full object-cover"
- />
- </div>
- </Rnd>
- )}
- </div>
- )}
- </div>
- );
-};
diff --git a/apps/web/app/record/Record.tsx b/apps/web/app/record/Record.tsx
new file mode 100644
index 000000000..32bbaa17a
--- /dev/null
+++ b/apps/web/app/record/Record.tsx
@@ -0,0 +1,531 @@
+"use client";
+
+import { useState, useEffect, useRef } from "react";
+import { users } from "@cap/database/schema";
+import { Mic, Video, Monitor } from "lucide-react";
+import { Rnd } from "react-rnd";
+import {
+ Button,
+ Logo,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@cap/ui";
+import { ActionButton } from "./_components/ActionButton";
+import toast from "react-hot-toast";
+
+// million-ignore
+export const Record = ({
+ user,
+}: {
+ user: typeof users.$inferSelect | null;
+}) => {
+ const [startingRecording, setStartingRecording] = useState(false);
+ const [stoppingRecording, setStoppingRecording] = useState(false);
+ const [isRecording, setIsRecording] = useState(false);
+ const [currentStoppingMessage, setCurrentStoppingMessage] =
+ useState("Stopping Recording");
+ const [recordingTime, setRecordingTime] = useState("00:00");
+
+ const [audioDevices, setAudioDevices] = useState<MediaDeviceInfo[]>([]);
+ const [videoDevices, setVideoDevices] = useState<MediaDeviceInfo[]>([]);
+ const [selectedAudioDevice, setSelectedAudioDevice] = useState<string>();
+ const [selectedVideoDevice, setSelectedVideoDevice] = useState<string>();
+ const [selectedAudioDeviceLabel, setSelectedAudioDeviceLabel] =
+ useState("Microphone");
+ const [selectedVideoDeviceLabel, setSelectedVideoDeviceLabel] =
+ useState("Webcam");
+
+ const [showAudioOptions, setShowAudioOptions] = useState(false);
+ const [showVideoOptions, setShowVideoOptions] = useState(false);
+ const [screenStream, setScreenStream] = useState<MediaStream | null>(null);
+ const [videoStream, setVideoStream] = useState<MediaStream | null>(null);
+ const [combinedStream, setCombinedStream] = useState<MediaStream | null>(
+ null
+ );
+ const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(
+ null
+ );
+ const [recordedBlobs, setRecordedBlobs] = useState<Blob[]>([]);
+ const screenPreviewRef = useRef<HTMLVideoElement>(null);
+ const webcamPreviewRef = useRef<HTMLVideoElement>(null);
+
+ const buttonStyles =
+ "w-full h-full flex flex-col items-center justify-center text-center space-y-1 py-2 pl-5 pr-7 group-hover:bg-gray-300 rounded-xl";
+
+ const getDevices = async () => {
+ try {
+ await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
+ const devices = await navigator.mediaDevices.enumerateDevices();
+ console.log("Devices:", devices);
+ const audioDevices = devices.filter(
+ (device) => device.kind === "audioinput"
+ );
+ const videoDevices = devices.filter(
+ (device) => device.kind === "videoinput"
+ );
+ setAudioDevices(audioDevices);
+ setVideoDevices(videoDevices);
+ } catch (error) {
+ console.error("Error accessing media devices:", error);
+ }
+ };
+
+ const startScreenCapture = async () => {
+ try {
+ const displayMediaOptions = {
+ video: {
+ displaySurface: "browser",
+ },
+ audio: false,
+ surfaceSwitching: "exclude",
+ selfBrowserSurface: "exclude",
+ systemAudio: "exclude",
+ };
+
+ const stream = await navigator.mediaDevices.getDisplayMedia(
+ displayMediaOptions
+ );
+ setScreenStream(stream);
+ } catch (error) {
+ console.error("Error capturing screen:", error);
+ }
+ };
+
+ const startVideoCapture = async (deviceId?: string) => {
+ try {
+ const constraints: MediaStreamConstraints = {
+ video: deviceId ? { deviceId } : true,
+ audio: selectedAudioDevice ? { deviceId: selectedAudioDevice } : false,
+ };
+
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
+ setVideoStream(stream);
+ } catch (error) {
+ console.error("Error capturing video:", error);
+ }
+ };
+
+ const stopScreenCapture = () => {
+ if (screenStream) {
+ screenStream.getTracks().forEach((track) => track.stop());
+ setScreenStream(null);
+ }
+ };
+
+ const stopVideoCapture = () => {
+ if (videoStream) {
+ videoStream.getTracks().forEach((track) => track.stop());
+ setVideoStream(null);
+ }
+ };
+
+ const startRecording = async () => {
+ if (screenStream && videoStream) {
+ setStartingRecording(true);
+
+ const combinedStream = new MediaStream();
+ const canvas = document.createElement("canvas");
+ const ctx = canvas.getContext("2d");
+
+ const screenSize = screenStream.getVideoTracks()[0].getSettings();
+ canvas.width = screenSize.width ?? 1280;
+ canvas.height = screenSize.height ?? 720;
+
+ let animationFrameId: number;
+
+ const drawCanvas = () => {
+ if (ctx) {
+ ctx.drawImage(
+ document.getElementById("screenPreview") as HTMLVideoElement,
+ 0,
+ 0,
+ canvas.width,
+ canvas.height
+ );
+
+ // Get the current position and size of the webcam preview
+ const webcamPreview = document.getElementById(
+ "webcamPreview"
+ ) as HTMLVideoElement;
+ const webcamRect = webcamPreview.getBoundingClientRect();
+ const containerRect = document
+ .querySelector(".aspect-w-16.aspect-h-9")
+ ?.getBoundingClientRect();
+
+ if (containerRect) {
+ const scaleX = canvas.width / containerRect.width;
+ const scaleY = canvas.height / containerRect.height;
+
+ const camWidth = webcamRect.width * scaleX;
+ const camHeight = webcamRect.height * scaleY;
+ const camX = (webcamRect.left - containerRect.left) * scaleX;
+ const camY = (webcamRect.top - containerRect.top) * scaleY;
+
+ // Calculate the aspect ratio of the original webcam video
+ const videoWidth = webcamPreview.videoWidth;
+ const videoHeight = webcamPreview.videoHeight;
+ const aspectRatio = videoWidth / videoHeight;
+
+ // Adjust the webcam preview size to maintain the aspect ratio
+ let newWidth = camWidth;
+ let newHeight = camWidth / aspectRatio;
+ if (newHeight > camHeight) {
+ newWidth = camHeight * aspectRatio;
+ newHeight = camHeight;
+ }
+
+ // Calculate the position to center the adjusted webcam preview
+ const centerX = camX + (camWidth - newWidth) / 2;
+ const centerY = camY + (camHeight - newHeight) / 2;
+
+ // Set the position and size of the circular webcam preview on the canvas
+ ctx.save();
+ ctx.beginPath();
+ ctx.arc(
+ centerX + newWidth / 2,
+ centerY + newHeight / 2,
+ Math.min(newWidth, newHeight) / 2,
+ 0,
+ 2 * Math.PI
+ );
+ ctx.clip();
+ ctx.drawImage(webcamPreview, centerX, centerY, newWidth, newHeight);
+ ctx.restore();
+ }
+
+ animationFrameId = requestAnimationFrame(drawCanvas);
+ }
+ };
+
+ drawCanvas();
+
+ const canvasStream = canvas.captureStream(30);
+ canvasStream
+ .getVideoTracks()
+ .forEach((track) => combinedStream.addTrack(track));
+
+ videoStream
+ .getAudioTracks()
+ .forEach((track) => combinedStream.addTrack(track));
+
+ setCombinedStream(combinedStream);
+
+ const options = { mimeType: "video/webm; codecs=vp9,opus" };
+ const mediaRecorder = new MediaRecorder(combinedStream, options);
+ const recordedChunks: Blob[] = [];
+
+ mediaRecorder.ondataavailable = function (event) {
+ if (event.data.size > 0) recordedChunks.push(event.data);
+ };
+
+ mediaRecorder.onstop = () => {
+ cancelAnimationFrame(animationFrameId);
+ const recordedBlob = new Blob(recordedChunks, { type: "video/webm" });
+ console.log("Recorded Blob:", recordedBlob);
+ setRecordedBlobs([recordedBlob]);
+ };
+
+ mediaRecorder.start();
+ setIsRecording(true);
+ setStartingRecording(false);
+ setMediaRecorder(mediaRecorder);
+ } else {
+ toast.error("No source selected for recording");
+ }
+ };
+
+ const stopRecording = () => {
+ setStoppingRecording(true);
+
+ if (mediaRecorder && mediaRecorder.state === "recording") {
+ mediaRecorder.stop();
+ setIsRecording(false);
+ setStoppingRecording(false);
+ }
+ };
+
+ useEffect(() => {
+ getDevices();
+ }, []);
+
+ useEffect(() => {
+ if (recordedBlobs.length > 0) {
+ const recordedVideo = new Blob(recordedBlobs, { type: "video/webm" });
+ const videoUrl = URL.createObjectURL(recordedVideo);
+ const link = document.createElement("a");
+ link.href = videoUrl;
+ link.download = "recorded_video.webm";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ URL.revokeObjectURL(videoUrl);
+ setRecordedBlobs([]);
+ }
+ }, [recordedBlobs]);
+
+ useEffect(() => {
+ const storedAudioDevice = localStorage.getItem("selectedAudioDevice");
+ const storedVideoDevice = localStorage.getItem("selectedVideoDevice");
+ const storedScreenStream = localStorage.getItem("screenStream");
+
+ if (storedAudioDevice) {
+ setSelectedAudioDevice(storedAudioDevice);
+ }
+ if (storedVideoDevice) {
+ setSelectedVideoDevice(storedVideoDevice);
+ startVideoCapture(storedVideoDevice);
+ }
+ if (storedScreenStream === "true") {
+ startScreenCapture();
+ }
+ }, []);
+
+ useEffect(() => {
+ if (selectedAudioDevice) {
+ localStorage.setItem("selectedAudioDevice", selectedAudioDevice);
+ } else {
+ localStorage.removeItem("selectedAudioDevice");
+ }
+ if (selectedVideoDevice) {
+ localStorage.setItem("selectedVideoDevice", selectedVideoDevice);
+ } else {
+ localStorage.removeItem("selectedVideoDevice");
+ }
+ if (screenStream) {
+ localStorage.setItem("screenStream", "true");
+ } else {
+ localStorage.removeItem("screenStream");
+ }
+ }, [selectedAudioDevice, selectedVideoDevice, screenStream]);
+
+ useEffect(() => {
+ if (screenPreviewRef.current && screenStream) {
+ screenPreviewRef.current.srcObject = screenStream;
+ }
+ if (webcamPreviewRef.current && videoStream) {
+ webcamPreviewRef.current.srcObject = videoStream;
+ }
+ }, [screenStream, videoStream]);
+
+ useEffect(() => {
+ if (stoppingRecording) {
+ const messages = ["Processing video", "Almost done", "Finishing up"];
+ let messageIndex = 0;
+
+ const nextMessage = () => {
+ setCurrentStoppingMessage(messages[messageIndex % messages.length]);
+ messageIndex++;
+ };
+
+ nextMessage();
+
+ const intervalId = setInterval(nextMessage, 2500);
+
+ return () => clearInterval(intervalId);
+ } else {
+ setCurrentStoppingMessage("");
+ }
+ }, [stoppingRecording]);
+
+ useEffect(() => {
+ let intervalId: NodeJS.Timeout;
+
+ if (isRecording && !startingRecording) {
+ const startTime = Date.now();
+
+ intervalId = setInterval(() => {
+ const seconds = Math.floor((Date.now() - startTime) / 1000);
+ const minutes = Math.floor(seconds / 60);
+ const formattedSeconds =
+ seconds % 60 < 10 ? `0${seconds % 60}` : seconds % 60;
+ setRecordingTime(`${minutes}:${formattedSeconds}`);
+ }, 1000);
+ }
+
+ return () => {
+ clearInterval(intervalId);
+ setRecordingTime("00:00");
+ };
+ }, [isRecording, startingRecording]);
+
+ useEffect(() => {
+ const storedAudioDevice = localStorage.getItem("selectedAudioDevice");
+ const storedVideoDevice = localStorage.getItem("selectedVideoDevice");
+ const storedScreenStream = localStorage.getItem("screenStream");
+
+ if (storedAudioDevice) {
+ setSelectedAudioDevice(storedAudioDevice);
+ const selectedAudioDeviceObj = audioDevices.find(
+ (device) => device.deviceId === storedAudioDevice
+ );
+ if (selectedAudioDeviceObj) {
+ setSelectedAudioDeviceLabel(selectedAudioDeviceObj.label);
+ }
+ }
+ if (storedVideoDevice) {
+ setSelectedVideoDevice(storedVideoDevice);
+ const selectedVideoDeviceObj = videoDevices.find(
+ (device) => device.deviceId === storedVideoDevice
+ );
+ if (selectedVideoDeviceObj) {
+ setSelectedVideoDeviceLabel(selectedVideoDeviceObj.label);
+ }
+ startVideoCapture(storedVideoDevice);
+ }
+ if (storedScreenStream === "true") {
+ startScreenCapture();
+ }
+ }, [audioDevices, videoDevices]);
+
+ return (
+ <div className="w-full h-screen bg-white flex">
+ <div className="min-w-[500px] h-full flex items-center justify-center">
+ <div className="w-full max-w-[290px] px-4 py-14 border-2 rounded-[15px] flex flex-col items-center justify-center bg-gradient-to-b from-white to-gray-200">
+ <div className="flex items-center justify-between mb-4">
+ <div>
+ <Logo showVersion className="w-24 h-auto" />
+ </div>
+ </div>
+ <div className="space-y-4 mb-4 w-full">
+ <div>
+ <label className="text-sm font-medium">Display</label>
+ <div className="flex items-center space-x-1">
+ <ActionButton
+ handler={() => {
+ screenStream ? stopScreenCapture() : startScreenCapture();
+ }}
+ icon={<Monitor className="w-5 h-5" />}
+ label={screenStream ? "Hide display" : "Select display"}
+ active={true}
+ />
+ </div>
+ </div>
+ <div>
+ <label className="text-sm font-medium">Webcam / Video</label>
+ <div className="space-y-2">
+ <DropdownMenu>
+ <DropdownMenuTrigger className="w-full">
+ <ActionButton
+ width="full"
+ icon={<Video className="w-5 h-5" />}
+ label={selectedVideoDeviceLabel}
+ active={true}
+ recordingOption={true}
+ optionName="Video"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-56">
+ {videoDevices.map((device) => (
+ <DropdownMenuItem
+ key={device.deviceId}
+ onSelect={() => {
+ setSelectedVideoDevice(device.deviceId);
+ setSelectedVideoDeviceLabel(device.label);
+ startVideoCapture(device.deviceId);
+ }}
+ >
+ {device.label}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <DropdownMenu>
+ <DropdownMenuTrigger className="w-full">
+ <ActionButton
+ width="full"
+ icon={<Mic className="w-5 h-5" />}
+ label={selectedAudioDeviceLabel}
+ active={true}
+ recordingOption={true}
+ optionName="Audio"
+ />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="w-56">
+ {audioDevices.map((device) => (
+ <DropdownMenuItem
+ key={device.deviceId}
+ onSelect={() => {
+ setSelectedAudioDevice(device.deviceId);
+ setSelectedAudioDeviceLabel(device.label);
+ startVideoCapture(device.deviceId);
+ }}
+ >
+ {device.label}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ </div>
+ <div className="group flex flex-col items-center justify-center w-full">
+ <Button
+ {...(isRecording && { variant: "destructive" })}
+ className="w-full flex mx-auto"
+ onClick={() => {
+ if (isRecording) {
+ stopRecording();
+ } else {
+ startRecording();
+ }
+ }}
+ spinner={startingRecording || stoppingRecording}
+ >
+ {startingRecording
+ ? "Starting..."
+ : isRecording
+ ? stoppingRecording
+ ? currentStoppingMessage
+ : `Stop - ${recordingTime}`
+ : "Start Recording"}
+ </Button>
+ </div>
+ </div>
+ </div>
+
+ <div className="border-l-2 h-full flex-grow">
+ <div className="w-full h-full top-0 left-0 h-full flex flex-col items-center justify-center p-4">
+ <div className="w-full text-left mb-3">
+ <span className="bg-white shadow-lg py-2 px-4 rounded-xl font-medium text-sm border">
+ Recording preview
+ </span>
+ </div>
+ <div className="bg-black relative w-full aspect-w-16 aspect-h-9 mx-auto border-2 border-gray-200 rounded-xl overflow-hidden shadow-xl">
+ <video
+ id="screenPreview"
+ ref={screenPreviewRef}
+ autoPlay
+ muted
+ className="w-full h-full object-contain"
+ />
+ {videoStream && (
+ <Rnd
+ default={{
+ x: 18,
+ y: 18,
+ width: 160,
+ height: 160,
+ }}
+ bounds="parent"
+ className="absolute"
+ lockAspectRatio={true}
+ >
+ <div className="w-full h-full rounded-full overflow-hidden">
+ <video
+ id="webcamPreview"
+ ref={webcamPreviewRef}
+ autoPlay
+ muted
+ className="w-full h-full object-cover rounded-full"
+ />
+ </div>
+ </Rnd>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/apps/web/app/record/_components/ActionButton.tsx b/apps/web/app/record/_components/ActionButton.tsx
new file mode 100644
index 000000000..5b4bfafe8
--- /dev/null
+++ b/apps/web/app/record/_components/ActionButton.tsx
@@ -0,0 +1,64 @@
+"use client";
+
+import { ReactNode } from "react";
+
+export const ActionButton = ({
+ handler,
+ icon,
+ label,
+ width,
+ active,
+ recordingOption = false,
+ optionName,
+}: {
+ handler?: () => void;
+ icon?: ReactNode;
+ label?: string;
+ width?: string;
+ active?: boolean;
+ recordingOption?: boolean;
+ optionName?: string;
+}) => {
+ const truncatedLabel =
+ label && label.length > 18 ? label.substring(0, 18) + "..." : label;
+
+ const commonProps = {
+ className: `${
+ active === true
+ ? "bg-white hover:bg-gray-100"
+ : "bg-gray-200 hover:bg-white"
+ } border-gray-300 w-full h-[50px] py-2 px-4 text-[14px] border-2 flex items-center justify-between rounded-[15px] flex-grow transition-all shadow-sm shadow-[0px 0px 180px rgba(255, 255, 255, 0.18)]`,
+ };
+
+ const Element = handler ? "button" : "div";
+
+ return (
+ <div className="flex-grow">
+ <Element {...(handler && { onClick: handler })} {...commonProps}>
+ <div className="flex items-center">
+ <span>{icon}</span>
+ {truncatedLabel && (
+ <span
+ className={`ml-2 truncate ${width !== "full" && "max-w-[100px]"}`}
+ >
+ {truncatedLabel === "None" ? `No ${optionName}` : truncatedLabel}
+ </span>
+ )}
+ </div>
+ {recordingOption && (
+ <div>
+ <span
+ className={`${
+ label === "None"
+ ? "bg-red-600 text-white"
+ : "bg-tertiary text-primary "
+ } h-5 w-8 font-medium text-xs rounded-full flex items-center justify-center`}
+ >
+ <span>{label === "None" ? "Off" : "On"}</span>
+ </span>
+ </div>
+ )}
+ </Element>
+ </div>
+ );
+};
diff --git a/apps/web/app/dashboard/record/page.tsx b/apps/web/app/record/page.tsx
similarity index 100%
rename from apps/web/app/dashboard/record/page.tsx
rename to apps/web/app/record/page.tsx
diff --git a/apps/web/components/Footer.tsx b/apps/web/components/Footer.tsx
index cb17ecc06..10ab876f5 100644
--- a/apps/web/components/Footer.tsx
+++ b/apps/web/components/Footer.tsx
@@ -10,6 +10,7 @@ export const Footer = () => {
pathname.includes("/dashboard") ||
pathname.includes("/s/") ||
pathname.includes("/onboarding") ||
+ pathname.includes("/record") ||
(typeof window !== "undefined" && window.location.href.includes("cap.link"))
)
return null;
diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsx
index 5c22b8125..53c6f937e 100644
--- a/apps/web/components/Navbar.tsx
+++ b/apps/web/components/Navbar.tsx
@@ -27,6 +27,7 @@ export const Navbar = ({ auth }: { auth: boolean }) => {
pathname.includes("/dashboard") ||
pathname.includes("/s/") ||
pathname.includes("/onboarding") ||
+ pathname.includes("/record") ||
(typeof window !== "undefined" && window.location.href.includes("cap.link"))
)
return null;
diff --git a/apps/web/components/pages/HomePage.tsx b/apps/web/components/pages/HomePage.tsx
index 0ac86b759..0fe46836f 100644
--- a/apps/web/components/pages/HomePage.tsx
+++ b/apps/web/components/pages/HomePage.tsx
@@ -118,7 +118,7 @@ export const HomePage = () => {
<div className="fade-in-up animate-delay-2">
<div className="flex items-center justify-center space-x-2 mb-3">
<Button href="/download" size="lg">
- Download for free
+ Get started for free
</Button>
</div>
<p className="text-gray-500 text-sm">
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index bb268686c..569f25f57 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -56,7 +56,13 @@ const nextConfig = {
const millionConfig = {
auto: {
rsc: true,
- skip: ["Parallax", "Toolbar", "react-scroll-parallax"],
+ skip: [
+ "Parallax",
+ "Toolbar",
+ "react-scroll-parallax",
+ "Record",
+ "ActionButton",
+ ],
},
};
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 2c8e39161..3705fafde 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -38,6 +38,7 @@
"dependencies": {
"@cap/utils": "workspace:*",
"@radix-ui/react-dialog": "^1.0.5",
+ "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
diff --git a/packages/ui/src/components/Dropdown.tsx b/packages/ui/src/components/Dropdown.tsx
new file mode 100644
index 000000000..fb37c3b47
--- /dev/null
+++ b/packages/ui/src/components/Dropdown.tsx
@@ -0,0 +1,203 @@
+"use client";
+
+import * as React from "react";
+import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
+import { Check, ChevronRight, Circle } from "lucide-react";
+
+import { classNames } from "@cap/utils";
+
+const DropdownMenu = DropdownMenuPrimitive.Root;
+
+const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
+
+const DropdownMenuGroup = DropdownMenuPrimitive.Group;
+
+const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
+
+const DropdownMenuSub = DropdownMenuPrimitive.Sub;
+
+const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
+
+const DropdownMenuSubTrigger = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean;
+ }
+>(({ className, inset, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubTrigger
+ ref={ref}
+ className={classNames(
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRight className="ml-auto h-4 w-4" />
+ </DropdownMenuPrimitive.SubTrigger>
+));
+DropdownMenuSubTrigger.displayName =
+ DropdownMenuPrimitive.SubTrigger.displayName;
+
+const DropdownMenuSubContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubContent
+ ref={ref}
+ className={classNames(
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+));
+DropdownMenuSubContent.displayName =
+ DropdownMenuPrimitive.SubContent.displayName;
+
+const DropdownMenuContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
+>(({ className, sideOffset = 4, ...props }, ref) => (
+ <DropdownMenuPrimitive.Portal>
+ <DropdownMenuPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={classNames(
+ "z-[1000000000] bg-white min-w-[8rem] overflow-hidden rounded-xl border p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+ </DropdownMenuPrimitive.Portal>
+));
+DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
+
+const DropdownMenuItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean;
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Item
+ ref={ref}
+ className={classNames(
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ />
+));
+DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
+
+const DropdownMenuCheckboxItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
+>(({ className, children, checked, ...props }, ref) => (
+ <DropdownMenuPrimitive.CheckboxItem
+ ref={ref}
+ className={classNames(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.CheckboxItem>
+));
+DropdownMenuCheckboxItem.displayName =
+ DropdownMenuPrimitive.CheckboxItem.displayName;
+
+const DropdownMenuRadioItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
+>(({ className, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.RadioItem
+ ref={ref}
+ className={classNames(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Circle className="h-2 w-2 fill-current" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.RadioItem>
+));
+DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
+
+const DropdownMenuLabel = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean;
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Label
+ ref={ref}
+ className={classNames(
+ "px-2 py-1.5 text-sm font-semibold",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ />
+));
+DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
+
+const DropdownMenuSeparator = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.Separator
+ ref={ref}
+ className={classNames("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+));
+DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
+
+const DropdownMenuShortcut = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => {
+ return (
+ <span
+ className={classNames(
+ "ml-auto text-xs tracking-widest opacity-60",
+ className
+ )}
+ {...props}
+ />
+ );
+};
+DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
+
+export {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuGroup,
+ DropdownMenuPortal,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuRadioGroup,
+};
diff --git a/packages/ui/src/components/icons/Logo.tsx b/packages/ui/src/components/icons/Logo.tsx
index 23224dafe..abd7ff752 100644
--- a/packages/ui/src/components/icons/Logo.tsx
+++ b/packages/ui/src/components/icons/Logo.tsx
@@ -1,78 +1,91 @@
-export const Logo = ({ className }: { className: string }) => {
+export const Logo = ({
+ className,
+ showVersion,
+}: {
+ className: string;
+ showVersion?: boolean;
+}) => {
return (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- className={className}
- fill="none"
- viewBox="0 0 719 269"
- >
- <path
- fill="#0A486B"
- d="M474.954 156.466c-3.122 16.278-10.217 29.23-21.286 38.856-10.927 9.484-25.118 14.226-42.572 14.226-14.333 0-26.892-3.397-37.677-10.192-10.643-6.936-18.873-16.349-24.692-28.24-5.818-11.89-8.727-25.267-8.727-40.13 0-14.863 2.838-28.31 8.514-40.342 5.819-12.032 14.12-21.445 24.905-28.24C384.204 55.468 396.763 52 411.096 52c16.603 0 30.368 4.53 41.295 13.589 10.927 9.059 18.164 21.304 21.712 36.733l-27.885 1.486c-2.129-8.776-6.244-15.641-12.346-20.596-6.102-5.096-13.765-7.644-22.989-7.644-9.65 0-17.739 2.407-24.266 7.22-6.386 4.812-11.14 11.465-14.262 19.959-3.122 8.351-4.683 17.764-4.683 28.239 0 10.475 1.561 19.818 4.683 28.028 3.122 8.21 7.876 14.792 14.262 19.746 6.527 4.813 14.616 7.219 24.266 7.219 9.65 0 17.526-2.76 23.628-8.28 6.243-5.662 10.359-13.236 12.346-22.72l28.097 1.487zM486.826 127.801c2.271-11.607 7.734-20.596 16.391-26.965 8.656-6.512 19.796-9.768 33.419-9.768 16.177 0 28.452 4.106 36.825 12.316 8.372 8.21 12.559 20.171 12.559 35.883v39.281c0 2.973.567 5.096 1.703 6.37 1.277 1.132 3.051 1.698 5.321 1.698h4.257v19.535l-6.598.212h-.852c-3.831.142-7.734-.142-11.707-.849-3.832-.708-7.237-2.336-10.217-4.884-2.981-2.548-4.683-6.441-5.109-11.678-2.838 5.804-7.45 10.546-13.836 14.226-6.386 3.68-14.191 5.521-23.415 5.521-11.636 0-21.357-2.902-29.162-8.706-7.663-5.945-11.494-13.73-11.494-23.356 0-7.078 1.631-12.811 4.895-17.199 3.406-4.388 8.089-7.856 14.049-10.404 6.102-2.548 14.049-4.742 23.841-6.582l31.716-6.37c-.142-8.635-2.058-15.004-5.747-19.109-3.69-4.247-9.366-6.37-17.029-6.37-5.96 0-10.927 1.628-14.9 4.883-3.832 3.114-6.457 7.715-7.876 13.802l-27.034-1.487zm25.331 47.987c0 4.105 1.703 7.502 5.108 10.191 3.548 2.548 8.586 3.822 15.114 3.822 5.25 0 9.933-1.274 14.048-3.822 4.258-2.547 7.522-6.369 9.792-11.465 2.413-5.238 3.619-11.537 3.619-18.898v-1.061l-21.712 3.822-3.832.637c-5.25.991-9.366 1.981-12.346 2.972-2.838.991-5.179 2.619-7.024 4.884-1.845 2.123-2.767 5.096-2.767 8.918zM611.079 93.616h24.905l.851 23.569-2.128-2.76c2.838-7.503 7.308-13.236 13.41-17.199 6.244-4.105 13.765-6.158 22.563-6.158 10.502 0 19.371 2.62 26.608 7.857 7.237 5.237 12.63 12.315 16.178 21.233 3.689 8.776 5.534 18.684 5.534 29.726 0 11.041-1.845 21.02-5.534 29.938-3.548 8.776-8.941 15.783-16.178 21.02-7.237 5.238-16.106 7.857-26.608 7.857-5.818 0-11.139-.92-15.964-2.761-4.683-1.84-8.728-4.529-12.133-8.068-3.264-3.539-5.818-7.927-7.663-13.165l2.554-2.123V238h-26.395V93.616zm24.266 56.268c0 6.794.994 13.022 2.98 18.684 2.129 5.521 5.322 9.98 9.579 13.377 4.257 3.397 9.437 5.096 15.539 5.096 9.224 0 16.178-3.539 20.861-10.616 4.824-7.078 7.237-15.925 7.237-26.541 0-10.475-2.413-19.322-7.237-26.542-4.683-7.219-11.637-10.828-20.861-10.828-6.102 0-11.282 1.769-15.539 5.308-4.257 3.397-7.45 7.927-9.579 13.589-1.986 5.521-2.98 11.678-2.98 18.473z"
- ></path>
- <path
- fill="url(#paint0_linear_0_1)"
- d="M218.623 0H50C22.386 0 0 22.386 0 50v168.623c0 27.614 22.386 50 50 50h168.623c27.614 0 50-22.386 50-50V50c0-27.614-22.386-50-50-50z"
- ></path>
- <path
- fill="url(#paint1_radial_0_1)"
- d="M134.646 240.418c58.415 0 105.77-47.355 105.77-105.77s-47.355-105.77-105.77-105.77-105.77 47.355-105.77 105.77 47.355 105.77 105.77 105.77z"
- ></path>
- <path
- fill="url(#paint2_linear_0_1)"
- d="M134.983 224.972c49.699 0 89.988-40.289 89.988-89.988 0-49.7-40.289-89.989-89.988-89.989-49.7 0-89.989 40.29-89.989 89.989 0 49.699 40.29 89.988 89.989 89.988z"
- ></path>
- <path
- fill="url(#paint3_radial_0_1)"
- d="M134.983 202.81c37.46 0 67.828-30.368 67.828-67.828 0-37.46-30.368-67.827-67.828-67.827-37.46 0-67.827 30.367-67.827 67.827 0 37.46 30.367 67.828 67.827 67.828z"
- ></path>
- <defs>
- <linearGradient
- id="paint0_linear_0_1"
- x1="134.311"
- x2="134.311"
- y1="0"
- y2="268.623"
- gradientUnits="userSpaceOnUse"
- >
- <stop stopColor="#A8DBF8"></stop>
- <stop offset="1" stopColor="#BCCBFF"></stop>
- </linearGradient>
- <radialGradient
- id="paint1_radial_0_1"
- cx="0"
- cy="0"
- r="1"
- gradientTransform="rotate(107.38 31.314 98.475) scale(149.225)"
- gradientUnits="userSpaceOnUse"
- >
- <stop offset="0.063" stopColor="#84D3FF"></stop>
- <stop offset="0.411" stopColor="#17ABFE"></stop>
- <stop offset="0.906" stopColor="#0770D1"></stop>
- </radialGradient>
- <linearGradient
- id="paint2_linear_0_1"
- x1="134.983"
- x2="134.983"
- y1="44.995"
- y2="224.972"
- gradientUnits="userSpaceOnUse"
- >
- <stop stopColor="#BBE8FF"></stop>
- <stop offset="1" stopColor="#018FEF"></stop>
- </linearGradient>
- <radialGradient
- id="paint3_radial_0_1"
- cx="0"
- cy="0"
- r="1"
- gradientTransform="rotate(98.584 14.543 129.964) scale(68.5955)"
- gradientUnits="userSpaceOnUse"
- >
- <stop stopColor="#7EC3FF"></stop>
- <stop offset="1" stopColor="#EAF5FF"></stop>
- </radialGradient>
- </defs>
- </svg>
+ <div className="flex items-center space-x-1">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ className={className}
+ fill="none"
+ viewBox="0 0 719 269"
+ >
+ <path
+ fill="#0A486B"
+ d="M474.954 156.466c-3.122 16.278-10.217 29.23-21.286 38.856-10.927 9.484-25.118 14.226-42.572 14.226-14.333 0-26.892-3.397-37.677-10.192-10.643-6.936-18.873-16.349-24.692-28.24-5.818-11.89-8.727-25.267-8.727-40.13 0-14.863 2.838-28.31 8.514-40.342 5.819-12.032 14.12-21.445 24.905-28.24C384.204 55.468 396.763 52 411.096 52c16.603 0 30.368 4.53 41.295 13.589 10.927 9.059 18.164 21.304 21.712 36.733l-27.885 1.486c-2.129-8.776-6.244-15.641-12.346-20.596-6.102-5.096-13.765-7.644-22.989-7.644-9.65 0-17.739 2.407-24.266 7.22-6.386 4.812-11.14 11.465-14.262 19.959-3.122 8.351-4.683 17.764-4.683 28.239 0 10.475 1.561 19.818 4.683 28.028 3.122 8.21 7.876 14.792 14.262 19.746 6.527 4.813 14.616 7.219 24.266 7.219 9.65 0 17.526-2.76 23.628-8.28 6.243-5.662 10.359-13.236 12.346-22.72l28.097 1.487zM486.826 127.801c2.271-11.607 7.734-20.596 16.391-26.965 8.656-6.512 19.796-9.768 33.419-9.768 16.177 0 28.452 4.106 36.825 12.316 8.372 8.21 12.559 20.171 12.559 35.883v39.281c0 2.973.567 5.096 1.703 6.37 1.277 1.132 3.051 1.698 5.321 1.698h4.257v19.535l-6.598.212h-.852c-3.831.142-7.734-.142-11.707-.849-3.832-.708-7.237-2.336-10.217-4.884-2.981-2.548-4.683-6.441-5.109-11.678-2.838 5.804-7.45 10.546-13.836 14.226-6.386 3.68-14.191 5.521-23.415 5.521-11.636 0-21.357-2.902-29.162-8.706-7.663-5.945-11.494-13.73-11.494-23.356 0-7.078 1.631-12.811 4.895-17.199 3.406-4.388 8.089-7.856 14.049-10.404 6.102-2.548 14.049-4.742 23.841-6.582l31.716-6.37c-.142-8.635-2.058-15.004-5.747-19.109-3.69-4.247-9.366-6.37-17.029-6.37-5.96 0-10.927 1.628-14.9 4.883-3.832 3.114-6.457 7.715-7.876 13.802l-27.034-1.487zm25.331 47.987c0 4.105 1.703 7.502 5.108 10.191 3.548 2.548 8.586 3.822 15.114 3.822 5.25 0 9.933-1.274 14.048-3.822 4.258-2.547 7.522-6.369 9.792-11.465 2.413-5.238 3.619-11.537 3.619-18.898v-1.061l-21.712 3.822-3.832.637c-5.25.991-9.366 1.981-12.346 2.972-2.838.991-5.179 2.619-7.024 4.884-1.845 2.123-2.767 5.096-2.767 8.918zM611.079 93.616h24.905l.851 23.569-2.128-2.76c2.838-7.503 7.308-13.236 13.41-17.199 6.244-4.105 13.765-6.158 22.563-6.158 10.502 0 19.371 2.62 26.608 7.857 7.237 5.237 12.63 12.315 16.178 21.233 3.689 8.776 5.534 18.684 5.534 29.726 0 11.041-1.845 21.02-5.534 29.938-3.548 8.776-8.941 15.783-16.178 21.02-7.237 5.238-16.106 7.857-26.608 7.857-5.818 0-11.139-.92-15.964-2.761-4.683-1.84-8.728-4.529-12.133-8.068-3.264-3.539-5.818-7.927-7.663-13.165l2.554-2.123V238h-26.395V93.616zm24.266 56.268c0 6.794.994 13.022 2.98 18.684 2.129 5.521 5.322 9.98 9.579 13.377 4.257 3.397 9.437 5.096 15.539 5.096 9.224 0 16.178-3.539 20.861-10.616 4.824-7.078 7.237-15.925 7.237-26.541 0-10.475-2.413-19.322-7.237-26.542-4.683-7.219-11.637-10.828-20.861-10.828-6.102 0-11.282 1.769-15.539 5.308-4.257 3.397-7.45 7.927-9.579 13.589-1.986 5.521-2.98 11.678-2.98 18.473z"
+ ></path>
+ <path
+ fill="url(#paint0_linear_0_1)"
+ d="M218.623 0H50C22.386 0 0 22.386 0 50v168.623c0 27.614 22.386 50 50 50h168.623c27.614 0 50-22.386 50-50V50c0-27.614-22.386-50-50-50z"
+ ></path>
+ <path
+ fill="url(#paint1_radial_0_1)"
+ d="M134.646 240.418c58.415 0 105.77-47.355 105.77-105.77s-47.355-105.77-105.77-105.77-105.77 47.355-105.77 105.77 47.355 105.77 105.77 105.77z"
+ ></path>
+ <path
+ fill="url(#paint2_linear_0_1)"
+ d="M134.983 224.972c49.699 0 89.988-40.289 89.988-89.988 0-49.7-40.289-89.989-89.988-89.989-49.7 0-89.989 40.29-89.989 89.989 0 49.699 40.29 89.988 89.989 89.988z"
+ ></path>
+ <path
+ fill="url(#paint3_radial_0_1)"
+ d="M134.983 202.81c37.46 0 67.828-30.368 67.828-67.828 0-37.46-30.368-67.827-67.828-67.827-37.46 0-67.827 30.367-67.827 67.827 0 37.46 30.367 67.828 67.827 67.828z"
+ ></path>
+ <defs>
+ <linearGradient
+ id="paint0_linear_0_1"
+ x1="134.311"
+ x2="134.311"
+ y1="0"
+ y2="268.623"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#A8DBF8"></stop>
+ <stop offset="1" stopColor="#BCCBFF"></stop>
+ </linearGradient>
+ <radialGradient
+ id="paint1_radial_0_1"
+ cx="0"
+ cy="0"
+ r="1"
+ gradientTransform="rotate(107.38 31.314 98.475) scale(149.225)"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop offset="0.063" stopColor="#84D3FF"></stop>
+ <stop offset="0.411" stopColor="#17ABFE"></stop>
+ <stop offset="0.906" stopColor="#0770D1"></stop>
+ </radialGradient>
+ <linearGradient
+ id="paint2_linear_0_1"
+ x1="134.983"
+ x2="134.983"
+ y1="44.995"
+ y2="224.972"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#BBE8FF"></stop>
+ <stop offset="1" stopColor="#018FEF"></stop>
+ </linearGradient>
+ <radialGradient
+ id="paint3_radial_0_1"
+ cx="0"
+ cy="0"
+ r="1"
+ gradientTransform="rotate(98.584 14.543 129.964) scale(68.5955)"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor="#7EC3FF"></stop>
+ <stop offset="1" stopColor="#EAF5FF"></stop>
+ </radialGradient>
+ </defs>
+ </svg>
+ {showVersion && (
+ <span className="text-[10px] font-medium text-gray-500">
+ v{process.env.appVersion}
+ </span>
+ )}
+ </div>
);
};
diff --git a/packages/ui/src/index.tsx b/packages/ui/src/index.tsx
index eda4055f0..ff53dcb45 100644
--- a/packages/ui/src/index.tsx
+++ b/packages/ui/src/index.tsx
@@ -17,6 +17,7 @@ export * from "./components/Dialog";
export * from "./components/Popover";
export * from "./components/Card";
export * from "./components/NavigationMenu";
+export * from "./components/Dropdown";
// Forms & Inputs
export * from "./components/input/Form";
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ad8133a98..40503bbfd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -395,6 +395,9 @@ importers:
'@radix-ui/react-dialog':
specifier: ^1.0.5
+ '@radix-ui/react-dropdown-menu':
+ specifier: ^2.0.6
'@radix-ui/react-label':
specifier: ^2.0.2
@@ -2816,6 +2819,33 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-i6TuFOoWmLWq+M/eCLGd/bQ2HfAX1RJgvrBQ6AQLmzfvsLdefxbWu8G9zczcPFfcSPehz9GcpF6K9QYreFV8hA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.23.8
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-menu': 2.0.6(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.48
+ '@types/react-dom': 18.2.18
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-UagjDk4ijOAnGu4WMUPj9ahi7/zJJqNZ9ZAiGPp7waUWJO0O1aWXi/udPphI0IUjvrhBsZJGSN66dR2dsueLWQ==}
peerDependencies:
@@ -2922,6 +2952,44 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-BVkFLS+bUC8HcImkRKPSiVumA1VPOOEC5WBMiT+QAVsPzW1FJzI9KnqgGxVDPBcql5xXrHkD3JOVoXWEXD8SYA==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.23.8
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-direction': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-dismissable-layer': 1.0.5(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-focus-guards': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-focus-scope': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-popper': 1.1.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-portal': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-presence': 1.0.1(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-roving-focus': 1.0.4(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-slot': 1.0.2(@types/[email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.48
+ '@types/react-dom': 18.2.18
+ aria-hidden: 1.2.3
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ react-remove-scroll: 2.5.5(@types/[email protected])([email protected])
+ dev: false
+
resolution: {integrity: sha512-Cc+seCS3PmWmjI51ufGG7zp1cAAIRqHVw7C9LOA2TZ+R4hG6rDvHcTqIsEEFLmZO3zNVH72jOOE7kKNy8W+RtA==}
peerDependencies:
@@ -3122,6 +3190,35 @@ packages:
react-dom: 18.2.0([email protected])
dev: false
+ resolution: {integrity: sha512-2mUg5Mgcu001VkGy+FfzZyzbmuUWzgWkj3rvv4yu+mLw03+mTzbxZHvfcGyFp2b8EkQeMkpRQ5FiA2Vr2O6TeQ==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0
+ react-dom: ^16.8 || ^17.0 || ^18.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+ dependencies:
+ '@babel/runtime': 7.23.8
+ '@radix-ui/primitive': 1.0.1
+ '@radix-ui/react-collection': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-compose-refs': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-context': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-direction': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-id': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-primitive': 1.0.3(@types/[email protected])(@types/[email protected])([email protected])([email protected])
+ '@radix-ui/react-use-callback-ref': 1.0.1(@types/[email protected])([email protected])
+ '@radix-ui/react-use-controllable-state': 1.0.1(@types/[email protected])([email protected])
+ '@types/react': 18.2.48
+ '@types/react-dom': 18.2.18
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ dev: false
+
resolution: {integrity: sha512-3mrKauI/tWXo1Ll+gN5dHcxDPdm/Df1ufcDLCecn+pnCIVcdWE7CujXo8QaXOWRJyZyQWWbpB8eFwHzWXlv5mQ==}
peerDependencies: