feat: add refresh button for non-touch devices
This commit is contained in:
parent
2926be0d87
commit
de9ed04ca8
6 changed files with 140 additions and 64 deletions
24
src/components/RefreshButton/index.tsx
Normal file
24
src/components/RefreshButton/index.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { Button } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { RefreshCcw } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
|
||||
export function RefreshButton({ onClick }: { onClick: () => void }) {
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="titlebar-icon"
|
||||
disabled={refreshing}
|
||||
onClick={() => {
|
||||
setRefreshing(true)
|
||||
onClick()
|
||||
setTimeout(() => setRefreshing(false), 500)
|
||||
}}
|
||||
className="text-muted-foreground focus:text-foreground [&_svg]:size-4"
|
||||
>
|
||||
<RefreshCcw className={cn(refreshing ? 'animate-spin' : '')} />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue