File tree Expand file tree Collapse file tree 5 files changed +16
-14
lines changed Expand file tree Collapse file tree 5 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ My personal remaining TODO.
6
6
- In the ReadMe, explain what changes might be needed if this app were intended to be run in a "concurrent" environment.
7
7
8
8
## Bonus:
9
- - * Change debug navbar into breadcrumb that remembers search term while viewing Pokémon (and update the readme to reflect this (#Design))*
10
9
- * When visiting a search page, add it to the search history. (useful for when people visit from a bookmark)*
11
10
- * Make it so that pressing the down arrow while the search history dropdown is open will move the focus into the dropdown*
12
11
- * Allow the user to remove history entries with an "X" button, like exists in the searchbar*
Original file line number Diff line number Diff line change 1
- import { FunctionComponent } from 'react' ;
1
+ import { useAppSelector } from '@/redux/hooks.ts' ;
2
+ import { Fragment , FunctionComponent } from 'react' ;
2
3
import { Link , useLocation } from 'react-router-dom' ;
3
4
4
5
////////////////////////////////////////////////////////////////////////////////
5
6
//TODO: Make `Nav` into a breadcrumb, rather than just a tool for debugging.
6
7
export const Nav : FunctionComponent = ( ) => {
7
8
const location = useLocation ( ) ;
9
+ const history = useAppSelector ( state => state . search . history ) ;
8
10
9
11
// // // // // // // // // // // // // // // // // // // //
10
12
const entries : Array < {
11
13
name : string ,
12
14
path : string ,
15
+ args ?: string ,
13
16
} > = [ {
14
17
name : 'Home' ,
15
18
path : '/' ,
16
19
} , {
17
20
name : 'Search' ,
18
21
path : '/search' ,
22
+ args : `?q=${ history [ 0 ] } ` ,
19
23
} , {
20
24
name : 'Pokémon' ,
21
25
path : '/pokemon' ,
22
- } , {
23
- name : '404' ,
24
- path : '/error' ,
25
26
} ] ;
26
27
27
28
// // // // // // // // // // // // // // // // // // // //
28
29
return (
29
- < nav style = { { display : 'none' } } >
30
+ < nav >
30
31
< ul > {
31
- entries . map ( ( entry , index ) =>
32
- < li key = { index } > {
33
- entry . path !== location . pathname
34
- ? < Link to = { entry . path } > { entry . name } </ Link >
35
- : < a className = "activated" > { entry . name } </ a >
36
- } </ li >
37
- )
32
+ entries . map ( ( entry , index ) => < Fragment key = { index } > {
33
+ entry . path !== location . pathname
34
+ ? < li > < Link to = { entry . path + ( entry . args ?? '' ) } > { entry . name } </ Link > </ li >
35
+ : < li className = "hide-following" > < a className = "activated" > { entry . name } </ a > </ li >
36
+ } </ Fragment > )
38
37
} </ ul >
39
38
</ nav >
40
39
) ;
Original file line number Diff line number Diff line change 93
93
display : block ;
94
94
@include button ($color-nav-background );
95
95
border-radius : unset ;
96
+
96
97
}
97
98
}
98
99
}
Original file line number Diff line number Diff line change 4
4
.error {
5
5
color : $color-error ;
6
6
}
7
+ .hide-following ~* {
8
+ display : none ;
9
+ }
7
10
.raw-data {
8
11
font-family : $font-mono ;
9
12
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " pokedex" ,
3
- "version" : " 1.1.1 " ,
3
+ "version" : " 1.2.0 " ,
4
4
"license" : " LAGPL-3.0-or-later" ,
5
5
"description" : " A web application that displays data on Pokémon®. Not affiliated with Nintendo®." ,
6
6
"keywords" : [
You can’t perform that action at this time.
0 commit comments