diff --git a/src/App.tsx b/src/App.tsx index adcb8594e..43e43cd4a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,17 @@ -import { PeoplePage } from './components/PeoplePage'; -import { Navbar } from './components/Navbar'; - +import { Outlet } from 'react-router-dom'; import './App.scss'; +import { Navbar } from './components/Navbar'; + export const App = () => { return (
- -
+
-

Home Page

-

Page not found

- +
-
+
); }; diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index c2aa20f1c..ae1b2c577 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,4 +1,13 @@ -export const Navbar = () => { +import React from 'react'; +import { NavLink } from 'react-router-dom'; +import cn from 'classnames'; + +export const Navbar: React.FC = () => { + const isActiveClass = ({ isActive }: { isActive: boolean }) => cn( + 'navbar-item', + { 'has-background-grey-lighter': isActive }, + ); + return ( diff --git a/src/components/PeopleFilters.tsx b/src/components/PeopleFilters.tsx index 2f1608bef..f246ab806 100644 --- a/src/components/PeopleFilters.tsx +++ b/src/components/PeopleFilters.tsx @@ -1,12 +1,61 @@ -export const PeopleFilters = () => { +import React, { ChangeEvent } from 'react'; +import classNames from 'classnames'; +import { useSearchParams } from 'react-router-dom'; + +import { SearchLink } from './SearchLink'; +import { getSearchWith } from '../utils/searchHelper'; + +const centuries = [16, 17, 18, 19, 20]; + +export const PeopleFilters: React.FC = () => { + const [searchParams, setSearchParams] = useSearchParams(); + + const params = { + query: searchParams.get('query') || '', + centuries: searchParams.getAll('century'), + sex: searchParams.get('sex'), + }; + + const handleQueryChange = (event: ChangeEvent) => { + const { value } = event.target; + + setSearchParams(getSearchWith(searchParams, { query: value || null })); + }; + + const renderSexFilter = (sex: string | null, label: string) => ( + + {label} + + ); + + const renderCenturyFilter = (century: number) => ( + century.toString() + !== paramsCentury) + : [...params.centuries, century.toString()], + }} + > + {century} + + ); + return (