diff --git a/package-lock.json b/package-lock.json index 004a59d5..37232e50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14269,6 +14269,16 @@ "shallowequal": "^1.0.2" } }, + "react-sortable-hoc": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/react-sortable-hoc/-/react-sortable-hoc-1.9.1.tgz", + "integrity": "sha512-2VeofjRav8+eZeE5Nm/+b8mrA94rQ+gBsqhXi8pRBSjOWNqslU3ZEm+0XhSlfoXJY2lkgHipfYAUuJbDtCixRg==", + "requires": { + "@babel/runtime": "^7.2.0", + "invariant": "^2.2.4", + "prop-types": "^15.5.7" + } + }, "react-stack-grid": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/react-stack-grid/-/react-stack-grid-0.7.1.tgz", diff --git a/package.json b/package.json index f748434c..ffd525c8 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,7 @@ "react-router": "^4.3.1", "react-router-dom": "^4.3.1", "react-scrollbar": "^0.5.4", + "react-sortable-hoc": "^1.9.1", "react-stack-grid": "^0.7.1", "redux": "^4.0.1", "redux-persist": "^5.10.0", diff --git a/src/components/editors/ImageEditor/index.tsx b/src/components/editors/ImageEditor/index.tsx index 63e9b340..d5762d6c 100644 --- a/src/components/editors/ImageEditor/index.tsx +++ b/src/components/editors/ImageEditor/index.tsx @@ -1,13 +1,12 @@ import React, { FC, useCallback, useEffect, useState } from 'react'; import uuid from 'uuid4'; import { INode, IFileWithUUID, IFile } from '~/redux/types'; -import * as styles from './styles.scss'; import * as UPLOAD_ACTIONS from '~/redux/uploads/actions'; import { connect } from 'react-redux'; import { selectUploads } from '~/redux/uploads/selectors'; import assocPath from 'ramda/es/assocPath'; import append from 'ramda/es/append'; -import { ImageUpload } from '~/components/upload/ImageUpload'; +import { ImageGrid } from '~/components/editors/ImageGrid'; const mapStateToProps = selectUploads; const mapDispatchToProps = { @@ -19,6 +18,8 @@ type IProps = ReturnType & typeof mapDispatchToProps & { setData: (val: INode) => void; } + + const ImageEditorUnconnected: FC = ({ data, setData, uploadUploadFiles, statuses, files }) => { const eventPreventer = useCallback(event => event.preventDefault(), []); const [temp, setTemp] = useState([]); @@ -100,7 +101,19 @@ const ImageEditorUnconnected: FC = ({ data, setData, uploadUploadFiles, }, [statuses, files]); return ( -
+ statuses[id])} + /> + ); +}; + +const ImageEditor = connect(mapStateToProps, mapDispatchToProps)(ImageEditorUnconnected) +export { ImageEditor }; + +/* + + { data.files.map(file => ( = ({ data, setData, uploadUploadFiles, /> )) } - { + + + + { + temp.map(id => ( + statuses[id] && ( + + ) + )) + } + + { temp.map(id => ( statuses[id] && ( = ({ data, setData, uploadUploadFiles, ) )) } - - - - ); -}; - -const ImageEditor = connect(mapStateToProps, mapDispatchToProps)(ImageEditorUnconnected) -export { ImageEditor }; + + +*/ \ No newline at end of file diff --git a/src/components/editors/ImageGrid/index.tsx b/src/components/editors/ImageGrid/index.tsx new file mode 100644 index 00000000..49fbf0a9 --- /dev/null +++ b/src/components/editors/ImageGrid/index.tsx @@ -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 }) =>
{children}
); + +const SortableList = SortableContainer(({ items, locked }: { items: IFile[], locked: IUploadStatus[] }) => { + return ( +
+ { + items.map((file, index) => ( + + + + )) + } +
+ ); +}); + +const ImageGrid: FC = ({ + items, + locked, +}) => { + + + return ( + + ) +} + +export { ImageGrid }; \ No newline at end of file diff --git a/src/components/editors/ImageGrid/styles.scss b/src/components/editors/ImageGrid/styles.scss new file mode 100644 index 00000000..f52a5dba --- /dev/null +++ b/src/components/editors/ImageGrid/styles.scss @@ -0,0 +1,25 @@ +.grid { + min-height: 200px; + padding-bottom: 60px; + box-sizing: border-box; + + // display: grid; + // grid-column-gap: $gap; + // grid-row-gap: $gap; + // grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + + // display: flex; + // flex-wrap: wrap; + // @media (max-width: 600px) { + // grid-template-columns: repeat(auto-fill, minmax(30vw, 1fr)); + // } +} + +.item { + // flex: 0 4 25%; + width: 25%; + float: left; + padding: $gap / 2; + z-index: 100; + box-sizing: border-box; +} \ No newline at end of file diff --git a/src/components/upload/ImageUpload/styles.scss b/src/components/upload/ImageUpload/styles.scss index b9888e0b..9dee39ef 100644 --- a/src/components/upload/ImageUpload/styles.scss +++ b/src/components/upload/ImageUpload/styles.scss @@ -30,6 +30,7 @@ border-radius: $radius; background: no-repeat 50% 50%; background-size: cover; + opacity: 0; } .progress { diff --git a/src/redux/node/reducer.ts b/src/redux/node/reducer.ts index 1e844b44..5826f9c4 100644 --- a/src/redux/node/reducer.ts +++ b/src/redux/node/reducer.ts @@ -19,7 +19,19 @@ const INITIAL_STATE: INodeState = { blocks: [ { ...EMPTY_BLOCK, type: 'image' }, ], - files: [{ ...EMPTY_FILE, id: uuid() }, { ...EMPTY_FILE, id: uuid() }] + files: [ + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + { ...EMPTY_FILE, id: uuid() }, + ] }, is_loading: false, error: null,