Skip to content

feat(site): Add Admin Dropdown menu #885

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 27 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Extract arrow components, navHeight
  • Loading branch information
presleyp committed Apr 6, 2022
commit 88bac07af51c8aeb0884d4d2dca77d4a101d1c9c
26 changes: 26 additions & 0 deletions site/src/components/Navbar/Arrows.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react"
import KeyboardArrowDown from "@material-ui/icons/KeyboardArrowDown"
import KeyboardArrowUp from "@material-ui/icons/KeyboardArrowUp"
import { fade, makeStyles, Theme } from "@material-ui/core/styles"

const useStyles = makeStyles((theme: Theme) => ({
arrowIcon: {
color: fade(theme.palette.primary.contrastText, 0.7),
marginLeft: theme.spacing(1),
width: 16,
height: 16,
},
arrowIconUp: {
color: theme.palette.primary.contrastText,
},
}))

export const OpenDropdown = () => {
const styles = useStyles()
return <KeyboardArrowDown className={styles.arrowIcon} />
}

export const CloseDropdown = () => {
const styles = useStyles()
return <KeyboardArrowUp className={`${styles.arrowIcon} ${styles.arrowIconUp}`} />
}
14 changes: 3 additions & 11 deletions site/src/components/Navbar/UserDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { BorderedMenu } from "../BorderedMenu"
import { LogoutIcon } from "../Icons"
import { UserAvatar } from "../User"
import { UserProfileCard } from "../User/UserProfileCard"
import { CloseDropdown, OpenDropdown } from "./Arrows"

export interface UserDropdownProps {
user: UserResponse
Expand All @@ -38,9 +39,9 @@ export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: U
<UserAvatar username={user.username} />
</Badge>
{anchorEl ? (
<KeyboardArrowUp className={`${styles.arrowIcon} ${styles.arrowIconUp}`} />
<CloseDropdown />
) : (
<KeyboardArrowDown className={styles.arrowIcon} />
<OpenDropdown />
)}
</div>
</MenuItem>
Expand Down Expand Up @@ -94,15 +95,6 @@ export const useStyles = makeStyles((theme) => ({
userInfo: {
marginBottom: theme.spacing(1),
},
arrowIcon: {
color: fade(theme.palette.primary.contrastText, 0.7),
marginLeft: theme.spacing(1),
width: 16,
height: 16,
},
arrowIconUp: {
color: theme.palette.primary.contrastText,
},

menuItem: {
height: 44,
Expand Down
1 change: 1 addition & 0 deletions site/src/theme/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export const MONOSPACE_FONT_FAMILY =
export const BODY_FONT_FAMILY = `"Inter", sans-serif`
export const lightButtonShadow = "0 2px 2px rgba(0, 23, 121, 0.08)"
export const emptyBoxShadow = "none"
export const navHeight = 56