Skip to content

Commit f97bae8

Browse files
committed
Merge branch 'main' into jamesdevubuntu
2 parents bc48193 + 82157fc commit f97bae8

File tree

2 files changed

+59
-18
lines changed

2 files changed

+59
-18
lines changed

frontend/src/components/Sidebar/Sidebar.module.css

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
align-items: center;
2424
border-radius: 8px;
2525
margin: 8px;
26+
27+
padding: 8px, 8px, 8px, 8px;
28+
box-shadow: 0px 0.6px 1.8px 0px #0000001C;
29+
box-shadow: 0px 3.2px 7.2px 0px #00000021;
30+
background-color: #F3F2F1;
31+
}
32+
33+
.navigationButtonActive {
34+
justify-content: center;
35+
align-items: center;
36+
border-radius: 8px;
37+
margin: 8px;
38+
39+
padding: 8px, 8px, 8px, 8px;
2640
}
2741

2842
.navigationButton:hover {
@@ -31,7 +45,17 @@
3145
}
3246

3347
.navigationButton > p {
34-
color: #0078D4;
3548
font-size: 12px;
3649
margin: 0;
50+
font-weight: 400;
51+
line-height: 16px;
52+
text-align: center;
3753
}
54+
55+
.navigationButtonActive > p {
56+
font-size: 12px;
57+
margin: 0;
58+
font-weight: 400;
59+
line-height: 16px;
60+
text-align: center;
61+
}

frontend/src/components/Sidebar/Sidebar.tsx

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,40 @@ import { Button, Avatar } from '@fluentui/react-components'
55
import styles from './Sidebar.module.css'
66
import { AppStateContext } from '../../state/AppProvider'
77
import { getUserInfo } from '../../api'
8-
import { useNavigate } from 'react-router-dom'
8+
import { useNavigate, useLocation } from 'react-router-dom'
99

1010
interface NavigationButtonProps {
1111
text: string
12-
icon: JSX.Element
12+
isActive: boolean
1313
onClick: () => void
1414
}
1515

16-
const NavigationButton = ({ text, icon, onClick }: NavigationButtonProps) => {
16+
const NavigationButton = ({ text, isActive, onClick }: NavigationButtonProps) => {
17+
const fontColor = isActive ? '#367AF6' : '#BEBBB8'
18+
const iconElements: { [key: string]: JSX.Element } = {
19+
'Browse': <News28Regular color={fontColor}/>,
20+
'Generate': <Book28Regular color={fontColor}/>,
21+
'Draft': <Notepad28Regular color={fontColor}/>
22+
}
23+
24+
const icon = iconElements[text]
25+
1726
return (
18-
<Stack
19-
onClick={onClick}
20-
className={styles.navigationButton}
21-
>
22-
<Button
23-
appearance="transparent"
24-
size="large"
25-
icon={icon}
26-
style={{ padding: '0' }}
27+
<Stack onClick={onClick} className={isActive ? styles.navigationButtonActive : styles.navigationButton}>
28+
<Button appearance="transparent"
29+
size="large"
30+
icon={icon}
31+
style={{ padding: '0' }}
2732
/>
28-
<p>{text}</p>
33+
<Text style={{ color: fontColor }}>{text}</Text>
2934
</Stack>
3035
)
3136
}
3237

3338
const Sidebar = (): JSX.Element => {
3439
const appStateContext = useContext(AppStateContext)
3540
const navigate = useNavigate()
41+
const location = useLocation();
3642
const [name, setName] = useState<string>("")
3743

3844
useEffect(() => {
@@ -46,17 +52,28 @@ const Sidebar = (): JSX.Element => {
4652
console.error('Error fetching user info: ', err)
4753
})
4854
}
49-
}, [])
55+
}, [])
56+
57+
// determine url from react-router-dom
58+
const determineView = () => {
59+
const url = location.pathname
60+
61+
const urlArr = url.split('/')
62+
const currentUrl = urlArr[urlArr.length - 1]
63+
return currentUrl
64+
}
65+
66+
const currentView = determineView()
5067

5168
return (
5269
<Stack className={styles.sidebarContainer}>
5370
<Stack horizontal className={styles.avatarContainer}>
5471
<Avatar color="colorful" name={name} />
5572
</Stack>
5673
<Stack className={styles.sidebarNavigationContainer}>
57-
<NavigationButton text={"Browse"} icon={<News28Regular color="#0078D4" />} onClick={() => { navigate("/chat") }} />
58-
<NavigationButton text={"Generate"} icon={<Book28Regular color="#0078D4" />} onClick={() => { navigate("/generate") }} />
59-
<NavigationButton text={"Draft"} icon={<Notepad28Regular color="#0078D4" />} onClick={() => { navigate("/draft") }} />
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") }} />
6077
</Stack>
6178
</Stack>
6279
)

0 commit comments

Comments
 (0)