diff --git a/src/App.js b/src/App.js index 3784575..0bfac41 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,43 @@ -import logo from './logo.svg'; +import { Component } from 'react' import './App.css'; +import { CardList } from './components/card-list/card-list.component' +import { SearchBox } from './components/search-box/search-box.component' -function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); +class App extends Component { + constructor(props) { + super(props); + + this.state = { + monsters: [], + searchField: '' + } + } + + componentDidMount() { + fetch('https://jsonplaceholder.typicode.com/users') + .then(response => response.json()).then( + users => this.setState({ monsters: users }) + ) + } + + + render() { + const { monsters, searchField } = this.state; + const filteredMonsters = monsters.filter(monster => + monster.name.toLowerCase().includes(searchField.toLowerCase()) + ); + + + return ( +
+ this.setState({ searchField: e.target.value })} + /> + +
+ ); + } } export default App; diff --git a/src/components/card-list/card-list.component.jsx b/src/components/card-list/card-list.component.jsx new file mode 100644 index 0000000..e00026f --- /dev/null +++ b/src/components/card-list/card-list.component.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { Card } from '../card/card.component' + + +import './card-list.styles.css' + +export const CardList = (props) => { + return
{ + props.monsters.map(monster => { + return + }) + }
+} + diff --git a/src/components/card-list/card-list.styles.css b/src/components/card-list/card-list.styles.css new file mode 100644 index 0000000..b403a4f --- /dev/null +++ b/src/components/card-list/card-list.styles.css @@ -0,0 +1,8 @@ +.card-list { + width: 85vw; + margin: 0 auto; + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-gap: 20px; + } + \ No newline at end of file diff --git a/src/components/card/card.component.jsx b/src/components/card/card.component.jsx new file mode 100644 index 0000000..2af704a --- /dev/null +++ b/src/components/card/card.component.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import './card.styles.css' + +export const Card = props => { + return ( +
+ monser +

{props.monster.name}

+

{props.monster.email}

+
+ ); +}; diff --git a/src/components/card/card.styles.css b/src/components/card/card.styles.css new file mode 100644 index 0000000..f5acbe3 --- /dev/null +++ b/src/components/card/card.styles.css @@ -0,0 +1,23 @@ +.card-container { + display: flex; + flex-direction: column; + background-color: #95dada; + border: 1px solid grey; + border-radius: 5px; + padding: 25px; + cursor: pointer; + -moz-osx-font-smoothing: grayscale; + backface-visibility: hidden; + transform: translateZ(0); + transition: transform 0.25s ease-out; +} + +.card-container:hover { + transform: scale(1.05); +} + +.card-container img { + margin-left: auto; + margin-right: auto; + max-width: 200px; +} \ No newline at end of file diff --git a/src/components/search-box/search-box.component.jsx b/src/components/search-box/search-box.component.jsx new file mode 100644 index 0000000..aafe323 --- /dev/null +++ b/src/components/search-box/search-box.component.jsx @@ -0,0 +1,15 @@ +import React from 'react'; + +import './search-box.styles.css' + +export const SearchBox = ({ placeholder, handleChange }) => { + return ( + + ); +}; + diff --git a/src/components/search-box/search-box.styles.css b/src/components/search-box/search-box.styles.css new file mode 100644 index 0000000..21fa568 --- /dev/null +++ b/src/components/search-box/search-box.styles.css @@ -0,0 +1,9 @@ +.search { + -webkit-appearance: none; + border: none; + outline: none; + padding: 10px; + width: 150px; + line-height: 30px; + margin-bottom: 30px; +} \ No newline at end of file