-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Platform] Add QC warnings to study page (#588)
* DetailPopover component * polish sumstats and warnings * cleanup popover * not available
- Loading branch information
Showing
3 changed files
with
127 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ReactNode, useState } from "react"; | ||
import { Typography, Popover, Box } from "@mui/material"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faCaretDown, faCaretRight } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
type DetailPopoverProps = { | ||
title: string; | ||
children: ReactNode; | ||
popoverId?: string; | ||
}; | ||
|
||
export default function DetailPopover({ | ||
title, | ||
children, | ||
popoverId = "simple-popover", | ||
}: DetailPopoverProps) { | ||
|
||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null); | ||
|
||
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const open = Boolean(anchorEl); | ||
const id = open ? popoverId : undefined; | ||
|
||
return ( | ||
<> | ||
<Typography | ||
variant="subtitle2" | ||
component="span" | ||
sx={{ | ||
display: "inline", | ||
cursor: "pointer", | ||
mr: 0.5, | ||
fontWeight: 600, | ||
color: "secondary.main" | ||
}} | ||
aria-describedby={id} | ||
onClick={handleClick} | ||
> | ||
{title} | ||
{" "} | ||
<FontAwesomeIcon icon={open ? faCaretDown : faCaretRight} /> | ||
</Typography> | ||
<Popover | ||
id={id} | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={handleClose} | ||
elevation={1} | ||
disableScrollLock | ||
transitionDuration={0} | ||
anchorOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}} | ||
> | ||
<Box p={2}>{children}</Box> | ||
</Popover> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters