1- import React , { useState } from 'react'
1+ import React , { useState , useEffect } from 'react'
22import { routes , RouteType } from '../../routes/routes'
33import styled from 'styled-components'
44import { useTranslation } from 'react-i18next'
55import { useRouter } from 'next/router'
6+ import Image from 'next/image'
67import { media } from '../../assets/styles/mixin'
78import SnsLink from './SnsLink'
9+ import PyconLogoWhite from '../../public/images/pyconkr_2022_logo_white.png'
10+ import Link from 'next/link'
811
912const Container = styled . nav `
13+ display: flex;
14+ justify-content: space-between;
15+ position: fixed;
16+ top: 0;
17+ left: 0;
18+ right: 0;
19+ z-index: 10;
20+ background: ${ ( props ) =>
21+ `linear-gradient(to bottom, ${ props . theme . colors . black_10 } , transparent)` } ;
1022 ${ media . mobile ( `
1123 display: none;
1224 ` ) }
13- ${ ( props ) => {
14- if ( props . isTransparent ) {
15- return `background: transparent;`
16- }
17- return `background-image: ${ props . theme . gradient } ;`
18- } }
25+ `
26+
27+ const HomeLink = styled . a `
28+ display: block;
29+ padding: 1.3rem;
1930`
2031
2132const List = styled . ul `
22- width: 1080px;
23- margin: 0 auto;
2433 display: flex;
2534 align-items: center;
2635 justify-content: space-between;
36+ margin-right: 1.5rem;
2737`
2838const ListItem = styled . li < { active ?: boolean } > `
29- padding: 1.3rem;
39+ padding: 0 1.3rem;
3040 font-weight: ${ ( props ) => ( props . active ? 'bold' : 'normal' ) } ;
3141 color: ${ ( props ) => props . theme . colors . white } ;
3242 position: relative;
3343`
34- export const Link = styled . a `
44+ export const BlockLink = styled ( Link ) `
3545 display: block;
3646 cursor: pointer;
3747`
@@ -69,7 +79,7 @@ export const SubMenuList = styled.ul`
6979 position: absolute;
7080 left: 0;
7181 right: 0;
72- top: 3.4rem ;
82+ top: 2.5rem ;
7383 width: 13rem;
7484 border: 1px solid rgba(0, 0, 0, 0.15);
7585 border-radius: 4px;
@@ -122,8 +132,20 @@ const NavBar = (props: NavProps) => {
122132 router . push ( router . asPath , undefined , { locale : lang } )
123133 }
124134
135+ useEffect ( ( ) => {
136+ setOpenedSubMenu ( '' )
137+ } , [ router . pathname ] )
138+
125139 return (
126140 < Container isTransparent = { isHome } >
141+ < HomeLink href = "/" >
142+ < Image
143+ src = { PyconLogoWhite }
144+ alt = "Pycon Korea 2022"
145+ width = { 140 }
146+ height = { 40 }
147+ />
148+ </ HomeLink >
127149 < List >
128150 { routes . map ( ( route , index ) => {
129151 return route . subMenu ? (
@@ -143,18 +165,18 @@ const NavBar = (props: NavProps) => {
143165 < SubMenuList >
144166 { route . subMenu . map ( ( subMenu , index ) => (
145167 < SubMenuListItem key = { index } >
146- < Link href = { getPath ( subMenu . path ) } >
168+ < BlockLink href = { getPath ( subMenu . path ) } >
147169 { t ( `pageTitle:${ subMenu . name } ` ) }
148- </ Link >
170+ </ BlockLink >
149171 </ SubMenuListItem >
150172 ) ) }
151173 </ SubMenuList >
152174 </ ListItem >
153175 ) : (
154176 < ListItem key = { index } active = { isActive ( route ) } >
155- < Link href = { getPath ( route . path ) } >
177+ < BlockLink href = { getPath ( route . path ) } >
156178 { t ( `pageTitle:${ route . name } ` ) }
157- </ Link >
179+ </ BlockLink >
158180 </ ListItem >
159181 )
160182 } ) }
0 commit comments