@nyris/nyris-webapp 0.3.5 → 0.3.12

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.
Files changed (206) hide show
  1. package/build/asset-manifest.json +18 -32
  2. package/build/index.html +1 -1
  3. package/build/{precache-manifest.bbb31f2ce7710d7eb3175b1b48241d24.js → precache-manifest.1b00dd5c15aa0815244681503d6fa9da.js} +13 -89
  4. package/build/service-worker.js +1 -1
  5. package/build/static/css/2.43a1c8b7.chunk.css +2 -0
  6. package/build/static/css/2.43a1c8b7.chunk.css.map +1 -0
  7. package/build/static/css/main.0c9239ba.chunk.css +2 -0
  8. package/build/static/css/main.0c9239ba.chunk.css.map +1 -0
  9. package/build/static/js/2.520bb6d6.chunk.js +3 -0
  10. package/build/static/js/2.520bb6d6.chunk.js.LICENSE.txt +79 -0
  11. package/build/static/js/2.520bb6d6.chunk.js.map +1 -0
  12. package/build/static/js/main.ef6a9744.chunk.js +2 -0
  13. package/build/static/js/main.ef6a9744.chunk.js.map +1 -0
  14. package/build/static/js/{runtime-main.b418ff16.js → runtime-main.f5553a9b.js} +1 -1
  15. package/build/static/js/{runtime-main.b418ff16.js.map → runtime-main.f5553a9b.js.map} +1 -1
  16. package/package.json +7 -30
  17. package/src/App.css +64 -20
  18. package/src/App.test.tsx +49 -0
  19. package/src/App.tsx +386 -15
  20. package/src/AppMD.tsx +320 -0
  21. package/src/actions/nyrisAppActions.ts +80 -0
  22. package/src/actions/searchActions.ts +323 -0
  23. package/src/components/CategoryFilter.tsx +16 -13
  24. package/src/components/Codes.tsx +20 -16
  25. package/src/components/ExampleImages.tsx +10 -15
  26. package/src/components/Feedback.tsx +12 -21
  27. package/src/components/FiltersList.tsx +122 -0
  28. package/src/components/Header.tsx +26 -29
  29. package/src/components/PredictedCategories.tsx +15 -12
  30. package/src/components/SelectedFiltersSummary.tsx +85 -0
  31. package/src/components/Sidebar.tsx +52 -0
  32. package/src/defaults.ts +3 -4
  33. package/src/epics/feedback.ts +59 -0
  34. package/src/epics/index.ts +223 -0
  35. package/src/epics/search.ts +239 -0
  36. package/src/epics/types.ts +12 -0
  37. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff +0 -0
  38. package/src/{common/assets/fonts → fonts}/roboto-bold-webfont.woff2 +0 -0
  39. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff +0 -0
  40. package/src/{common/assets/fonts → fonts}/roboto-italic-webfont.woff2 +0 -0
  41. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff +0 -0
  42. package/src/{common/assets/fonts → fonts}/roboto-regular-webfont.woff2 +0 -0
  43. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff +0 -0
  44. package/src/{common/assets/fonts → fonts}/robotocondensed-bold-webfont.woff2 +0 -0
  45. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff +0 -0
  46. package/src/{common/assets/fonts → fonts}/robotocondensed-bolditalic-webfont.woff2 +0 -0
  47. package/src/{common/assets/images → images}/fav/android-icon-192x192.png +0 -0
  48. package/src/{common/assets/images → images}/fav/apple-icon-114x114.png +0 -0
  49. package/src/{common/assets/images → images}/fav/apple-icon-120x120.png +0 -0
  50. package/src/{common/assets/images → images}/fav/apple-icon-144x144.png +0 -0
  51. package/src/{common/assets/images → images}/fav/apple-icon-152x152.png +0 -0
  52. package/src/{common/assets/images → images}/fav/apple-icon-180x180.png +0 -0
  53. package/src/{common/assets/images → images}/fav/apple-icon-57x57.png +0 -0
  54. package/src/{common/assets/images → images}/fav/apple-icon-60x60.png +0 -0
  55. package/src/{common/assets/images → images}/fav/apple-icon-72x72.png +0 -0
  56. package/src/{common/assets/images → images}/fav/apple-icon-76x76.png +0 -0
  57. package/src/{common/assets/images → images}/fav/browserconfig.xml +0 -0
  58. package/src/{common/assets/images → images}/fav/favicon-16x16.png +0 -0
  59. package/src/{common/assets/images → images}/fav/favicon-32x32.png +0 -0
  60. package/src/{common/assets/images → images}/fav/favicon-96x96.png +0 -0
  61. package/src/{common/assets/images → images}/fav/manifest.json +0 -0
  62. package/src/{common/assets/images → images}/ic_cam.png +0 -0
  63. package/src/{common/assets/images → images}/ic_cam.svg +0 -0
  64. package/src/{common/assets/images → images}/ic_cam_large.png +0 -0
  65. package/src/{common/assets/images → images}/ic_cam_large.svg +0 -0
  66. package/src/{common/assets/images → images}/ic_cam_large_noimage.png +0 -0
  67. package/src/{common/assets/images → images}/ic_close_feedback.png +0 -0
  68. package/src/{common/assets/images → images}/ic_close_feedback.svg +0 -0
  69. package/src/{common/assets/images → images}/ic_shopNow.png +0 -0
  70. package/src/{common/assets/images → images}/ic_shopNow.svg +0 -0
  71. package/src/{common/assets/images → images}/ic_shopNowLight.png +0 -0
  72. package/src/{common/assets/images → images}/ic_shopNowLight.svg +0 -0
  73. package/src/{common/assets/images → images}/nyris_logo.png +0 -0
  74. package/src/{common/assets/images → images}/rewe.svg +0 -0
  75. package/src/{common/assets/images → images}/sectionTransBack.png +0 -0
  76. package/src/{common/assets/images → images}/sectionTransBack.svg +0 -0
  77. package/src/{common/assets/images → images}/sectionTransTop.png +0 -0
  78. package/src/{common/assets/images → images}/sectionTransTop.svg +0 -0
  79. package/src/index.css +502 -570
  80. package/src/index.tsx +170 -16
  81. package/src/types.ts +7 -51
  82. package/src/utils.ts +5 -0
  83. package/tsconfig.json +8 -3
  84. package/build/js/settings.example.js +0 -31
  85. package/build/js/test.js +0 -56
  86. package/build/static/css/2.8285176a.chunk.css +0 -2
  87. package/build/static/css/2.8285176a.chunk.css.map +0 -1
  88. package/build/static/css/main.6676fe1f.chunk.css +0 -2
  89. package/build/static/css/main.6676fe1f.chunk.css.map +0 -1
  90. package/build/static/js/2.4a55bc61.chunk.js +0 -3
  91. package/build/static/js/2.4a55bc61.chunk.js.LICENSE.txt +0 -124
  92. package/build/static/js/2.4a55bc61.chunk.js.map +0 -1
  93. package/build/static/js/main.2660f94a.chunk.js +0 -2
  94. package/build/static/js/main.2660f94a.chunk.js.map +0 -1
  95. package/build/static/media/Fill.37094b44.svg +0 -3
  96. package/build/static/media/Montserrat-Bold.5a052e98.otf +0 -0
  97. package/build/static/media/Montserrat-Light.21789e89.otf +0 -0
  98. package/build/static/media/Montserrat-Medium.a53e0373.otf +0 -0
  99. package/build/static/media/Montserrat-Regular.71cdc681.otf +0 -0
  100. package/build/static/media/Montserrat-SemiBold.f613d915.otf +0 -0
  101. package/build/static/media/Rectangle.4dd8b747.png +0 -0
  102. package/build/static/media/admin.9529c7f6.svg +0 -3
  103. package/build/static/media/bg-support-page.6ac55268.svg +0 -9
  104. package/build/static/media/book_mark.8e294c0b.svg +0 -3
  105. package/build/static/media/icon_dislike.94607ca6.svg +0 -3
  106. package/build/static/media/icon_like.a4fb1b18.svg +0 -3
  107. package/build/static/media/icon_modal_image.3068d0ea.svg +0 -21
  108. package/build/static/media/icon_search_image.c2c728c0.svg +0 -3
  109. package/build/static/media/nyris_logo.22d8f250.svg +0 -3
  110. package/build/static/media/reload_icon.4b579a74.svg +0 -3
  111. package/build/static/media/save_search.bebaeebf.svg +0 -3
  112. package/build/static/media/support.289c3a3c.svg +0 -3
  113. package/build/static/media/translate_icon.f0492297.svg +0 -3
  114. package/public/js/settings.example.js +0 -31
  115. package/public/js/test.js +0 -56
  116. package/src/Router.tsx +0 -97
  117. package/src/Store/Auth.ts +0 -44
  118. package/src/Store/Nyris.ts +0 -77
  119. package/src/Store/Search.ts +0 -243
  120. package/src/Store/Store.ts +0 -53
  121. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Bold.otf +0 -0
  122. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Light.otf +0 -0
  123. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Medium.otf +0 -0
  124. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-Regular.otf +0 -0
  125. package/src/common/assets/fonts/Montserrat_OTF/Montserrat-SemiBold.otf +0 -0
  126. package/src/common/assets/icons/Fill.png +0 -0
  127. package/src/common/assets/icons/Fill.svg +0 -3
  128. package/src/common/assets/icons/Icon_wechat.png +0 -0
  129. package/src/common/assets/icons/Icon_whatsapp.png +0 -0
  130. package/src/common/assets/icons/admin.png +0 -0
  131. package/src/common/assets/icons/admin.svg +0 -3
  132. package/src/common/assets/icons/book_mark.png +0 -0
  133. package/src/common/assets/icons/book_mark.svg +0 -3
  134. package/src/common/assets/icons/icon_barcode.png +0 -0
  135. package/src/common/assets/icons/icon_camera.png +0 -0
  136. package/src/common/assets/icons/icon_dislike.svg +0 -3
  137. package/src/common/assets/icons/icon_disslike.png +0 -0
  138. package/src/common/assets/icons/icon_email.png +0 -0
  139. package/src/common/assets/icons/icon_like.png +0 -0
  140. package/src/common/assets/icons/icon_like.svg +0 -3
  141. package/src/common/assets/icons/icon_modal_image.png +0 -0
  142. package/src/common/assets/icons/icon_modal_image.svg +0 -21
  143. package/src/common/assets/icons/icon_picture.png +0 -0
  144. package/src/common/assets/icons/icon_search_image.png +0 -0
  145. package/src/common/assets/icons/icon_search_image.svg +0 -3
  146. package/src/common/assets/icons/nyris_logo.svg +0 -3
  147. package/src/common/assets/icons/reload_icon.png +0 -0
  148. package/src/common/assets/icons/reload_icon.svg +0 -3
  149. package/src/common/assets/icons/save_search.png +0 -0
  150. package/src/common/assets/icons/save_search.svg +0 -3
  151. package/src/common/assets/icons/setting_search_icon.png +0 -0
  152. package/src/common/assets/icons/support.png +0 -0
  153. package/src/common/assets/icons/support.svg +0 -3
  154. package/src/common/assets/icons/translate_icon.png +0 -0
  155. package/src/common/assets/icons/translate_icon.svg +0 -3
  156. package/src/common/assets/icons/view_off.png +0 -0
  157. package/src/common/assets/images/Rectangle.png +0 -0
  158. package/src/common/assets/images/bg-support-page.svg +0 -9
  159. package/src/common/assets/images/image_test.png +0 -0
  160. package/src/components/CustomHits/index.tsx +0 -57
  161. package/src/components/DetailItem.tsx +0 -175
  162. package/src/components/DragDropFile.tsx +0 -192
  163. package/src/components/FilterComponent.tsx +0 -33
  164. package/src/components/Footer.tsx +0 -29
  165. package/src/components/FooterMD.tsx +0 -54
  166. package/src/components/FooterNewVersion.tsx +0 -12
  167. package/src/components/FooterResult.tsx +0 -47
  168. package/src/components/HeaderMd.tsx +0 -38
  169. package/src/components/HeaderNewVersion.tsx +0 -92
  170. package/src/components/Layout.tsx +0 -46
  171. package/src/components/LoadingScreen/index.tsx +0 -29
  172. package/src/components/Navigation.tsx +0 -34
  173. package/src/components/Panigation/Pagination.tsx +0 -140
  174. package/src/components/Panigation/cx.js +0 -3
  175. package/src/components/Panigation/isModifierClick.js +0 -10
  176. package/src/components/Saved/AllItem.tsx +0 -32
  177. package/src/components/Saved/Category.tsx +0 -16
  178. package/src/components/carousel/DefaultCarousel.tsx +0 -48
  179. package/src/components/common.d.ts +0 -9
  180. package/src/components/common.scss +0 -54
  181. package/src/components/default-select.tsx +0 -44
  182. package/src/components/hitItem/hits.tsx +0 -50
  183. package/src/components/hitItem/infinitiHits.tsx +0 -33
  184. package/src/components/input/inputSearch.tsx +0 -77
  185. package/src/components/modal/DefaultModal.tsx +0 -28
  186. package/src/components/results/ItemResult.tsx +0 -155
  187. package/src/components/search/ListSearch.tsx +0 -209
  188. package/src/modules/LandingPage/App.tsx +0 -318
  189. package/src/modules/LandingPage/AppMD.tsx +0 -399
  190. package/src/modules/LandingPage/common.scss +0 -1304
  191. package/src/modules/LandingPage/index.tsx +0 -169
  192. package/src/modules/LandingPage/indexNewVersion.tsx +0 -110
  193. package/src/modules/LandingPage/propsType.ts +0 -43
  194. package/src/page/Auth/login.tsx +0 -7
  195. package/src/page/Exception/404.tsx +0 -11
  196. package/src/page/History/index.tsx +0 -76
  197. package/src/page/Profile/index.tsx +0 -87
  198. package/src/page/Saved/MockData.ts +0 -223
  199. package/src/page/Saved/index.tsx +0 -166
  200. package/src/page/Support/index.tsx +0 -160
  201. package/src/page/result/MockData.ts +0 -36
  202. package/src/page/result/index.tsx +0 -418
  203. package/src/services/Feedback.ts +0 -64
  204. package/src/services/image.ts +0 -40
  205. package/src/services/session.ts +0 -17
  206. package/src/services/types.ts +0 -50
package/src/AppMD.tsx ADDED
@@ -0,0 +1,320 @@
1
+ import {AppProps} from "./App";
2
+ import {useDropzone} from "react-dropzone";
3
+ import {
4
+ makeStyles,
5
+ AppBar,
6
+ Button, Card, CardActions, CardContent,
7
+ CardMedia, CircularProgress,
8
+ Container,
9
+ CssBaseline, Fab,
10
+ Grid, Hidden,
11
+ Link,
12
+ Toolbar,
13
+ Typography
14
+ } from "@material-ui/core";
15
+ import {PhotoCamera, ArrowBack, Image} from "@material-ui/icons";
16
+ import Icon from "@material-ui/core/Icon";
17
+ import * as React from "react";
18
+ import {NodeGroup} from "react-move";
19
+ import classNames from 'classnames';
20
+ import {Capture, Preview} from "@nyris/nyris-react-components";
21
+ import {cadExtensions} from "@nyris/nyris-api";
22
+
23
+
24
+ const useStyles = makeStyles(theme => ({
25
+ icon: {
26
+ marginRight: theme.spacing(2),
27
+ },
28
+ heroContent: {
29
+ backgroundColor: theme.palette.background.paper,
30
+ padding: theme.spacing(8, 0, 6),
31
+ transition: 'all 300ms',
32
+ overflow: 'hidden',
33
+ height: 500
34
+ },
35
+ heroContentClosed: {
36
+ height: 0,
37
+ padding: 0
38
+ },
39
+ heroButtons: {
40
+ marginTop: theme.spacing(4),
41
+ },
42
+ cardGrid: {
43
+ paddingTop: theme.spacing(8),
44
+ paddingBottom: theme.spacing(8),
45
+ minHeight: 600,
46
+ overflow: 'hidden',
47
+ transition: 'all 300ms',
48
+ },
49
+ cardGridCollapsed: {
50
+ height: 0,
51
+ opacity: 0,
52
+ minHeight: 0,
53
+ paddingTop: 0,
54
+ paddingBottom: 0,
55
+ },
56
+ card: {
57
+ height: '100%',
58
+ display: 'flex',
59
+ flexDirection: 'column',
60
+ },
61
+ cardMedia: {
62
+ paddingTop: '56.25%', // 16:9
63
+ backgroundSize: 'contain'
64
+ },
65
+ cardContent: {
66
+ flexGrow: 1,
67
+ paddingBottom: 0
68
+ },
69
+ footer: {
70
+ backgroundColor: theme.palette.background.paper,
71
+ padding: theme.spacing(6),
72
+ },
73
+ withElipsis: {
74
+ textOverflow: 'ellipsis',
75
+ overflow: 'hidden',
76
+ whiteSpace: 'nowrap'
77
+ },
78
+ loading: {
79
+ margin: theme.spacing(2),
80
+ },
81
+ fabContainer: {
82
+ position: 'fixed',
83
+ bottom: theme.spacing(2),
84
+
85
+ },
86
+ fab: {
87
+ marginLeft: theme.spacing(2),
88
+ },
89
+ }));
90
+
91
+ const makeFileHandler = (action: any) => (e: any) => {
92
+ let file = (e.dataTransfer && e.dataTransfer.files[0]) || e.target.files[0];
93
+ if (e.target && e.target.value) {
94
+ e.target.value = "";
95
+ }
96
+
97
+ if (file) {
98
+ action(file);
99
+ }
100
+ };
101
+
102
+ function Copyright() {
103
+ return (
104
+
105
+ <Typography variant="body2" color="textSecondary" align="center">
106
+ {'Powered by '}
107
+ <Link color="inherit" href="https://nyris.io/" component='a' target="_blank">
108
+ nyris.io
109
+ </Link>
110
+ </Typography>
111
+ );
112
+ }
113
+
114
+
115
+ const AppMD: React.FC<AppProps> = ({settings, handlers, showPart, previewImage, loading, search: {results, regions, previewSelection, requestId, duration}, mdSettings}) => {
116
+ const classes = useStyles();
117
+ const {getRootProps, getInputProps, isDragActive} = useDropzone({onDrop: (fs: File[]) => handlers.onFileDropped(fs[0])});
118
+
119
+ const minPreviewHeight = 400;
120
+ const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
121
+ const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
122
+ const acceptTypes =
123
+ [ 'image/*' ].concat(
124
+ settings.cadSearch ? cadExtensions : []
125
+ ).join(',');
126
+
127
+ return (
128
+ <React.Fragment>
129
+ {mdSettings.resultLinkIcon && <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />}
130
+ <CssBaseline/>
131
+ {showPart === 'camera' &&
132
+ <Capture onCaptureComplete={handlers.onCaptureComplete} onCaptureCanceled={handlers.onCaptureCanceled}
133
+ useAppText='Use default camera app'/>}
134
+ <AppBar position={"relative"} style={{backgroundColor: mdSettings.appBarCustomBackgroundColor}}>
135
+
136
+ <Container maxWidth='md' style={{flexDirection: 'row', display: 'flex'}}>
137
+ <img src={mdSettings.appBarLogoUrl} style={{height: '2em', minHeight: '64px', display: 'flex'}} alt="Logo"/>
138
+ <Toolbar component="span">
139
+ <Typography style={{color: mdSettings.appBarCustomTextColor}}>
140
+ { mdSettings.appBarTitle }
141
+ </Typography>
142
+ </Toolbar>
143
+ </Container>
144
+ </AppBar>
145
+
146
+ <main>
147
+ <div
148
+ className={classNames(classes.heroContent, showPart === 'results' ? classes.heroContentClosed : null)}>
149
+ <Container maxWidth='md'>
150
+ <div>
151
+ <Hidden mdUp>
152
+ <div style={{textAlign: 'center'}}>
153
+ <PhotoCamera style={{fontSize: '20em', color: '#cccccc'}}/>
154
+ </div>
155
+ <div style={{textAlign: 'center'}}>
156
+ <Button variant={"contained"} color={"primary"} onClick={handlers.onCameraClick}>Take
157
+ a
158
+ picture</Button>
159
+ </div>
160
+ <div style={{textAlign: 'center'}}>
161
+ <Typography>
162
+ or
163
+ </Typography>
164
+ </div>
165
+ <div style={{textAlign: 'center'}}>
166
+ <input
167
+ accept={acceptTypes}
168
+ id="raised-button-file"
169
+ type="file"
170
+ onChange={makeFileHandler(handlers.onSelectFile)}
171
+ style={{width: '.1px', height: '.1px', overflow: 'hidden', opacity: 0}}
172
+ />
173
+ <label htmlFor="raised-button-file">
174
+ <Button variant={"contained"} color={"primary"} component="span">
175
+ Select a file
176
+ </Button>
177
+ </label>
178
+ </div>
179
+ </Hidden>
180
+ <Hidden smDown>
181
+ <div style={{borderStyle: 'dashed', borderWidth: 5, borderColor: isDragActive ? '#ccc' : '#eee', borderRadius: 10, padding: 10, paddingBottom: 30}}
182
+ {...getRootProps({ onClick: e => { e.stopPropagation() }}) }>
183
+ <div style={{textAlign: 'center'}}>
184
+ <Image style={{fontSize: '20em', color: '#cccccc'}}/>
185
+ </div>
186
+ <div style={{textAlign: 'center'}}>
187
+ <Typography variant='body2'>
188
+ DROP AN IMAGE
189
+ </Typography>
190
+ </div>
191
+ <div style={{textAlign: 'center'}}>
192
+ <Typography variant="subtitle2">
193
+ or
194
+ </Typography>
195
+ </div>
196
+ <div style={{textAlign: 'center'}}>
197
+ <input
198
+ accept={acceptTypes}
199
+ id="raised-button-file"
200
+ type="file"
201
+ {...getInputProps()}
202
+ onChange={makeFileHandler(handlers.onSelectFile)}
203
+ style={{width: '.1px', height: '.1px', overflow: 'hidden', opacity: 0}}
204
+ />
205
+ <label htmlFor="raised-button-file">
206
+ <Button variant={"contained"} color={"primary"} component="span">
207
+ Select an image
208
+ </Button>
209
+ </label>
210
+ </div>
211
+ </div>
212
+ </Hidden>
213
+ </div>
214
+ </Container>
215
+ </div>
216
+ <Container className={classNames(classes.cardGrid, showPart !== 'results' && classes.cardGridCollapsed)}
217
+ maxWidth="md">
218
+
219
+ { previewImage &&
220
+ <Card style={{marginBottom: '4em'}} raised={true}>
221
+ <Preview key={previewImage.id}
222
+ maxWidth={document.body.clientWidth}
223
+ maxHeight={maxPreviewHeight}
224
+ dotColor={mdSettings.primaryColor}
225
+ onSelectionChange={handlers.onSelectionChange} regions={regions}
226
+ selection={previewSelection} image={previewImage.canvas}/>
227
+ </Card>
228
+ }
229
+
230
+ {loading && <div style={{textAlign: 'center'}}>
231
+ <CircularProgress className={classes.loading}/>
232
+ </div>}
233
+
234
+ <Grid container spacing={4}>
235
+ <NodeGroup data={results}
236
+ keyAccessor={r => r.position + r.sku}
237
+ start={(r, i) => ({opacity: 0, translateX: -100})}
238
+ enter={(r, i) => ({
239
+ opacity: [1],
240
+ translateX: [0],
241
+ timing: {delay: i * 100, duration: 300}
242
+ })}>
243
+ {rs =>
244
+ <>
245
+ {rs.map(({key, data: result, state}) =>
246
+ <Grid item key={key} xs={12} sm={4} md={3}>
247
+ <Card className={classes.card} style={{
248
+ opacity: state.opacity,
249
+ position: 'relative',
250
+ transform: `translateX(${state.translateX}%)`
251
+ }}>
252
+ <CardMedia
253
+ className={classes.cardMedia}
254
+ image={(result.img && result.img.url) || settings.noImageUrl}
255
+ title={result.title}
256
+ />
257
+ <CardContent className={classes.cardContent}>
258
+ <Typography gutterBottom variant="subtitle2" component="h5"
259
+ className={classes.withElipsis}>
260
+ {result[mdSettings.resultFirstRowProperty]}
261
+ </Typography>
262
+ <Typography variant="body2" className={classes.withElipsis}>
263
+ {result[mdSettings.resultSecondRowProperty]}
264
+ </Typography>
265
+ </CardContent>
266
+ {result.l &&
267
+ <CardActions>
268
+ <Button variant="outlined" style={{marginLeft: 'auto'}}
269
+ size="small" color="primary"
270
+ onClick={() => handlers.onLinkClick(result.position, result.l)}
271
+ onAuxClick={() => handlers.onLinkClick(result.position, result.l)} >
272
+ { mdSettings.resultLinkIcon && <React.Fragment>
273
+ <Icon>{ mdSettings.resultLinkIcon }</Icon>
274
+ {' '}
275
+ </React.Fragment> }
276
+ {mdSettings.resultLinkText}
277
+ </Button>
278
+ </CardActions>
279
+ }
280
+ </Card>
281
+ </Grid>
282
+ )}
283
+ </>
284
+ }
285
+
286
+ </NodeGroup>
287
+
288
+ </Grid>
289
+
290
+ {results.length === 0 && showPart === 'results' && !loading && (
291
+ <Typography variant="h3" align="center">We did not find anything</Typography>
292
+ )}
293
+
294
+
295
+ </Container>
296
+ {showPart !== 'start' &&
297
+ <Container maxWidth='lg'>
298
+ <div className={classes.fabContainer}>
299
+ <Fab aria-label='back' className={classes.fab} color='primary' onClick={handlers.onShowStart}>
300
+ <ArrowBack/>
301
+ </Fab>
302
+ </div>
303
+ </Container>
304
+ }
305
+
306
+ </main>
307
+
308
+ <footer className={classes.footer}>
309
+
310
+ <Typography variant="subtitle1" align="center" color="textSecondary">
311
+ {requestId && showPart === 'results' && <div style={{textAlign: 'center', fontSize: '0.7em', paddingTop: '0.8em'}}>Request
312
+ identifier {requestId}</div>}
313
+ </Typography>
314
+ <Copyright/>
315
+ </footer>
316
+ </React.Fragment>
317
+ );
318
+ };
319
+
320
+ export default AppMD;
@@ -0,0 +1,80 @@
1
+ import { AppAction } from "../types";
2
+
3
+ export type NyrisAppPart = "start" | "camera" | "results";
4
+ export type NyrisFeedbackState =
5
+ | "hidden"
6
+ | "question"
7
+ | "positive"
8
+ | "negative";
9
+
10
+ export interface NyrisAppState {
11
+ showPart: NyrisAppPart;
12
+ feedbackState: NyrisFeedbackState;
13
+ }
14
+
15
+ export type NyrisAction =
16
+ | { type: "SHOW_START" }
17
+ | { type: "SHOW_CAMERA" }
18
+ | { type: "SHOW_RESULTS" }
19
+ | { type: "SHOW_FEEDBACK" }
20
+ | { type: "HIDE_FEEDBACK" }
21
+ | { type: "RESULT_LINK_CLICKED"; position: number; url: string }
22
+ | { type: "RESULT_IMAGE_CLICKED"; position: number; url: string };
23
+
24
+ export const showCamera = (): NyrisAction => ({ type: "SHOW_CAMERA" });
25
+ export const showStart = (): NyrisAction => ({ type: "SHOW_START" });
26
+ export const showResults = (): NyrisAction => ({ type: "SHOW_RESULTS" });
27
+ export const showFeedback = (): NyrisAction => ({ type: "SHOW_FEEDBACK" });
28
+ export const hideFeedback = (): NyrisAction => ({ type: "HIDE_FEEDBACK" });
29
+
30
+ const initialNyrisState: NyrisAppState = {
31
+ showPart: "start",
32
+ feedbackState: "hidden",
33
+ };
34
+
35
+ export function reducer(
36
+ state: NyrisAppState = initialNyrisState,
37
+ action: AppAction
38
+ ): NyrisAppState {
39
+ switch (action.type) {
40
+ case "SHOW_START":
41
+ return {
42
+ ...state,
43
+ showPart: "start",
44
+ };
45
+ case "SHOW_CAMERA":
46
+ return {
47
+ ...state,
48
+ showPart: "camera",
49
+ };
50
+ case "SEARCH_REQUEST_START":
51
+ case "REGION_REQUEST_START":
52
+ case "SHOW_RESULTS":
53
+ return {
54
+ ...state,
55
+ showPart: "results",
56
+ };
57
+ case "SHOW_FEEDBACK":
58
+ return {
59
+ ...state,
60
+ feedbackState: "question",
61
+ };
62
+ case "HIDE_FEEDBACK":
63
+ return {
64
+ ...state,
65
+ feedbackState: "hidden",
66
+ };
67
+ case "FEEDBACK_SUBMIT_POSITIVE":
68
+ return {
69
+ ...state,
70
+ feedbackState: "positive",
71
+ };
72
+ case "FEEDBACK_SUBMIT_NEGATIVE":
73
+ return {
74
+ ...state,
75
+ feedbackState: "negative",
76
+ };
77
+ default:
78
+ return state;
79
+ }
80
+ }