Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge branch 'main' into desktop-tailwind-v4

Ilya4b864786238e
diff --cc apps/desktop/src/routes/(window-chrome)/settings/general.tsx
index acb3735a5,d0345a907..39067ab42
--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
@@@ -199,6 -177,51 +177,51 @@@ function Inner(props: { initialStore: G
setSettings(reconcile(deriveGeneralSettings(props.initialStore)));
});
+ let scrollContainerRef: HTMLDivElement | undefined;
+
+ const scrollToSection = (section: string) => {
+ try {
+ localStorage.removeItem("cap.settings.scrollToSection");
- } catch {}
++ } catch { }
+ const attempt = (remaining: number) => {
+ const target = document.getElementById(`settings-section-${section}`);
+ const container = scrollContainerRef;
+ if (!target || !container) {
+ if (remaining > 0) {
+ window.setTimeout(() => attempt(remaining - 1), 50);
+ }
+ return;
+ }
+ const containerRect = container.getBoundingClientRect();
+ const targetRect = target.getBoundingClientRect();
+ const offset =
+ targetRect.top - containerRect.top + container.scrollTop - 8;
+ container.scrollTo({ top: offset, behavior: "smooth" });
+ target.classList.add("settings-section-pulse");
+ window.setTimeout(() => {
+ target.classList.remove("settings-section-pulse");
+ }, 1600);
+ };
+ attempt(10);
+ };
+
+ onMount(() => {
+ let pending: string | null = null;
+ try {
+ pending = localStorage.getItem("cap.settings.scrollToSection");
- } catch {}
++ } catch { }
+ if (pending) {
+ scrollToSection(pending);
+ }
+
+ const unlisten = events.requestScrollToSettingsSection.listen((event) => {
+ scrollToSection(event.payload.section);
+ });
+ onCleanup(() => {
- unlisten.then((cb) => cb()).catch(() => {});
++ unlisten.then((cb) => cb()).catch(() => { });
+ });
+ });
+
const [windows, { refetch: refetchWindows }] = createResource(
async () => {
// Fetch windows with a small delay to avoid blocking initial render
@@@ -809,91 -1017,83 +1017,83 @@@ function DefaultProjectNameCard(props:
>
Save
</Button>
- </div>
- </div>
-
- <div class="flex flex-col gap-2 w-full">
- <Input
- autocorrect="off"
- ref={inputRef}
- type="text"
- class="bg-gray-3 font-mono"
- value={inputValue()}
- onInput={(e) => {
- setInputValue(e.currentTarget.value);
- updatePreview(e.currentTarget.value);
- }}
- />
-
- <div class="w-full flex items-center py-2 px-2 rounded-lg bg-gray-transparent-50 border border-dashed border-gray-5">
- <IconCapLogo class="size-4 pointer-events-none mr-2" />
- <p class="whitespace-pre-wrap">{preview()}</p>
- </div>
-
- <Collapsible class="w-full rounded-lg">
- <Collapsible.Trigger class="group inline-flex items-center w-full text-xs rounded-lg outline-hidden px-0.5 py-1">
- <IconCapChevronDown class="size-4 ui-group-expanded:rotate-180 transition-transform duration-300 ease-in-out" />
- <p class="py-0.5 px-1">How to customize?</p>
- </Collapsible.Trigger>
-
- <Collapsible.Content class="opacity-0 transition animate-collapsible-up data-expanded:animate-collapsible-down data-expanded:opacity-100 text-xs text-gray-12 space-y-3 px-1 pb-2">
- <p class="border-t pt-3">
- Use placeholders in your template that will be automatically
- filled in.
- </p>
+ </>
+ }
+ >
+ <SectionCard padded>
+ <div class="flex flex-col gap-3">
+ <Input
+ autocorrect="off"
+ ref={inputRef}
+ type="text"
+ class="bg-gray-3 font-mono"
+ value={inputValue()}
+ onInput={(e) => {
+ setInputValue(e.currentTarget.value);
+ updatePreview(e.currentTarget.value);
+ }}
+ />
- <div class="space-y-1">
- <p class="font-medium text-foreground">Recording Mode</p>
- <p>
- <CodeView>{"{recording_mode}"}</CodeView> → "Studio", "Instant",
- or "Screenshot"
- </p>
- <p>
- <CodeView>{"{mode}"}</CodeView> → "studio", "instant", or
- "screenshot"
- </p>
- </div>
+ <div class="flex gap-2 items-center px-3 py-2 rounded-lg border border-dashed bg-gray-3 border-gray-5">
+ <IconCapLogo class="pointer-events-none size-4 shrink-0" />
+ <p class="text-xs text-gray-12 whitespace-pre-wrap">{preview()}</p>
+ </div>
- <div class="space-y-1">
- <p class="font-medium text-foreground">Target</p>
- <p>
- <CodeView>{"{target_kind}"}</CodeView> → "Display", "Window", or
- "Area"
- </p>
- <p>
- <CodeView>{"{target_name}"}</CodeView> → The name of the monitor
- or the title of the app depending on the recording mode.
- </p>
- </div>
+ <Collapsible class="w-full rounded-lg">
+ <Collapsible.Trigger class="inline-flex gap-1 items-center text-xs transition-colors text-gray-10 hover:text-gray-12 group">
+ <IconCapChevronDown class="size-3.5 ui-group-expanded:rotate-180 transition-transform duration-200" />
+ <span>Available placeholders</span>
+ </Collapsible.Trigger>
- <div class="space-y-1">
- <p class="font-medium text-foreground">Date &amp; Time</p>
- <p>
- <CodeView>{"{date}"}</CodeView> → {dateString}
- </p>
- <p>
- <CodeView>{"{time}"}</CodeView> →{" "}
- {macos ? "09:41 AM" : "12:00 PM"}
- <Collapsible.Content class="space-y-3 pt-3 text-xs text-gray-12 opacity-0 transition animate-collapsible-up ui-expanded:animate-collapsible-down ui-expanded:opacity-100">
++ <Collapsible.Content class="space-y-3 pt-3 text-xs text-gray-12 opacity-0 transition animate-collapsible-up data-expanded:animate-collapsible-down data-expanded:opacity-100">
+ <p class="text-gray-10">
+ Click any placeholder to copy it. Time supports custom formats
+ via <code class="text-gray-12">{"{moment:HH:mm}"}</code>.
</p>
- </div>
- <div class="space-y-1">
- <p class="font-medium text-foreground">Custom Formats</p>
- <p>
- You can also use a custom format for time. The placeholders are
- case-sensitive. For 24-hour time, use{" "}
- <CodeView>{"{moment:HH:mm}"}</CodeView> or use lower cased{" "}
- <code>hh</code> for 12-hour format.
- </p>
- <p class="flex flex-col items-start pt-1">
- <CodeView>{MOMENT_EXAMPLE_TEMPLATE}</CodeView> →{" "}
- {momentExample()}
- </p>
- </div>
- </Collapsible.Content>
- </Collapsible>
- </div>
- </div>
+ <div class="space-y-1">
+ <p class="font-medium text-gray-12">Recording mode</p>
+ <p>
+ <CodeView>{"{recording_mode}"}</CodeView> → "Studio",
+ "Instant", or "Screenshot"
+ </p>
+ <p>
+ <CodeView>{"{mode}"}</CodeView> → "studio", "instant", or
+ "screenshot"
+ </p>
+ </div>
+
+ <div class="space-y-1">
+ <p class="font-medium text-gray-12">Target</p>
+ <p>
+ <CodeView>{"{target_kind}"}</CodeView> → "Display", "Window",
+ or "Area"
+ </p>
+ <p>
+ <CodeView>{"{target_name}"}</CodeView> → Monitor name or
+ window title.
+ </p>
+ </div>
+
+ <div class="space-y-1">
+ <p class="font-medium text-gray-12">Date &amp; time</p>
+ <p>
+ <CodeView>{"{date}"}</CodeView> → {dateString}
+ </p>
+ <p>
+ <CodeView>{"{time}"}</CodeView> →{" "}
+ {macos ? "09:41 AM" : "12:00 PM"}
+ </p>
+ <p class="flex flex-col items-start pt-1">
+ <CodeView>{MOMENT_EXAMPLE_TEMPLATE}</CodeView> →{" "}
+ {momentExample()}
+ </p>
+ </div>
+ </Collapsible.Content>
+ </Collapsible>
+ </div>
+ </SectionCard>
+ </Section>
);
}
@@@ -1053,12 -1247,12 +1247,12 @@@ function ExcludedWindowsSkeleton()
<div class="flex flex-wrap gap-2" aria-hidden="true">
<For each={chipWidths}>
{(width) => (
- <div class="flex items-center gap-2 rounded-full border border-gray-4 bg-gray-3 px-3 py-1.5 animate-pulse">
+ <div class="flex gap-2 items-center pr-1 pl-3 py-1.5 rounded-full border bg-gray-3 border-gray-4 animate-pulse">
<div class="flex flex-col gap-1 leading-tight">
- <div class={cx("h-3 rounded-sm bg-gray-4", width)} />
- <div class="h-2 w-16 rounded-sm bg-gray-4" />
- <div class={cx("h-2.5 rounded bg-gray-4", width)} />
- <div class="w-14 h-2 rounded bg-gray-4" />
++ <div class={cx("h-2.5 rounded-sm bg-gray-4", width)} />
++ <div class="w-14 h-2 rounded-sm bg-gray-4" />
</div>
- <div class="size-6 rounded-full bg-gray-4" />
+ <div class="rounded-full size-5 bg-gray-4" />
</div>
)}
</For>
diff --cc apps/desktop/src/routes/editor/ConfigSidebar.tsx
index ceac100bd,4344bc09c..eab539341
--- a/apps/desktop/src/routes/editor/ConfigSidebar.tsx
+++ b/apps/desktop/src/routes/editor/ConfigSidebar.tsx
@@@ -1790,9 -1816,9 +1812,9 @@@ function BackgroundConfig(props: { scro
class="relative aspect-square group"
>
<KRadioGroup.ItemInput class="peer" />
- <KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg transition cursor-pointer ui-not-checked:ring-offset-1 ui-not-checked:ring-offset-gray-200 ui-not-checked:hover:ring-1 ui-not-checked:hover:ring-gray-400 ui-checked:ring-2 ui-checked:ring-gray-500 ui-checked:ring-offset-2 ui-checked:ring-offset-gray-200">
+ <KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg transition cursor-pointer not-data-checked:ring-offset-1 not-data-checked:ring-offset-gray-200 not-data-checked:hover:ring-1 not-data-checked:hover:ring-gray-400 data-checked:ring-2 data-checked:ring-gray-500 data-checked:ring-offset-2 data-checked:ring-offset-gray-200">
<img
- src={photo.url!}
+ src={photo.url}
loading="eager"
class="object-cover w-full h-full"
alt="Wallpaper option"
@@@ -1811,9 -1837,9 +1833,9 @@@
class="relative aspect-square group"
>
<KRadioGroup.ItemInput class="peer" />
- <KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg border cursor-pointer border-gray-5 ui-checked:border-blue-9 ui-checked:ring-2 ui-checked:ring-blue-9 peer-focus-visible:border-2 peer-focus-visible:border-blue-9">
+ <KRadioGroup.ItemControl class="overflow-hidden w-full h-full rounded-lg border cursor-pointer border-gray-5 data-checked:border-blue-9 data-checked:ring-2 data-checked:ring-blue-9 peer-focus-visible:border-2 peer-focus-visible:border-blue-9">
<img
- src={photo.url!}
+ src={photo.url}
alt="Wallpaper option"
class="object-cover w-full h-full"
loading="lazy"
@@@ -2251,9 -2277,19 +2273,19 @@@ function CameraConfig(props: { scrollRe
value={`${project.camera.position.x}:${project.camera.position.y}`}
onChange={(v) => {
const [x, y] = v.split(":");
- setProject("camera", "position", { x, y } as any);
+ const xPosition = CAMERA_X_POSITIONS.find(
+ (position) => position === x,
+ );
+ const yPosition = CAMERA_Y_POSITIONS.find(
+ (position) => position === y,
+ );
+ if (!xPosition || !yPosition) return;
+ setProject("camera", "position", {
+ x: xPosition,
+ y: yPosition,
+ });
}}
- class="mt-[0.75rem] rounded-[0.5rem] border border-gray-3 bg-gray-2 w-full h-[7.5rem] relative"
+ class="mt-3 rounded-lg border border-gray-3 bg-gray-2 w-full h-30 relative"
>
<For
each={[
@@@ -2767,8 -2803,8 +2799,8 @@@ function TextSegmentConfig(props:
</MenuItem>
)}
>
- <KSelect.Trigger class="flex w-full items-center justify-between rounded-md border border-gray-3 bg-gray-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:border-gray-4 hover:bg-gray-3 focus:border-blue-9 focus:outline-none focus:ring-1 focus:ring-blue-9">
+ <KSelect.Trigger class="flex w-full items-center justify-between rounded-md border border-gray-3 bg-gray-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:border-gray-4 hover:bg-gray-3 focus:border-blue-9 focus:outline-hidden focus:ring-1 focus:ring-blue-9">
- <KSelect.Value<any> class="truncate">
+ <KSelect.Value<{ label: string; value: number }> class="truncate">
{(state) => {
const selected = state.selectedOption();
if (selected) return selected.label;
diff --cc apps/desktop/src/routes/in-progress-recording.tsx
index 9db3377ca,309bbf702..1ac98309c
--- a/apps/desktop/src/routes/in-progress-recording.tsx
+++ b/apps/desktop/src/routes/in-progress-recording.tsx
@@@ -75,10 -75,10 +75,10 @@@ function InProgressRecordingInner()
window.COUNTDOWN === 0
? { variant: "initializing" }
: {
-- variant: "countdown",
-- from: window.COUNTDOWN,
-- current: window.COUNTDOWN,
-- },
++ variant: "countdown",
++ from: window.COUNTDOWN,
++ current: window.COUNTDOWN,
++ },
);
const [start, setStart] = createSignal(Date.now());
const [time, setTime] = createSignal(Date.now());
@@@ -162,9 -163,9 +163,9 @@@
const [pauseResumes, setPauseResumes] = createStore<
| []
| [
-- ...Array<{ pause: number; resume?: number }>,
-- { pause: number; resume?: number },
-- ]
++ ...Array<{ pause: number; resume?: number }>,
++ { pause: number; resume?: number },
++ ]
>([]);
createEffect(() => {
@@@ -669,10 -683,20 +683,20 @@@
}
>
<button
- disabled={stopRecording.isPending || isCountdown()}
+ disabled={
+ stopRequested() ||
+ stopRecording.isPending ||
+ isCountdown()
+ }
- class="flex flex-row items-center gap-[0.25rem] rounded-lg py-[0.25rem] px-[0.5rem] text-red-300 transition-colors duration-100 hover:bg-red-500/[0.08] active:bg-red-500/[0.12] disabled:opacity-60 disabled:hover:bg-transparent"
+ class="flex flex-row items-center gap-1 rounded-lg py-1 px-2 text-red-300 transition-colors duration-100 hover:bg-red-500/8 active:bg-red-500/12 disabled:opacity-60 disabled:hover:bg-transparent"
type="button"
- onClick={() => stopRecording.mutate()}
+ onPointerDown={(event) => {
+ if (event.button !== 0) return;
+ event.preventDefault();
+ event.stopPropagation();
+ requestStopRecording();
+ }}
+ onClick={requestStopRecording}
title="Stop recording"
aria-label="Stop recording"
>
@@@ -753,9 -777,9 +777,8 @@@
<div
class="absolute inset-0 bg-blue-9 transition-transform duration-100"
style={{
-- transform: `translateX(-${
-- (1 - audioLevel()) * 100
-- }%)`,
++ transform: `translateX(-${(1 - audioLevel()) * 100
++ }%)`,
}}
/>
</div>
@@@ -806,7 -830,7 +829,7 @@@
class={cx(
"text-red-10 hover:bg-red-3/40",
issuePanelVisible() &&
-- "bg-red-3/40 ring-1 ring-red-8",
++ "bg-red-3/40 ring-1 ring-red-8",
)}
onClick={() => toggleIssuePanel()}
title={issueMessages().join(", ")}