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

Skip to content

refactor: Make the navbar wider #5689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions site/src/components/NavbarView/NavbarView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ describe("NavbarView", () => {
process.env = env
})

it("renders content", async () => {
// When
render(
<NavbarView
user={MockUser}
onSignOut={noop}
canViewAuditLog
canViewDeployment
/>,
)

// Then
await screen.findAllByText("Coder", { exact: false })
})

it("workspaces nav link has the correct href", async () => {
render(
<NavbarView
Expand Down
56 changes: 20 additions & 36 deletions site/src/components/NavbarView/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import List from "@material-ui/core/List"
import ListItem from "@material-ui/core/ListItem"
import { makeStyles } from "@material-ui/core/styles"
import MenuIcon from "@material-ui/icons/Menu"
import { CoderIcon } from "components/Icons/CoderIcon"
import { useState } from "react"
import { NavLink, useLocation } from "react-router-dom"
import { colors } from "theme/colors"
import * as TypesGen from "../../api/typesGenerated"
import { containerWidth, navHeight, sidePadding } from "../../theme/constants"
import { navHeight } from "../../theme/constants"
import { combineClasses } from "../../util/combineClasses"
import { Logo } from "../Icons/Logo"
import { UserDropdown } from "../UserDropdown/UsersDropdown"

export interface NavbarViewProps {
Expand Down Expand Up @@ -114,11 +114,13 @@ export const NavbarView: React.FC<React.PropsWithChildren<NavbarViewProps>> = ({
>
<div className={styles.drawer}>
<div className={styles.drawerHeader}>
{logo_url ? (
<img src={logo_url} alt="Custom Logo" />
) : (
<Logo fill="white" opacity={1} width={125} />
)}
<div className={combineClasses([styles.logo, styles.drawerLogo])}>
{logo_url ? (
<img src={logo_url} alt="Custom Logo" />
) : (
<CoderIcon />
)}
</div>
</div>
<NavItems
canViewAuditLog={canViewAuditLog}
Expand All @@ -131,7 +133,7 @@ export const NavbarView: React.FC<React.PropsWithChildren<NavbarViewProps>> = ({
{logo_url ? (
<img src={logo_url} alt="Custom Logo" />
) : (
<Logo fill="white" opacity={1} width={125} />
<CoderIcon fill="white" opacity={1} width={125} />
)}
</NavLink>

Expand Down Expand Up @@ -159,20 +161,13 @@ const useStyles = makeStyles((theme) => ({
root: {
height: navHeight,
background: theme.palette.background.paper,
"@media (display-mode: standalone)": {
borderTop: `1px solid ${theme.palette.divider}`,
},
borderBottom: `1px solid ${theme.palette.divider}`,
transition: "margin 150ms ease",
},
wrapper: {
position: "relative",
display: "flex",
justifyContent: "space-between",
alignItems: "center",
margin: "0 auto",
maxWidth: containerWidth,
padding: `0 ${sidePadding}px`,
[theme.breakpoints.up("md")]: {
justifyContent: "flex-start",
},
Expand All @@ -195,6 +190,7 @@ const useStyles = makeStyles((theme) => ({
},
},
profileButton: {
paddingRight: theme.spacing(2),
[theme.breakpoints.up("md")]: {
marginLeft: "auto",
},
Expand All @@ -208,13 +204,19 @@ const useStyles = makeStyles((theme) => ({
alignItems: "center",
display: "flex",
height: navHeight,
paddingRight: theme.spacing(4),
color: theme.palette.text.primary,
padding: theme.spacing(2),
// svg is for the Coder logo, img is for custom images
"& svg, & img": {
width: 109,
maxHeight: `calc(${navHeight}px)`,
width: "100%",
height: "100%",
objectFit: "contain",
},
},
drawerLogo: {
padding: 0,
maxHeight: theme.spacing(5),
},
title: {
flex: 1,
textAlign: "center",
Expand All @@ -238,26 +240,8 @@ const useStyles = makeStyles((theme) => ({

// NavLink adds this class when the current route matches.
"&.active": {
position: "relative",
color: theme.palette.text.primary,
fontWeight: "bold",

"&::before": {
content: `" "`,
left: 0,
width: 2,
height: "100%",
background: theme.palette.secondary.dark,
position: "absolute",

[theme.breakpoints.up("md")]: {
bottom: 0,
left: theme.spacing(3),
width: `calc(100% - 2 * ${theme.spacing(3)}px)`,
right: theme.spacing(3),
height: 2,
},
},
},

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