@@ -7,24 +7,42 @@ import { AppStateContext } from '../../state/AppProvider'
77import { getUserInfo } from '../../api'
88import { useNavigate , useLocation } from 'react-router-dom'
99
10+
11+ enum NavigationButtonStates {
12+ Active = 'active' ,
13+ Inactive = 'inactive' ,
14+ Disabled = 'disabled'
15+ }
16+
1017interface NavigationButtonProps {
1118 text : string
12- isActive : boolean
19+ buttonState : NavigationButtonStates
1320 onClick : ( ) => void
1421}
1522
16- const NavigationButton = ( { text, isActive, onClick } : NavigationButtonProps ) => {
17- const fontColor = isActive ? '#367AF6' : '#BEBBB8'
23+ const NavigationButton = ( { text, buttonState, onClick } : NavigationButtonProps ) => {
24+ const fontColor = {
25+ [ NavigationButtonStates . Active ] : '#367AF6' ,
26+ [ NavigationButtonStates . Inactive ] : '#BEBBB8' ,
27+ [ NavigationButtonStates . Disabled ] : '#797775'
28+ } [ buttonState ]
29+
1830 const iconElements : { [ key : string ] : JSX . Element } = {
1931 'Browse' : < News28Regular color = { fontColor } /> ,
2032 'Generate' : < Book28Regular color = { fontColor } /> ,
2133 'Draft' : < Notepad28Regular color = { fontColor } />
2234 }
2335
36+ const buttonStyle = {
37+ [ NavigationButtonStates . Active ] : styles . navigationButtonActive ,
38+ [ NavigationButtonStates . Inactive ] : styles . navigationButton ,
39+ [ NavigationButtonStates . Disabled ] : styles . navigationButtonDisabled
40+ } [ buttonState ]
41+
2442 const icon = iconElements [ text ]
2543
2644 return (
27- < Stack onClick = { onClick } className = { isActive ? styles . navigationButtonActive : styles . navigationButton } >
45+ < Stack onClick = { buttonState === NavigationButtonStates . Inactive ? onClick : ( ) => { } } className = { buttonStyle } >
2846 < Button appearance = "transparent"
2947 size = "large"
3048 icon = { icon }
@@ -65,15 +83,19 @@ const Sidebar = (): JSX.Element => {
6583
6684 const currentView = determineView ( )
6785
86+ // inactive, disabled, active
87+ var draftButtonState = NavigationButtonStates . Disabled
88+ if ( appStateContext ?. state . draftedDocument ) { draftButtonState = currentView === 'draft' ? NavigationButtonStates . Active : NavigationButtonStates . Inactive }
89+
6890 return (
6991 < Stack className = { styles . sidebarContainer } >
7092 < Stack horizontal className = { styles . avatarContainer } >
7193 < Avatar color = "colorful" name = { name } />
7294 </ Stack >
7395 < Stack className = { styles . sidebarNavigationContainer } >
74- < NavigationButton text = { "Browse" } isActive = { currentView === 'chat' } onClick = { ( ) => { navigate ( "/chat" ) } } />
75- < NavigationButton text = { "Generate" } isActive = { currentView === 'generate' } onClick = { ( ) => { navigate ( "/generate" ) } } />
76- < NavigationButton text = { "Draft" } isActive = { currentView === 'draft' } onClick = { ( ) => { navigate ( "/draft" ) } } />
96+ < NavigationButton text = { "Browse" } buttonState = { currentView === 'chat' ? NavigationButtonStates . Active : NavigationButtonStates . Inactive } onClick = { ( ) => { navigate ( "/chat" ) } } />
97+ < NavigationButton text = { "Generate" } buttonState = { currentView === 'generate' ? NavigationButtonStates . Active : NavigationButtonStates . Inactive } onClick = { ( ) => { navigate ( "/generate" ) } } />
98+ < NavigationButton text = { "Draft" } buttonState = { draftButtonState } onClick = { ( ) => { navigate ( "/draft" ) } } />
7799 </ Stack >
78100 </ Stack >
79101 )
0 commit comments