66 Chevron ,
77 Share ,
88 ShareWhite ,
9+ GnbHomeActive ,
10+ GnbHomeInactive ,
11+ GnbHomeWhite ,
912} from '@/icons' ;
1013import { Text } from '../text' ;
1114import {
@@ -15,6 +18,7 @@ import {
1518 leftButtonWrapper ,
1619 rightButtonWrapper ,
1720 logoButton ,
21+ rightActions ,
1822} from './index.styles' ;
1923import { useRouter } from 'next/router' ;
2024import { useCurrentLocale } from '@/i18n/navigation' ;
@@ -33,6 +37,8 @@ interface Props {
3337 logo ?: LogoType ;
3438 onLogoClick ?: ( ) => void ;
3539 backgroundColor ?: BackgroundColor ;
40+ homeButton ?: boolean ;
41+ onHomeClick ?: ( ) => void ;
3642 rightButton ?: boolean ;
3743 rightButtonType ?: RightButtonType ;
3844 onRightButtonClick ?: ( ) => void ;
@@ -59,6 +65,12 @@ const RIGHT_BUTTON_ICON_MAP = {
5965 share : < Share width = "24px" height = "24px" /> ,
6066} as const ;
6167
68+ const HOME_BUTTON_ICON_MAP = {
69+ white : < GnbHomeWhite width = "24px" height = "24px" /> ,
70+ styled : < GnbHomeActive width = "24px" height = "24px" /> ,
71+ dark : < GnbHomeInactive width = "24px" height = "24px" /> ,
72+ } as const ;
73+
6274const LOGO_MAP = {
6375 light : < KommaSpaceLogoWhite width = "90px" height = "40px" /> ,
6476 dark : < KommaSpaceLogo width = "90px" height = "40px" /> ,
@@ -72,6 +84,8 @@ export function AppBar({
7284 leftButton = false ,
7385 buttonType = 'styled' ,
7486 backgroundColor = 'none' ,
87+ homeButton = false ,
88+ onHomeClick,
7589 rightButton = false ,
7690 rightButtonType = 'share' ,
7791 onRightButtonClick,
@@ -88,15 +102,28 @@ export function AppBar({
88102 router . push ( `/${ currentLocale } ${ ROUTES . HOME } ` ) ;
89103 } ;
90104
105+ const handleHomeClick = ( ) => {
106+ if ( onHomeClick ) {
107+ onHomeClick ( ) ;
108+ return ;
109+ }
110+ router . push ( `/${ currentLocale } ${ ROUTES . HOME } ` ) ;
111+ } ;
112+
91113 return (
92114 < header css = { wrapper ( { backgroundColor : BACKGROUND_COLOR_MAP [ backgroundColor ] } ) } >
93115 < div css = { contents } >
94116 { leftButton && (
95- < button onClick = { onBackClick } css = { leftButtonWrapper ( { buttonType } ) } >
117+ < button
118+ type = "button"
119+ onClick = { onBackClick }
120+ css = { leftButtonWrapper ( { buttonType } ) }
121+ aria-label = { t ( 'button.back' ) }
122+ >
96123 { BUTTON_ICON_MAP [ buttonType ] }
97124 </ button >
98125 ) }
99- < div css = { center } >
126+ < div css = { center ( { leftButton , homeButton , rightButton } ) } >
100127 { logo && (
101128 < button
102129 type = "button"
@@ -113,10 +140,29 @@ export function AppBar({
113140 </ Text >
114141 ) }
115142 </ div >
116- { rightButton && (
117- < button onClick = { onRightButtonClick } css = { rightButtonWrapper ( { buttonType } ) } >
118- { RIGHT_BUTTON_ICON_MAP [ rightButtonType ] }
119- </ button >
143+ { ( homeButton || rightButton ) && (
144+ < div css = { rightActions } >
145+ { homeButton && (
146+ < button
147+ type = "button"
148+ onClick = { handleHomeClick }
149+ css = { rightButtonWrapper ( { buttonType } ) }
150+ aria-label = { t ( 'button.home' ) }
151+ >
152+ { HOME_BUTTON_ICON_MAP [ buttonType ] }
153+ </ button >
154+ ) }
155+ { rightButton && (
156+ < button
157+ type = "button"
158+ onClick = { onRightButtonClick }
159+ css = { rightButtonWrapper ( { buttonType } ) }
160+ aria-label = { t ( 'button.share' ) }
161+ >
162+ { RIGHT_BUTTON_ICON_MAP [ rightButtonType ] }
163+ </ button >
164+ ) }
165+ </ div >
120166 ) }
121167 </ div >
122168 </ header >
0 commit comments