-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ProjectSettings] Refactor with Accordian component (#3233)
- Loading branch information
1 parent
7ef8502
commit 2fff26d
Showing
5 changed files
with
73 additions
and
63 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import { ExpandMore } from "@mui/icons-material"; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Grid, | ||
Typography, | ||
} from "@mui/material"; | ||
import { type ReactElement, type ReactNode } from "react"; | ||
|
||
interface BaseSettingsProps { | ||
/** Setting content (goes in `AccordionDetails`). */ | ||
body: ReactNode; | ||
/** Representative icon (goes first in `AccordionSummary` before title). */ | ||
icon: ReactNode; | ||
/** If maxWidth not specified, defaults to 700px. */ | ||
maxWidth?: string | number; | ||
/** Setting title (goes second in `AccordionSummary` after icon). */ | ||
title: ReactNode; | ||
} | ||
|
||
/** An accordion that holds a single project setting. */ | ||
export default function BaseSettings(props: BaseSettingsProps): ReactElement { | ||
return ( | ||
<Accordion | ||
defaultExpanded | ||
disableGutters | ||
sx={{ | ||
background: (theme) => theme.palette.background.default, | ||
border: (theme) => `1px solid ${theme.palette.divider}`, | ||
maxWidth: props.maxWidth || "700px", | ||
}} | ||
> | ||
<AccordionSummary expandIcon={<ExpandMore />}> | ||
<Grid container spacing={2} style={{ flexWrap: "nowrap" }}> | ||
<Grid item style={{ marginTop: 4, color: "grey" }}> | ||
{props.icon} | ||
</Grid> | ||
<Grid item> | ||
<Typography variant="h5">{props.title}</Typography> | ||
</Grid> | ||
</Grid> | ||
</AccordionSummary> | ||
<AccordionDetails>{props.body}</AccordionDetails> | ||
</Accordion> | ||
); | ||
} |
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
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