-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a GroupSection component which can be used in the Menu component. --------- Co-authored-by: Ricky James Smith <jamesricky@me.com> Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com>
- Loading branch information
1 parent
47eb81c
commit f06f4be
Showing
6 changed files
with
162 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
"@comet/admin": minor | ||
--- | ||
|
||
Add `MenuItemGroup` component to group menu items | ||
|
||
**Example:** | ||
|
||
```tsx | ||
<MenuItemGroup title="Some item group title"> | ||
<MenuItemRouterLink primary="Menu item 1" icon={<Settings />} to="/menu-item-1" /> | ||
<MenuItemRouterLink primary="Menu item 2" icon={<Settings />} to="/menu-item-2" /> | ||
<MenuItemRouterLink primary="Menu item 3" icon={<Settings />} to="/menu-item-3" /> | ||
{ /* Some more menu items... */ } | ||
</MenuItemGroup> | ||
``` |
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
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,51 @@ | ||
import { Box, ComponentsOverrides, Theme, Typography } from "@mui/material"; | ||
import { createStyles, WithStyles, withStyles } from "@mui/styles"; | ||
import * as React from "react"; | ||
|
||
export type MenuItemGroupClassKey = "root" | "title"; | ||
|
||
const styles = (theme: Theme) => | ||
createStyles<MenuItemGroupClassKey, MenuItemGroupProps>({ | ||
root: { marginTop: theme.spacing(8) }, | ||
title: { | ||
fontWeight: theme.typography.fontWeightBold, | ||
fontSize: 14, | ||
lineHeight: "20px", | ||
borderBottom: `1px solid ${theme.palette.grey[50]}`, | ||
padding: theme.spacing(2, 4), | ||
}, | ||
}); | ||
|
||
export interface MenuItemGroupProps { | ||
title?: React.ReactNode; | ||
} | ||
|
||
const ItemGroup: React.FC<React.PropsWithChildren<WithStyles<typeof styles> & MenuItemGroupProps>> = ({ title, children, classes }) => { | ||
return ( | ||
<Box className={classes.root}> | ||
<Typography className={classes.title} variant="h3"> | ||
{title} | ||
</Typography> | ||
{children} | ||
</Box> | ||
); | ||
}; | ||
|
||
export const MenuItemGroup = withStyles(styles, { name: "CometAdminMenuItemGroup" })(ItemGroup); | ||
|
||
declare module "@mui/material/styles" { | ||
interface ComponentsPropsList { | ||
CometAdminMenuItemGroup: MenuItemGroupProps; | ||
} | ||
|
||
interface ComponentNameToClassKey { | ||
CometAdminMenuItemGroup: MenuItemGroupClassKey; | ||
} | ||
|
||
interface Components { | ||
CometAdminMenuItemGroup?: { | ||
defaultProps?: ComponentsPropsList["CometAdminMenuItemGroup"]; | ||
styleOverrides?: ComponentsOverrides<Theme>["CometAdminMenuItemGroup"]; | ||
}; | ||
} | ||
} |
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