Skip to content

Commit 3e2ac49

Browse files
committed
style vertical nav differently
1 parent 5c79a39 commit 3e2ac49

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/client/components/NavBar/index.tsx

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,64 +85,66 @@ const NavBar = () => {
8585
}}
8686
>
8787
<Stack sx={{ paddingTop: 4, paddingRight: 4 }}>
88-
{!isDesktopDevice && <NavItems user={user} t={t} languages={languages} handleLanguageChange={handleLanguageChange} language={language} />}
88+
{!isDesktopDevice && <NavItems user={user} t={t} languages={languages} handleLanguageChange={handleLanguageChange} language={language} vertical />}
8989
</Stack>
9090
</Drawer>
9191
</>
9292
)
9393
}
94-
const NavItemButton = ({ children, to, path, current, icon }) => (
95-
<Button
96-
component={Link}
97-
to={to}
98-
size="small"
99-
variant="text"
100-
startIcon={icon}
101-
sx={{
102-
borderBottom: '2px solid',
103-
borderBottomLeftRadius: '0',
104-
borderBottomRightRadius: '0',
105-
borderBottomColor: matchPath({ path: path }, current) ? 'primary.main' : 'transparent',
106-
}}
107-
>
108-
{children}
109-
</Button>
110-
)
94+
const NavItemButton = ({ children, to, path, current, icon, vertical }) => {
95+
const borderSide = vertical ? 'Left' : 'Bottom'
96+
return (
97+
<Button
98+
component={Link}
99+
to={to}
100+
size="small"
101+
variant="text"
102+
startIcon={icon}
103+
sx={{
104+
[`border${borderSide}`]: '2px solid',
105+
borderRadius: '0',
106+
[`border${borderSide}Color`]: matchPath({ path: path }, current) ? 'primary.main' : 'transparent',
107+
}}
108+
>
109+
{children}
110+
</Button>
111+
)
112+
}
111113

112-
const NavItems = ({ user, t, languages, handleLanguageChange, language }) => {
114+
const NavItems = ({ user, t, languages, handleLanguageChange, language, vertical = false }) => {
113115
const anchorRef = useRef<HTMLButtonElement>(null)
114116
const { pathname } = useLocation()
115117
const [openLanguageSelect, setOpenLanguageSelect] = useState(false)
116118

117119
return (
118120
<>
119121
{user?.preferences?.chatVersion !== 2 && (
120-
<NavItemButton to="/v2" path="v2/*" current={pathname} icon={<GradeOutlined sx={styles.icon} />}>
122+
<NavItemButton to="/v2" path="v2/*" current={pathname} icon={<GradeOutlined sx={styles.icon} />} vertical={vertical}>
121123
{t('tryNew')}
122124
</NavItemButton>
123125
)}
124126
{user?.preferences?.chatVersion !== 1 && (
125-
<NavItemButton to="/v1" path="v1/*" current={pathname} icon={<GradeOutlined sx={styles.icon} />}>
127+
<NavItemButton to="/v1" path="v1/*" current={pathname} icon={<GradeOutlined sx={styles.icon} />} vertical={vertical}>
126128
{t('useOld')}
127129
</NavItemButton>
128130
)}
129131
{user.enrolledCourses.length > 0 && (
130-
<NavItemButton to="/chats" path="chats/*" current={pathname} icon={<BookmarksOutlined sx={styles.icon} />}>
132+
<NavItemButton to="/chats" path="chats/*" current={pathname} icon={<BookmarksOutlined sx={styles.icon} />} vertical={vertical}>
131133
{t('chats')}
132134
</NavItemButton>
133135
)}
134136
{user.ownCourses.length > 0 && (
135-
<NavItemButton to="/courses" path="courses/*" current={pathname} icon={<BookmarksOutlined sx={styles.icon} />}>
137+
<NavItemButton to="/courses" path="courses/*" current={pathname} icon={<BookmarksOutlined sx={styles.icon} />} vertical={vertical}>
136138
{t('courses')}
137139
</NavItemButton>
138140
)}
139141
{user.isStatsViewer && (
140-
<NavItemButton to="/statistics" path="statistics/*" current={pathname} icon={<AdminPanelSettingsOutlined sx={styles.icon} />}>
142+
<NavItemButton to="/statistics" path="statistics/*" current={pathname} icon={<AdminPanelSettingsOutlined sx={styles.icon} />} vertical={vertical}>
141143
{t('courseStats')}
142144
</NavItemButton>
143145
)}
144146
{user.isAdmin && (
145-
<NavItemButton to="/admin" path="admin/*" current={pathname} icon={<AdminPanelSettingsOutlined sx={styles.icon} />}>
147+
<NavItemButton to="/admin" path="admin/*" current={pathname} icon={<AdminPanelSettingsOutlined sx={styles.icon} />} vertical={vertical}>
146148
{t('admin')}
147149
</NavItemButton>
148150
)}

0 commit comments

Comments
 (0)