Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Countdown overlay refresh, screen/window choice

Richie McIlroy5b5aaee036e9
diff --git a/apps/desktop/src/components/recording/ActionButton.tsx b/apps/desktop/src/components/recording/ActionButton.tsx
index fb1aee570..8c6eab166 100644
--- a/apps/desktop/src/components/recording/ActionButton.tsx
+++ b/apps/desktop/src/components/recording/ActionButton.tsx
@@ -5,17 +5,21 @@ export const ActionButton = ({
icon,
label,
width,
+ active,
}: {
handler: () => void;
icon?: ReactNode;
label?: string;
width?: string;
+ active?: boolean;
}) => {
return (
<div className="flex-grow">
<button
onClick={handler}
- className="w-full h-[50px] py-2 px-4 bg-gray-100 hover:bg-white text-[15px] border-2 border-gray-300 flex items-center justify-start rounded-[15px] flex-grow transition-all"
+ className={`${
+ active === true ? "bg-white" : "bg-gray-200"
+ } border-gray-300 hover:bg-white w-full h-[50px] py-2 px-4 text-[15px] border-2 flex items-center justify-start rounded-[15px] flex-grow transition-all`}
>
<span>{icon}</span>
{label && (
diff --git a/apps/desktop/src/components/windows/inner/Countdown.tsx b/apps/desktop/src/components/windows/inner/Countdown.tsx
index 810b8bca9..f30cabfed 100644
--- a/apps/desktop/src/components/windows/inner/Countdown.tsx
+++ b/apps/desktop/src/components/windows/inner/Countdown.tsx
@@ -25,9 +25,9 @@ export const Countdown: React.FC<CountdownOverlayProps> = ({
return countdown > 0 ? (
<div
- className="fixed inset-0 z-50 flex items-center justify-center"
+ className="absolute inset-0 z-50 flex items-center justify-center"
style={{
- backgroundColor: "rgba(0, 0, 0, 0.5)",
+ backgroundColor: "rgba(0, 0, 0, 0.75)",
}}
>
<span className="text-white text-6xl font-bold">{countdown}</span>
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index 4407872a8..8d081b244 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -2,6 +2,8 @@ import { useState, useEffect } from "react";
import { useMediaDevices } from "@/utils/recording/MediaDeviceContext";
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 "@/components/Button";
import { Logo } from "@/components/icons/Logo";
@@ -17,12 +19,14 @@ import { getSelectedVideoProperties } from "@/utils/recording/utils";
import { getLatestVideoId, saveLatestVideoId } from "@/utils/database/utils";
import { openLinkInBrowser } from "@/utils/helpers";
import { uuidParse } from "@cap/utils";
+import toast, { Toaster } from "react-hot-toast";
export const Recorder = ({ session }: { session: AuthSession | null }) => {
const {
devices,
selectedVideoDevice,
selectedAudioDevice,
+ selectedDisplayType,
isRecording,
setIsRecording,
} = useMediaDevices();
@@ -227,19 +231,38 @@ export const Recorder = ({ session }: { session: AuthSession | null }) => {
</div>
<div className="space-y-4 w-full">
<div>
- <label className="text-sm font-medium">Webcam Settings</label>
+ <label className="text-sm font-medium">Display</label>
+ <div className="flex items-center space-x-1">
+ <ActionButton
+ handler={() => console.log("Screen option selected")}
+ icon={<Screen className="w-5 h-5" />}
+ label="Screen"
+ active={selectedDisplayType === "screen"}
+ />
+ <ActionButton
+ handler={() => toast.error("This option is coming soon!")}
+ icon={<Window className="w-5 h-5" />}
+ label="Window"
+ active={selectedDisplayType === "window"}
+ />
+ </div>
+ </div>
+ <div>
+ <label className="text-sm font-medium">Webcam / Video</label>
<div className="space-y-1">
<ActionButton
width="full"
handler={() => handleContextClick("video")}
icon={<Video className="w-5 h-5" />}
label={selectedVideoDevice?.label || "Video"}
+ active={selectedVideoDevice !== null}
/>
<ActionButton
width="full"
handler={() => handleContextClick("audio")}
icon={<Microphone className="w-5 h-5" />}
label={selectedAudioDevice?.label || "Mic"}
+ active={selectedAudioDevice !== null}
/>
</div>
</div>
@@ -261,6 +284,7 @@ export const Recorder = ({ session }: { session: AuthSession | null }) => {
)}
</div>
</div>
+ <Toaster />
</div>
);
};
diff --git a/apps/desktop/src/utils/recording/MediaDeviceContext.tsx b/apps/desktop/src/utils/recording/MediaDeviceContext.tsx
index 1df477dca..2768a754f 100644
--- a/apps/desktop/src/utils/recording/MediaDeviceContext.tsx
+++ b/apps/desktop/src/utils/recording/MediaDeviceContext.tsx
@@ -20,6 +20,10 @@ export interface MediaDeviceContextData {
setSelectedVideoDevice: React.Dispatch<React.SetStateAction<Devices | null>>;
selectedAudioDevice: Devices | null;
setSelectedAudioDevice: React.Dispatch<React.SetStateAction<Devices | null>>;
+ selectedDisplayType: "screen" | "window" | "area";
+ setSelectedDisplayType: React.Dispatch<
+ React.SetStateAction<"screen" | "window" | "area">
+ >;
devices: Devices[];
getDevices: () => Promise<void>;
isRecording: boolean;
@@ -37,6 +41,9 @@ export const MediaDeviceProvider: React.FC<React.PropsWithChildren<{}>> = ({
useState<Devices | null>(null);
const [selectedAudioDevice, setSelectedAudioDevice] =
useState<Devices | null>(null);
+ const [selectedDisplayType, setSelectedDisplayType] = useState<
+ "screen" | "window" | "area"
+ >("screen");
const [devices, setDevices] = useState<Devices[]>([]);
const [isRecording, setIsRecording] = useState(false);
@@ -136,6 +143,8 @@ export const MediaDeviceProvider: React.FC<React.PropsWithChildren<{}>> = ({
setSelectedVideoDevice,
selectedAudioDevice,
setSelectedAudioDevice,
+ selectedDisplayType,
+ setSelectedDisplayType,
devices,
getDevices,
isRecording,
diff --git a/apps/desktop/src/utils/recording/useMediaRecorder.ts b/apps/desktop/src/utils/recording/useMediaRecorder.ts
index 2bf3a2aae..73e862222 100644
--- a/apps/desktop/src/utils/recording/useMediaRecorder.ts
+++ b/apps/desktop/src/utils/recording/useMediaRecorder.ts
@@ -71,9 +71,9 @@ export const useMediaRecorder = () => {
await writeTextFile({ path: segmentListPath, contents: "" });
// Set up and start the MediaRecorder
- if (MediaRecorder.isTypeSupported("video/webm;codecs=vp8")) {
+ if (MediaRecorder.isTypeSupported("video/webm;codecs=h264")) {
mediaRecorder.current = new MediaRecorder(stream, {
- mimeType: "video/webm;codecs=vp8",
+ mimeType: "video/webm;codecs=h264",
});
} else {
// Fallback to the default MIME type if 'webm' is not supported
diff --git a/apps/web/app/auth/callback/route.ts b/apps/web/app/auth/callback/route.ts
index a725896d8..8b1cf7897 100644
--- a/apps/web/app/auth/callback/route.ts
+++ b/apps/web/app/auth/callback/route.ts
@@ -1,15 +1,37 @@
-import { createSupabaseServerClient } from "@/utils/database/supabase/route";
+import { cookies } from "next/headers";
import { NextResponse } from "next/server";
-import type { NextRequest } from "next/server";
+import { type CookieOptions, createServerClient } from "@supabase/ssr";
-export async function GET(request: NextRequest) {
- const supabase = await createSupabaseServerClient();
- const requestUrl = new URL(request.url);
- const code = requestUrl.searchParams.get("code");
+export async function GET(request: Request) {
+ const { searchParams, origin } = new URL(request.url);
+ const code = searchParams.get("code");
+ const next = searchParams.get("next") ?? "/";
if (code) {
- await supabase.auth.exchangeCodeForSession(code);
+ const cookieStore = cookies();
+ const supabase = createServerClient(
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
+ {
+ cookies: {
+ get(name: string) {
+ return cookieStore.get(name)?.value;
+ },
+ set(name: string, value: string, options: CookieOptions) {
+ cookieStore.set({ name, value, ...options });
+ },
+ remove(name: string, options: CookieOptions) {
+ cookieStore.delete({ name, ...options });
+ },
+ },
+ }
+ );
+ const { error } = await supabase.auth.exchangeCodeForSession(code);
+ if (!error) {
+ return NextResponse.redirect(`${origin}${next}`);
+ }
}
- return NextResponse.redirect(requestUrl.origin);
+ // return the user to an error page with instructions
+ return NextResponse.redirect(`${origin}/auth/auth-code-error`);
}
diff --git a/apps/web/app/login/page.tsx b/apps/web/app/login/page.tsx
index eba1292fb..01f0a83d6 100644
--- a/apps/web/app/login/page.tsx
+++ b/apps/web/app/login/page.tsx
@@ -30,18 +30,12 @@ export default function AuthUI() {
<div className="flex flex-col space-y-4">
<Auth
supabaseClient={supabase}
- view="sign_up"
- otpType="signup"
+ view="magic_link"
+ otpType="magiclink"
providers={[]}
redirectTo={`${process.env.NEXT_PUBLIC_URL}/auth/callback`}
magicLink={true}
- localization={{
- variables: {
- magic_link: {
- link_text: "",
- },
- },
- }}
+ showLinks={false}
appearance={{
theme: ThemeSupa,
variables: {
diff --git a/apps/web/utils/database/supabase/route.ts b/apps/web/utils/database/supabase/route.ts
index 7a9e05f26..690f6e6b3 100644
--- a/apps/web/utils/database/supabase/route.ts
+++ b/apps/web/utils/database/supabase/route.ts
@@ -1,4 +1,4 @@
-import { createServerClient, type CookieOptions } from "@supabase/ssr";
+import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";
import type { Database } from "@cap/utils";