1
1
import Head from 'next/head' ;
2
2
import Link from 'next/link' ;
3
+ import { useState } from 'react' ;
3
4
import { isEmpty } from 'lodash' ;
4
5
5
- import { BurgerIcon , TailwindIcon } from '../../icons' ;
6
+ import { BurgerIcon , TailwindIcon , Bag , User , Wishlist } from '../../icons' ;
6
7
7
8
const Header = ( { header } ) => {
8
9
9
10
const { headerMenuItems, siteDescription, siteLogoUrl, siteTitle, favicon } = header || { } ;
10
11
12
+ const [ isMenuVisible , setMenuVisibility ] = useState ( false ) ;
13
+
11
14
return (
12
15
< >
13
16
< Head >
@@ -22,7 +25,8 @@ const Header = ( { header } ) => {
22
25
< a >
23
26
{
24
27
siteLogoUrl ? (
25
- < img className = "mr-2" src = { siteLogoUrl } alt = { `${ siteTitle } logo` } width = "86"
28
+ < img className = "mr-2" src = { siteLogoUrl } alt = { `${ siteTitle } logo` }
29
+ width = "86"
26
30
height = "86" />
27
31
) : < TailwindIcon />
28
32
}
@@ -37,47 +41,41 @@ const Header = ( { header } ) => {
37
41
</ div >
38
42
< div className = "block lg:hidden" >
39
43
< button
44
+ onClick = { ( ) => setMenuVisibility ( ! isMenuVisible ) }
40
45
className = "flex items-center px-3 py-2 border rounded text-black border-black hover:text-black hover:border-black" >
41
- < BurgerIcon />
46
+ < BurgerIcon className = "fill-current h-3 w-3" />
42
47
</ button >
43
48
</ div >
44
- < div
45
- className = "h-0 w-full overflow-hidden lg:h-full flex-grow lg:flex lg:items-center lg:w-auto" >
49
+ < div className = { `${ isMenuVisible ? 'max-h-full' : 'h-0' } overflow-hidden w-full lg:h-full block flex-grow lg:flex lg:items-center lg:w-auto` } >
46
50
< div className = "text-sm font-medium uppercase lg:flex-grow" >
47
51
{ ! isEmpty ( headerMenuItems ) && headerMenuItems . length ? headerMenuItems . map ( menuItem => (
48
- < Link key = { menuItem ?. ID } href = { menuItem ?. url || '/' } >
52
+ < Link key = { menuItem ?. ID } href = { menuItem ?. url || '/' } >
49
53
< a className = "block mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10"
50
- dangerouslySetInnerHTML = { { __html : menuItem . title } } />
54
+ dangerouslySetInnerHTML = { { __html : menuItem . title } } />
51
55
</ Link >
52
56
) ) : null }
53
57
</ div >
54
58
< div className = "text-sm font-medium" >
55
59
< a href = "#responsive-header"
56
- className = "block mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10" >
57
- < svg xmlns = "http://www.w3.org/2000/svg" className = "hidden lg:block m-auto"
58
- fill = "none" viewBox = "0 0 24 24" width = "18" height = "auto" stroke = "currentColor" >
59
- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2"
60
- d = "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" > </ path >
61
- </ svg >
60
+ className = "flex mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10" >
61
+ < span className = "flex flex-row items-center lg:flex-col" >
62
+ < User className = "mr-1 lg:mr-0" />
62
63
Profile
64
+ </ span >
63
65
</ a >
64
66
< a href = "#responsive-header"
65
- className = "block mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10" >
66
- < svg xmlns = "http://www.w3.org/2000/svg" className = "hidden lg:block m-auto"
67
- fill = "none" viewBox = "0 0 24 24" width = "18" height = "auto" stroke = "currentColor" >
68
- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2"
69
- d = "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" > </ path >
70
- </ svg >
71
- Wishlist
67
+ className = "flex mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10" >
68
+ < span className = "flex flex-row items-center lg:flex-col" >
69
+ < Wishlist className = "mr-1 lg:mr-0" />
70
+ Wishlist
71
+ </ span >
72
72
</ a >
73
- < a className = "block mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10"
73
+ < a className = "flex mt-4 lg:inline-block lg:mt-0 text-black hover:text-black mr-10"
74
74
href = "/cart/" >
75
- < svg xmlns = "http://www.w3.org/2000/svg" className = "hidden lg:block m-auto"
76
- fill = "none" viewBox = "0 0 24 24" width = "18" height = "auto" stroke = "currentColor" >
77
- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2"
78
- d = "M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" > </ path >
79
- </ svg >
75
+ < span className = "flex flex-row items-center lg:flex-col" >
76
+ < Bag className = "mr-1 lg:mr-0" />
80
77
Bag
78
+ </ span >
81
79
</ a >
82
80
</ div >
83
81
</ div >
0 commit comments