@nyris/nyris-webapp 0.3.23 → 0.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/asset-manifest.json +12 -18
- package/build/index.html +1 -1
- package/build/{precache-manifest.550e76235499efc131a68c80392f6bfc.js → precache-manifest.3eed67031bd288eaf7ff98cd02aef6d7.js} +11 -35
- package/build/service-worker.js +1 -1
- package/build/static/css/main.0d30f026.chunk.css +2 -0
- package/build/static/css/main.0d30f026.chunk.css.map +1 -0
- package/build/static/js/2.ad8c5320.chunk.js +3 -0
- package/build/static/js/{2.f0507df9.chunk.js.LICENSE.txt → 2.ad8c5320.chunk.js.LICENSE.txt} +0 -15
- package/build/static/js/2.ad8c5320.chunk.js.map +1 -0
- package/build/static/js/main.7c54ad4d.chunk.js +3 -0
- package/build/static/js/main.7c54ad4d.chunk.js.map +1 -0
- package/package.json +5 -3
- package/src/App.tsx +24 -15
- package/src/Router.tsx +6 -41
- package/src/Store/Store.ts +14 -23
- package/src/Store/{Auth.ts → auth/Auth.ts} +6 -17
- package/src/Store/auth/types.ts +11 -0
- package/src/Store/constants.ts +21 -0
- package/src/Store/nyris/Nyris.ts +67 -0
- package/src/Store/nyris/types.ts +11 -0
- package/src/Store/{Search.ts → search/Search.ts} +3 -63
- package/src/Store/search/search.initialState.ts +28 -0
- package/src/Store/search/types.ts +34 -0
- package/src/components/DetailItem.tsx +29 -25
- package/src/components/DragDropFile.tsx +8 -3
- package/src/components/Feedback.tsx +11 -14
- package/src/components/FooterMobile.tsx +3 -51
- package/src/components/FooterResult.tsx +1 -1
- package/src/components/Header.tsx +29 -30
- package/src/components/HeaderMobile.tsx +14 -21
- package/src/components/Layout.tsx +11 -27
- package/src/components/PanelResult/index.tsx +1 -1
- package/src/components/{LoadingScreen → ProductList}/index.tsx +3 -3
- package/src/components/appMobile.scss +2 -21
- package/src/components/carousel/ImagePreviewCarousel.tsx +2 -1
- package/src/components/clear-refinements/clear-refinements.tsx +1 -1
- package/src/components/common.scss +2 -0
- package/src/components/drawer/cameraCustom.tsx +7 -14
- package/src/components/input/inputSearch.tsx +9 -8
- package/src/components/pre-filter/{desktop/index.tsx → index.tsx} +5 -5
- package/src/components/results/ItemResult.tsx +40 -34
- package/src/constants.ts +12 -0
- package/src/hooks/useVisualSearch.tsx +2 -2
- package/src/i18n.ts +10 -0
- package/src/index.css +13 -0
- package/src/index.tsx +0 -20
- package/src/{modules/LandingPage/indexNewVersion.tsx → page/landingPage/AppMD.tsx} +2 -4
- package/src/{modules/LandingPage → page/landingPage}/AppMobile.tsx +4 -5
- package/src/{modules/LandingPage → page/landingPage}/common.scss +2 -8
- package/src/page/result/index.tsx +8 -10
- package/src/services/Feedback.ts +48 -71
- package/src/services/{filter.tsx → filter.ts} +1 -1
- package/src/services/types.ts +30 -39
- package/src/translations.ts +22 -0
- package/src/types.ts +13 -66
- package/build/js/test.js +0 -84
- package/build/static/css/main.c956b74c.chunk.css +0 -2
- package/build/static/css/main.c956b74c.chunk.css.map +0 -1
- package/build/static/js/2.f0507df9.chunk.js +0 -3
- package/build/static/js/2.f0507df9.chunk.js.map +0 -1
- package/build/static/js/main.247c7b7e.chunk.js +0 -3
- package/build/static/js/main.247c7b7e.chunk.js.map +0 -1
- package/build/static/media/Rectangle.4dd8b747.png +0 -0
- package/build/static/media/icon_company.2b2a0a61.svg +0 -3
- package/build/static/media/icon_email.132d632b.svg +0 -3
- package/build/static/media/icon_phone.09335da9.svg +0 -3
- package/build/static/media/icon_textArea.f6d78b61.svg +0 -3
- package/build/static/media/icon_users.2013c76e.svg +0 -3
- package/public/js/test.js +0 -84
- package/src/App.css +0 -65
- package/src/Store/Nyris.ts +0 -77
- package/src/components/AppContainer.tsx +0 -126
- package/src/components/CategoryFilter.tsx +0 -17
- package/src/components/Codes.tsx +0 -20
- package/src/components/CustomHits/index.tsx +0 -47
- package/src/components/Footer.tsx +0 -96
- package/src/components/FooterMD.tsx +0 -54
- package/src/components/FooterNewVersion.tsx +0 -12
- package/src/components/HeaderMd.tsx +0 -38
- package/src/components/HeaderNewVersion.tsx +0 -112
- package/src/components/Navigation.tsx +0 -34
- package/src/components/PredictedCategories.tsx +0 -14
- package/src/components/Refine.tsx +0 -28
- package/src/components/RelevantSort.tsx +0 -12
- package/src/components/Result.tsx +0 -210
- package/src/components/Saved/AllItem.tsx +0 -32
- package/src/components/Saved/Category.tsx +0 -16
- package/src/components/auto-complete/basic.tsx +0 -153
- package/src/components/autocomplete/plugins/popular-searches/popular-searches.css +0 -3
- package/src/components/autocomplete/plugins/popular-searches/popular-searches.tsx +0 -75
- package/src/components/button/clear-fillter.tsx +0 -30
- package/src/components/camera/screenshot.tsx +0 -33
- package/src/components/count/count.tsx +0 -20
- package/src/components/hitItem/hits.tsx +0 -50
- package/src/components/hitItem/infinitiHits.tsx +0 -33
- package/src/components/icon/icon.tsx +0 -13
- package/src/components/icon_textArea.svg +0 -3
- package/src/components/refinement-list/index.tsx +0 -42
- package/src/components/results/pagination.tsx +0 -34
- package/src/components/search/ListSearch.tsx +0 -209
- package/src/defaults.ts +0 -37
- package/src/modules/LandingPage/App.tsx +0 -318
- package/src/modules/LandingPage/AppMD.tsx +0 -399
- package/src/modules/LandingPage/index.tsx +0 -186
- package/src/modules/LandingPage/propsType.ts +0 -43
- package/src/page/Auth/login.tsx +0 -7
- package/src/page/Exception/404.tsx +0 -11
- package/src/page/History/index.tsx +0 -76
- package/src/page/Profile/index.tsx +0 -140
- package/src/page/ResultMobile/index.tsx +0 -12
- package/src/page/Saved/MockData.ts +0 -223
- package/src/page/Saved/index.tsx +0 -166
- package/src/page/Support/MockData.ts +0 -45
- package/src/page/Support/index.tsx +0 -492
- package/src/page/result/MockData.ts +0 -50
- /package/build/static/js/{main.247c7b7e.chunk.js.LICENSE.txt → main.7c54ad4d.chunk.js.LICENSE.txt} +0 -0
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import "App.css";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
3
|
-
import Result from "components/Result";
|
|
4
|
-
import ExampleImages from "components/ExampleImages";
|
|
5
|
-
import CategoryFilter from "components/CategoryFilter";
|
|
6
|
-
import PredictedCategories from "components/PredictedCategories";
|
|
7
|
-
import Codes from "components/Codes";
|
|
8
|
-
import { useDropzone } from "react-dropzone";
|
|
9
|
-
import classNames from "classnames";
|
|
10
|
-
import { Animate, NodeGroup } from "react-move";
|
|
11
|
-
import {
|
|
12
|
-
makeFileHandler,
|
|
13
|
-
Capture, Preview,
|
|
14
|
-
} from "@nyris/nyris-react-components";
|
|
15
|
-
import { Snackbar } from "@material-ui/core";
|
|
16
|
-
import MuiAlert, { AlertProps } from "@material-ui/lab/Alert";
|
|
17
|
-
|
|
18
|
-
import {AppProps} from "./propsType";
|
|
19
|
-
|
|
20
|
-
function Alert(props: AlertProps) {
|
|
21
|
-
return <MuiAlert elevation={6} variant="filled" {...props} />;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const LandingPageApp = (props: AppProps) => {
|
|
25
|
-
const {
|
|
26
|
-
handlers,
|
|
27
|
-
showPart,
|
|
28
|
-
acceptTypes,
|
|
29
|
-
settings,
|
|
30
|
-
search,
|
|
31
|
-
loading,
|
|
32
|
-
previewImage
|
|
33
|
-
} = props;
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
results,
|
|
37
|
-
requestId,
|
|
38
|
-
duration,
|
|
39
|
-
categoryPredictions,
|
|
40
|
-
codes,
|
|
41
|
-
filterOptions,
|
|
42
|
-
errorMessage,
|
|
43
|
-
regions,
|
|
44
|
-
previewSelection
|
|
45
|
-
} = search;
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
onExampleImageClick,
|
|
49
|
-
onImageClick,
|
|
50
|
-
onLinkClick,
|
|
51
|
-
onFileDropped,
|
|
52
|
-
onCaptureComplete,
|
|
53
|
-
onCaptureCanceled,
|
|
54
|
-
onSelectFile,
|
|
55
|
-
onCameraClick,
|
|
56
|
-
onShowStart,
|
|
57
|
-
onSelectionChange,
|
|
58
|
-
} = handlers;
|
|
59
|
-
|
|
60
|
-
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
61
|
-
onDrop: (fs: File[]) => {
|
|
62
|
-
onFileDropped(fs[0]);
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const [toastOpen, setToastOpen] = useState(false);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (errorMessage !== "") {
|
|
70
|
-
setToastOpen(true);
|
|
71
|
-
}
|
|
72
|
-
}, [errorMessage]);
|
|
73
|
-
|
|
74
|
-
const minPreviewHeight = 400;
|
|
75
|
-
const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
|
|
76
|
-
const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div>
|
|
80
|
-
{showPart === "camera" && (
|
|
81
|
-
<Capture
|
|
82
|
-
onCaptureComplete={ onCaptureComplete }
|
|
83
|
-
onCaptureCanceled={ onCaptureCanceled }
|
|
84
|
-
useAppText="Use default camera app"
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
<div
|
|
88
|
-
className={classNames("headSection", {
|
|
89
|
-
hidden: showPart === "results",
|
|
90
|
-
})}
|
|
91
|
-
id="headSection"
|
|
92
|
-
>
|
|
93
|
-
<div
|
|
94
|
-
{...getRootProps({
|
|
95
|
-
onClick: (e) => {
|
|
96
|
-
e.stopPropagation();
|
|
97
|
-
},
|
|
98
|
-
})}
|
|
99
|
-
className={classNames("wrapper", "dragAndDropActionArea", {
|
|
100
|
-
fileIsHover: isDragActive,
|
|
101
|
-
})}
|
|
102
|
-
>
|
|
103
|
-
<div className="contentWrap">
|
|
104
|
-
<section className="uploadImage">
|
|
105
|
-
<input
|
|
106
|
-
type="button"
|
|
107
|
-
name="file"
|
|
108
|
-
id="capture"
|
|
109
|
-
className="inputfile"
|
|
110
|
-
accept="image/*"
|
|
111
|
-
capture="environment"
|
|
112
|
-
onClick={() => onCameraClick()}
|
|
113
|
-
/>
|
|
114
|
-
<input
|
|
115
|
-
type="file"
|
|
116
|
-
name="file"
|
|
117
|
-
id="capture_file"
|
|
118
|
-
className="inputfile"
|
|
119
|
-
accept={acceptTypes}
|
|
120
|
-
capture="environment"
|
|
121
|
-
/>
|
|
122
|
-
<input
|
|
123
|
-
{...getInputProps()}
|
|
124
|
-
type="file"
|
|
125
|
-
name="file"
|
|
126
|
-
id="select_file"
|
|
127
|
-
className="inputfile"
|
|
128
|
-
accept={acceptTypes}
|
|
129
|
-
onChange={makeFileHandler(onSelectFile)}
|
|
130
|
-
/>
|
|
131
|
-
<div className="onDesktop">
|
|
132
|
-
Drop an image
|
|
133
|
-
<div className="smallText">or</div>
|
|
134
|
-
</div>
|
|
135
|
-
<div className="onMobile camIcon">
|
|
136
|
-
<img src="./images/ic_cam_large.svg" alt="Camera" />
|
|
137
|
-
</div>
|
|
138
|
-
<label
|
|
139
|
-
htmlFor="capture"
|
|
140
|
-
className="btn primary onMobile"
|
|
141
|
-
style={{ marginBottom: "2em", width: "22em" }}
|
|
142
|
-
>
|
|
143
|
-
<span className="onMobile">Take a picture</span>
|
|
144
|
-
</label>
|
|
145
|
-
<br />
|
|
146
|
-
<label
|
|
147
|
-
htmlFor="select_file"
|
|
148
|
-
className="btn primary"
|
|
149
|
-
style={{ width: "22em" }}
|
|
150
|
-
>
|
|
151
|
-
<span>Select a file</span>
|
|
152
|
-
</label>
|
|
153
|
-
<label
|
|
154
|
-
htmlFor="capture"
|
|
155
|
-
className="mobileUploadHandler onMobile"
|
|
156
|
-
/>
|
|
157
|
-
</section>
|
|
158
|
-
<ExampleImages
|
|
159
|
-
images={settings.exampleImages}
|
|
160
|
-
onExampleImageClicked={onExampleImageClick}
|
|
161
|
-
/>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
<div
|
|
165
|
-
className={classNames("tryDifferent", {
|
|
166
|
-
hidden: showPart !== "results",
|
|
167
|
-
})}
|
|
168
|
-
onClick={() => onShowStart()}
|
|
169
|
-
>
|
|
170
|
-
<div className="icIcon"></div>
|
|
171
|
-
<div className="textDesc"> Try a different image</div>
|
|
172
|
-
<br style={{ clear: "both" }} />
|
|
173
|
-
</div>
|
|
174
|
-
<div className="headerSeparatorTop" />
|
|
175
|
-
<div className="headerSeparatorBack" />
|
|
176
|
-
</div>
|
|
177
|
-
|
|
178
|
-
<section
|
|
179
|
-
className={classNames(
|
|
180
|
-
"results",
|
|
181
|
-
{ resultsActive: showPart === "results" },
|
|
182
|
-
results.length === 1 ? "singleProduct" : "multipleProducts"
|
|
183
|
-
)}
|
|
184
|
-
>
|
|
185
|
-
{errorMessage && (
|
|
186
|
-
<div className="errorMsg">
|
|
187
|
-
{errorMessage}
|
|
188
|
-
<div
|
|
189
|
-
style={{
|
|
190
|
-
textAlign: "center",
|
|
191
|
-
fontSize: "0.7em",
|
|
192
|
-
paddingTop: "0.8em",
|
|
193
|
-
}}
|
|
194
|
-
>
|
|
195
|
-
<span>
|
|
196
|
-
Make sure to include the request ID when reporting a problem:{" "}
|
|
197
|
-
{requestId}
|
|
198
|
-
</span>
|
|
199
|
-
</div>
|
|
200
|
-
</div>
|
|
201
|
-
)}
|
|
202
|
-
<Animate
|
|
203
|
-
show={loading}
|
|
204
|
-
start={{ opacity: 0.0 }}
|
|
205
|
-
enter={{ opacity: [1.0], timing: { duration: 300 } }}
|
|
206
|
-
leave={{ opacity: [0.0], timing: { duration: 300 } }}
|
|
207
|
-
>
|
|
208
|
-
{(s) => (
|
|
209
|
-
<div className="loadingOverlay" style={{ ...s }}>
|
|
210
|
-
<div className="loading" />
|
|
211
|
-
</div>
|
|
212
|
-
)}
|
|
213
|
-
</Animate>
|
|
214
|
-
{settings.preview && previewImage && (
|
|
215
|
-
<div className="preview">
|
|
216
|
-
<Preview
|
|
217
|
-
key={previewImage?.id}
|
|
218
|
-
onSelectionChange={ onSelectionChange }
|
|
219
|
-
image={previewImage?.canvas}
|
|
220
|
-
selection={previewSelection}
|
|
221
|
-
regions={regions}
|
|
222
|
-
maxWidth={document.body.clientWidth}
|
|
223
|
-
maxHeight={maxPreviewHeight}
|
|
224
|
-
dotColor="#4C8F9F"
|
|
225
|
-
/>
|
|
226
|
-
</div>
|
|
227
|
-
)}
|
|
228
|
-
<div className="predicted-categories">
|
|
229
|
-
<PredictedCategories cs={categoryPredictions} />
|
|
230
|
-
</div>
|
|
231
|
-
<div className="predicted-categories">
|
|
232
|
-
<Codes codes={codes} />
|
|
233
|
-
</div>
|
|
234
|
-
<CategoryFilter cats={filterOptions} />
|
|
235
|
-
<div className="wrapper">
|
|
236
|
-
<NodeGroup
|
|
237
|
-
data={results}
|
|
238
|
-
keyAccessor={(r) => r.sku}
|
|
239
|
-
start={(r, i) => ({ opacity: 0, translateX: -100 })}
|
|
240
|
-
enter={(r, i) => ({
|
|
241
|
-
opacity: [1],
|
|
242
|
-
translateX: [0],
|
|
243
|
-
timing: { delay: i * 100, duration: 300 },
|
|
244
|
-
})}
|
|
245
|
-
>
|
|
246
|
-
{(rs) => (
|
|
247
|
-
<>
|
|
248
|
-
{rs.map(({ key, data, state }) => (
|
|
249
|
-
<Result
|
|
250
|
-
key={key}
|
|
251
|
-
noImageUrl={settings.noImageUrl}
|
|
252
|
-
template={settings.resultTemplate}
|
|
253
|
-
onImageClick={onImageClick}
|
|
254
|
-
onLinkClick={onLinkClick}
|
|
255
|
-
result={data}
|
|
256
|
-
style={{
|
|
257
|
-
opacity: state.opacity,
|
|
258
|
-
transform: `translateX(${state.translateX}%)`,
|
|
259
|
-
}}
|
|
260
|
-
/>
|
|
261
|
-
))}
|
|
262
|
-
</>
|
|
263
|
-
)}
|
|
264
|
-
</NodeGroup>
|
|
265
|
-
|
|
266
|
-
{(results.length === 0 &&
|
|
267
|
-
showPart === "results" &&
|
|
268
|
-
!loading && (
|
|
269
|
-
<div className="noResults">
|
|
270
|
-
We did not find anything{" "}
|
|
271
|
-
<span role="img" aria-label="sad face">
|
|
272
|
-
😕
|
|
273
|
-
</span>
|
|
274
|
-
</div>
|
|
275
|
-
))}
|
|
276
|
-
|
|
277
|
-
<br style={{ clear: "both" }} />
|
|
278
|
-
|
|
279
|
-
{duration && showPart === "results" && (
|
|
280
|
-
<div
|
|
281
|
-
style={{
|
|
282
|
-
textAlign: "center",
|
|
283
|
-
fontSize: "0.7em",
|
|
284
|
-
paddingTop: "0.8em",
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
Search took {duration.toFixed(2)} seconds
|
|
288
|
-
</div>
|
|
289
|
-
)}
|
|
290
|
-
|
|
291
|
-
{requestId && showPart === "results" && (
|
|
292
|
-
<div
|
|
293
|
-
style={{
|
|
294
|
-
textAlign: "center",
|
|
295
|
-
fontSize: "0.7em",
|
|
296
|
-
paddingTop: "0.8em",
|
|
297
|
-
}}
|
|
298
|
-
>
|
|
299
|
-
Request identifier {requestId}
|
|
300
|
-
</div>
|
|
301
|
-
)}
|
|
302
|
-
</div>
|
|
303
|
-
</section>
|
|
304
|
-
|
|
305
|
-
<Snackbar
|
|
306
|
-
open={toastOpen}
|
|
307
|
-
autoHideDuration={3000}
|
|
308
|
-
onClose={() => setToastOpen(false)}
|
|
309
|
-
>
|
|
310
|
-
<Alert onClose={() => setToastOpen(false)} severity="error">
|
|
311
|
-
{errorMessage}
|
|
312
|
-
</Alert>
|
|
313
|
-
</Snackbar>
|
|
314
|
-
</div>
|
|
315
|
-
);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
export default LandingPageApp;
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { useDropzone } from "react-dropzone";
|
|
2
|
-
import {
|
|
3
|
-
makeStyles,
|
|
4
|
-
Button,
|
|
5
|
-
Card,
|
|
6
|
-
CardActions,
|
|
7
|
-
CardContent,
|
|
8
|
-
CardMedia,
|
|
9
|
-
CircularProgress,
|
|
10
|
-
Container,
|
|
11
|
-
CssBaseline,
|
|
12
|
-
Fab,
|
|
13
|
-
Grid,
|
|
14
|
-
Hidden,
|
|
15
|
-
Typography,
|
|
16
|
-
} from "@material-ui/core";
|
|
17
|
-
import { PhotoCamera, ArrowBack, Image } from "@material-ui/icons";
|
|
18
|
-
import Icon from "@material-ui/core/Icon";
|
|
19
|
-
import { NodeGroup } from "react-move";
|
|
20
|
-
import classNames from "classnames";
|
|
21
|
-
import {Capture, Preview} from "@nyris/nyris-react-components";
|
|
22
|
-
import _ from "lodash";
|
|
23
|
-
import {AppProps} from "./propsType";
|
|
24
|
-
import React from "react";
|
|
25
|
-
|
|
26
|
-
const useStyles = makeStyles((theme) => ({
|
|
27
|
-
icon: {
|
|
28
|
-
marginRight: theme.spacing(2),
|
|
29
|
-
},
|
|
30
|
-
heroContent: {
|
|
31
|
-
backgroundColor: theme.palette.background.paper,
|
|
32
|
-
padding: theme.spacing(8, 0, 6),
|
|
33
|
-
transition: "all 300ms",
|
|
34
|
-
overflow: "hidden",
|
|
35
|
-
height: 500,
|
|
36
|
-
},
|
|
37
|
-
heroContentClosed: {
|
|
38
|
-
height: 0,
|
|
39
|
-
padding: 0,
|
|
40
|
-
},
|
|
41
|
-
heroButtons: {
|
|
42
|
-
marginTop: theme.spacing(4),
|
|
43
|
-
},
|
|
44
|
-
cardGrid: {
|
|
45
|
-
paddingTop: theme.spacing(8),
|
|
46
|
-
paddingBottom: theme.spacing(8),
|
|
47
|
-
minHeight: 600,
|
|
48
|
-
overflow: "hidden",
|
|
49
|
-
transition: "all 300ms",
|
|
50
|
-
},
|
|
51
|
-
cardGridCollapsed: {
|
|
52
|
-
height: 0,
|
|
53
|
-
opacity: 0,
|
|
54
|
-
minHeight: 0,
|
|
55
|
-
paddingTop: 0,
|
|
56
|
-
paddingBottom: 0,
|
|
57
|
-
},
|
|
58
|
-
card: {
|
|
59
|
-
height: "100%",
|
|
60
|
-
display: "flex",
|
|
61
|
-
flexDirection: "column",
|
|
62
|
-
},
|
|
63
|
-
cardMedia: {
|
|
64
|
-
paddingTop: "56.25%", // 16:9
|
|
65
|
-
backgroundSize: "contain",
|
|
66
|
-
},
|
|
67
|
-
cardContent: {
|
|
68
|
-
flexGrow: 1,
|
|
69
|
-
paddingBottom: 0,
|
|
70
|
-
},
|
|
71
|
-
footer: {
|
|
72
|
-
backgroundColor: theme.palette.background.paper,
|
|
73
|
-
padding: theme.spacing(6),
|
|
74
|
-
},
|
|
75
|
-
withElipsis: {
|
|
76
|
-
textOverflow: "ellipsis",
|
|
77
|
-
overflow: "hidden",
|
|
78
|
-
whiteSpace: "nowrap",
|
|
79
|
-
},
|
|
80
|
-
loading: {
|
|
81
|
-
margin: theme.spacing(2),
|
|
82
|
-
},
|
|
83
|
-
fabContainer: {
|
|
84
|
-
position: "fixed",
|
|
85
|
-
bottom: theme.spacing(2),
|
|
86
|
-
},
|
|
87
|
-
fab: {
|
|
88
|
-
marginLeft: theme.spacing(2),
|
|
89
|
-
},
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
const makeFileHandler = (action: any) => (e: any) => {
|
|
93
|
-
let file = (e.dataTransfer && e.dataTransfer.files[0]) || e.target.files[0];
|
|
94
|
-
if (e.target && e.target.value) {
|
|
95
|
-
e.target.value = "";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (file) {
|
|
99
|
-
action(file);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const LandingPageAppMD = (props: AppProps) => {
|
|
104
|
-
const classes = useStyles();
|
|
105
|
-
const {
|
|
106
|
-
handlers,
|
|
107
|
-
showPart,
|
|
108
|
-
acceptTypes,
|
|
109
|
-
settings,
|
|
110
|
-
search,
|
|
111
|
-
loading,
|
|
112
|
-
previewImage
|
|
113
|
-
} = props;
|
|
114
|
-
|
|
115
|
-
const mdSettings = settings.themePage.materialDesign;
|
|
116
|
-
|
|
117
|
-
const {
|
|
118
|
-
results,
|
|
119
|
-
regions,
|
|
120
|
-
previewSelection,
|
|
121
|
-
} = search;
|
|
122
|
-
|
|
123
|
-
const {
|
|
124
|
-
onLinkClick,
|
|
125
|
-
onFileDropped,
|
|
126
|
-
onCaptureComplete,
|
|
127
|
-
onCaptureCanceled,
|
|
128
|
-
onSelectFile,
|
|
129
|
-
onCameraClick,
|
|
130
|
-
onShowStart,
|
|
131
|
-
onSelectionChange,
|
|
132
|
-
} = handlers;
|
|
133
|
-
|
|
134
|
-
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
135
|
-
onDrop: (fs: File[]) => {
|
|
136
|
-
onFileDropped(fs[0]);
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<React.Fragment>
|
|
143
|
-
{!_.isEmpty(mdSettings?.resultLinkIcon) && (
|
|
144
|
-
<link
|
|
145
|
-
rel="stylesheet"
|
|
146
|
-
href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
|
147
|
-
/>
|
|
148
|
-
)}
|
|
149
|
-
<CssBaseline />
|
|
150
|
-
{showPart === "camera" && (
|
|
151
|
-
<Capture
|
|
152
|
-
onCaptureComplete={onCaptureComplete}
|
|
153
|
-
onCaptureCanceled={onCaptureCanceled}
|
|
154
|
-
useAppText="Use default camera app"
|
|
155
|
-
/>
|
|
156
|
-
)}
|
|
157
|
-
<main>
|
|
158
|
-
<div
|
|
159
|
-
className={classNames(
|
|
160
|
-
classes.heroContent,
|
|
161
|
-
showPart === "results" ? classes.heroContentClosed : null
|
|
162
|
-
)}
|
|
163
|
-
>
|
|
164
|
-
<Container maxWidth="md">
|
|
165
|
-
<div>
|
|
166
|
-
<Hidden mdUp>
|
|
167
|
-
<div style={{ textAlign: "center" }}>
|
|
168
|
-
<PhotoCamera style={{ fontSize: "20em", color: "#cccccc" }} />
|
|
169
|
-
</div>
|
|
170
|
-
<div style={{ textAlign: "center" }}>
|
|
171
|
-
<Button
|
|
172
|
-
variant={"contained"}
|
|
173
|
-
color={"primary"}
|
|
174
|
-
onClick={onCameraClick}
|
|
175
|
-
>
|
|
176
|
-
Take a picture
|
|
177
|
-
</Button>
|
|
178
|
-
</div>
|
|
179
|
-
<div style={{ textAlign: "center" }}>
|
|
180
|
-
<Typography>or</Typography>
|
|
181
|
-
</div>
|
|
182
|
-
<div style={{ textAlign: "center" }}>
|
|
183
|
-
<input
|
|
184
|
-
accept={acceptTypes}
|
|
185
|
-
id="raised-button-file"
|
|
186
|
-
type="file"
|
|
187
|
-
onChange={makeFileHandler(onSelectFile)}
|
|
188
|
-
style={{
|
|
189
|
-
width: ".1px",
|
|
190
|
-
height: ".1px",
|
|
191
|
-
overflow: "hidden",
|
|
192
|
-
opacity: 0,
|
|
193
|
-
}}
|
|
194
|
-
/>
|
|
195
|
-
<label htmlFor="raised-button-file">
|
|
196
|
-
<Button
|
|
197
|
-
variant={"contained"}
|
|
198
|
-
color={"primary"}
|
|
199
|
-
component="span"
|
|
200
|
-
>
|
|
201
|
-
Select a file
|
|
202
|
-
</Button>
|
|
203
|
-
</label>
|
|
204
|
-
</div>
|
|
205
|
-
</Hidden>
|
|
206
|
-
<Hidden smDown>
|
|
207
|
-
<div
|
|
208
|
-
style={{
|
|
209
|
-
borderStyle: "dashed",
|
|
210
|
-
borderWidth: 5,
|
|
211
|
-
borderColor: isDragActive ? "#ccc" : "#eee",
|
|
212
|
-
borderRadius: 10,
|
|
213
|
-
padding: 10,
|
|
214
|
-
paddingBottom: 30,
|
|
215
|
-
}}
|
|
216
|
-
{...getRootProps({
|
|
217
|
-
onClick: (e) => {
|
|
218
|
-
e.stopPropagation();
|
|
219
|
-
},
|
|
220
|
-
})}
|
|
221
|
-
>
|
|
222
|
-
<div style={{ textAlign: "center" }}>
|
|
223
|
-
<Image style={{ fontSize: "20em", color: "#cccccc" }} />
|
|
224
|
-
</div>
|
|
225
|
-
<div style={{ textAlign: "center" }}>
|
|
226
|
-
<Typography variant="body2">DROP AN IMAGE</Typography>
|
|
227
|
-
</div>
|
|
228
|
-
<div style={{ textAlign: "center" }}>
|
|
229
|
-
<Typography variant="subtitle2">or</Typography>
|
|
230
|
-
</div>
|
|
231
|
-
<div style={{ textAlign: "center" }}>
|
|
232
|
-
<input
|
|
233
|
-
accept={acceptTypes}
|
|
234
|
-
id="raised-button-file"
|
|
235
|
-
type="file"
|
|
236
|
-
{...getInputProps()}
|
|
237
|
-
onChange={makeFileHandler(onSelectFile)}
|
|
238
|
-
style={{
|
|
239
|
-
width: ".1px",
|
|
240
|
-
height: ".1px",
|
|
241
|
-
overflow: "hidden",
|
|
242
|
-
opacity: 0,
|
|
243
|
-
}}
|
|
244
|
-
/>
|
|
245
|
-
<label htmlFor="raised-button-file">
|
|
246
|
-
<Button
|
|
247
|
-
variant={"contained"}
|
|
248
|
-
color={"primary"}
|
|
249
|
-
component="span"
|
|
250
|
-
>
|
|
251
|
-
Select an image
|
|
252
|
-
</Button>
|
|
253
|
-
</label>
|
|
254
|
-
</div>
|
|
255
|
-
</div>
|
|
256
|
-
</Hidden>
|
|
257
|
-
</div>
|
|
258
|
-
</Container>
|
|
259
|
-
</div>
|
|
260
|
-
<Container
|
|
261
|
-
className={classNames(
|
|
262
|
-
classes.cardGrid,
|
|
263
|
-
showPart !== "results" && classes.cardGridCollapsed
|
|
264
|
-
)}
|
|
265
|
-
maxWidth="md"
|
|
266
|
-
>
|
|
267
|
-
{previewImage && (
|
|
268
|
-
<Card style={{ marginBottom: "4em" }} raised={true}>
|
|
269
|
-
<Preview
|
|
270
|
-
key={previewImage?.id}
|
|
271
|
-
onSelectionChange={onSelectionChange}
|
|
272
|
-
image={previewImage?.canvas}
|
|
273
|
-
selection={previewSelection}
|
|
274
|
-
regions={regions}
|
|
275
|
-
maxWidth={400}
|
|
276
|
-
maxHeight={500}
|
|
277
|
-
dotColor="#FBD914"
|
|
278
|
-
/>
|
|
279
|
-
</Card>
|
|
280
|
-
)}
|
|
281
|
-
|
|
282
|
-
{loading && (
|
|
283
|
-
<div style={{ textAlign: "center" }}>
|
|
284
|
-
<CircularProgress className={classes.loading} />
|
|
285
|
-
</div>
|
|
286
|
-
)}
|
|
287
|
-
|
|
288
|
-
<Grid container spacing={4}>
|
|
289
|
-
<NodeGroup
|
|
290
|
-
data={results}
|
|
291
|
-
keyAccessor={(r) => r.position + r.sku}
|
|
292
|
-
start={(r, i) => ({ opacity: 0, translateX: -100 })}
|
|
293
|
-
enter={(r, i) => ({
|
|
294
|
-
opacity: [1],
|
|
295
|
-
translateX: [0],
|
|
296
|
-
timing: { delay: i * 100, duration: 300 },
|
|
297
|
-
})}
|
|
298
|
-
>
|
|
299
|
-
{(rs) => (
|
|
300
|
-
<>
|
|
301
|
-
{rs.map(({ key, data: result, state }) => (
|
|
302
|
-
<Grid item key={key} xs={12} sm={4} md={3}>
|
|
303
|
-
<Card
|
|
304
|
-
className={classes.card}
|
|
305
|
-
style={{
|
|
306
|
-
opacity: state.opacity,
|
|
307
|
-
position: "relative",
|
|
308
|
-
transform: `translateX(${state.translateX}%)`,
|
|
309
|
-
}}
|
|
310
|
-
>
|
|
311
|
-
<CardMedia
|
|
312
|
-
className={classes.cardMedia}
|
|
313
|
-
image={
|
|
314
|
-
(result.img && result.img.url) ||
|
|
315
|
-
settings.noImageUrl
|
|
316
|
-
}
|
|
317
|
-
title={result.title}
|
|
318
|
-
/>
|
|
319
|
-
<CardContent className={classes.cardContent}>
|
|
320
|
-
<Typography
|
|
321
|
-
gutterBottom
|
|
322
|
-
variant="subtitle2"
|
|
323
|
-
component="h5"
|
|
324
|
-
className={classes.withElipsis}
|
|
325
|
-
>
|
|
326
|
-
{result[mdSettings?.resultFirstRowProperty!!]}
|
|
327
|
-
</Typography>
|
|
328
|
-
<Typography
|
|
329
|
-
variant="body2"
|
|
330
|
-
className={classes.withElipsis}
|
|
331
|
-
>
|
|
332
|
-
{result[mdSettings?.resultSecondRowProperty!!]}
|
|
333
|
-
</Typography>
|
|
334
|
-
</CardContent>
|
|
335
|
-
{result.l && (
|
|
336
|
-
<CardActions>
|
|
337
|
-
<Button
|
|
338
|
-
variant="outlined"
|
|
339
|
-
style={{ marginLeft: "auto" }}
|
|
340
|
-
size="small"
|
|
341
|
-
color="primary"
|
|
342
|
-
onClick={
|
|
343
|
-
() => {
|
|
344
|
-
onLinkClick(
|
|
345
|
-
result.position,
|
|
346
|
-
result.l
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
onAuxClick={() => {
|
|
351
|
-
onLinkClick(
|
|
352
|
-
result.position,
|
|
353
|
-
result.l
|
|
354
|
-
);
|
|
355
|
-
}}
|
|
356
|
-
>
|
|
357
|
-
{mdSettings?.resultLinkIcon && (
|
|
358
|
-
<React.Fragment>
|
|
359
|
-
<Icon>{mdSettings.resultLinkIcon}</Icon>{" "}
|
|
360
|
-
</React.Fragment>
|
|
361
|
-
)}
|
|
362
|
-
{mdSettings?.resultLinkText}
|
|
363
|
-
</Button>
|
|
364
|
-
</CardActions>
|
|
365
|
-
)}
|
|
366
|
-
</Card>
|
|
367
|
-
</Grid>
|
|
368
|
-
))}
|
|
369
|
-
</>
|
|
370
|
-
)}
|
|
371
|
-
</NodeGroup>
|
|
372
|
-
</Grid>
|
|
373
|
-
|
|
374
|
-
{results.length === 0 && showPart === "results" && !loading && (
|
|
375
|
-
<Typography variant="h3" align="center">
|
|
376
|
-
We did not find anything
|
|
377
|
-
</Typography>
|
|
378
|
-
)}
|
|
379
|
-
</Container>
|
|
380
|
-
{showPart !== "start" && (
|
|
381
|
-
<Container maxWidth="lg">
|
|
382
|
-
<div className={classes.fabContainer}>
|
|
383
|
-
<Fab
|
|
384
|
-
aria-label="back"
|
|
385
|
-
className={classes.fab}
|
|
386
|
-
color="primary"
|
|
387
|
-
onClick={onShowStart}
|
|
388
|
-
>
|
|
389
|
-
<ArrowBack />
|
|
390
|
-
</Fab>
|
|
391
|
-
</div>
|
|
392
|
-
</Container>
|
|
393
|
-
)}
|
|
394
|
-
</main>
|
|
395
|
-
</React.Fragment>
|
|
396
|
-
);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
export default LandingPageAppMD;
|