Skip to content

Commit

Permalink
feat(v2): animate file list (#109)
Browse files Browse the repository at this point in the history
* feat(v2): animate file list

* fix tests
  • Loading branch information
murgatt committed Feb 5, 2024
1 parent f0de396 commit 435f6f7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"test": "vitest"
},
"dependencies": {
"@formkit/auto-animate": "0.8.1",
"@hookform/resolvers": "3.3.2",
"@radix-ui/react-label": "2.0.2",
"@radix-ui/react-navigation-menu": "1.1.4",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/components/FileList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useAutoAnimate } from '@formkit/auto-animate/react';
import { ListXIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { getFiles, useStore } from 'src/store';
Expand All @@ -9,10 +10,11 @@ export const FileList = () => {
const { t } = useTranslation();
const files = useStore(getFiles);
const clearFiles = useStore(state => state.clearFiles);
const [listRef] = useAutoAnimate();

return (
<div className="relative h-full">
<ul className="flex h-full flex-col gap-3 overflow-y-auto px-4 pb-14 pt-4">
<ul className="flex h-full flex-col gap-3 overflow-y-auto px-4 pb-14 pt-4" ref={listRef}>
{files.map(file => (
<li key={file.path}>
<FileCard file={file} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/__tests__/FileList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ vi.mock('src/store/selectors', () => ({
getFiles: vi.fn(),
}));

vi.mock('@formkit/auto-animate/react', () => ({
useAutoAnimate: vi.fn().mockReturnValue([]),
}));

const file1 = { name: 'file1.mkv', path: '/path/file1.mkv', size: 1024 } as VideoFile;
const file2 = { name: 'file2.mkv', path: '/path/file2.mkv', size: 1024 } as VideoFile;
const file3 = { name: 'file3.mkv', path: '/path/file3.mkv', size: 1024 } as VideoFile;
Expand Down

0 comments on commit 435f6f7

Please sign in to comment.