import * as SliderPrimitive from '@radix-ui/react-slider'; import * as React from 'react'; import { cn } from '@/lib/utils'; import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip'; function useMediaQuery(query: string) { const [matches, setMatches] = React.useState(false); React.useEffect(() => { const media = window.matchMedia(query); setMatches(media.matches); }, [query]); return matches; } const Slider = ({ ref, className, tooltip, ...props }: { ref?: any; className?: string; tooltip?: string; value: number[]; max: number; step: number; onValueChange: (value: number[]) => void; }) => { const isMobile = useMediaQuery('(max-width: 768px)'); return ( <> {isMobile && (
{tooltip}
)} {tooltip && !isMobile ? ( {tooltip} ) : ( )} ); }; Slider.displayName = SliderPrimitive.Root.displayName; export { Slider };