Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit fe0ef63

Browse files
committed
feature: next/pre preview image
1 parent 578fa57 commit fe0ef63

4 files changed

Lines changed: 40 additions & 13 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"react-infinite-scroll-component": "^6.1.0",
7979
"react-konva": "17.0.2-6",
8080
"react-markdown": "^8.0.3",
81+
"react-multi-carousel": "^2.8.2",
8182
"react-redux": "^7.2.4",
8283
"react-router-dom": "^5.2.0",
8384
"react-scripts": "4.0.3",

src/routes/AnnotationPage/AnnotationEditor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ const AnnotationEditor = function () {
7878
display="flex"
7979
gap={2}
8080
height={MAX_HEIGHT_EDITOR}
81-
sx={{ padding: 1, backgroundColor: "#2a3648" }}
81+
sx={{ backgroundColor: "#2a3648" }}
82+
justifyContent="center"
83+
alignContent="center"
8284
>
8385
<ImagePreview />
8486
</Box>

src/routes/AnnotationPage/ImagePreview/index.tsx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { Box, List, ListItem, Skeleton, Typography } from "@mui/material";
1+
import { Box, Skeleton, Typography } from "@mui/material";
22
import { BeforeUnload } from "components";
33
import { useEffect, useMemo, useState } from "react";
4+
import Carousel from "react-multi-carousel";
5+
import "react-multi-carousel/lib/styles.css";
46
import { useDispatch, useSelector } from "react-redux";
57
import { resetCurrentStateDrawObject } from "reduxes/annotation/action";
68
import { selectorAnnotationStatehHistory } from "reduxes/annotation/selector";
@@ -126,6 +128,15 @@ function ImagePreview() {
126128
const handleCloseDialog = () => {
127129
setIsOpenDiaglog(false);
128130
};
131+
132+
const responsive = {
133+
desktop: {
134+
breakpoint: { max: 3000, min: 1024 },
135+
items: 3,
136+
paritialVisibilityGutter: 60,
137+
slidesToSlide: 2,
138+
},
139+
};
129140
const renderContent = () => {
130141
if (!currentAnnotationFiles) {
131142
return <Skeleton variant="circular" width={40} height={40} />;
@@ -136,17 +147,23 @@ function ImagePreview() {
136147
isActive={!!needConfirmChangePreviewImageDialog}
137148
message={QUIT_ANNOTATION_EDITOR_PROMPT_MESSAGE}
138149
/>
139-
<List
150+
<Box
140151
sx={{
141-
overflow: "auto",
142-
display: "flex",
143-
flexDirection: "row",
144-
padding: 0,
152+
width: "95vw",
153+
lineHeight: "10vh",
145154
}}
146155
>
147-
{currentAnnotationFiles.items.map((item) => (
148-
<ListItem key={item.filename}>
149-
<ImagePreviewBadge filename={item.filename}>
156+
<Carousel
157+
partialVisbile
158+
itemClass="image-item"
159+
responsive={responsive}
160+
deviceType="desktop"
161+
swipeable={false}
162+
draggable
163+
// showDots
164+
>
165+
{currentAnnotationFiles.items.map((item) => (
166+
<ImagePreviewBadge key={item.filename} filename={item.filename}>
150167
<Box
151168
sx={{
152169
// background: `url(${fileThumbByImageName[imageName]})no-repeat center`,
@@ -182,9 +199,9 @@ function ImagePreview() {
182199
</Box>
183200
</Box>
184201
</ImagePreviewBadge>
185-
</ListItem>
186-
))}
187-
</List>
202+
))}
203+
</Carousel>
204+
</Box>
188205
{currentPreviewImageName && nextPreviewImageName && (
189206
<ChangePreviewConfirmDialog
190207
isOpen={isOpenDiaglog}

src/styles/custom.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,10 @@ input:-webkit-autofill:active {
112112
border: 2px solid !important;
113113
border-radius: 4px !important;
114114
}
115+
#__next {
116+
padding: 20px;
117+
}
118+
.image-item {
119+
padding: 20px 0 20px 20px;
120+
width: 300px !important;
121+
}

0 commit comments

Comments
 (0)