-
Notifications
You must be signed in to change notification settings - Fork 411
basic_markup #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zarichnyi
wants to merge
4
commits into
mate-academy:master
Choose a base branch
from
zarichnyi:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
basic_markup #113
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| module.exports = { | ||
| extends: "@mate-academy/eslint-config-react-typescript", | ||
| // extends: "@mate-academy/eslint-config-react", | ||
| extends: "@mate-academy/eslint-config-react", | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import React from 'react'; | ||
| import { NavLink, Switch, Route, Redirect } from 'react-router-dom'; | ||
| import { Home } from './components/HomePage/Home'; | ||
| import { Peoples } from './components/PeoplePage/PeopleTable'; | ||
| import { PageNotFound } from './components/PageNotFound/PageNotFound'; | ||
|
|
||
| import './App.scss'; | ||
|
|
||
| const App = () => ( | ||
| <div className="App"> | ||
|
|
||
| <nav className="nav"> | ||
| <ul className="nav__block"> | ||
| <li className="nav__item"> | ||
| <NavLink className="nav__link" to="/" exact>Home Page</NavLink> | ||
| </li> | ||
| <li className="nav__item"> | ||
| <NavLink className="nav__link" to="/peoples">Peoples Page</NavLink> | ||
| </li> | ||
| </ul> | ||
| </nav> | ||
|
|
||
| <Switch> | ||
| <Route path="/" exact component={Home} /> | ||
| <Route path="/home"> | ||
| <Redirect to="/" /> | ||
| </Route> | ||
| <Route path="/peoples" component={Peoples} /> | ||
| <Route path="*" component={PageNotFound} /> | ||
| </Switch> | ||
| </div> | ||
| ); | ||
|
|
||
| export default App; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,47 @@ | ||
| // styles go here | ||
| ul { | ||
| list-style: none; | ||
| } | ||
|
|
||
| html { | ||
| overflow-y: scroll; | ||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| background-color: #7FDBFF; | ||
| } | ||
|
|
||
| #root { | ||
| margin: 0; | ||
| } | ||
|
|
||
|
|
||
| .App { | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .nav { | ||
| display: flex; | ||
| justify-content: center; | ||
|
|
||
| &__block { | ||
| display: flex; | ||
| column-gap: 100px; | ||
| } | ||
|
|
||
| &__link { | ||
| color: #023e8a; | ||
| font-size: 30px; | ||
| text-decoration: none; | ||
| padding: 10px; | ||
| border-radius: 10px; | ||
| border:2px solid transparent; | ||
|
|
||
| &:hover { | ||
| border:2px solid black; | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // eslint-disable-next-line max-len | ||
| const peoples = 'https://mate-academy.github.io/react_people-table/api/people.json'; | ||
|
|
||
| export const getPeople = async() => { | ||
| const response = await fetch(peoples); | ||
| const people = response.json(); | ||
|
|
||
| return people; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import React from 'react'; | ||
| import './Home.scss'; | ||
|
|
||
| export const Home = () => ( | ||
| <h1 className="title">Home Page</h1> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .title { | ||
| text-align: center; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| import React from 'react'; | ||||||
| import './PageNotFound.scss'; | ||||||
|
|
||||||
| export const PageNotFound = () => (<h1 className="title"> PAGE NOT FOUND </h1>); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
так має також спрацювати, но карще це записувати не в одну лінію коду |
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .title { | ||
| text-align: center; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import React from 'react'; | ||
| import classNames from 'classnames'; | ||
| import propTypes from 'prop-types'; | ||
| import { useLocation } from 'react-router-dom'; | ||
| import { PersonName } from '../PersonName/PersonName'; | ||
| import './PeopleStyle.scss'; | ||
|
|
||
| export const PeoplesList = ({ people }) => { | ||
| const location = useLocation(); | ||
|
|
||
| const findParent = parentName => ( | ||
| people.find(person => person.name === parentName) | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| {people.map((person) => { | ||
| const { slug, name, sex, born, died, motherName, fatherName } = person; | ||
|
|
||
| return ( | ||
| <tr | ||
| key={person.name} | ||
| className={ | ||
| classNames( | ||
| { selected: `/peoples/${slug}` === location.pathname }, | ||
| )} | ||
| > | ||
| <td className="table__list-item"> | ||
| <PersonName | ||
| name={name} | ||
| slug={slug} | ||
| sex={sex} | ||
| /> | ||
| </td> | ||
| <td>{sex}</td> | ||
| <td>{born}</td> | ||
| <td>{died}</td> | ||
| <td> | ||
| {findParent(motherName) | ||
| ? ( | ||
| <PersonName | ||
| name={motherName} | ||
| slug={findParent(motherName).slug} | ||
| sex={findParent(motherName).sex} | ||
| /> | ||
| ) | ||
| : <>{motherName}</> | ||
| } | ||
| </td> | ||
| <td> | ||
| {findParent(fatherName) | ||
| ? ( | ||
| <PersonName | ||
| name={fatherName} | ||
| slug={findParent(fatherName).slug} | ||
| sex={findParent(fatherName).sex} | ||
| /> | ||
| ) | ||
| : <>{fatherName}</> | ||
| } | ||
| </td> | ||
| </tr> | ||
| ); | ||
| })} | ||
| </> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| .active { | ||
| background-color: #2a9d8f; | ||
| } | ||
|
|
||
| .title { | ||
| text-align: center; | ||
| } | ||
|
|
||
| .selected { | ||
| background-color: #06d6a0; | ||
| } | ||
|
|
||
| .table { | ||
| margin: 0 auto; | ||
| border-spacing: 0; | ||
|
|
||
| &__title-item { | ||
| padding: 10px; | ||
| background-color: #0077b6; | ||
| font-size: 18px; | ||
| } | ||
|
|
||
| &__list-item { | ||
| padding: 15px 0; | ||
| } | ||
|
|
||
| &__name-male { | ||
| color: #0077b6; | ||
| } | ||
|
|
||
| &__name-female { | ||
| color: #dc2f02; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // eslint-disable-next-line no-unused-vars | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { useLocation } from 'react-router-dom'; | ||
| import * as api from '../../api/GetPeople'; | ||
| import { PeoplesList } from './PeopleList'; | ||
| import { SearchInput } from '../SearchSection/SearchInput'; | ||
|
|
||
| export const Peoples = () => { | ||
| const [people, setPeople] = useState(''); | ||
| const location = useLocation(); | ||
| const searchParams = new URLSearchParams(location.search); | ||
| const getUrlQuery = searchParams.get('query'); | ||
|
|
||
| const tableTitle = ['Name', 'Sex', 'Born', 'Died', 'Mother', 'Father']; | ||
|
|
||
| useEffect(() => { | ||
| api.getPeople().then((peopleFromServer) => { | ||
| setPeople(peopleFromServer); | ||
| localStorage.setItem('people', JSON.stringify(peopleFromServer)); | ||
| }); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| if (getUrlQuery) { | ||
| setPeople(JSON.parse(localStorage.getItem('people')).filter((person) => { | ||
| const { name, motherName, fatherName } = person; | ||
|
|
||
| return (name.toLowerCase().includes(getUrlQuery) | ||
| || (motherName && motherName.toLowerCase().includes(getUrlQuery)) | ||
| || (fatherName && fatherName.toLowerCase().includes(getUrlQuery)) | ||
| ); | ||
| })); | ||
| } else { | ||
| setPeople(JSON.parse(localStorage.getItem('people'))); | ||
| } | ||
| }, [getUrlQuery]); | ||
|
|
||
| return ( | ||
| <> | ||
| <h1 className="title">Peoples Page</h1> | ||
| <SearchInput /> | ||
| <table className="table"> | ||
| <thead className="table__title"> | ||
| <tr> | ||
| {tableTitle.map(item => ( | ||
| <th className="table__title-item" key={item}>{item}</th> | ||
| ))} | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {people | ||
| ? <PeoplesList people={[...people]} /> | ||
| : 'Loading...' | ||
| } | ||
| </tbody> | ||
| </table> | ||
| </> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import React from 'react'; | ||
| import classNames from 'classnames'; | ||
| import { Link } from 'react-router-dom'; | ||
| import './PersonName.scss'; | ||
|
|
||
| export const PersonName = ({ name, slug, sex }) => { | ||
|
|
||
| return ( | ||
| <Link | ||
| className={classNames('table__list-link', | ||
| { 'table__name-male': sex === 'm' }, | ||
| { 'table__name-female': sex === 'f' }) | ||
| } | ||
| to={{ pathname: `/peoples/${slug}` }} | ||
| > | ||
| { name} | ||
| </Link> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .table { | ||
| &__list-link { | ||
| text-decoration: none; | ||
| font-size: 18px; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import React from 'react'; | ||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
| import './SearchInput.scss'; | ||
|
|
||
| export const SearchInput = () => { | ||
| const history = useHistory(); | ||
| const location = useLocation(); | ||
| const searchParams = new URLSearchParams(location.search); | ||
| const query = searchParams.get('query') || ''; | ||
|
|
||
| return ( | ||
| <div className="search_person_block"> | ||
| <input | ||
| className="search_person_input" | ||
| placeholder="Find person" | ||
| type="text" | ||
| value={query} | ||
| onChange={(event) => { | ||
| searchParams.set('query', (event.target.value).toLocaleLowerCase()); | ||
| history.push({ | ||
| search: searchParams.toString() === 'query=' | ||
| ? '' | ||
| : searchParams.toString(), | ||
| }); | ||
| }} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .search_person_block { | ||
| display: flex; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .search_person_input { | ||
| width: 30em; | ||
| height: 2em; | ||
| border-color: blue; | ||
| outline: none; | ||
| padding: 5px; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не забувай про пусту лінію в кінці файлу