Skip to content

refactor: start using emotion for styling #9909

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 17 commits into from
Sep 29, 2023
Prev Previous commit
Next Next commit
one more!
  • Loading branch information
aslilac committed Sep 29, 2023
commit 33f89c32d32a8091b6956dc669fab2d5f0eaf965
42 changes: 17 additions & 25 deletions site/src/components/Dashboard/Navbar/UserDropdown/UserDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Badge from "@mui/material/Badge";
import MenuItem from "@mui/material/MenuItem";
import { makeStyles } from "@mui/styles";
import { useState, FC, PropsWithChildren, MouseEvent } from "react";
import { colors } from "theme/colors";
import * as TypesGen from "api/typesGenerated";
Expand All @@ -13,6 +12,7 @@ import {
import { UserAvatar } from "components/UserAvatar/UserAvatar";
import { UserDropdownContent } from "./UserDropdownContent";
import { BUTTON_SM_HEIGHT } from "theme/theme";
import { css } from "@emotion/react";

export interface UserDropdownProps {
user: TypesGen.User;
Expand All @@ -27,7 +27,6 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
supportLinks,
onSignOut,
}: UserDropdownProps) => {
const styles = useStyles();
const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>();

const handleDropdownClick = (ev: MouseEvent<HTMLLIElement>): void => {
Expand All @@ -40,11 +39,25 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
return (
<>
<MenuItem
className={styles.menuItem}
css={(theme) => css`
height: ${navHeight};
padding: ${theme.spacing(1.5, 0)};

&:hover {
background-color: transparent;
}
`}
onClick={handleDropdownClick}
data-testid="user-dropdown-trigger"
>
<div className={styles.inner}>
<div
css={{
display: "flex",
alignItems: "center",
minWidth: 0,
maxWidth: 300,
}}
>
<Badge overlap="circular">
<UserAvatar
sx={{
Expand Down Expand Up @@ -90,24 +103,3 @@ export const UserDropdown: FC<PropsWithChildren<UserDropdownProps>> = ({
</>
);
};

export const useStyles = makeStyles((theme) => ({
divider: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1),
},
inner: {
display: "flex",
alignItems: "center",
minWidth: 0,
maxWidth: 300,
},
menuItem: {
height: navHeight,
padding: theme.spacing(1.5, 0),

"&:hover": {
backgroundColor: "transparent",
},
},
}));