diff --git a/src/common/components/comment/__snapshots__/index.spec.tsx.snap b/src/common/components/comment/__snapshots__/index.spec.tsx.snap index c6c9c472ec2..f48ce3fbf62 100644 --- a/src/common/components/comment/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/comment/__snapshots__/index.spec.tsx.snap @@ -219,7 +219,7 @@ exports[`(1) Default render 1`] = `
@@ -584,7 +584,7 @@ exports[`(2) Cancellable, in progress 1`] = `
diff --git a/src/common/components/entry-vote-btn/__snapshots__/index.spec.tsx.snap b/src/common/components/entry-vote-btn/__snapshots__/index.spec.tsx.snap index 52de0baf2e4..25ae346ad6a 100644 --- a/src/common/components/entry-vote-btn/__snapshots__/index.spec.tsx.snap +++ b/src/common/components/entry-vote-btn/__snapshots__/index.spec.tsx.snap @@ -41,37 +41,44 @@ Array [
-
-
+
+
+
-
+
{
- this.upSliderChanged(x)} + this.upSliderChanged(x)} />
{`${upSliderVal && upSliderVal.toFixed(1)}%`}
@@ -379,11 +377,9 @@ export class VoteDialog extends Component {
- this.downSliderChanged(x)} + this.downSliderChanged(x)} />
diff --git a/src/common/features/packages-helpers/index.ts b/src/common/features/packages-helpers/index.ts new file mode 100644 index 00000000000..cdaa7e5cc2e --- /dev/null +++ b/src/common/features/packages-helpers/index.ts @@ -0,0 +1 @@ +export * from "./react-input-slider-wrapper"; diff --git a/src/common/features/packages-helpers/react-input-slider-wrapper.tsx b/src/common/features/packages-helpers/react-input-slider-wrapper.tsx new file mode 100644 index 00000000000..7ea17d1d173 --- /dev/null +++ b/src/common/features/packages-helpers/react-input-slider-wrapper.tsx @@ -0,0 +1,32 @@ +import Slider from "react-input-slider"; +import React, { useRef } from "react"; + +interface Props { + value: number; + onChange: (v: number) => void; +} + +export function ReactInputSliderWrapper({ value, onChange }: Props) { + const rootRef = useRef(null); + + const handleKeyboard = (e: React.KeyboardEvent) => { + if (e.key === "ArrowLeft" && value > 0) { + onChange(value - 1); + } + if (e.key === "ArrowRight" && value < 100) { + onChange(value + 1); + } + }; + + return ( + rootRef.current?.focus()} + > + onChange(x)} /> + + ); +}