1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

tried grid

This commit is contained in:
muerwre 2019-08-08 17:21:59 +07:00
parent 10b013f9a8
commit 125a120c85
6 changed files with 25 additions and 17 deletions

View file

@ -86,14 +86,8 @@ const ImageEditorUnconnected: FC<IProps> = ({ data, setData, uploadUploadFiles,
useEffect(() => console.log({ data }), [data]); useEffect(() => console.log({ data }), [data]);
useEffect(() => { useEffect(() => {
console.log({ temp, files });
Object.entries(statuses).forEach(([id, status]) => { Object.entries(statuses).forEach(([id, status]) => {
// todo: make this working
console.log({ id, uuid: status.uuid, file: files[status.uuid], files });
if (temp.includes(id) && !!status.uuid && files[status.uuid]) { if (temp.includes(id) && !!status.uuid && files[status.uuid]) {
console.log(`${id} uploaded`);
onFileAdd(files[status.uuid]); onFileAdd(files[status.uuid]);
setTemp(temp.filter(el => el !== id)); setTemp(temp.filter(el => el !== id));
} }
@ -103,7 +97,7 @@ const ImageEditorUnconnected: FC<IProps> = ({ data, setData, uploadUploadFiles,
return ( return (
<ImageGrid <ImageGrid
items={data.files} items={data.files}
locked={temp.map(id => statuses[id])} locked={temp.filter(id => !!statuses[id]).map(id => statuses[id])}
/> />
); );
}; };

View file

@ -17,7 +17,7 @@ const SortableList = SortableContainer(({ items, locked }: { items: IFile[], loc
<div className={styles.grid}> <div className={styles.grid}>
{ {
items.map((file, index) => ( items.map((file, index) => (
<SortableItem key={file.id} index={index}> <SortableItem key={file.id} index={index} collection={0}>
<ImageUpload <ImageUpload
id={file.id} id={file.id}
thumb={file.url} thumb={file.url}
@ -25,6 +25,17 @@ const SortableList = SortableContainer(({ items, locked }: { items: IFile[], loc
</SortableItem> </SortableItem>
)) ))
} }
{
locked.map((item, index) => (
<SortableItem key={item.temp_id} index={index} collection={1} disabled>
<ImageUpload
thumb={item.preview}
progress={item.progress}
is_uploading
/>
</SortableItem>
))
}
<div style={{ clear: 'both' }} /> <div style={{ clear: 'both' }} />
</div> </div>
); );

View file

@ -3,22 +3,22 @@
padding-bottom: 60px; padding-bottom: 60px;
box-sizing: border-box; box-sizing: border-box;
// display: grid; display: grid;
// grid-column-gap: $gap; grid-column-gap: $gap;
// grid-row-gap: $gap; grid-row-gap: $gap;
// grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
// display: flex; // display: flex;
// flex-wrap: wrap; // flex-wrap: wrap;
// @media (max-width: 600px) { @media (max-width: 600px) {
// grid-template-columns: repeat(auto-fill, minmax(30vw, 1fr)); grid-template-columns: repeat(auto-fill, minmax(30vw, 1fr));
// } }
} }
.item { .item {
// flex: 0 4 25%; // flex: 0 4 25%;
width: 25%; // width: 25%;
float: left; // float: left;
// padding: $gap / 2; // padding: $gap / 2;
z-index: 100; z-index: 100;
box-sizing: border-box; box-sizing: border-box;

View file

@ -37,4 +37,5 @@ export const EMPTY_UPLOAD_STATUS: IUploadStatus = {
progress: 0, progress: 0,
thumbnail_url: null, thumbnail_url: null,
type: null, type: null,
temp_id: null,
} }

View file

@ -11,6 +11,7 @@ export interface IUploadStatus {
type: string; type: string;
thumbnail_url: string; thumbnail_url: string;
progress: number; progress: number;
temp_id: UUID;
} }
export interface IUploadState { export interface IUploadState {

View file

@ -49,6 +49,7 @@ function* uploadFile({ file, temp_id }: IFileWithUUID) {
preview, preview,
is_uploading: true, is_uploading: true,
type: file.type, type: file.type,
temp_id,
} }
) )
); );