File tree Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { useRef } from "react" ;
2
2
import { Link } from "react-router" ;
3
- import { IconBars3 } from "." ;
3
+ import { IconBars3 , IconGlobe } from "." ;
4
+ import { useStore } from "../store" ;
4
5
5
6
export function Header ( ) {
6
7
const drawerRef = useRef < HTMLInputElement > ( null ) ;
7
8
9
+ const setMessage = useStore ( ( s ) => s . setMessage ) ;
10
+
8
11
const closeDrawer = ( ) => {
9
12
if ( drawerRef . current ) {
10
13
drawerRef . current . checked = false ;
11
14
}
12
15
} ;
13
16
17
+ const handleLink = ( ) => {
18
+ closeDrawer ( ) ;
19
+ setMessage ( "info" , "" ) ; // clear any messages
20
+ } ;
21
+
22
+ // SideBar nav item
23
+ const NavItem = ( {
24
+ to,
25
+ icon,
26
+ label,
27
+ } : {
28
+ to : string ;
29
+ icon : JSX . Element ;
30
+ label : string ;
31
+ } ) => (
32
+ < li >
33
+ < Link to = { to } onClick = { handleLink } >
34
+ < span className = "text-primary" > { icon } </ span >
35
+ { label }
36
+ </ Link >
37
+ </ li >
38
+ ) ;
39
+
14
40
// https://v5.daisyui.com/components/drawer/#drawer-that-opens-from-right-side-of-page
15
41
const SideBar = ( ) => (
16
42
< div className = "drawer" >
@@ -36,11 +62,7 @@ export function Header() {
36
62
className = "drawer-overlay"
37
63
> </ label >
38
64
< ul className = "menu bg-base-200 text-base-content min-h-full w-40 p-4" >
39
- < li >
40
- < Link to = "/" onClick = { closeDrawer } >
41
- Networks
42
- </ Link >
43
- </ li >
65
+ < NavItem to = "/" label = "Networks" icon = { < IconGlobe /> } />
44
66
</ ul >
45
67
</ div >
46
68
</ div >
You can’t perform that action at this time.
0 commit comments