Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions apps/desktop/src/components/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,36 @@ const toggleControlStyles = cva(
size: {
sm: "w-9 h-[1.25rem] p-[0.125rem]",
md: "w-11 h-[1.5rem] p-[0.125rem]",
lg: "w-14 h-[1.75rem] p-[0.1875rem]"
}
lg: "w-14 h-[1.75rem] p-[0.1875rem]",
},
},
defaultVariants: {
size: "md"
}
size: "md",
},
}
);

const toggleThumbStyles = cva(
"ui-checked:bg-solid-white bg-gray-10 rounded-full transition-transform ui-checked:translate-x-[calc(100%)]",
"bg-white rounded-full transition-transform ui-checked:translate-x-[calc(100%)]",
{
variants: {
size: {
sm: "size-[1rem]",
md: "size-[1.25rem]",
lg: "size-[1.5rem]"
}
lg: "size-[1.5rem]",
},
},
defaultVariants: {
size: "md"
}
size: "md",
},
}
);

export function Toggle(props: ComponentProps<typeof KSwitch> & { size?: 'sm' | 'md' | 'lg' }) {
const [local, others] = splitProps(props, ['size']);

export function Toggle(
props: ComponentProps<typeof KSwitch> & { size?: "sm" | "md" | "lg" }
) {
const [local, others] = splitProps(props, ["size"]);

return (
<KSwitch {...others}>
<KSwitch.Input class="peer" />
Expand Down
158 changes: 115 additions & 43 deletions apps/desktop/src/routes/editor/ConfigSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { cx } from "cva";
import {
For,
Show,
Suspense,
ValidComponent,
batch,
createEffect,
Expand All @@ -42,6 +43,7 @@ import { generalSettingsStore } from "~/store";
import {
type BackgroundSource,
StereoMode,
TimelineSegment,
ZoomSegment,
commands,
} from "~/utils/tauri";
Expand Down Expand Up @@ -215,7 +217,7 @@ export function ConfigSidebar() {
return (
<KTabs
value={state.selectedTab}
class="flex flex-col shrink-0 flex-1 max-w-[26rem] overflow-hidden rounded-xl z-10 bg-gray-50 relative shadow-sm"
class="flex flex-col shrink-0 flex-1 max-w-[26rem] overflow-hidden rounded-xl z-10 relative bg-gray-1 dark:bg-gray-2 border border-gray-3"
>
<KTabs.List class="flex overflow-hidden relative z-40 flex-row items-center h-16 text-lg border-b border-gray-3 shrink-0">
<For
Expand Down Expand Up @@ -546,24 +548,50 @@ export function ConfigSidebar() {
</Field>
</KTabs.Content>
</div>
<Show
when={(() => {
const selection =
editorState.timeline.selection?.type === "zoom" &&
editorState.timeline.selection;
if (!selection) return;

const segment = project.timeline?.zoomSegments?.[selection.index];
if (!segment) return;

return { selection, segment };
})()}
>
{(value) => (
<ZoomSegmentConfig
segment={value().segment}
segmentIndex={value().selection.index}
/>
<Show when={editorState.timeline.selection}>
{(selection) => (
<div class="absolute inset-0 p-[0.75rem] text-[0.875rem] space-y-4 bg-gray-1 dark:bg-gray-2 z-50 animate-in slide-in-from-bottom-2 fade-in">
<Suspense>
<Show
when={(() => {
const zoomSelection = selection();
if (zoomSelection.type !== "zoom") return;

const segment =
project.timeline?.zoomSegments?.[zoomSelection.index];
if (!segment) return;

return { selection: zoomSelection, segment };
})()}
>
{(value) => (
<ZoomSegmentConfig
segment={value().segment}
segmentIndex={value().selection.index}
/>
)}
</Show>
<Show
when={(() => {
const clipSegment = selection();
if (clipSegment.type !== "clip") return;

const segment =
project.timeline?.segments?.[clipSegment.index];
if (!segment) return;

return { selection: clipSegment, segment };
})()}
>
{(value) => (
<ClipSegmentConfig
segment={value().segment}
segmentIndex={value().selection.index}
/>
)}
</Show>
</Suspense>
</div>
)}
</Show>
</KTabs>
Expand Down Expand Up @@ -1613,7 +1641,6 @@ function ZoomSegmentConfig(props: {
project,
setProject,
editorInstance,
editorState,
setEditorState,
projectHistory,
} = useEditorContext();
Expand All @@ -1626,10 +1653,7 @@ function ZoomSegmentConfig(props: {
};

return (
<div
data-visible={editorState.timeline.selection?.type === "zoom"}
class="absolute inset-0 p-[0.75rem] text-[0.875rem] space-y-6 bg-gray-2 z-50 animate-in slide-in-from-bottom-2 fade-in"
>
<>
<div class="flex flex-row justify-between items-center">
<div class="flex gap-2 items-center">
<EditorButton
Expand Down Expand Up @@ -1682,23 +1706,13 @@ function ZoomSegmentConfig(props: {
class="space-y-6"
value={props.segment.mode === "auto" ? "auto" : "manual"}
onChange={(v) => {
if (v === "auto") {
setProject(
"timeline",
"zoomSegments",
props.segmentIndex,
"mode",
"auto"
);
} else {
setProject(
"timeline",
"zoomSegments",
props.segmentIndex,
"mode",
{ manual: states.manual }
);
}
setProject(
"timeline",
"zoomSegments",
props.segmentIndex,
"mode",
v === "auto" ? "auto" : { manual: states.manual }
);
}}
>
<KTabs.List class="flex flex-row items-center rounded-[0.5rem] relative border">
Expand All @@ -1716,7 +1730,7 @@ function ZoomSegmentConfig(props: {
Manual
</KTabs.Trigger>
<KTabs.Indicator class="absolute flex p-px inset-0 transition-transform peer-focus-visible:outline outline-2 outline-blue-9 outline-offset-2 rounded-[0.6rem] overflow-hidden">
<div class="flex-1 bg-gray-2" />
<div class="flex-1 bg-gray-3" />
</KTabs.Indicator>
</KTabs.List>
<KTabs.Content value="manual" tabIndex="">
Expand Down Expand Up @@ -1893,7 +1907,65 @@ function ZoomSegmentConfig(props: {
</KTabs.Content>
</KTabs>
</Field>
</div>
</>
);
}

function ClipSegmentConfig(props: {
segmentIndex: number;
segment: TimelineSegment;
}) {
const { setProject, setEditorState, project } = useEditorContext();

return (
<>
<div class="flex flex-row justify-between items-center">
<div class="flex gap-2 items-center">
<EditorButton
onClick={() => setEditorState("timeline", "selection", null)}
leftIcon={<IconLucideCheck />}
>
Done
</EditorButton>
</div>
<EditorButton
variant="danger"
onClick={() => {
batch(() => {
setProject(
"timeline",
"segments",
produce((s) => {
if (!s) return;
return s.splice(props.segmentIndex, 1);
})
);
setEditorState("timeline", "selection", null);
});
}}
disabled={
(
project.timeline?.segments.filter(
(s) => s.recordingSegment === props.segment.recordingSegment
) ?? []
).length < 2
}
leftIcon={<IconCapTrash />}
>
Delete
</EditorButton>
</div>
<ComingSoonTooltip>
<Field name="Hide Cursor" disabled value={<Toggle disabled />} />
</ComingSoonTooltip>
<ComingSoonTooltip>
<Field
name="Disable Smooth Cursor Movement"
disabled
value={<Toggle disabled />}
/>
</ComingSoonTooltip>
</>
);
}

Expand Down
14 changes: 11 additions & 3 deletions apps/desktop/src/routes/editor/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function Player() {
});

return (
<div class="flex flex-col flex-1 bg-gray-50 bg-opacity-5 rounded-xl shadow-sm">
<div class="flex flex-col flex-1 rounded-xl bg-gray-1 dark:bg-gray-2 border border-gray-3">
<div class="flex gap-3 justify-center p-3">
<AspectRatioSelect />
<EditorButton
Expand Down Expand Up @@ -157,8 +157,16 @@ export function Player() {
}
as={KToggleButton}
variant="danger"
leftIcon={<IconCapScissors class="text-gray-12" />}
/>{" "}
leftIcon={
<IconCapScissors
class={cx(
editorState.timeline.interactMode === "split"
? "text-white"
: "text-gray-12"
)}
/>
}
/>
<div class="w-px h-8 rounded-full bg-gray-4" />
<Tooltip content="Zoom out">
<IconCapZoomOut
Expand Down
7 changes: 0 additions & 7 deletions apps/desktop/src/routes/editor/PresetsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {

export function PresetsDropdown() {
const { setDialog, presets, setProject } = useEditorContext();
const [activePreset, setActivePreset] = createSignal<number | null>(presets.query.data?.default ?? null);
return (
<KDropdownMenu gutter={8} placement="bottom">
<EditorButton<typeof KDropdownMenu.Trigger>
Expand Down Expand Up @@ -55,15 +54,9 @@ export function PresetsDropdown() {
onClick={() => {
setShowSettings(false);
setProject(reconcile(preset.config));
setActivePreset(i());
}}
>
<span class="mr-auto">{preset.name}</span>
<Show when={Object.is(activePreset(), i())}>
<span class="px-2 py-1 text-[11px] rounded-full bg-blue-8 text-gray-1 dark:text-gray-12">
Current
</span>
</Show>
<Show when={presets.query.data?.default === i()}>
<span class="px-2 py-1 text-[11px] rounded-full bg-gray-2 text-gray-11">
Default
Expand Down
Loading