generated from mate-academy/react_people-table
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Initial solution #1110
Open
v1RnT
wants to merge
4
commits into
mate-academy:master
Choose a base branch
from
v1RnT: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
Initial solution #1110
Changes from all commits
Commits
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 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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,27 @@ | ||
import { | ||
Navigate, | ||
Route, | ||
HashRouter as Router, | ||
Routes, | ||
} from 'react-router-dom'; | ||
import { HomePage } from './pages/HomePage'; | ||
import { PeoplePage } from './pages/PeoplePage'; | ||
import { PageNotFound } from './pages/PageNotFound'; | ||
import { App } from './App'; | ||
import { Paths } from './types/Paths'; | ||
|
||
export const Root = () => ( | ||
<Router> | ||
<Routes> | ||
<Route path={Paths.Home} element={<App />}> | ||
<Route index element={<HomePage />} /> | ||
<Route path={Paths.HomePage} element={<Navigate to="/" replace />} /> | ||
<Route path={Paths.People} element={<PeoplePage />}> | ||
<Route index /> | ||
<Route path={Paths.PersonDetail} /> | ||
</Route> | ||
<Route path={Paths.PageNotFound} element={<PageNotFound />} /> | ||
</Route> | ||
</Routes> | ||
</Router> | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains 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,31 @@ | ||
import cn from 'classnames'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
export const Navbar = () => { | ||
const activeNavbar = ({ isActive }: { isActive: boolean }) => { | ||
return cn('navbar-item', { | ||
'has-background-grey-lighter': isActive, | ||
}); | ||
}; | ||
|
||
return ( | ||
<nav | ||
data-cy="nav" | ||
className="navbar is-fixed-top has-shadow" | ||
role="navigation" | ||
aria-label="main navigation" | ||
> | ||
<div className="container"> | ||
<div className="navbar-brand"> | ||
<NavLink className={activeNavbar} to="/"> | ||
Home | ||
</NavLink> | ||
|
||
<NavLink aria-current="page" className={activeNavbar} to="/people"> | ||
People | ||
</NavLink> | ||
</div> | ||
</div> | ||
</nav> | ||
); | ||
}; |
This file contains 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 @@ | ||
export * from './Navbar'; |
This file was deleted.
Oops, something went wrong.
This file contains 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,102 @@ | ||
import cn from 'classnames'; | ||
import { SearchLink } from '../SearchLink'; | ||
import { useFilters } from '../../hooks/useFilters'; | ||
import { CENTURIES } from '../../constants/CENTURIES'; | ||
import { Sex } from '../../types/Sex'; | ||
|
||
export const PeopleFilters = () => { | ||
const { sex, query, centuries, handleSetQuery, getCenturiesParams } = | ||
useFilters(); | ||
|
||
return ( | ||
<nav className="panel"> | ||
<p className="panel-heading">Filters</p> | ||
|
||
<p className="panel-tabs" data-cy="SexFilter"> | ||
<SearchLink | ||
className={cn({ 'is-active': sex === null })} | ||
params={{ sex: null }} | ||
> | ||
All | ||
</SearchLink> | ||
|
||
<SearchLink | ||
className={cn({ 'is-active': sex === Sex.MALE })} | ||
params={{ sex: Sex.MALE }} | ||
> | ||
Male | ||
</SearchLink> | ||
|
||
<SearchLink | ||
className={cn({ 'is-active': sex === Sex.FEMALE })} | ||
params={{ sex: Sex.FEMALE }} | ||
> | ||
Female | ||
</SearchLink> | ||
</p> | ||
|
||
<div className="panel-block"> | ||
<p className="control has-icons-left"> | ||
<input | ||
data-cy="NameFilter" | ||
type="search" | ||
className="input" | ||
placeholder="Search" | ||
value={query} | ||
onChange={event => { | ||
handleSetQuery(event.target.value); | ||
}} | ||
/> | ||
|
||
<span className="icon is-left"> | ||
<i className="fas fa-search" aria-hidden="true" /> | ||
</span> | ||
</p> | ||
</div> | ||
|
||
<div className="panel-block"> | ||
<div className="level is-flex-grow-1 is-mobile" data-cy="CenturyFilter"> | ||
<div className="level-left"> | ||
{CENTURIES.map(century => ( | ||
<SearchLink | ||
key={century} | ||
data-cy="century" | ||
params={{ | ||
centuries: getCenturiesParams(century), | ||
}} | ||
className={cn('button mr-1', { | ||
'is-info': centuries.includes(century), | ||
})} | ||
> | ||
{century} | ||
</SearchLink> | ||
))} | ||
</div> | ||
|
||
<div className="level-right ml-4"> | ||
<SearchLink | ||
data-cy="centuryALL" | ||
className={cn('button is-success', { | ||
'is-outlined': centuries.length !== 0, | ||
})} | ||
params={{ centuries: null }} | ||
> | ||
All | ||
</SearchLink> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div className="panel-block"> | ||
<SearchLink | ||
className={cn('button is-link is-outlined is-fullwidth', { | ||
'is-outlined': sex === null && !centuries.length && query === '', | ||
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. Create a variable for these conditions checks |
||
})} | ||
params={{ sex: null, centuries: null, query: null }} | ||
> | ||
Reset all filters | ||
</SearchLink> | ||
</div> | ||
</nav> | ||
); | ||
}; |
This file contains 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 @@ | ||
export * from './PeopleFilters'; |
This file was deleted.
Oops, something went wrong.
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.
You can create an
enum
forsex
values