1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

added SortableAudioGrid

This commit is contained in:
Fedor Katurov 2022-06-30 15:58:46 +07:00
parent 586ebb7480
commit 47a6e02c21
14 changed files with 175 additions and 131 deletions

View file

@ -1,15 +1,8 @@
import React, { FC, useCallback } from 'react';
import { SortEnd } from 'react-sortable-hoc';
import { SortableAudioGrid } from '~/components/editors/SortableAudioGrid';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
import { SortableAudioGrid } from '~/components/sortable';
import { UploadStatus } from '~/store/uploader/UploaderStore';
import { IFile } from '~/types';
import { moveArrItem } from '~/utils/fn';
import styles from './styles.module.scss';
interface IProps {
files: IFile[];
@ -18,17 +11,9 @@ interface IProps {
}
const AudioGrid: FC<IProps> = ({ files, setFiles, locked }) => {
const { innerWidth } = useWindowSize();
const onMove = useCallback(
({ oldIndex, newIndex }: SortEnd) => {
setFiles(
moveArrItem(
oldIndex,
newIndex,
files.filter(file => !!file)
) as IFile[]
);
(newFiles: IFile[]) => {
setFiles(newFiles);
},
[setFiles, files]
);
@ -56,11 +41,8 @@ const AudioGrid: FC<IProps> = ({ files, setFiles, locked }) => {
onDelete={onDrop}
onTitleChange={onTitleChange}
onSortEnd={onMove}
axis="xy"
items={files}
locked={locked}
pressDelay={innerWidth < 768 ? 200 : 0}
helperClass={styles.helper}
/>
);
};