Skip to content

Commit eeda113

Browse files
simplify flex layout and use inline styles
1 parent fb8a624 commit eeda113

File tree

4 files changed

+61
-147
lines changed

4 files changed

+61
-147
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"dependencies": {
99
"@appbaseio/reactivesearch": "^2.0.0-alpha-05",
1010
"react": "^16.2.0",
11-
"react-dom": "^16.2.0",
12-
"reflexbox": "^3.0.0-0"
11+
"react-dom": "^16.2.0"
1312
},
1413
"scripts": {
1514
"start": "react-scripts start",

src/App.css

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/App.js

Lines changed: 60 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,66 @@
11
import React, { Component } from 'react';
2-
import './App.css';
3-
// reactivesearch components
4-
import {
5-
ReactiveBase,
6-
CategorySearch,
7-
SingleRange,
8-
ResultCard
9-
} from '@appbaseio/reactivesearch';
10-
// For layouts, you can use a layout system of your choice
11-
import { Flex, Box } from 'reflexbox';
2+
import { ReactiveBase, CategorySearch, SingleRange, ResultCard } from '@appbaseio/reactivesearch';
123

134
class App extends Component {
14-
15-
// takes one hit response from query and returns it
16-
// in the ResultCard format to render UI view.
17-
onData({ _source: res }) {
18-
const result = {
19-
image: "https://www.enterprise.com/content/dam/global-vehicle-images/cars/FORD_FOCU_2012-1.png",
20-
title: res.name,
21-
desc: res.brand + " " + "★".repeat(res.rating),
22-
url: "#"
23-
};
24-
return result;
25-
}
26-
27-
render() {
28-
return (
29-
<ReactiveBase
30-
app="car-store"
31-
credentials="cf7QByt5e:d2d60548-82a9-43cc-8b40-93cbbe75c34c">
32-
<Flex column={false} className="flex-wrapper">
33-
<Flex column w={[1, 1, 1/3]} wrap>
34-
<Box m={2} pt={3}>
35-
<CategorySearch
36-
componentId="SearchSensor"
37-
dataField="name"
38-
categoryField="brand.raw"
39-
placeholder="Search Cars"
40-
/>
41-
</Box>
42-
<Box m={2} pt={2}>
43-
<SingleRange
44-
componentId="RatingsSensor"
45-
dataField="rating"
46-
title="RatingsFilter"
47-
data={
48-
[{ start: 4, end: 5, label: "4 stars and up" },
49-
{ start: 3, end: 5, label: "3 stars and up" },
50-
{ start: 2, end: 5, label: "2 stars and up" },
51-
{ start: 1, end: 5, label: "> 1 stars" }]
52-
}
53-
defaultSelected={"4 stars and up"}
54-
/>
55-
</Box>
56-
</Flex>
57-
<Flex w={[1, 1, 2/3]} wrap>
58-
<ResultCard
59-
innerClass={{
60-
"resultstats": "resultstats"
61-
}}
62-
className="results"
63-
componentId="SearchResult"
64-
dataField="name"
65-
title="Results"
66-
from={0}
67-
size={6}
68-
pagination
69-
onData={this.onData}
70-
sortOptions={[
71-
{
72-
label: "Lowest Price First",
73-
dataField: "price",
74-
sortBy: "asc"
75-
},
76-
{
77-
label: "Highest Price First",
78-
dataField: "price",
79-
sortBy: "desc"
80-
},
81-
{
82-
label: "Most rated",
83-
dataField: "rating",
84-
sortBy: "desc"
85-
}
86-
]}
87-
react={{
88-
and: ["SearchSensor", "RatingsSensor"]
89-
}}
90-
/>
91-
</Flex>
92-
</Flex>
93-
</ReactiveBase>
94-
);
95-
}
5+
render() {
6+
return (
7+
<ReactiveBase
8+
app="car-store"
9+
credentials="cf7QByt5e:d2d60548-82a9-43cc-8b40-93cbbe75c34c">
10+
<div style={{ display: "flex", "flex-direction": "row" }}>
11+
<div style={{ display: "flex", "flex-direction": "column", "width": "40%" }}>
12+
<CategorySearch
13+
componentId="searchbox"
14+
dataField="name"
15+
categoryField="brand.raw"
16+
placeholder="Search for cars"
17+
style={{
18+
padding: "5px",
19+
"margin-top": "10px"
20+
}}
21+
/>
22+
<SingleRange
23+
componentId="ratingsfilter"
24+
title="Filter by ratings"
25+
dataField="rating"
26+
data={[
27+
{"start": "4", "end": "5", "label": "4 stars and up"},
28+
{"start": "3", "end": "5", "label": "3 stars and up"},
29+
{"start": "2", "end": "5", "label": "2 stars and up"},
30+
{"start": "1", "end": "5", "label": "see all ratings"},
31+
]}
32+
defaultSelected="4 stars and up"
33+
style={{
34+
padding: "5px",
35+
"margin-top": "10px"
36+
}}
37+
/>
38+
</div>
39+
<ResultCard
40+
componentId="result"
41+
title="Results"
42+
from={0}
43+
size={6}
44+
pagination={true}
45+
react={{
46+
and: ["searchbox", "ratingsfilter"]
47+
}}
48+
onData={({_source: res}) => {
49+
return {
50+
image: "https://www.enterprise.com/content/dam/global-vehicle-images/cars/FORD_FOCU_2012-1.png",
51+
title: res.name,
52+
desc: res.brand + " " + "★".repeat(res.rating)
53+
}
54+
}}
55+
style={{
56+
"width": "60%",
57+
"text-align": "center"
58+
}}
59+
/>
60+
</div>
61+
</ReactiveBase>
62+
);
63+
}
9664
}
9765

9866
export default App;

yarn.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5472,12 +5472,6 @@ redux@^3.7.2:
54725472
loose-envify "^1.1.0"
54735473
symbol-observable "^1.0.3"
54745474

5475-
reflexbox@^3.0.0-0:
5476-
version "3.0.0-0"
5477-
resolved "https://registry.yarnpkg.com/reflexbox/-/reflexbox-3.0.0-0.tgz#ffc1669be396823a61f74b2d6cd501a7eda1f3c2"
5478-
dependencies:
5479-
prop-types "^15.5.10"
5480-
54815475
regenerate@^1.2.1:
54825476
version "1.3.3"
54835477
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f"

0 commit comments

Comments
 (0)