feat: animations
This commit is contained in:
1 parent
e4788ae384
commit
7b55619cf5
16 files changed
+643
-320
No files matched your search
@@ -1,15 +1,15 @@
|
||||
import { ChangeEvent, useRef, useState } from 'react';
|
||||
import { Search as SearchIcon, XCircle } from 'lucide-react';
|
||||
import { ChangeEvent, FC, useRef, useState } from 'react';
|
||||
import { create, InstanceProps } from 'react-modal-promise';
|
||||
import { XCircle } from 'lucide-react';
|
||||
|
||||
import List from '@/components/Movie/List';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||
import { Modal } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import useSearch from './useSearch';
|
||||
|
||||
const Search = () => {
|
||||
const [isShow, setIsShow] = useState(false);
|
||||
const Search: FC<InstanceProps<void>> = ({ isOpen, onResolve }) => {
|
||||
const [title, setTitle] = useState('');
|
||||
const [query, setQuery] = useState('');
|
||||
const timeout = useRef<NodeJS.Timeout>();
|
||||
@@ -31,54 +31,45 @@ const Search = () => {
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setIsShow(false);
|
||||
handleReset();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button variant='outline' size='icon' onClick={() => setIsShow(true)}>
|
||||
<SearchIcon />
|
||||
</Button>
|
||||
{isShow && (
|
||||
<Dialog defaultOpen={true} onOpenChange={handleClose}>
|
||||
<DialogContent className='block p-3 max-w-[950px]' onClose={() => setIsShow(false)}>
|
||||
<div className='relative'>
|
||||
<Input
|
||||
ref={inputRef}
|
||||
autoFocus
|
||||
placeholder='Start entering title...'
|
||||
value={title}
|
||||
onChange={handleChangeTitle}
|
||||
className='pr-10'
|
||||
/>
|
||||
<Button
|
||||
variant='outline'
|
||||
size='icon'
|
||||
onClick={handleReset}
|
||||
disabled={!query.length}
|
||||
className='absolute right-0 top-0'
|
||||
>
|
||||
<XCircle />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{Boolean(results?.pages.length) && (
|
||||
<div className='mt-3'>
|
||||
<List
|
||||
pages={results!.pages}
|
||||
fetchNextPage={fetchNextPage}
|
||||
hasNextPage={hasNextPage}
|
||||
withBottomGap={false}
|
||||
onPreviewClose={handleClose}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<Modal className='block p-3 max-w-[950px]' isOpen={isOpen} onClose={() => onResolve()}>
|
||||
<div className='relative'>
|
||||
<Input
|
||||
ref={inputRef}
|
||||
autoFocus
|
||||
placeholder='Start entering title...'
|
||||
value={title}
|
||||
onChange={handleChangeTitle}
|
||||
className='pr-10'
|
||||
/>
|
||||
<Button
|
||||
variant='outline'
|
||||
size='icon'
|
||||
onClick={handleReset}
|
||||
disabled={!query.length}
|
||||
className='absolute right-0 top-0'
|
||||
>
|
||||
<XCircle />
|
||||
</Button>
|
||||
</div>
|
||||
{Boolean(results?.pages.length) && (
|
||||
<div className='mt-3'>
|
||||
<List
|
||||
pages={results!.pages}
|
||||
fetchNextPage={fetchNextPage}
|
||||
hasNextPage={hasNextPage}
|
||||
withBottomGap={false}
|
||||
onPreviewClose={handleClose}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export const showSearchModal = create(Search);
|
||||
|
||||
export default Search;
|
||||
Reference in new issue
Block a user