From 2e50d9c22cc94cec143d4cdc06548f728af1ffe3 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 13 Apr 2024 07:53:52 -0600 Subject: [PATCH] Refactor sliders --- .../player/PreviewThumbnailPlayer.tsx | 6 +- web/src/components/player/VideoControls.tsx | 4 +- web/src/components/ui/slider-no-thumb.tsx | 26 -------- web/src/components/ui/slider-volume.tsx | 26 -------- web/src/components/ui/slider.tsx | 62 ++++++++++++++++++- 5 files changed, 66 insertions(+), 58 deletions(-) delete mode 100644 web/src/components/ui/slider-no-thumb.tsx delete mode 100644 web/src/components/ui/slider-volume.tsx diff --git a/web/src/components/player/PreviewThumbnailPlayer.tsx b/web/src/components/player/PreviewThumbnailPlayer.tsx index b4994de60..e640cfbb7 100644 --- a/web/src/components/player/PreviewThumbnailPlayer.tsx +++ b/web/src/components/player/PreviewThumbnailPlayer.tsx @@ -8,7 +8,6 @@ import React, { import { useApiHost } from "@/api"; import { isCurrentHour } from "@/utils/dateUtil"; import { ReviewSegment } from "@/types/review"; -import { Slider } from "../ui/slider-no-thumb"; import { getIconForLabel } from "@/utils/iconUtil"; import TimeAgo from "../dynamic/TimeAgo"; import useSWR from "swr"; @@ -23,6 +22,7 @@ import ImageLoadingIndicator from "../indicators/ImageLoadingIndicator"; import useContextMenu from "@/hooks/use-contextmenu"; import ActivityIndicator from "../indicators/activity-indicator"; import { TimeRange } from "@/types/timeline"; +import { NoThumbSlider } from "../ui/slider"; type PreviewPlayerProps = { review: ReviewSegment; @@ -543,7 +543,7 @@ function VideoPreview({ > - - {video.muted == false && ( - , - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - - - -)); -Slider.displayName = SliderPrimitive.Root.displayName; - -export { Slider }; diff --git a/web/src/components/ui/slider-volume.tsx b/web/src/components/ui/slider-volume.tsx deleted file mode 100644 index 1493488a3..000000000 --- a/web/src/components/ui/slider-volume.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from "react"; -import * as SliderPrimitive from "@radix-ui/react-slider"; - -import { cn } from "@/lib/utils"; - -const Slider = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - - - -)); -Slider.displayName = SliderPrimitive.Root.displayName; - -export { Slider }; diff --git a/web/src/components/ui/slider.tsx b/web/src/components/ui/slider.tsx index e161daec0..4907ff9d8 100644 --- a/web/src/components/ui/slider.tsx +++ b/web/src/components/ui/slider.tsx @@ -23,4 +23,64 @@ const Slider = React.forwardRef< )) Slider.displayName = SliderPrimitive.Root.displayName -export { Slider } +const VolumeSlider = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + + +)); +VolumeSlider.displayName = SliderPrimitive.Root.displayName; + +const NoThumbSlider = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + + +)); +NoThumbSlider.displayName = SliderPrimitive.Root.displayName; + +const DualThumbSlider = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + + +)) +DualThumbSlider.displayName = SliderPrimitive.Root.displayName + +export { DualThumbSlider, Slider, NoThumbSlider, VolumeSlider }