Skip to content

Commit 88bac07

Browse files
committed
Extract arrow components, navHeight
1 parent 8944e10 commit 88bac07

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

site/src/components/Navbar/Arrows.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react"
2+
import KeyboardArrowDown from "@material-ui/icons/KeyboardArrowDown"
3+
import KeyboardArrowUp from "@material-ui/icons/KeyboardArrowUp"
4+
import { fade, makeStyles, Theme } from "@material-ui/core/styles"
5+
6+
const useStyles = makeStyles((theme: Theme) => ({
7+
arrowIcon: {
8+
color: fade(theme.palette.primary.contrastText, 0.7),
9+
marginLeft: theme.spacing(1),
10+
width: 16,
11+
height: 16,
12+
},
13+
arrowIconUp: {
14+
color: theme.palette.primary.contrastText,
15+
},
16+
}))
17+
18+
export const OpenDropdown = () => {
19+
const styles = useStyles()
20+
return <KeyboardArrowDown className={styles.arrowIcon} />
21+
}
22+
23+
export const CloseDropdown = () => {
24+
const styles = useStyles()
25+
return <KeyboardArrowUp className={`${styles.arrowIcon} ${styles.arrowIconUp}`} />
26+
}

site/src/components/Navbar/UserDropdown.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { BorderedMenu } from "../BorderedMenu"
1212
import { LogoutIcon } from "../Icons"
1313
import { UserAvatar } from "../User"
1414
import { UserProfileCard } from "../User/UserProfileCard"
15+
import { CloseDropdown, OpenDropdown } from "./Arrows"
1516

1617
export interface UserDropdownProps {
1718
user: UserResponse
@@ -38,9 +39,9 @@ export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: U
3839
<UserAvatar username={user.username} />
3940
</Badge>
4041
{anchorEl ? (
41-
<KeyboardArrowUp className={`${styles.arrowIcon} ${styles.arrowIconUp}`} />
42+
<CloseDropdown />
4243
) : (
43-
<KeyboardArrowDown className={styles.arrowIcon} />
44+
<OpenDropdown />
4445
)}
4546
</div>
4647
</MenuItem>
@@ -94,15 +95,6 @@ export const useStyles = makeStyles((theme) => ({
9495
userInfo: {
9596
marginBottom: theme.spacing(1),
9697
},
97-
arrowIcon: {
98-
color: fade(theme.palette.primary.contrastText, 0.7),
99-
marginLeft: theme.spacing(1),
100-
width: 16,
101-
height: 16,
102-
},
103-
arrowIconUp: {
104-
color: theme.palette.primary.contrastText,
105-
},
10698

10799
menuItem: {
108100
height: 44,

site/src/theme/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export const MONOSPACE_FONT_FAMILY =
66
export const BODY_FONT_FAMILY = `"Inter", sans-serif`
77
export const lightButtonShadow = "0 2px 2px rgba(0, 23, 121, 0.08)"
88
export const emptyBoxShadow = "none"
9+
export const navHeight = 56

0 commit comments

Comments
 (0)