Quellcode durchsuchen

Fix gallary gird.

Pushkar Anand vor 4 Jahren
Ursprung
Commit
ce4a521636
3 geänderte Dateien mit 39 neuen und 37 gelöschten Zeilen
  1. 3 3
      src/pages/gallery/components/PreviewCard.tsx
  2. 31 34
      src/pages/gallery/index.tsx
  3. 5 0
      yarn.lock

+ 3 - 3
src/pages/gallery/components/PreviewCard.tsx

@@ -13,10 +13,10 @@ interface IProps {
 
 
 const Cont = styled.div<{ disabled: boolean }>`
 const Cont = styled.div<{ disabled: boolean }>`
     background: #555 url(/image.svg) no-repeat center;
     background: #555 url(/image.svg) no-repeat center;
-    margin: 0 4px;
-    display: inline-block;
-    width: 192px;
+    display: block;
+    width: fit-content;
     height: 192px;
     height: 192px;
+    min-width: 100%;
     overflow: hidden;
     overflow: hidden;
     position: relative;
     position: relative;
     cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
     cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};

+ 31 - 34
src/pages/gallery/index.tsx

@@ -75,8 +75,11 @@ const DeadCenter = styled.div`
     flex-direction: column;
     flex-direction: column;
 `;
 `;
 
 
-const ListContainer = styled.div`
-    display: flex;
+const ListContainer = styled.div<{columns: number}>`
+    display: grid;
+    grid-template-columns: repeat(${props => props.columns}, 1fr);
+    grid-column-gap: 8px;
+    padding: 0 8px;
     max-width: 100%;
     max-width: 100%;
     color: #fff;
     color: #fff;
 
 
@@ -94,13 +97,12 @@ const ListContainer = styled.div`
 `;
 `;
 
 
 const DateContainer = styled.div`
 const DateContainer = styled.div`
-    padding: 0 4px;
+    padding-top: 15px;
 `;
 `;
 
 
 export default function Gallery(props) {
 export default function Gallery(props) {
     const router = useRouter();
     const router = useRouter();
     const [loading, setLoading] = useState(false);
     const [loading, setLoading] = useState(false);
-    const [reload, setReload] = useState(0);
     const [collections, setCollections] = useState<collection[]>([]);
     const [collections, setCollections] = useState<collection[]>([]);
     const [collectionLatestFile, setCollectionLatestFile] = useState<
     const [collectionLatestFile, setCollectionLatestFile] = useState<
         collectionLatestFile[]
         collectionLatestFile[]
@@ -113,6 +115,7 @@ export default function Gallery(props) {
         maxSpreadZoom: 5,
         maxSpreadZoom: 5,
     });
     });
     const fetching: { [k: number]: boolean } = {};
     const fetching: { [k: number]: boolean } = {};
+    const [sinceTime, setSinceTime] = useState(0);
 
 
     const [progress, setProgress] = useState(0)
     const [progress, setProgress] = useState(0)
 
 
@@ -150,16 +153,9 @@ export default function Gallery(props) {
         }
         }
         setCollectionLatestFile(collectionLatestFile);
         setCollectionLatestFile(collectionLatestFile);
         setFavItemIds(favItemIds);
         setFavItemIds(favItemIds);
-
+        setSinceTime((new Date()).getTime());
         props.setUploadButtonView(true);
         props.setUploadButtonView(true);
     }
     }
-    if (!data || loading) {
-        return (
-            <div className='text-center'>
-                <Spinner animation='border' variant='primary' />
-            </div>
-        );
-    }
 
 
     const updateUrl = (index: number) => (url: string) => {
     const updateUrl = (index: number) => (url: string) => {
         data[index] = {
         data[index] = {
@@ -272,6 +268,14 @@ export default function Gallery(props) {
         }
         }
     };
     };
 
 
+    if (!data || loading) {
+        return (
+            <div className='text-center'>
+                <Spinner animation='border' variant='primary' />
+            </div>
+        );
+    }
+
     const selectCollection = (id?: string) => {
     const selectCollection = (id?: string) => {
         const href = `/gallery?collection=${id || ''}`;
         const href = `/gallery?collection=${id || ''}`;
         router.push(href, undefined, { shallow: true });
         router.push(href, undefined, { shallow: true });
@@ -308,7 +312,7 @@ export default function Gallery(props) {
     return (
     return (
         <>
         <>
             <LoadingBar
             <LoadingBar
-                color='#f11946'
+                color='##007bff'
                 progress={progress}
                 progress={progress}
                 onLoaderFinished={() => setProgress(0)}
                 onLoaderFinished={() => setProgress(0)}
             />
             />
@@ -386,34 +390,27 @@ export default function Gallery(props) {
                                 <List
                                 <List
                                     itemSize={(index) =>
                                     itemSize={(index) =>
                                         timeStampList[index].itemType === ITEM_TYPE.TIME
                                         timeStampList[index].itemType === ITEM_TYPE.TIME
-                                            ? 30
+                                            ? 45
                                             : 200
                                             : 200
                                     }
                                     }
                                     height={height}
                                     height={height}
                                     width={width}
                                     width={width}
                                     itemCount={timeStampList.length}
                                     itemCount={timeStampList.length}
-                                    key={`${router.query.collection}-${columns}`}
+                                    key={`${router.query.collection}-${columns}-${sinceTime}`}
                                 >
                                 >
                                     {({ index, style }) => {
                                     {({ index, style }) => {
-                                        return (
-                                            <ListItem style={style}>
-                                                <ListContainer>
-                                                    {timeStampList[index].itemType ===
-                                                        ITEM_TYPE.TIME ? (
-                                                            <DateContainer>
-                                                                {timeStampList[index].date}
-                                                            </DateContainer>
-                                                        ) : (
-                                                            timeStampList[index].items.map((item, idx) => {
-                                                                return getThumbnail(
-                                                                    filteredData,
-                                                                    timeStampList[index].itemStartIndex + idx
-                                                                );
-                                                            })
-                                                        )}
-                                                </ListContainer>
-                                            </ListItem>
-                                        );
+                                        return (<ListItem style={style}>
+                                            <ListContainer columns={timeStampList[index].itemType === ITEM_TYPE.TIME
+                                                ? 1 : columns}>
+                                                {
+                                                    timeStampList[index].itemType === ITEM_TYPE.TIME
+                                                        ? <DateContainer>{timeStampList[index].date}</DateContainer>
+                                                        : timeStampList[index].items.map((item, idx) =>{
+                                                            return getThumbnail(filteredData, timeStampList[index].itemStartIndex + idx);
+                                                        })
+                                                }
+                                            </ListContainer>
+                                        </ListItem>);
                                     }}
                                     }}
                                 </List>
                                 </List>
                             );
                             );

+ 5 - 0
yarn.lock

@@ -4993,6 +4993,11 @@ react-refresh@0.8.3:
   resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
   resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f"
   integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==
   integrity sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==
 
 
+react-top-loading-bar@^2.0.1:
+  version "2.0.1"
+  resolved "https://registry.yarnpkg.com/react-top-loading-bar/-/react-top-loading-bar-2.0.1.tgz#c8805ad9c1068766fdd3cadd414e67cfdf1878e9"
+  integrity sha512-wkRlK9Rte4TU817GDcjlsCoDOxrrnvsNvK609FKyio0EIrmmqjQDz5DB8HbN88CHNZBy5Lh/OBALc03ioWFPuQ==
+
 react-transition-group@^4.4.1:
 react-transition-group@^4.4.1:
   version "4.4.1"
   version "4.4.1"
   resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9"
   resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-4.4.1.tgz#63868f9325a38ea5ee9535d828327f85773345c9"