From 269d2b59ebb6a9a94e65f52ae0ceff1791c87331 Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Mon, 23 Oct 2023 17:15:13 +0200 Subject: [PATCH] Add manipulation buttons to caption offset --- src/components/Icon.tsx | 2 + .../atoms/settings/CaptionSettingsView.tsx | 60 ++++++++++++++++--- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 5a086d9f..2c4e6e29 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -9,6 +9,7 @@ export enum Icons { ARROW_LEFT = "arrowLeft", ARROW_RIGHT = "arrowRight", CHEVRON_DOWN = "chevronDown", + CHEVRON_UP = "chevronUp", CHEVRON_RIGHT = "chevronRight", CHEVRON_LEFT = "chevronLeft", CLAPPER_BOARD = "clapperBoard", @@ -61,6 +62,7 @@ const iconList: Record = { eyeSlash: ``, arrowLeft: ``, chevronDown: ``, + chevronUp: ``, chevronRight: ``, chevronLeft: ``, clapperBoard: ``, diff --git a/src/components/player/atoms/settings/CaptionSettingsView.tsx b/src/components/player/atoms/settings/CaptionSettingsView.tsx index 53d67cd5..2029dcb4 100644 --- a/src/components/player/atoms/settings/CaptionSettingsView.tsx +++ b/src/components/player/atoms/settings/CaptionSettingsView.tsx @@ -41,6 +41,7 @@ function CaptionSetting(props: { label: string; min: number; decimalsAllowed?: number; + controlButtons?: boolean; }) { const inputRef = useRef(null); const ref = useRef(null); @@ -76,6 +77,10 @@ function CaptionSetting(props: { }; }, [isFocused]); + function setNewValue(value: number) { + props.onChange?.(Math.min(Math.max(value, props.min), props.max)); + } + const inputClasses = "px-3 py-1 bg-video-context-inputBg rounded w-20 text-left text-white cursor-text"; const textTransformer = props.textTransformer ?? ((s) => s); @@ -143,17 +148,57 @@ function CaptionSetting(props: { } /> ) : ( - + + {props.controlButtons ? ( +
+ + +
+ ) : null} + )} @@ -186,6 +231,7 @@ export function CaptionSettingsView({ id }: { id: string }) { value={delay} textTransformer={(s) => `${s}s`} decimalsAllowed={1} + controlButtons />