mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
image grid
This commit is contained in:
parent
af3b413903
commit
2dd0cb28e2
7 changed files with 127 additions and 13 deletions
42
src/components/editors/ImageGrid/index.tsx
Normal file
42
src/components/editors/ImageGrid/index.tsx
Normal file
|
@ -0,0 +1,42 @@
|
|||
import React, { FC, ReactChildren } from 'react';
|
||||
import { SortableContainer, SortableElement } from 'react-sortable-hoc';
|
||||
import * as styles from './styles.scss';
|
||||
import { ImageUpload } from '~/components/upload/ImageUpload';
|
||||
import { IFile } from '~/redux/types';
|
||||
import { IUploadStatus } from '~/redux/uploads/reducer';
|
||||
|
||||
interface IProps {
|
||||
items: IFile[];
|
||||
locked: IUploadStatus[];
|
||||
};
|
||||
|
||||
const SortableItem = SortableElement(({ children }) => <div className={styles.item}>{children}</div>);
|
||||
|
||||
const SortableList = SortableContainer(({ items, locked }: { items: IFile[], locked: IUploadStatus[] }) => {
|
||||
return (
|
||||
<div className={styles.grid}>
|
||||
{
|
||||
items.map((file, index) => (
|
||||
<SortableItem key={file.id} index={index}>
|
||||
<ImageUpload
|
||||
thumb={file.url}
|
||||
/>
|
||||
</SortableItem>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
const ImageGrid: FC<IProps> = ({
|
||||
items,
|
||||
locked,
|
||||
}) => {
|
||||
|
||||
|
||||
return (
|
||||
<SortableList onSortEnd={console.log} axis="xy" items={items} locked={locked} />
|
||||
)
|
||||
}
|
||||
|
||||
export { ImageGrid };
|
Loading…
Add table
Add a link
Reference in a new issue