forked from jbilcke-hf/clapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f304ad7
commit ef82923
Showing
18 changed files
with
162 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react' | ||
import * as SliderPrimitive from '@radix-ui/react-slider' | ||
import { cn } from '@/lib/utils' | ||
|
||
const Slider = React.forwardRef< | ||
React.ElementRef<typeof SliderPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & { | ||
trackClass?: string | ||
rangeClass?: string | ||
thumbClass?: string | ||
} | ||
>(({ className, trackClass, rangeClass, thumbClass, ...props }, ref) => ( | ||
<SliderPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
'relative flex touch-none select-none items-center', | ||
className | ||
)} | ||
{...props} | ||
> | ||
<SliderPrimitive.Track | ||
className={cn( | ||
`relative grow overflow-hidden rounded border border-neutral-900 bg-neutral-100 dark:bg-neutral-700/70`, | ||
`h-1.5 w-full`, | ||
trackClass | ||
)} | ||
> | ||
<SliderPrimitive.Range | ||
className={cn( | ||
`absolute bg-neutral-900/80 dark:bg-neutral-50/40`, | ||
`h-full rounded-none`, | ||
rangeClass | ||
)} | ||
/> | ||
</SliderPrimitive.Track> | ||
<SliderPrimitive.Thumb | ||
className={cn( | ||
`block border border-neutral-400 bg-neutral-400 shadow-lg ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-neutral-950 focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50 dark:border-neutral-400 dark:bg-neutral-400 dark:ring-offset-neutral-400 dark:focus-visible:ring-neutral-400`, | ||
`h-3 w-3 rounded-full`, | ||
thumbClass | ||
)} | ||
/> | ||
</SliderPrimitive.Root> | ||
)) | ||
Slider.displayName = 'Slider' | ||
|
||
export { Slider } |
37 changes: 37 additions & 0 deletions
37
packages/app/src/components/core/timeline/TimelineZoom.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as React from 'react' | ||
import { BiSolidZoomIn, BiSolidZoomOut } from 'react-icons/bi' | ||
import { useTimeline } from '@aitube/timeline' | ||
|
||
import { cn } from '@/lib/utils' | ||
|
||
import { Slider } from './Slider' | ||
import { useDebounceFn } from '@/lib/hooks' | ||
|
||
export function TimelineZoom() { | ||
const setHorizontalZoomLevel = useTimeline((s) => s.setHorizontalZoomLevel) | ||
const minHorizontalZoomLevel = useTimeline((s) => s.minHorizontalZoomLevel) | ||
const maxHorizontalZoomLevel = useTimeline((s) => s.maxHorizontalZoomLevel) | ||
|
||
const onValueChange = useDebounceFn((values: number[]) => { | ||
setHorizontalZoomLevel(values[0]) | ||
}, 250) | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
`flex w-40 flex-row items-center justify-center`, | ||
`space-x-1.5 text-xl text-white/40` | ||
)} | ||
> | ||
<BiSolidZoomIn className="" /> | ||
<Slider | ||
className={cn('w-full')} | ||
orientation="horizontal" | ||
min={minHorizontalZoomLevel} | ||
max={maxHorizontalZoomLevel} | ||
onValueChange={onValueChange} | ||
/> | ||
<BiSolidZoomOut className="" /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,4 +130,4 @@ export function VUMeter({ className = 'w-24 h-full' }) { | |
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useRef, useEffect } from 'react' | ||
|
||
type Timer = ReturnType<typeof setTimeout> | ||
type SomeFunction = (...args: any[]) => void | ||
/** | ||
* | ||
* @param func The original, non debounced function (You can pass any number of args to it) | ||
* @param delay The delay (in ms) for the function to return | ||
* @returns The debounced function, which will run only if the debounced function has not been called in the last (delay) ms | ||
*/ | ||
|
||
export function useDebounceFn<Func extends SomeFunction>( | ||
func: Func, | ||
delay = 1000 | ||
) { | ||
const timer = useRef<Timer>() | ||
|
||
useEffect(() => { | ||
return () => { | ||
if (!timer.current) return | ||
clearTimeout(timer.current) | ||
} | ||
}, []) | ||
|
||
const debouncedFunction = ((...args) => { | ||
const newTimer = setTimeout(() => { | ||
func(...args) | ||
}, delay) | ||
clearTimeout(timer.current) | ||
timer.current = newTimer | ||
}) as Func | ||
|
||
return debouncedFunction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters