From fb14cdb4406483ea79de416c7da2451b425a8168 Mon Sep 17 00:00:00 2001 From: Mathias Date: Tue, 2 Mar 2021 20:46:04 +0100 Subject: [PATCH] Lab3 cleanup --- lab3/src/components/App/App.css | 36 ++++++++++------------ lab3/src/components/Container/Container.js | 2 +- lab3/src/components/List/List.js | 27 ++++++++-------- lab3/src/index.css | 3 +- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/lab3/src/components/App/App.css b/lab3/src/components/App/App.css index 61e3b2e..8a4bc3d 100644 --- a/lab3/src/components/App/App.css +++ b/lab3/src/components/App/App.css @@ -1,31 +1,27 @@ -#root { - background: whitesmoke; -} - .App { - padding: 25px 15px 25px 15px; - border: 2px solid gray; - min-height: 250px; + padding: 25px 15px 25px 15px; + border: 2px solid gray; + min-height: 250px; } .App-header { - background-color: #222; - height: 150px; - padding: 20px; - color: white; - font-size: 42px; - text-align: center; + background-color: #222; + height: 150px; + padding: 20px; + color: white; + font-size: 42px; + text-align: center; } .App-header-description { - font-size: 18px; + font-size: 18px; } @keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } diff --git a/lab3/src/components/Container/Container.js b/lab3/src/components/Container/Container.js index 8883992..db5a3a1 100644 --- a/lab3/src/components/Container/Container.js +++ b/lab3/src/components/Container/Container.js @@ -35,7 +35,7 @@ const Container = () => { console.log("FOO"); }} /> - + ); }; diff --git a/lab3/src/components/List/List.js b/lab3/src/components/List/List.js index 1a27f0a..f528562 100644 --- a/lab3/src/components/List/List.js +++ b/lab3/src/components/List/List.js @@ -4,9 +4,12 @@ import { connect } from "react-redux"; import "./List.css"; -const List = ({ items, title }) => { +const List = ({ title }) => { const [searchTerm, setSearchTerm] = useState(""); + // Task 7: Get users from store + const users = []; + const onItemClick = (userId) => { console.log("Clicked on user", userId); }; @@ -15,23 +18,23 @@ const List = ({ items, title }) => { setSearchTerm(e.target.value); }; - const filterListItemsBySearchTerm = (searchTerm) => - items.filter((item) => - item.name.toLowerCase().includes(searchTerm.toLowerCase()) + const filterUsersBySearchTerm = (searchTerm) => + users.filter((user) => + user.name.toLowerCase().includes(searchTerm.toLowerCase()) ); - const filteredItems = filterListItemsBySearchTerm(searchTerm); + const filteredUsers = filterUsersBySearchTerm(searchTerm); return (

{title}

- {filteredItems.length === 0 ? ( + {filteredUsers.length === 0 ? (
Empty list...
) : (
    - {filteredItems.length > 0 && - filteredItems.map((item) => ( + {filteredUsers.length > 0 && + filteredUsers.map((item) => (
  • { ); }; -const mapStateToProps = (state) => { - return { - items: [], // TODO: Task 6 - Implement mapStateToProps - }; -}; - -export default connect(mapStateToProps, null)(List); +export default List; diff --git a/lab3/src/index.css b/lab3/src/index.css index 38b4c2d..1c21b00 100644 --- a/lab3/src/index.css +++ b/lab3/src/index.css @@ -1,5 +1,6 @@ body { margin: 0; padding: 0; - font-family: 'Lato', sans-serif; + font-family: "Lato", sans-serif; + background: whitesmoke; }