@nyris/nyris-webapp 0.3.6 → 0.3.13
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/build/asset-manifest.json +11 -11
- package/build/index.html +1 -1
- package/build/{precache-manifest.bffed513ca17d8ac16af1cc3aaa7d908.js → precache-manifest.793f0a4375602ec8cd0fba83bf0e3e67.js} +9 -9
- package/build/service-worker.js +1 -1
- package/build/static/css/main.0c9239ba.chunk.css +2 -0
- package/build/static/css/main.0c9239ba.chunk.css.map +1 -0
- package/build/static/js/2.520bb6d6.chunk.js +3 -0
- package/build/static/js/{2.4e9a4ce1.chunk.js.LICENSE.txt → 2.520bb6d6.chunk.js.LICENSE.txt} +0 -0
- package/build/static/js/2.520bb6d6.chunk.js.map +1 -0
- package/build/static/js/main.8405239a.chunk.js +2 -0
- package/build/static/js/main.8405239a.chunk.js.map +1 -0
- package/package.json +2 -2
- package/src/App.tsx +346 -213
- package/src/actions/nyrisAppActions.ts +69 -65
- package/src/actions/searchActions.ts +301 -196
- package/src/components/CategoryFilter.tsx +16 -13
- package/src/components/Codes.tsx +20 -16
- package/src/components/ExampleImages.tsx +27 -17
- package/src/components/Feedback.tsx +78 -48
- package/src/components/FiltersList.tsx +106 -59
- package/src/components/Header.tsx +29 -17
- package/src/components/PredictedCategories.tsx +15 -12
- package/src/components/Result.tsx +186 -113
- package/src/components/SelectedFiltersSummary.tsx +84 -0
- package/src/components/Sidebar.tsx +41 -32
- package/src/epics/index.ts +173 -104
- package/src/epics/search.ts +209 -177
- package/src/index.css +98 -9
- package/src/index.tsx +148 -144
- package/src/utils.ts +5 -0
- package/build/static/css/main.2a76dc8a.chunk.css +0 -2
- package/build/static/css/main.2a76dc8a.chunk.css.map +0 -1
- package/build/static/js/2.4e9a4ce1.chunk.js +0 -3
- package/build/static/js/2.4e9a4ce1.chunk.js.map +0 -1
- package/build/static/js/main.ec93aa4d.chunk.js +0 -2
- package/build/static/js/main.ec93aa4d.chunk.js.map +0 -1
- package/src/Demo2.tsx +0 -220
|
@@ -1,55 +1,85 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {NyrisFeedbackState} from "../actions/nyrisAppActions";
|
|
3
|
-
import {Animate} from "react-move";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NyrisFeedbackState } from "../actions/nyrisAppActions";
|
|
3
|
+
import { Animate } from "react-move";
|
|
4
4
|
|
|
5
5
|
interface FeedbackProps {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
feedbackState: NyrisFeedbackState;
|
|
7
|
+
onPositiveFeedback?: () => void;
|
|
8
|
+
onNegativeFeedback?: () => void;
|
|
9
|
+
onClose?: () => void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const Feedback: React.FC<FeedbackProps> = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
12
|
+
const Feedback: React.FC<FeedbackProps> = ({
|
|
13
|
+
feedbackState,
|
|
14
|
+
onPositiveFeedback,
|
|
15
|
+
onNegativeFeedback,
|
|
16
|
+
onClose,
|
|
17
|
+
}) => {
|
|
18
|
+
let inner: any = null;
|
|
19
|
+
switch (feedbackState) {
|
|
20
|
+
case "question":
|
|
21
|
+
inner = (
|
|
22
|
+
<div className="feedbackForm">
|
|
23
|
+
<p>Did you find what you were looking for?</p>
|
|
24
|
+
<div
|
|
25
|
+
className="btn primary positiveFeedback"
|
|
26
|
+
onClick={onPositiveFeedback}
|
|
27
|
+
>
|
|
28
|
+
Yes
|
|
29
|
+
</div>
|
|
30
|
+
<div
|
|
31
|
+
className="btn secondary negativeFeedback"
|
|
32
|
+
onClick={onNegativeFeedback}
|
|
33
|
+
>
|
|
34
|
+
No
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
break;
|
|
39
|
+
case "positive":
|
|
40
|
+
inner = (
|
|
41
|
+
<div className="feedbackMessage positive">
|
|
42
|
+
Great, thank you for your feedback!
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
case "negative":
|
|
47
|
+
inner = (
|
|
48
|
+
<div className="feedbackMessage negative">
|
|
49
|
+
We saved your request so we can track down the issue and improve the
|
|
50
|
+
search experience. Your Feedback helps us to make our service better
|
|
51
|
+
for everyone, thank you!
|
|
52
|
+
<br />
|
|
53
|
+
<div className="btn dismiss" onClick={onClose}>
|
|
54
|
+
Dismiss
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
inner = null;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<Animate
|
|
65
|
+
show={feedbackState !== "hidden"}
|
|
66
|
+
start={{ y: 100, opacity: 0 }}
|
|
67
|
+
enter={{ y: [0], opacity: [1] }}
|
|
68
|
+
leave={{ y: [100], opacity: [0] }}
|
|
69
|
+
>
|
|
70
|
+
{({ y, opacity }) => (
|
|
71
|
+
<section
|
|
72
|
+
className="feedback"
|
|
73
|
+
style={{ transform: `translateY(${y}%)`, opacity }}
|
|
74
|
+
>
|
|
75
|
+
<div className="wrapper">{inner}</div>
|
|
76
|
+
<div className="closeFeedbackContainer">
|
|
77
|
+
<div className="closeFeedback" onClick={onClose} />
|
|
78
|
+
</div>
|
|
79
|
+
</section>
|
|
80
|
+
)}
|
|
81
|
+
</Animate>
|
|
82
|
+
);
|
|
53
83
|
};
|
|
54
84
|
|
|
55
85
|
export default Feedback;
|
|
@@ -1,69 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Filter } from "@nyris/nyris-api";
|
|
3
|
+
import {
|
|
4
|
+
addToSelectedFilters,
|
|
5
|
+
removeFromSelectedFilters,
|
|
6
|
+
filterChanged,
|
|
7
|
+
searchFilters,
|
|
8
|
+
} from "../actions/searchActions";
|
|
9
|
+
import { useDispatch } from "react-redux";
|
|
10
|
+
import { RiArrowDropUpLine, RiArrowDropDownLine } from "react-icons/ri";
|
|
11
|
+
import { capitalizeFirstLetter } from "../utils";
|
|
12
|
+
import { AiOutlineSearch } from "react-icons/ai";
|
|
7
13
|
|
|
8
14
|
interface FilterProps {
|
|
9
|
-
|
|
15
|
+
filter: Filter;
|
|
16
|
+
selectedValues?: string[];
|
|
10
17
|
}
|
|
11
18
|
|
|
19
|
+
const FiltersList: React.FC<FilterProps> = ({ filter, selectedValues }) => {
|
|
20
|
+
const dispatch = useDispatch();
|
|
21
|
+
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
22
|
+
const [searchInp, setSearchInp] = useState("");
|
|
23
|
+
const handleToggler = () => {
|
|
24
|
+
if (isCollapsed) {
|
|
25
|
+
setIsCollapsed(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setIsCollapsed(true);
|
|
29
|
+
};
|
|
30
|
+
const onFilterChanged = (
|
|
31
|
+
e: React.ChangeEvent<HTMLInputElement>,
|
|
32
|
+
value: string
|
|
33
|
+
) => {
|
|
34
|
+
if (e.target.checked) {
|
|
35
|
+
if (filter.key) dispatch(addToSelectedFilters(filter.key, value));
|
|
36
|
+
} else {
|
|
37
|
+
if (filter.key) dispatch(removeFromSelectedFilters(filter.key, value));
|
|
38
|
+
}
|
|
39
|
+
dispatch(filterChanged());
|
|
40
|
+
};
|
|
12
41
|
|
|
42
|
+
const handleChangeOnSearchInputTyped = (
|
|
43
|
+
e: React.ChangeEvent<HTMLInputElement>
|
|
44
|
+
) => {
|
|
45
|
+
setSearchInp(e.target.value);
|
|
46
|
+
};
|
|
13
47
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const onFilterChanged=(e: React.ChangeEvent<HTMLInputElement>,value:string) =>{
|
|
19
|
-
var updatedList = [...checked];
|
|
20
|
-
console.log(e.target.checked);
|
|
21
|
-
if (e.target.checked) {
|
|
22
|
-
if(filter.key)
|
|
23
|
-
dispatch(addToSelectedFilters(filter.key , value));
|
|
24
|
-
updatedList = [...checked, value];
|
|
25
|
-
} else {
|
|
26
|
-
if(filter.key)
|
|
27
|
-
dispatch(removeFromSelectedFilters(filter.key, value));
|
|
28
|
-
updatedList.splice(checked.indexOf(value), 1);
|
|
29
|
-
}
|
|
30
|
-
setChecked(updatedList);
|
|
31
|
-
console.log(updatedList);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (searchInp === "") {
|
|
50
|
+
dispatch(searchFilters(filter.key!, ""));
|
|
32
51
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<div>
|
|
38
|
-
<div className='item'>
|
|
39
|
-
<RiLayoutGridLine className="sidebar-icon" />
|
|
40
|
-
<span className="sidebar-text"> {filter.key}</span>
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<div className='item'>
|
|
44
|
-
<div className="list-container">
|
|
45
|
-
|
|
46
|
-
{filter.values.slice(0, 6).map((item, index) => (
|
|
47
|
-
<div key={index}>
|
|
48
|
-
<input value={item} type="checkbox" onChange={(e)=>onFilterChanged(e,item)} />
|
|
49
|
-
|
|
50
|
-
<label className='itemLabel'>{item}</label>
|
|
51
|
-
</div>
|
|
52
|
-
))}
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
);
|
|
52
|
+
if (searchInp.length > 3) {
|
|
53
|
+
dispatch(searchFilters(filter.key!, searchInp));
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
}, [searchInp, filter.key, dispatch]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<div className="item">
|
|
60
|
+
<span className="sidebar-text">
|
|
61
|
+
{capitalizeFirstLetter(filter.key!)}
|
|
62
|
+
</span>
|
|
63
|
+
<RiArrowDropUpLine
|
|
64
|
+
className={
|
|
65
|
+
isCollapsed ? "sidebar-icon" : "sidebar-icon collapsedHide"
|
|
66
|
+
}
|
|
67
|
+
onClick={() => handleToggler()}
|
|
68
|
+
/>
|
|
69
|
+
<RiArrowDropDownLine
|
|
70
|
+
className={
|
|
71
|
+
isCollapsed ? "sidebar-icon collapsedHide" : "sidebar-icon"
|
|
72
|
+
}
|
|
73
|
+
onClick={() => handleToggler()}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div
|
|
78
|
+
className={
|
|
79
|
+
isCollapsed ? "list-container" : "list-container collapsedHide"
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
<div className="searchBar">
|
|
83
|
+
<input
|
|
84
|
+
id="searchQueryInput"
|
|
85
|
+
name="searchQueryInput"
|
|
86
|
+
placeholder="Search"
|
|
87
|
+
value={searchInp}
|
|
88
|
+
onChange={(e) => handleChangeOnSearchInputTyped(e)}
|
|
89
|
+
/>
|
|
90
|
+
<button id="searchQuerySubmit" type="submit" name="searchQuerySubmit">
|
|
91
|
+
<AiOutlineSearch />
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
{filter &&
|
|
95
|
+
filter.values &&
|
|
96
|
+
filter.values.length > 0 &&
|
|
97
|
+
filter.values.map((item, index) => {
|
|
98
|
+
const checked = selectedValues && selectedValues.includes(item);
|
|
99
|
+
return (
|
|
100
|
+
<div key={index}>
|
|
101
|
+
<input
|
|
102
|
+
value={item}
|
|
103
|
+
checked={checked ? true : false}
|
|
104
|
+
type="checkbox"
|
|
105
|
+
onChange={(e) => onFilterChanged(e, item)}
|
|
106
|
+
/>
|
|
107
|
+
<span className="itemLabel">{item}</span>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
65
113
|
);
|
|
66
|
-
|
|
67
|
-
}
|
|
114
|
+
};
|
|
68
115
|
|
|
69
|
-
export default FiltersList;
|
|
116
|
+
export default FiltersList;
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
const Header = () =>{
|
|
4
|
-
return (
|
|
3
|
+
const Header = () => {
|
|
4
|
+
return (
|
|
5
5
|
<div id="header">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
<section id="branding"></section>
|
|
7
|
+
<div id="menu" className="menuWrap" role="navigation">
|
|
8
|
+
<ul>
|
|
9
|
+
<li>
|
|
10
|
+
<a
|
|
11
|
+
href="https://nyris.io/imprint/#privacy"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noopener noreferrer"
|
|
14
|
+
>
|
|
15
|
+
Privacy Policy
|
|
16
|
+
</a>
|
|
17
|
+
</li>
|
|
18
|
+
<li>
|
|
19
|
+
<a
|
|
20
|
+
href="https://nyris.io/"
|
|
21
|
+
target="_blank"
|
|
22
|
+
rel="noopener noreferrer"
|
|
23
|
+
>
|
|
24
|
+
Visit our Website
|
|
25
|
+
</a>
|
|
26
|
+
</li>
|
|
27
|
+
</ul>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
export default Header;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
3
|
-
const PredictedCategories = ({cs}: {cs: {name: string, score: number}[]}) =>
|
|
4
|
-
<>
|
|
5
|
-
{cs.map((c) =>
|
|
6
|
-
<small key={c.name}>
|
|
7
|
-
{c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
|
|
8
|
-
{(c.score * 100).toFixed(0)}%
|
|
9
|
-
</small>)}
|
|
10
|
-
</>
|
|
11
|
-
;
|
|
12
|
-
|
|
1
|
+
import React from "react";
|
|
13
2
|
|
|
3
|
+
const PredictedCategories = ({
|
|
4
|
+
cs,
|
|
5
|
+
}: {
|
|
6
|
+
cs: { name: string; score: number }[];
|
|
7
|
+
}) => (
|
|
8
|
+
<>
|
|
9
|
+
{cs.map((c) => (
|
|
10
|
+
<small key={c.name}>
|
|
11
|
+
{c.name === "" ? "No category" : c.name.split(" > ").slice(-1)[0]}:
|
|
12
|
+
{(c.score * 100).toFixed(0)}%
|
|
13
|
+
</small>
|
|
14
|
+
))}
|
|
15
|
+
</>
|
|
16
|
+
);
|
|
14
17
|
export default PredictedCategories;
|