Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

wip: Main screen design

Richie McIlroy1edc1acc146f
diff --git a/apps/desktop-solid/src-tauri/src/lib.rs b/apps/desktop-solid/src-tauri/src/lib.rs
index 55f30dfb1..4dfbc6815 100644
--- a/apps/desktop-solid/src-tauri/src/lib.rs
+++ b/apps/desktop-solid/src-tauri/src/lib.rs
@@ -257,7 +257,7 @@ async fn get_rendered_video(
.app_data_dir()
.unwrap()
.join("recordings")
- .join(format!("{video_id}.cap"));
+ .join(format!("{video_id}"));
dbg!(&video_dir);
if video_dir.exists() {
diff --git a/apps/desktop-solid/src/routes/index.tsx b/apps/desktop-solid/src/routes/index.tsx
index 3fa9e80c6..b39413a21 100644
--- a/apps/desktop-solid/src/routes/index.tsx
+++ b/apps/desktop-solid/src/routes/index.tsx
@@ -6,6 +6,15 @@ import { createOptionsQuery, createWindowsQuery } from "../utils/queries";
import { commands, events } from "../utils/tauri";
import Header from "../components/Header";
+import { DropdownMenu as KDropdownMenu } from "@kobalte/core/dropdown-menu";
+import {
+ EditorButton,
+ MenuItemList,
+ PopperContent,
+ DropdownItem,
+ topLeftAnimateClasses,
+} from "./editor/ui";
+
export default function () {
const cameras = createCameras();
const options = createOptionsQuery();
@@ -20,111 +29,20 @@ export default function () {
commands.showPreviousRecordingsWindow();
});
- const screenInputFilePath =
- "/Users/richie/Library/Application Support/so.cap.desktop-solid/recordings/ac2909e0-2f5e-45ff-95e3-8efb50a56a12.cap/content/display.mp4";
- const webcamInputFilePath =
- "/Users/richie/Library/Application Support/so.cap.desktop-solid/recordings/ac2909e0-2f5e-45ff-95e3-8efb50a56a12.cap/content/camera.mp4";
-
- const settings = {
- webcamSize: { width: 320, height: 240 },
- webcamPosition: { x: 10, y: 10 },
- webcamStyle: { borderRadius: 50, shadow: "rgba(0, 0, 0, 0.5)" },
- videoOutputSize: { width: 1280, height: 720 },
- videoBackground: "#000000",
- videoPadding: 20,
- };
-
- async function testRender() {
- try {
- const outputFilePath = await commands.renderVideo({
- screen_recording_path: screenInputFilePath,
- webcam_recording_path: webcamInputFilePath,
- webcam_size: [settings.webcamSize.width, settings.webcamSize.height],
- webcam_position: [
- settings.webcamPosition.x / 100,
- settings.webcamPosition.y / 100,
- ],
- webcam_style: {
- border_radius: settings.webcamStyle.borderRadius,
- shadow_color: [0, 0, 0, 0.5],
- shadow_blur: 5,
- shadow_offset: [2, 2],
- },
- output_size: [
- settings.videoOutputSize.width,
- settings.videoOutputSize.height,
- ],
- background: { Color: [0, 0, 0, 1] },
- });
- console.log(`Video rendered successfully: ${outputFilePath}`);
- } catch (error) {
- console.error("Error rendering video:", error);
- }
- }
-
commands.showPreviousRecordingsWindow();
return (
<>
<Header />
<div class="px-3">
- <button
- type="button"
- onClick={() => commands.showPreviousRecordingsWindow()}
- >
- Open prev recordings window
- </button>
<Suspense fallback="LOADING">
<Show when={options.data}>
{(options) => (
<>
<div class="max-w-64 space-y-4">
<div class="flex flex-col gap-1">
- <label>Camera</label>
- <div>
- <select
- class="w-full"
- value={camera()?.deviceId}
- onChange={(e) => {
- const o = options();
- const deviceId = e.target.value;
- const label = cameras().find(
- (c) => c.deviceId === deviceId
- )?.label;
- if (!label) return;
-
- commands.setRecordingOptions({
- ...o,
- cameraLabel: label,
- });
- }}
- >
- <For each={cameras()}>
- {(camera) => (
- <option value={camera.deviceId}>
- {camera.label}
- </option>
- )}
- </For>
- </select>
- {options().cameraLabel && (
- <button
- type="button"
- onClick={() =>
- commands.setRecordingOptions({
- ...options(),
- cameraLabel: null,
- })
- }
- >
- Remove
- </button>
- )}
- </div>
- </div>
- <div>
<label>Capture</label>
- <div class="flex flex-row justify-between gap-1">
+ <div class="flex flex-row justify-between gap-1 border border-gray-200 rounded-[8px]">
<button
type="button"
class={cx(
@@ -144,30 +62,50 @@ export default function () {
</button>
<Show when={windows.data?.[0]}>
{(window) => (
- <button
- type="button"
- class={cx(
- "flex-1",
- options().captureTarget !== "screen"
- ? "bg-neutral-200"
- : "bg-neutral-100"
- )}
- onClick={() => {
- const captureTarget = options();
- if (
- typeof captureTarget === "object" &&
- "window" in captureTarget
- )
- return;
-
- commands.setRecordingOptions({
- ...options(),
- captureTarget: { window: window().id },
- });
- }}
- >
- Window
- </button>
+ <KDropdownMenu gutter={8}>
+ <EditorButton<typeof KDropdownMenu.Trigger>
+ as={KDropdownMenu.Trigger}
+ class={cx(
+ "flex-1",
+ options().captureTarget !== "screen"
+ ? "bg-neutral-200"
+ : "bg-neutral-100"
+ )}
+ >
+ Window
+ </EditorButton>
+ <KDropdownMenu.Portal>
+ <PopperContent<typeof KDropdownMenu.Content>
+ as={KDropdownMenu.Content}
+ class={cx(
+ "w-72 max-h-56",
+ topLeftAnimateClasses
+ )}
+ >
+ <MenuItemList<typeof KDropdownMenu.Group>
+ as={KDropdownMenu.Group}
+ class="flex-1 overflow-y-auto scrollbar-none"
+ >
+ <For each={windows.data}>
+ {(window) => (
+ <DropdownItem
+ onSelect={() => {
+ commands.setRecordingOptions({
+ ...options(),
+ captureTarget: {
+ window: window.id,
+ },
+ });
+ }}
+ >
+ {window.name}
+ </DropdownItem>
+ )}
+ </For>
+ </MenuItemList>
+ </PopperContent>
+ </KDropdownMenu.Portal>
+ </KDropdownMenu>
)}
</Show>
</div>
@@ -203,36 +141,74 @@ export default function () {
)}
</Show>
</div>
- {
- <div>
- {!isRecording() ? (
- <button
- type="button"
- onClick={() =>
- commands
- .startRecording()
- .then(() => setIsRecording(true))
- }
- >
- Start Recording
- </button>
- ) : (
+ <div class="flex flex-col gap-1">
+ <label>Camera</label>
+ <div class="relative">
+ <select
+ class="w-full"
+ value={camera()?.deviceId}
+ onChange={(e) => {
+ const o = options();
+ const deviceId = e.target.value;
+ const label = cameras().find(
+ (c) => c.deviceId === deviceId
+ )?.label;
+ if (!label) return;
+
+ commands.setRecordingOptions({
+ ...o,
+ cameraLabel: label,
+ });
+ }}
+ >
+ <For each={cameras()}>
+ {(camera) => (
+ <option value={camera.deviceId}>
+ {camera.label}
+ </option>
+ )}
+ </For>
+ </select>
+ {options().cameraLabel && (
<button
type="button"
onClick={() =>
- commands
- .stopRecording()
- .then(() => setIsRecording(false))
+ commands.setRecordingOptions({
+ ...options(),
+ cameraLabel: null,
+ })
}
>
- Stop Recording
+ Remove
</button>
)}
- <button type="button" onClick={testRender}>
- Test Render
- </button>
</div>
- }
+ </div>
+ <div class="flex flex-col gap-1">
+ <label>Microphone</label>
+ <div class="flex items-center gap-2">
+ <select class="w-full">
+ <option>No Audio</option>
+ </select>
+ <button type="button">Off</button>
+ </div>
+ </div>
+ <div class="flex flex-col gap-1">
+ <button
+ type="button"
+ class="bg-blue-500 text-white py-2 rounded"
+ onClick={() =>
+ commands
+ .startRecording()
+ .then(() => setIsRecording(true))
+ }
+ >
+ Start Recording
+ </button>
+ <button type="button" class="text-blue-500">
+ Open Cap on Web
+ </button>
+ </div>
</div>
</>
)}
diff --git a/apps/desktop-solid/src/routes/prev-recordings.tsx b/apps/desktop-solid/src/routes/prev-recordings.tsx
index 9b81c271d..365bdb3d8 100644
--- a/apps/desktop-solid/src/routes/prev-recordings.tsx
+++ b/apps/desktop-solid/src/routes/prev-recordings.tsx
@@ -36,7 +36,7 @@ export default function () {
return (
<div class="w-screen h-screen bg-transparent relative">
- <div class="absolute left-0 bottom-0 flex flex-col-reverse pl-[40px] pb-[80px] gap-8">
+ <div class="absolute left-0 bottom-0 flex flex-col-reverse pl-[40px] pb-[80px] gap-4">
<For each={recordings.data}>
{(recording, i) => {
const [ref, setRef] = createSignal<HTMLElement | null>(null);
@@ -49,6 +49,8 @@ export default function () {
size: 0,
});
+ const [imageExists, setImageExists] = createSignal(true);
+
const { present } = createPresence({
show: () => !exiting(),
element: ref,
@@ -106,122 +108,166 @@ export default function () {
// closingRecording = recording;
// }
// }}
-
+ style={{
+ "border-color": "rgba(255, 255, 255, 0.2)",
+ "box-shadow": "0px 2px 4px rgba(18, 22, 31, 0.12)",
+ }}
class={cx(
- "w-[250px] h-[150px] rounded-xl overflow-hidden shadow border border-gray-100/20 relative flex flex-col items-center justify-center border-[5px] border-gray-500 ring-[1px]ring-white shadow-[0px 2px 4px rgba(18, 22, 31, 0.12)] group transition-all",
+ "w-[260px] h-[150px] p-[4px] bg-gray-500 rounded-[12px] overflow-hidden shadow border-[1px] group transition-all relative",
"transition-[transform,opacity] duration-300",
exiting()
? "animate-out slide-out-to-left-32 fade-out"
: "animate-in fade-in"
)}
>
- <img
- class="pointer-events-none w-full h-full object-cover absolute inset-0 -z-10 "
- alt="screenshot"
- src={convertFileSrc(`${recording}/screenshots/display.jpg`)}
- />
- <div class="w-full h-full absolute inset-0 transition-all opacity-0 group-hover:opacity-100 backdrop-blur group-hover:backdrop-blur bg-gray-500/80 text-white p-4">
- <TooltipIconButton
- class="absolute left-3 top-3"
- tooltipText="Close"
- tooltipPlacement="right"
- onClick={() => {
- setExiting(true);
- }}
- >
- <IconCapCircleX class="w-[16px] h-[16px]" />
- </TooltipIconButton>
- <TooltipIconButton
- class="absolute left-3 bottom-3"
- tooltipText="Edit"
- tooltipPlacement="right"
- onClick={() => {
- new WebviewWindow("editor", {
- width: 1440,
- height: 1024,
- url: `/editor?path=${recording}`,
- });
- }}
- >
- <IconCapEditor class="w-[16px] h-[16px]" />
- </TooltipIconButton>
- <TooltipIconButton
- class="absolute right-3 top-3 z-20"
- tooltipText="Copy to Clipboard"
- tooltipPlacement="left"
- onClick={async () => {
- setIsLoading(true);
- try {
- await commands.copyRenderedVideoToClipboard(
- recording,
- "clipboard"
- );
- setIsLoading(false);
- setIsSuccess(true);
- setTimeout(() => setIsSuccess(false), 2000);
- } catch (error) {
- setIsLoading(false);
- window.alert("Failed to copy to clipboard");
- }
- }}
- >
- <Show when={isLoading()}>
- <IconLucideLoaderCircle class="w-[16px] h-[16px] animate-spin" />
- </Show>
- <Show when={isSuccess()}>
- <IconLucideCheck class="w-[16px] h-[16px]" />
- </Show>
- <Show when={!isLoading() && !isSuccess()}>
- <IconCapCopy class="w-[16px] h-[16px]" />
- </Show>
- </TooltipIconButton>
- <TooltipIconButton
- class="absolute right-3 bottom-3"
- tooltipText="Create Shareable Link"
- tooltipPlacement="left"
- onClick={async () => {
- setIsLoading(true);
- try {
- setIsLoading(false);
- setIsSuccess(true);
- setTimeout(() => setIsSuccess(false), 2000);
- } catch (error) {
- setIsLoading(false);
- window.alert("Failed to create shareable link");
- }
- }}
- >
- <IconCapUpload class="w-[16px] h-[16px]" />
- </TooltipIconButton>
- <IconButton
- class="absolute inset-0 m-auto w-[65px] h-[32px] hover:bg-gray-300 text-[14px]"
- onClick={async () => {
- setIsLoading(true);
- try {
- setIsLoading(false);
- setIsSuccess(true);
- setTimeout(() => setIsSuccess(false), 2000);
- } catch (error) {
- setIsLoading(false);
- window.alert("Failed to save recording");
- }
- }}
- >
- Save
- </IconButton>
- </div>
<div
- style={{ color: "white", "font-size": "14px" }}
- class="absolute bottom-0 left-0 right-0 font-medium bg-gray-500 bg-opacity-40 backdrop-blur p-2 flex justify-between items-center group-hover:opacity-0 pointer-events-none transition-all"
+ class="w-full h-full flex relative bg-transparent rounded-[8px] border-[1px] overflow-hidden z-10"
+ style={{ "border-color": "rgba(255, 255, 255, 0.2)" }}
>
- <p class="flex items-center">
- <IconCapCamera class="w-[20px] h-[20px] mr-1" />
- {Math.floor(metadata().duration / 60)}:
- {Math.floor(metadata().duration % 60)
- .toString()
- .padStart(2, "0")}
- </p>
- <p>{metadata().size.toFixed(2)} MB</p>
+ <Show
+ when={imageExists()}
+ fallback={
+ <div class="pointer-events-none w-[105%] h-[105%] absolute inset-0 -z-10 bg-gray-400" />
+ }
+ >
+ <img
+ class="pointer-events-none w-[105%] h-[105%] object-cover absolute inset-0 -z-10"
+ alt="screenshot"
+ src={convertFileSrc(
+ `${recording}/screenshots/display.jpg`
+ )}
+ onError={() => setImageExists(false)}
+ />
+ </Show>
+ <div class="w-full h-full absolute inset-0 transition-all opacity-0 group-hover:opacity-100 backdrop-blur group-hover:backdrop-blur bg-gray-500/80 text-white p-4">
+ <TooltipIconButton
+ class="absolute left-3 top-3"
+ tooltipText="Close"
+ tooltipPlacement="right"
+ onClick={() => {
+ setExiting(true);
+ }}
+ >
+ <IconCapCircleX class="w-[16px] h-[16px]" />
+ </TooltipIconButton>
+ <TooltipIconButton
+ class="absolute left-3 bottom-3"
+ tooltipText="Edit"
+ tooltipPlacement="right"
+ onClick={() => {
+ new WebviewWindow("editor", {
+ width: 1440,
+ height: 1024,
+ url: `/editor?path=${recording}`,
+ });
+ }}
+ >
+ <IconCapEditor class="w-[16px] h-[16px]" />
+ </TooltipIconButton>
+ <TooltipIconButton
+ class="absolute right-3 top-3 z-20"
+ tooltipText="Copy to Clipboard"
+ tooltipPlacement="left"
+ onClick={async () => {
+ setIsLoading(true);
+ try {
+ await commands.copyRenderedVideoToClipboard(
+ recording,
+ {
+ aspectRatio: "classic",
+ background: {
+ source: {
+ type: "color",
+ value: [0, 0, 0],
+ },
+ blur: 0,
+ padding: 0,
+ rounding: 0,
+ inset: 0,
+ },
+ camera: {
+ hide: false,
+ mirror: false,
+ position: { x: "left", y: "bottom" },
+ rounding: 0,
+ shadow: 0,
+ },
+ audio: { mute: false, improve: false },
+ cursor: {
+ hideWhenIdle: false,
+ size: 16,
+ type: "pointer",
+ },
+ hotkeys: { show: false },
+ }
+ );
+ setIsLoading(false);
+ setIsSuccess(true);
+ setTimeout(() => setIsSuccess(false), 2000);
+ } catch (error) {
+ setIsLoading(false);
+ window.alert("Failed to copy to clipboard");
+ }
+ }}
+ >
+ <Show when={isLoading()}>
+ <IconLucideLoaderCircle class="w-[16px] h-[16px] animate-spin" />
+ </Show>
+ <Show when={isSuccess()}>
+ <IconLucideCheck class="w-[16px] h-[16px]" />
+ </Show>
+ <Show when={!isLoading() && !isSuccess()}>
+ <IconCapCopy class="w-[16px] h-[16px]" />
+ </Show>
+ </TooltipIconButton>
+ <TooltipIconButton
+ class="absolute right-3 bottom-3"
+ tooltipText="Create Shareable Link"
+ tooltipPlacement="left"
+ onClick={async () => {
+ setIsLoading(true);
+ try {
+ setIsLoading(false);
+ setIsSuccess(true);
+ setTimeout(() => setIsSuccess(false), 2000);
+ } catch (error) {
+ setIsLoading(false);
+ window.alert("Failed to create shareable link");
+ }
+ }}
+ >
+ <IconCapUpload class="w-[16px] h-[16px]" />
+ </TooltipIconButton>
+ <IconButton
+ class="absolute inset-0 m-auto w-[65px] h-[32px] hover:bg-gray-300 text-[14px]"
+ onClick={async () => {
+ setIsLoading(true);
+ try {
+ setIsLoading(false);
+ setIsSuccess(true);
+ setTimeout(() => setIsSuccess(false), 2000);
+ } catch (error) {
+ setIsLoading(false);
+ window.alert("Failed to save recording");
+ }
+ }}
+ >
+ Save
+ </IconButton>
+ </div>
+ <div
+ style={{ color: "white", "font-size": "14px" }}
+ class="absolute bottom-0 left-0 right-0 font-medium bg-gray-500 bg-opacity-40 backdrop-blur p-2 flex justify-between items-center group-hover:opacity-0 pointer-events-none transition-all"
+ >
+ <p class="flex items-center">
+ <IconCapCamera class="w-[20px] h-[20px] mr-1" />
+ {Math.floor(metadata().duration / 60)}:
+ {Math.floor(metadata().duration % 60)
+ .toString()
+ .padStart(2, "0")}
+ </p>
+ <p>{metadata().size.toFixed(2)} MB</p>
+ </div>
</div>
</div>
</Show>