Browse Source

add image close button and scroll image list

master
azri 3 weeks ago
parent
commit
6d8a9b4dbb
2 changed files with 26 additions and 10 deletions
  1. 25
    9
      src/components/ImageView/ImageView.jsx
  2. 1
    1
      src/services/ProductService.js

+ 25
- 9
src/components/ImageView/ImageView.jsx View File

8
   DialogContent,
8
   DialogContent,
9
 } from "@mui/material";
9
 } from "@mui/material";
10
 import Grid from '@mui/material/Grid2';
10
 import Grid from '@mui/material/Grid2';
11
+import CloseIcon from "@mui/icons-material/Close";
11
 import defaultImage from "../../assets/images/default.png"
12
 import defaultImage from "../../assets/images/default.png"
12
 
13
 
13
 // Utility function to check if an object is empty
14
 // Utility function to check if an object is empty
53
               component="img"
54
               component="img"
54
               alt="Preview"
55
               alt="Preview"
55
               sx={{
56
               sx={{
56
-                width:{
57
-                  xs:"100%",
58
-                  sm:"100%",
59
-                  md:"70%"
57
+                width: {
58
+                  xs: "100%",
59
+                  sm: "100%",
60
+                  md: "70%"
60
                 },
61
                 },
61
                 height: "auto",
62
                 height: "auto",
62
                 display: "block",
63
                 display: "block",
73
               display: "flex",
74
               display: "flex",
74
               flexDirection: "row",
75
               flexDirection: "row",
75
               justifyContent: {
76
               justifyContent: {
76
-                xs:"left",
77
-                sm:"left",
78
-                md:"center"
77
+                xs: "left",
78
+                sm: "left",
79
+                md: "center"
79
               },
80
               },
80
-              flexWrap:"wrap",
81
+              overflowX: "scroll",
82
+              overflowY: "none",
81
               padding: 2,
83
               padding: 2,
82
               gap: 2
84
               gap: 2
83
             }}
85
             }}
109
 
111
 
110
       {/* Zoom Dialog */}
112
       {/* Zoom Dialog */}
111
       <Dialog open={isZoomed} onClose={handleZoomToggle} maxWidth="lg">
113
       <Dialog open={isZoomed} onClose={handleZoomToggle} maxWidth="lg">
112
-        <DialogContent>
114
+        <DialogContent sx={{ position: "relative" }}>
113
           <img
115
           <img
114
             src={previewImage || defaultImage}
116
             src={previewImage || defaultImage}
115
             alt="Zoomed Preview"
117
             alt="Zoomed Preview"
118
               height: "auto",
120
               height: "auto",
119
             }}
121
             }}
120
           />
122
           />
123
+          <Box sx={{ width: 50, height: 50, position: "absolute", top: 10, right: 10 }}>
124
+            <IconButton
125
+              onClick={handleZoomToggle}
126
+              sx={{
127
+                backgroundColor: "white",
128
+                color: "black",
129
+                "&:hover": {
130
+                  backgroundColor: "lightgray",
131
+                },
132
+              }}
133
+            >
134
+              <CloseIcon />
135
+            </IconButton>
136
+          </Box>
121
         </DialogContent>
137
         </DialogContent>
122
       </Dialog>
138
       </Dialog>
123
     </Box>
139
     </Box>

+ 1
- 1
src/services/ProductService.js View File

127
           currencyCode
127
           currencyCode
128
         }
128
         }
129
       }
129
       }
130
-      images(first: 4) {
130
+      images(first: 250) {
131
         nodes {
131
         nodes {
132
           url
132
           url
133
         }
133
         }

Loading…
Cancel
Save