├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── images
│ ├── dishes
│ │ ├── Mushroom-Risotto-Recipe-1-1200.jpg
│ │ ├── as-tomato-bruschetta-articleLarge.jpg
│ │ ├── dimsums.jpg
│ │ ├── nacho-burger.jpg
│ │ ├── pesto-chicken.jpg
│ │ └── shiitake-salmon-fried-rice-0218-103230720.jpg
│ ├── gif
│ │ └── empty.gif
│ └── places
│ │ ├── ameri.jpg
│ │ ├── china.jpg
│ │ ├── fookyew2.jpg
│ │ ├── italian.webp
│ │ ├── italiian.jpg
│ │ └── sea.jpg
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
└── src
├── App.css
├── App.jsx
├── components
├── Home
│ ├── FilterPanel
│ │ ├── index.jsx
│ │ └── styles.css
│ ├── List
│ │ ├── ListItem
│ │ │ ├── index.jsx
│ │ │ └── styles.css
│ │ ├── index.jsx
│ │ └── styles.css
│ └── SearchBar
│ │ ├── index.jsx
│ │ └── styles.css
└── common
│ ├── CheckboxProton
│ └── index.jsx
│ ├── EmptyView
│ ├── index.jsx
│ └── styles.css
│ ├── FilterListToggle
│ └── index.jsx
│ └── SliderProton
│ └── index.jsx
├── constants
└── index.js
├── index.js
└── pages
└── Home
├── index.jsx
└── styles.css
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "filters",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@material-ui/core": "^4.11.4",
7 | "@material-ui/icons": "^4.11.2",
8 | "@material-ui/lab": "^4.0.0-alpha.58",
9 | "@testing-library/jest-dom": "^5.13.0",
10 | "@testing-library/react": "^11.2.7",
11 | "@testing-library/user-event": "^12.8.3",
12 | "react": "^17.0.2",
13 | "react-dom": "^17.0.2",
14 | "react-scripts": "4.0.3",
15 | "web-vitals": "^1.1.2"
16 | },
17 | "scripts": {
18 | "start": "react-scripts start",
19 | "build": "react-scripts build",
20 | "test": "react-scripts test",
21 | "eject": "react-scripts eject"
22 | },
23 | "eslintConfig": {
24 | "extends": [
25 | "react-app",
26 | "react-app/jest"
27 | ]
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/favicon.ico
--------------------------------------------------------------------------------
/public/images/dishes/Mushroom-Risotto-Recipe-1-1200.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/Mushroom-Risotto-Recipe-1-1200.jpg
--------------------------------------------------------------------------------
/public/images/dishes/as-tomato-bruschetta-articleLarge.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/as-tomato-bruschetta-articleLarge.jpg
--------------------------------------------------------------------------------
/public/images/dishes/dimsums.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/dimsums.jpg
--------------------------------------------------------------------------------
/public/images/dishes/nacho-burger.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/nacho-burger.jpg
--------------------------------------------------------------------------------
/public/images/dishes/pesto-chicken.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/pesto-chicken.jpg
--------------------------------------------------------------------------------
/public/images/dishes/shiitake-salmon-fried-rice-0218-103230720.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/dishes/shiitake-salmon-fried-rice-0218-103230720.jpg
--------------------------------------------------------------------------------
/public/images/gif/empty.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/gif/empty.gif
--------------------------------------------------------------------------------
/public/images/places/ameri.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/ameri.jpg
--------------------------------------------------------------------------------
/public/images/places/china.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/china.jpg
--------------------------------------------------------------------------------
/public/images/places/fookyew2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/fookyew2.jpg
--------------------------------------------------------------------------------
/public/images/places/italian.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/italian.webp
--------------------------------------------------------------------------------
/public/images/places/italiian.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/italiian.jpg
--------------------------------------------------------------------------------
/public/images/places/sea.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/images/places/sea.jpg
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codefreeeze/filters-materialui-react/87cd6f69893de044f3fcae088f4611c093decb4f/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
2 |
3 | *,
4 | *::after,
5 | *::before {
6 | margin: 0;
7 | }
8 |
9 | body {
10 | font-family: 'Raleway', sans-serif;
11 | }
12 |
13 | input {
14 | font-family: 'Raleway', sans-serif;
15 | }
16 |
17 | /* Hide scrollbar for Chrome, Safari and Opera */
18 | ::-webkit-scrollbar {
19 | display: none;
20 | }
21 |
22 | /* Hide scrollbar for IE, Edge and Firefox */
23 | body {
24 | -ms-overflow-style: none; /* IE and Edge */
25 | scrollbar-width: none; /* Firefox */
26 | }
27 |
--------------------------------------------------------------------------------
/src/App.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Home from './pages/Home';
3 | import './App.css';
4 |
5 | const App = () => ;
6 |
7 | export default App;
8 |
--------------------------------------------------------------------------------
/src/components/Home/FilterPanel/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { categoryList, ratingList } from '../../../constants';
3 | import CheckboxProton from '../../common/CheckboxProton';
4 | import FilterListToggle from '../../common/FilterListToggle';
5 | import SliderProton from '../../common/SliderProton';
6 | import './styles.css';
7 |
8 | const FilterPanel = ({
9 | selectedCategory,
10 | selectCategory,
11 | selectedRating,
12 | selectedPrice,
13 | selectRating,
14 | cuisines,
15 | changeChecked,
16 | changePrice,
17 | }) => (
18 |
19 |
27 |
28 |
Cuisine
29 | {cuisines.map((cuisine) => (
30 |
35 | ))}
36 |
37 |
38 |
Price Range
39 |
40 |
41 |
42 |
Star Rating
43 |
48 |
49 |
50 | );
51 |
52 | export default FilterPanel;
53 |
--------------------------------------------------------------------------------
/src/components/Home/FilterPanel/styles.css:
--------------------------------------------------------------------------------
1 | .label {
2 | margin-bottom: 0.8rem;
3 | font-weight: 600;
4 | }
5 | .input-group {
6 | margin-bottom: 2rem;
7 | }
8 | .label-range {
9 | margin-bottom: 2.5rem;
10 | }
11 |
--------------------------------------------------------------------------------
/src/components/Home/List/ListItem/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './styles.css';
3 |
4 | const ListItem = ({
5 | item: { coverSrc, title, price, deliveryFee, serviceTime, rating },
6 | }) => (
7 |
8 |

9 |
10 | {title}
11 | 🌟{rating}
12 |
13 |
21 |
22 | );
23 |
24 | export default ListItem;
25 |
--------------------------------------------------------------------------------
/src/components/Home/List/ListItem/styles.css:
--------------------------------------------------------------------------------
1 | .listItem-wrap img {
2 | width: 100%;
3 | border-radius: 15px;
4 | height: 200px;
5 | object-fit: cover;
6 | }
7 | .listItem-wrap header {
8 | display: flex;
9 | justify-content: space-between;
10 | margin: 1rem 0 1rem 0;
11 | align-items: center;
12 | }
13 |
14 | .listItem-wrap header span {
15 | font-size: 0.7rem;
16 | background-color: #97ffff;
17 | padding: 0.5rem;
18 | border-radius: 10px;
19 | }
20 | .listItem-wrap footer {
21 | font-size: 0.8rem;
22 | display: flex;
23 | align-items: center;
24 | justify-content: space-between;
25 | }
26 | .listItem-wrap footer p:first-child span {
27 | color: rgba(0, 0, 0, 0.26);
28 | font-weight: 600;
29 | }
30 |
--------------------------------------------------------------------------------
/src/components/Home/List/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ListItem from './ListItem';
3 | import './styles.css';
4 |
5 | const List = ({ list }) => (
6 |
7 | {list.map((item) => (
8 |
9 | ))}
10 |
11 | );
12 |
13 | export default List;
14 |
--------------------------------------------------------------------------------
/src/components/Home/List/styles.css:
--------------------------------------------------------------------------------
1 | .list-wrap {
2 | display: grid;
3 | grid-template-columns: repeat(3, 1fr);
4 | grid-gap: 2rem;
5 | }
6 |
--------------------------------------------------------------------------------
/src/components/Home/SearchBar/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './styles.css';
3 | import SearchIcon from '@material-ui/icons/Search';
4 |
5 | const SearchBar = ({ value, changeInput }) => (
6 |
7 |
8 |
14 |
15 | );
16 |
17 | export default SearchBar;
18 |
--------------------------------------------------------------------------------
/src/components/Home/SearchBar/styles.css:
--------------------------------------------------------------------------------
1 | .searchBar-wrap {
2 | display: flex;
3 | align-items: center;
4 | border-bottom: 1px solid rgba(0, 0, 0, 0.26);
5 | padding: 1.5rem 1rem;
6 | }
7 | .searchBar-icon {
8 | color: rgba(0, 0, 0, 0.26);
9 | margin-right: 2rem;
10 | }
11 |
12 | .searchBar-wrap input {
13 | font-size: 1.5rem;
14 | outline: none;
15 | border: none;
16 | width: 100%;
17 | }
18 |
19 | .searchBar-wrap input::placeholder {
20 | color: rgba(0, 0, 0, 0.26);
21 | }
22 |
--------------------------------------------------------------------------------
/src/components/common/CheckboxProton/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import Checkbox from '@material-ui/core/Checkbox';
3 | import { makeStyles } from '@material-ui/core/styles';
4 | import FormControlLabel from '@material-ui/core/FormControlLabel';
5 |
6 | const useStyles = makeStyles({
7 | root: {
8 | '&$checked': {
9 | color: '#000',
10 | },
11 | },
12 | checked: {},
13 | wrap: {
14 | width: '100%',
15 | display: 'flex',
16 | flexDirection: 'row-reverse',
17 | justifyContent: 'space-between',
18 | alignItems: 'center',
19 | marginLeft: 0,
20 | },
21 | label: {
22 | fontSize: '.8rem',
23 | fontFamily: `'Raleway', sans-serif`,
24 | },
25 | });
26 |
27 | const CheckboxProton = ({ changeChecked, cuisine }) => {
28 | const classes = useStyles();
29 | const { checked, label, id } = cuisine;
30 | return (
31 |
32 | changeChecked(id)}
46 | inputProps={{ 'aria-label': 'checkbox with small size' }}
47 | />
48 | }
49 | label={label}
50 | />
51 |
52 | );
53 | };
54 |
55 | export default CheckboxProton;
56 |
--------------------------------------------------------------------------------
/src/components/common/EmptyView/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import './styles.css';
3 |
4 | const EmptyView = () => (
5 |
6 |

7 |
8 | );
9 |
10 | export default EmptyView;
11 |
--------------------------------------------------------------------------------
/src/components/common/EmptyView/styles.css:
--------------------------------------------------------------------------------
1 | .emptyView-wrap {
2 | display: flex;
3 | justify-content: center;
4 | align-items: center;
5 | height: 100%;
6 | }
7 | .emptyView-wrap img {
8 | max-width: 500px;
9 | width: 100%;
10 | }
11 |
--------------------------------------------------------------------------------
/src/components/common/FilterListToggle/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ToggleButton from '@material-ui/lab/ToggleButton';
3 | import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
4 | import { makeStyles } from '@material-ui/core/styles';
5 |
6 | const useStyles = makeStyles({
7 | root: {
8 | width: '100%',
9 | justifyContent: 'space-between',
10 | },
11 | toggle: {
12 | fontFamily: `'Raleway', sans-serif`,
13 | fontSize: '.8rem',
14 | border: '1px solid rgba(0, 0, 0, 0.12)',
15 | borderRadius: '10px',
16 | '&.MuiToggleButtonGroup-groupedHorizontal:not(:last-child)': {
17 | borderRadius: '10px',
18 | },
19 | '&.MuiToggleButtonGroup-groupedHorizontal:not(:first-child)': {
20 | borderRadius: '10px',
21 | border: '1px solid rgba(0, 0, 0, 0.12)',
22 | },
23 | '&.Mui-selected': {
24 | borderRadius: '10px',
25 | background: '#000',
26 | color: '#fff',
27 | },
28 | '&.MuiToggleButton-root': {
29 | '&:hover': {
30 | background: '#000',
31 | color: '#fff',
32 | },
33 | },
34 | },
35 | });
36 |
37 | const FilterListToggle = ({ options, value, selectToggle }) => {
38 | const classes = useStyles();
39 | return (
40 |
46 | {options.map(({ label, id, value }) => (
47 |
48 | {label}
49 |
50 | ))}
51 |
52 | );
53 | };
54 |
55 | export default FilterListToggle;
56 |
--------------------------------------------------------------------------------
/src/components/common/SliderProton/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { makeStyles } from '@material-ui/core/styles';
3 | import Typography from '@material-ui/core/Typography';
4 | import Slider from '@material-ui/core/Slider';
5 |
6 | const useStyles = makeStyles({
7 | root: {
8 | width: '100%',
9 | },
10 | thumb: {
11 | color: '#000',
12 | },
13 | rail: {
14 | color: `rgba(0, 0, 0, 0.26)`,
15 | },
16 | track: {
17 | color: '#000',
18 | },
19 | });
20 |
21 | const SliderProton = ({ value, changePrice }) => {
22 | const classes = useStyles();
23 |
24 | return (
25 |
26 |
38 |
39 | );
40 | };
41 |
42 | export default SliderProton;
43 |
--------------------------------------------------------------------------------
/src/constants/index.js:
--------------------------------------------------------------------------------
1 | export const categoryList = [
2 | {
3 | id: 1,
4 | value: 'place',
5 | label: '🚩 Places',
6 | },
7 | {
8 | id: 2,
9 | value: 'dish',
10 | label: '🍕 Dishes',
11 | },
12 | ];
13 |
14 | export const ratingList = [
15 | {
16 | id: 1,
17 | value: '1',
18 | label: '1🌟',
19 | },
20 | {
21 | id: 2,
22 | value: '2',
23 | label: '2🌟',
24 | },
25 | {
26 | id: 3,
27 | value: '3',
28 | label: '3🌟',
29 | },
30 | {
31 | id: 4,
32 | value: '4',
33 | label: '4🌟',
34 | },
35 | {
36 | id: 5,
37 | value: '5',
38 | label: '5🌟',
39 | },
40 | ];
41 |
42 | export const dataList = [
43 | {
44 | id: 1,
45 | title: 'lounge resort',
46 | serviceTime: '45-60min',
47 | deliveryFee: 3.44,
48 | category: 'place',
49 | cuisine: 'american',
50 | rating: 5,
51 | price: 2500,
52 | coverSrc: '/images/places/ameri.jpg',
53 | },
54 | {
55 | id: 2,
56 | title: 'door urban',
57 | serviceTime: '15-20min',
58 | deliveryFee: 4.94,
59 | category: 'place',
60 | cuisine: 'italian',
61 | rating: 4,
62 | price: 1000,
63 | coverSrc: '/images/places/italian.webp',
64 | },
65 | {
66 | id: 3,
67 | title: 'chow',
68 | serviceTime: '30-22min',
69 | deliveryFee: 4.94,
70 | category: 'place',
71 | cuisine: 'chinese',
72 | rating: 3,
73 | price: 2000,
74 | coverSrc: '/images/places/china.jpg',
75 | },
76 | {
77 | id: 4,
78 | title: 'wharf seafood',
79 | serviceTime: '10-18min',
80 | deliveryFee: 2.14,
81 | category: 'place',
82 | cuisine: 'american',
83 | rating: 1,
84 | price: 1800,
85 | coverSrc: '/images/places/sea.jpg',
86 | },
87 | {
88 | id: 5,
89 | title: 'Tossin',
90 | serviceTime: '25-30min',
91 | deliveryFee: 6.79,
92 | category: 'place',
93 | cuisine: 'italian',
94 | rating: 5,
95 | price: 2000,
96 | coverSrc: '/images/places/italiian.jpg',
97 | },
98 | {
99 | id: 6,
100 | title: 'stories noodles',
101 | serviceTime: '5-15min',
102 | deliveryFee: 2.87,
103 | category: 'place',
104 | cuisine: 'chinese',
105 | rating: 5,
106 | price: 3500,
107 | coverSrc: '/images/places/fookyew2.jpg',
108 | },
109 | {
110 | id: 7,
111 | title: 'Nacho cheeseburger',
112 | serviceTime: '50-65min',
113 | deliveryFee: 8.5,
114 | category: 'dish',
115 | cuisine: 'american',
116 | rating: 2,
117 | price: 2200,
118 | coverSrc: '/images/dishes/nacho-burger.jpg',
119 | },
120 | {
121 | id: 8,
122 | title: 'Mushroom Risotto',
123 | serviceTime: '10-15min',
124 | deliveryFee: 1.8,
125 | category: 'dish',
126 | cuisine: 'italian',
127 | rating: 1,
128 | price: 1900,
129 | coverSrc: '/images/dishes/Mushroom-Risotto-Recipe-1-1200.jpg',
130 | },
131 | {
132 | id: 9,
133 | title: 'Shitake Fried Rice',
134 | serviceTime: '12-18min',
135 | deliveryFee: 3.33,
136 | category: 'dish',
137 | cuisine: 'chinese',
138 | rating: 4,
139 | price: 2750,
140 | coverSrc: '/images/dishes/shiitake-salmon-fried-rice-0218-103230720.jpg',
141 | },
142 | {
143 | id: 10,
144 | title: 'Pesto chicken stew',
145 | serviceTime: '30-38min',
146 | deliveryFee: 1.9,
147 | category: 'dish',
148 | cuisine: 'american',
149 | rating: 2,
150 | price: 4350,
151 | coverSrc: '/images/dishes/pesto-chicken.jpg',
152 | },
153 | {
154 | id: 11,
155 | title: 'Bruschetta',
156 | serviceTime: '16-20min',
157 | deliveryFee: 4.1,
158 | category: 'dish',
159 | cuisine: 'italian',
160 | rating: 3,
161 | price: 3300,
162 | coverSrc: '/images/dishes/as-tomato-bruschetta-articleLarge.jpg',
163 | },
164 | {
165 | id: 12,
166 | title: 'Dim Sums',
167 | serviceTime: '24-30min',
168 | deliveryFee: 1.5,
169 | category: 'dish',
170 | cuisine: 'chinese',
171 | rating: 2,
172 | price: 4100,
173 | coverSrc: '/images/dishes/dimsums.jpg',
174 | },
175 | ];
176 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | ReactDOM.render(
6 |
7 |
8 | ,
9 | document.getElementById('root')
10 | );
11 |
--------------------------------------------------------------------------------
/src/pages/Home/index.jsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import EmptyView from '../../components/common/EmptyView';
3 | import FilterPanel from '../../components/Home/FilterPanel';
4 | import List from '../../components/Home/List';
5 | import SearchBar from '../../components/Home/SearchBar';
6 | import { dataList } from '../../constants';
7 | import './styles.css';
8 |
9 | const Home = () => {
10 | const [selectedCategory, setSelectedCategory] = useState(null);
11 | const [selectedRating, setSelectedRating] = useState(null);
12 | const [selectedPrice, setSelectedPrice] = useState([1000, 5000]);
13 |
14 | const [cuisines, setCuisines] = useState([
15 | { id: 1, checked: false, label: 'American' },
16 | { id: 2, checked: false, label: 'Chinese' },
17 | { id: 3, checked: false, label: 'Italian' },
18 | ]);
19 |
20 | const [list, setList] = useState(dataList);
21 | const [resultsFound, setResultsFound] = useState(true);
22 | const [searchInput, setSearchInput] = useState('');
23 |
24 | const handleSelectCategory = (event, value) =>
25 | !value ? null : setSelectedCategory(value);
26 |
27 | const handleSelectRating = (event, value) =>
28 | !value ? null : setSelectedRating(value);
29 |
30 | const handleChangeChecked = (id) => {
31 | const cusinesStateList = cuisines;
32 | const changeCheckedCuisines = cusinesStateList.map((item) =>
33 | item.id === id ? { ...item, checked: !item.checked } : item
34 | );
35 | setCuisines(changeCheckedCuisines);
36 | };
37 |
38 | const handleChangePrice = (event, value) => {
39 | setSelectedPrice(value);
40 | };
41 |
42 | const applyFilters = () => {
43 | let updatedList = dataList;
44 |
45 | // Rating Filter
46 | if (selectedRating) {
47 | updatedList = updatedList.filter(
48 | (item) => parseInt(item.rating) === parseInt(selectedRating)
49 | );
50 | }
51 |
52 | // Category Filter
53 | if (selectedCategory) {
54 | updatedList = updatedList.filter(
55 | (item) => item.category === selectedCategory
56 | );
57 | }
58 |
59 | // Cuisine Filter
60 | const cuisinesChecked = cuisines
61 | .filter((item) => item.checked)
62 | .map((item) => item.label.toLowerCase());
63 |
64 | if (cuisinesChecked.length) {
65 | updatedList = updatedList.filter((item) =>
66 | cuisinesChecked.includes(item.cuisine)
67 | );
68 | }
69 |
70 | // Search Filter
71 | if (searchInput) {
72 | updatedList = updatedList.filter(
73 | (item) =>
74 | item.title.toLowerCase().search(searchInput.toLowerCase().trim()) !==
75 | -1
76 | );
77 | }
78 |
79 | // Price Filter
80 | const minPrice = selectedPrice[0];
81 | const maxPrice = selectedPrice[1];
82 |
83 | updatedList = updatedList.filter(
84 | (item) => item.price >= minPrice && item.price <= maxPrice
85 | );
86 |
87 | setList(updatedList);
88 |
89 | !updatedList.length ? setResultsFound(false) : setResultsFound(true);
90 | };
91 |
92 | useEffect(() => {
93 | applyFilters();
94 | }, [selectedRating, selectedCategory, cuisines, searchInput, selectedPrice]);
95 |
96 | return (
97 |
98 | {/* Search Bar */}
99 |
setSearchInput(e.target.value)}
102 | />
103 |
104 | {/* Filter Panel */}
105 |
106 |
116 |
117 | {/* List & Empty View */}
118 |
119 | {resultsFound ?
: }
120 |
121 |
122 |
123 | );
124 | };
125 |
126 | export default Home;
127 |
--------------------------------------------------------------------------------
/src/pages/Home/styles.css:
--------------------------------------------------------------------------------
1 | .home {
2 | display: flex;
3 | flex-direction: column;
4 | height: 100vh;
5 | }
6 | .home_panelList-wrap,
7 | .home_panel-wrap,
8 | .home_list-wrap {
9 | overflow-y: auto;
10 | }
11 |
12 | .home_panelList-wrap {
13 | flex: 1;
14 | display: flex;
15 | }
16 | .home_panel-wrap {
17 | flex-basis: 280px;
18 | padding: 1rem;
19 | }
20 | .home_list-wrap {
21 | flex: 1;
22 | padding: 1rem;
23 | }
24 |
--------------------------------------------------------------------------------