Skip to content

Commit

Permalink
fix QuickSelect style
Browse files Browse the repository at this point in the history
  • Loading branch information
tihuan committed Dec 14, 2022
1 parent 97f5258 commit 1bb7c05
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 2 additions & 0 deletions frontend/src/common/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,5 @@ themeOptions.colors.info = infoColors;
const appTheme = makeThemeOptions(themeOptions);

export const theme = createTheme(appTheme);

export const OFF_WHITE = "#f8f8f8";
5 changes: 3 additions & 2 deletions frontend/src/pages/docs/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import pathTool from "path";
import { Fragment, memo, useState } from "react";
import rehypeSlug from "rehype-slug";
import { noop } from "src/common/constants/utils";
import { OFF_WHITE } from "src/common/theme";
import EmbeddedGoogleSlides from "src/components/EmbeddedGoogleSlides";
import Layout from "src/components/Layout";
import { StyledDocsLayout } from "src/components/Layout/style";
Expand Down Expand Up @@ -263,7 +264,7 @@ interface Props {
}

const StyledLeftNav = styled.div`
background-color: #f8f8f8;
background-color: ${OFF_WHITE};
border-right: 1px solid #eaeaea;
grid-area: leftsidebar;
width: 100%;
Expand All @@ -278,7 +279,7 @@ const StyledLeftNav = styled.div`
::-webkit-scrollbar-thumb {
background-clip: padding-box;
border-right: 4px #f8f8f8 solid;
border-right: 4px ${OFF_WHITE} solid;
background-color: grey;
}
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Popper } from "@mui/material";
import { AutocompleteRenderOptionState } from "@mui/material/Autocomplete";
import {
AutocompleteCloseReason,
Expand Down Expand Up @@ -34,6 +33,7 @@ import {
ButtonWrapper,
StyledButtonText,
StyledMenuItem,
StyledPopper,
StyledSelectButton,
} from "./style";

Expand Down Expand Up @@ -198,15 +198,17 @@ export default function QuickSelect<
return;
}
const { nativeEvent } = e;

if (
(nativeEvent instanceof FocusEvent &&
nativeEvent.relatedTarget instanceof Element &&
nativeEvent.relatedTarget?.id !== `${dataTestId}-id`) ||
(nativeEvent instanceof FocusEvent &&
!(nativeEvent.relatedTarget instanceof Element)) ||
!(nativeEvent instanceof FocusEvent)
)
) {
setOpen(false);
}

setInput("");
};
Expand Down Expand Up @@ -267,7 +269,11 @@ export default function QuickSelect<
{text}
</StyledSelectButton>
</ButtonWrapper>
<Popper open={open} className={classes.popper} anchorEl={ref.current}>
<StyledPopper
open={open}
className={classes.popper}
anchorEl={ref.current}
>
<MenuSelect
open
PopperComponent={DropdownPopper}
Expand Down Expand Up @@ -302,7 +308,7 @@ export default function QuickSelect<
: "No options"
}
/>
</Popper>
</StyledPopper>
</>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import styled from "@emotion/styled";
import { autocompleteClasses, Popper } from "@mui/material";
import { Button, ButtonIcon, MenuItem } from "czifui";
import { OFF_WHITE } from "src/common/theme";

export const ButtonWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -29,3 +31,16 @@ export const StyledButtonText = styled.span`
export const StyledFixedSizeList = styled.span`
background-color: pink;
`;

export const StyledPopper = styled(Popper)`
/* Overwrite default MUI styles */
&& {
.${autocompleteClasses.focused}[aria-selected="true"] {
background-color: transparent;
}
.${autocompleteClasses.focused}:hover {
background-color: ${OFF_WHITE};
}
}
`;

0 comments on commit 1bb7c05

Please sign in to comment.