Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5a7538

Browse files
refactor: Make the navbar wider (#5689)
1 parent a5073a8 commit f5a7538

File tree

2 files changed

+20
-51
lines changed

2 files changed

+20
-51
lines changed

site/src/components/NavbarView/NavbarView.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ describe("NavbarView", () => {
2020
process.env = env
2121
})
2222

23-
it("renders content", async () => {
24-
// When
25-
render(
26-
<NavbarView
27-
user={MockUser}
28-
onSignOut={noop}
29-
canViewAuditLog
30-
canViewDeployment
31-
/>,
32-
)
33-
34-
// Then
35-
await screen.findAllByText("Coder", { exact: false })
36-
})
37-
3823
it("workspaces nav link has the correct href", async () => {
3924
render(
4025
<NavbarView

site/src/components/NavbarView/NavbarView.tsx

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import List from "@material-ui/core/List"
44
import ListItem from "@material-ui/core/ListItem"
55
import { makeStyles } from "@material-ui/core/styles"
66
import MenuIcon from "@material-ui/icons/Menu"
7+
import { CoderIcon } from "components/Icons/CoderIcon"
78
import { useState } from "react"
89
import { NavLink, useLocation } from "react-router-dom"
910
import { colors } from "theme/colors"
1011
import * as TypesGen from "../../api/typesGenerated"
11-
import { containerWidth, navHeight, sidePadding } from "../../theme/constants"
12+
import { navHeight } from "../../theme/constants"
1213
import { combineClasses } from "../../util/combineClasses"
13-
import { Logo } from "../Icons/Logo"
1414
import { UserDropdown } from "../UserDropdown/UsersDropdown"
1515

1616
export interface NavbarViewProps {
@@ -114,11 +114,13 @@ export const NavbarView: React.FC<React.PropsWithChildren<NavbarViewProps>> = ({
114114
>
115115
<div className={styles.drawer}>
116116
<div className={styles.drawerHeader}>
117-
{logo_url ? (
118-
<img src={logo_url} alt="Custom Logo" />
119-
) : (
120-
<Logo fill="white" opacity={1} width={125} />
121-
)}
117+
<div className={combineClasses([styles.logo, styles.drawerLogo])}>
118+
{logo_url ? (
119+
<img src={logo_url} alt="Custom Logo" />
120+
) : (
121+
<CoderIcon />
122+
)}
123+
</div>
122124
</div>
123125
<NavItems
124126
canViewAuditLog={canViewAuditLog}
@@ -131,7 +133,7 @@ export const NavbarView: React.FC<React.PropsWithChildren<NavbarViewProps>> = ({
131133
{logo_url ? (
132134
<img src={logo_url} alt="Custom Logo" />
133135
) : (
134-
<Logo fill="white" opacity={1} width={125} />
136+
<CoderIcon fill="white" opacity={1} width={125} />
135137
)}
136138
</NavLink>
137139

@@ -159,20 +161,13 @@ const useStyles = makeStyles((theme) => ({
159161
root: {
160162
height: navHeight,
161163
background: theme.palette.background.paper,
162-
"@media (display-mode: standalone)": {
163-
borderTop: `1px solid ${theme.palette.divider}`,
164-
},
165164
borderBottom: `1px solid ${theme.palette.divider}`,
166-
transition: "margin 150ms ease",
167165
},
168166
wrapper: {
169167
position: "relative",
170168
display: "flex",
171169
justifyContent: "space-between",
172170
alignItems: "center",
173-
margin: "0 auto",
174-
maxWidth: containerWidth,
175-
padding: `0 ${sidePadding}px`,
176171
[theme.breakpoints.up("md")]: {
177172
justifyContent: "flex-start",
178173
},
@@ -195,6 +190,7 @@ const useStyles = makeStyles((theme) => ({
195190
},
196191
},
197192
profileButton: {
193+
paddingRight: theme.spacing(2),
198194
[theme.breakpoints.up("md")]: {
199195
marginLeft: "auto",
200196
},
@@ -208,13 +204,19 @@ const useStyles = makeStyles((theme) => ({
208204
alignItems: "center",
209205
display: "flex",
210206
height: navHeight,
211-
paddingRight: theme.spacing(4),
207+
color: theme.palette.text.primary,
208+
padding: theme.spacing(2),
212209
// svg is for the Coder logo, img is for custom images
213210
"& svg, & img": {
214-
width: 109,
215-
maxHeight: `calc(${navHeight}px)`,
211+
width: "100%",
212+
height: "100%",
213+
objectFit: "contain",
216214
},
217215
},
216+
drawerLogo: {
217+
padding: 0,
218+
maxHeight: theme.spacing(5),
219+
},
218220
title: {
219221
flex: 1,
220222
textAlign: "center",
@@ -238,26 +240,8 @@ const useStyles = makeStyles((theme) => ({
238240

239241
// NavLink adds this class when the current route matches.
240242
"&.active": {
241-
position: "relative",
242243
color: theme.palette.text.primary,
243244
fontWeight: "bold",
244-
245-
"&::before": {
246-
content: `" "`,
247-
left: 0,
248-
width: 2,
249-
height: "100%",
250-
background: theme.palette.secondary.dark,
251-
position: "absolute",
252-
253-
[theme.breakpoints.up("md")]: {
254-
bottom: 0,
255-
left: theme.spacing(3),
256-
width: `calc(100% - 2 * ${theme.spacing(3)}px)`,
257-
right: theme.spacing(3),
258-
height: 2,
259-
},
260-
},
261245
},
262246

263247
[theme.breakpoints.up("md")]: {

0 commit comments

Comments
 (0)