Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Redesign mode select UI and update window sizing

Richie McIlroy6272334c4008
diff --git a/apps/desktop/src/components/ModeSelect.tsx b/apps/desktop/src/components/ModeSelect.tsx
index 61f1d17a6..14fb82d99 100644
--- a/apps/desktop/src/components/ModeSelect.tsx
+++ b/apps/desktop/src/components/ModeSelect.tsx
@@ -1,47 +1,89 @@
import { cx } from "cva";
import { type JSX, Show } from "solid-js";
+import instantModeDark from "~/assets/illustrations/instant-mode-dark.png";
+import instantModeLight from "~/assets/illustrations/instant-mode-light.png";
+import studioModeDark from "~/assets/illustrations/studio-mode-dark.png";
+import studioModeLight from "~/assets/illustrations/studio-mode-light.png";
import { createOptionsQuery } from "~/utils/queries";
-import type { RecordingMode } from "~/utils/tauri";
+import { commands, type RecordingMode } from "~/utils/tauri";
interface ModeOptionProps {
mode: RecordingMode;
title: string;
description: string;
- standalone?: boolean;
- icon: (props: { class: string; style?: JSX.CSSProperties }) => JSX.Element;
+ imageDark?: string;
+ imageLight?: string;
+ icon?: (props: { class: string; style?: JSX.CSSProperties }) => JSX.Element;
isSelected: boolean;
onSelect: (mode: RecordingMode) => void;
}
const ModeOption = (props: ModeOptionProps) => {
+ const hasImage = () => props.imageDark && props.imageLight;
+
return (
<div
data-tauri-drag-region="none"
onClick={() => props.onSelect(props.mode)}
class={cx(
- "p-5 space-y-3 rounded-lg border transition-all duration-200 cursor-pointer h-fit",
+ "relative flex flex-col items-center rounded-xl border-2 transition-all duration-200 cursor-pointer overflow-hidden group",
props.isSelected
- ? "border-blue-7 bg-blue-3/60 dark:border-blue-6 dark:bg-blue-4/40"
- : "border-gray-4 dark:border-gray-3 dark:bg-gray-2 hover:border-gray-6 dark:hover:border-gray-4 hover:bg-gray-2 dark:hover:bg-gray-3",
+ ? "border-blue-9 bg-blue-3 dark:bg-blue-3/30 shadow-lg shadow-blue-9/10"
+ : "border-gray-4 dark:border-gray-5 bg-gray-2 dark:bg-gray-3 hover:border-gray-6 dark:hover:border-gray-6 hover:bg-gray-3 dark:hover:bg-gray-4",
)}
role="button"
aria-pressed={props.isSelected}
>
- <div class="flex flex-col items-center mb-2 text-center">
- {props.icon({
- class: "size-12 mb-5 invert dark:invert-0",
- })}
- <h3 class="text-lg font-medium text-gray-12">{props.title}</h3>
+ <Show when={props.isSelected}>
+ <div class="absolute top-2.5 right-2.5 flex items-center justify-center size-5 rounded-full bg-blue-9">
+ <IconLucideCheck class="size-3 text-white" />
+ </div>
+ </Show>
+
+ <div class="flex items-center justify-center w-full pt-5 pb-3">
+ <Show
+ when={hasImage()}
+ fallback={
+ <div
+ class={cx(
+ "flex items-center justify-center size-20 rounded-full",
+ props.isSelected
+ ? "bg-blue-4 dark:bg-blue-4/50"
+ : "bg-gray-3 dark:bg-gray-4",
+ )}
+ >
+ {props.icon?.({
+ class: "size-10 invert dark:invert-0",
+ })}
+ </div>
+ }
+ >
+ <img
+ src={props.imageDark}
+ alt={props.title}
+ class="hidden dark:block size-20 object-contain"
+ />
+ <img
+ src={props.imageLight}
+ alt={props.title}
+ class="block dark:hidden size-20 object-contain"
+ />
+ </Show>
</div>
- <p
- class={cx(
- "mx-auto w-full text-sm max-w-[300px]",
- props.isSelected ? "text-gray-12" : "text-gray-11",
- )}
- >
- {props.description}
- </p>
+ <div class="flex flex-col items-center px-4 pb-4 text-center">
+ <h3
+ class={cx(
+ "text-base font-semibold mb-1.5",
+ props.isSelected ? "text-blue-11" : "text-gray-12",
+ )}
+ >
+ {props.title}
+ </h3>
+ <p class="text-xs leading-relaxed text-gray-11 line-clamp-3">
+ {props.description}
+ </p>
+ </div>
</div>
);
};
@@ -51,28 +93,28 @@ const ModeSelect = (props: { onClose?: () => void; standalone?: boolean }) => {
const handleModeChange = (mode: RecordingMode) => {
setOptions({ mode });
+ commands.setRecordingMode(mode);
};
const modeOptions = [
{
mode: "instant" as const,
- title: "Instant Mode",
- description:
- "Share your screen instantly with a shareable link. No waiting for rendering, just capture and share. Uploads in the background as you record.",
- icon: IconCapInstant,
+ title: "Instant",
+ description: "Share instantly with a link. Uploads as you record.",
+ imageDark: instantModeDark,
+ imageLight: instantModeLight,
},
{
mode: "studio" as const,
- title: "Studio Mode",
- description:
- "Records at the highest quality and framerate, completely locally. Captures both your screen and camera separately for editing and exporting later.",
- icon: IconCapFilmCut,
+ title: "Studio",
+ description: "Highest quality local recording for editing later.",
+ imageDark: studioModeDark,
+ imageLight: studioModeLight,
},
{
mode: "screenshot" as const,
- title: "Screenshot Mode",
- description:
- "Capture high-quality screenshots of your screen or specific windows. Annotate and share instantly.",
+ title: "Screenshot",
+ description: "Capture and annotate screenshots instantly.",
icon: IconCapScreenshot,
},
];
@@ -81,9 +123,9 @@ const ModeSelect = (props: { onClose?: () => void; standalone?: boolean }) => {
<div
data-tauri-drag-region="none"
class={cx(
- "grid grid-cols-1 md:grid-cols-3 gap-8 items-center text-center bg-gray-1",
+ "relative",
props.standalone
- ? "absolute z-10 border border-gray-3 p-16 rounded-xl"
+ ? "absolute z-10 border border-gray-3 p-8 rounded-xl bg-gray-1"
: "",
)}
onClick={(e) => e.stopPropagation()}
@@ -91,26 +133,26 @@ const ModeSelect = (props: { onClose?: () => void; standalone?: boolean }) => {
<Show when={props.onClose}>
<div
onClick={() => props.onClose?.()}
- class="absolute -top-2.5 -right-2.5 p-2 rounded-full border duration-200 bg-gray-2 border-gray-3 hover:bg-gray-3 transition-duration"
+ class="absolute -top-2.5 -right-2.5 p-2 rounded-full border duration-200 bg-gray-2 border-gray-3 hover:bg-gray-3 transition-colors cursor-pointer"
>
<IconCapX class="invert-1 size-2 dark:invert" />
</div>
</Show>
- {props.standalone && (
- <h2 class="text-[24px] col-span-2 font-medium text-center text-gray-12">
- Recording Modes
- </h2>
- )}
- {modeOptions.map((option) => (
- <ModeOption
- mode={option.mode}
- title={option.title}
- description={option.description}
- icon={option.icon}
- isSelected={rawOptions.mode === option.mode}
- onSelect={handleModeChange}
- />
- ))}
+
+ <div class="grid grid-cols-3 gap-4">
+ {modeOptions.map((option) => (
+ <ModeOption
+ mode={option.mode}
+ title={option.title}
+ description={option.description}
+ imageDark={option.imageDark}
+ imageLight={option.imageLight}
+ icon={option.icon}
+ isSelected={rawOptions.mode === option.mode}
+ onSelect={handleModeChange}
+ />
+ ))}
+ </div>
</div>
);
};
diff --git a/apps/desktop/src/routes/mode-select.tsx b/apps/desktop/src/routes/mode-select.tsx
index 2726a9240..9ba65b0ff 100644
--- a/apps/desktop/src/routes/mode-select.tsx
+++ b/apps/desktop/src/routes/mode-select.tsx
@@ -24,8 +24,8 @@ const ModeSelectWindow = () => {
try {
const currentSize = await window.innerSize();
- if (currentSize.width !== 900 || currentSize.height !== 500) {
- await window.setSize(new LogicalSize(900, 500));
+ if (currentSize.width !== 580 || currentSize.height !== 340) {
+ await window.setSize(new LogicalSize(580, 340));
}
} catch (error) {
console.error("Failed to set window size:", error);
@@ -39,21 +39,27 @@ const ModeSelectWindow = () => {
return (
<div
data-tauri-drag-region
- class="flex relative justify-center items-center p-4 min-h-screen bg-gray-1"
+ class="flex flex-col relative justify-center items-center min-h-screen bg-gray-1"
>
{isWindows && (
<div class="absolute top-0 right-0 z-50 h-9">
<CaptionControlsWindows11 />
</div>
)}
- <div
- data-tauri-drag-region="none"
- class="relative z-10 space-y-10 w-full max-w-5xl"
- >
- <h2 class="text-[24px] font-medium text-center text-gray-12">
- Recording Modes
- </h2>
- <ModeSelect />
+
+ <div class="flex flex-col items-center w-full px-6 py-5">
+ <div class="mb-5 text-center">
+ <h2 class="text-xl font-semibold text-gray-12 mb-1">
+ Choose Recording Mode
+ </h2>
+ <p class="text-sm text-gray-11">
+ Select how you want to capture your screen
+ </p>
+ </div>
+
+ <div data-tauri-drag-region="none" class="w-full max-w-lg">
+ <ModeSelect />
+ </div>
</div>
</div>
);
diff --git a/apps/desktop/src/utils/queries.ts b/apps/desktop/src/utils/queries.ts
index fafc9cb35..8ee5c89a8 100644
--- a/apps/desktop/src/utils/queries.ts
+++ b/apps/desktop/src/utils/queries.ts
@@ -7,7 +7,7 @@ import {
useQuery,
} from "@tanstack/solid-query";
import { getCurrentWindow } from "@tauri-apps/api/window";
-import { createEffect, createMemo } from "solid-js";
+import { createEffect, createMemo, onCleanup } from "solid-js";
import { createStore, reconcile } from "solid-js/store";
import { useRecordingOptions } from "~/routes/(window-chrome)/OptionsContext";
import {
@@ -161,6 +161,13 @@ export function createOptionsQuery() {
});
});
+ const storeListenerCleanup = recordingSettingsStore.listen((data) => {
+ if (data?.mode && data.mode !== _state.mode) {
+ _setState("mode", data.mode);
+ }
+ });
+ onCleanup(() => storeListenerCleanup.then((c) => c()));
+
const [state, setState] = makePersisted([_state, _setState], {
name: PERSIST_KEY,
});