-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathApp.js
More file actions
181 lines (178 loc) Β· 5.91 KB
/
App.js
File metadata and controls
181 lines (178 loc) Β· 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import React, { Component } from "react";
import {
ReactiveBase,
DataSearch,
MultiList,
RangeSlider,
SingleRange,
SelectedFilters,
ResultCard,
ReactiveList
} from "@appbaseio/reactivesearch";
import "./App.css";
class App extends Component {
render() {
return (
<ReactiveBase
app="good-books-ds"
url="https://xe6N9nDRV:51ea7a8a-6354-4b5f-83e1-12dce3b7ec47@arc-cluster-appbase-demo-ps1pgt.searchbase.io"
enableAppbase
>
<div className="navbar">
<div className="logo">The Booksearch App</div>
<DataSearch
className="datasearch"
componentId="mainSearch"
dataField={[
"original_title",
"original_title.search",
"authors",
"authors.search"
]}
queryFormat="and"
placeholder="Search for a book title or an author"
innerClass={{
input: "searchbox",
list: "suggestionlist"
}}
autosuggest={false}
iconPosition="left"
filterLabel="search"
/>
</div>
<div className={"display"}>
<div className={"leftSidebar"}>
<SingleRange
componentId="ratingsFilter"
dataField="average_rating_rounded"
title="Book Ratings"
data={[
{ start: 4, end: 5, label: "β
β
β
β
& up" },
{ start: 3, end: 5, label: "β
β
β
& up" },
{ start: 2, end: 5, label: "β
β
& up" },
{ start: 1, end: 5, label: "β
& up" }
]}
react={{
and: "mainSearch"
}}
filterLabel="Ratings"
/>
<RangeSlider
componentId="publishFilter"
dataField="original_publication_year"
title="Year of Publication"
filterLabel="published"
range={{
start: 1970,
end: 2017
}}
rangeLabels={{
start: "1970",
end: "2017"
}}
interval={2}
/>
<MultiList
componentId="authorFilter"
dataField="authors.keyword"
title="Authors"
size={1000}
showCheckbox={false}
className="authors"
innerClass={{
list: "author-list"
}}
placeholder="Filter by author name"
filterLabel="Authors"
/>
</div>
<div className={"mainBar"}>
<SelectedFilters showClearAll="default" />
<ReactiveList
componentId="SearchResult"
dataField="original_title"
size={8}
pagination
react={{
and: [
"mainSearch",
"ratingsFilter",
"publishFilter",
"authorFilter"
]
}}
sortOptions={[
{
dataField: "average_rating",
sortBy: "desc",
label: "Ratings (High to low)"
},
{
dataField: "original_title.keyword",
sortBy: "asc",
label: "Title A->Z"
},
{
dataField: "original_title.keyword",
sortBy: "desc",
label: "Title Z->A"
}
]}
render={({ data }) => (
<ReactiveList.ResultCardsWrapper>
{data.map(item => (
<ResultCard key={item.id}>
<ResultCard.Image src={item.image} />
<ResultCard.Title>
<div
className="book-title"
dangerouslySetInnerHTML={{
__html: item.original_title
}}
/>
</ResultCard.Title>
<ResultCard.Description>
<div className="flex column justify-space-between">
<div>
<div>
by{" "}
<span className="authors-list">
{item.authors}
</span>
</div>
<div className="ratings-list flex align-center">
<span className="stars">
{Array(item.average_rating_rounded)
.fill("x")
.map((
item, // eslint-disable-line
index
) => (
<i
className="fas fa-star"
key={index} // eslint-disable-line
/>
))}
</span>
<span className="avg-rating">
({item.average_rating} avg)
</span>
</div>
</div>
<span className="pub-year">
Pub {item.original_publication_year}
</span>
</div>
</ResultCard.Description>
</ResultCard>
))}
</ReactiveList.ResultCardsWrapper>
)}
/>
</div>
</div>
</ReactiveBase>
);
}
}
export default App;