-
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.
With this PR the Menu will stay open in collapsed variant showing only the icons. **Note:** The chevron arrows which are currently cut of will be fixed in another PR. ## Screen recording https://github.com/vivid-planet/comet/assets/56400587/6034a7e2-3f25-4c6d-b4a8-2b17331574ec --------- Co-authored-by: Ricky James Smith <jamesricky@me.com> Co-authored-by: Johannes Obermair <48853629+johnnyomair@users.noreply.github.com> Co-authored-by: Thomas Dax <thomas.dax@vivid-planet.com>
- Loading branch information
1 parent
f06f4be
commit 02d33e2
Showing
6 changed files
with
148 additions
and
71 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,5 @@ | ||
--- | ||
"@comet/admin": minor | ||
--- | ||
|
||
Show icons in permanent menu even in closed state. |
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ lang/ | |
.pnp.* | ||
junit.xml | ||
.env.local | ||
/.idea/** |
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 |
---|---|---|
@@ -1,58 +1,66 @@ | ||
import { Theme } from "@mui/material"; | ||
import { createStyles } from "@mui/styles"; | ||
import { CSSObject, Drawer as MuiDrawer, DrawerProps, Theme } from "@mui/material"; | ||
import { styled } from "@mui/material/styles"; | ||
import { createStyles, StyledComponent } from "@mui/styles"; | ||
import { MUIStyledCommonProps } from "@mui/system"; | ||
import * as React from "react"; | ||
|
||
import { MenuProps } from "./Menu"; | ||
import { MasterLayoutContext } from "../MasterLayoutContext"; | ||
import { DEFAULT_DRAWER_WIDTH, DEFAULT_DRAWER_WIDTH_COLLAPSED, MenuProps } from "./Menu"; | ||
|
||
export type MenuClassKey = "drawer" | "permanent" | "temporary" | "open" | "closed"; | ||
const openedMixin = (theme: Theme, drawerWidth?: number): CSSObject => ({ | ||
width: drawerWidth ?? DEFAULT_DRAWER_WIDTH, | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
overflowX: "hidden", | ||
}); | ||
const closedMixin = (theme: Theme, drawerVariant: DrawerProps["variant"], drawerWidth?: number, drawerWidthCollapsed?: number): CSSObject => ({ | ||
width: drawerVariant === "temporary" ? drawerWidth ?? DEFAULT_DRAWER_WIDTH : drawerWidthCollapsed ?? DEFAULT_DRAWER_WIDTH_COLLAPSED, | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
overflowX: "hidden", | ||
}); | ||
export const Drawer: StyledComponent<DrawerProps & MUIStyledCommonProps<Theme> & Pick<MenuProps, "drawerWidth" | "drawerWidthCollapsed">> = styled( | ||
MuiDrawer, | ||
{ shouldForwardProp: (prop) => prop !== "drawerWidth" && prop !== "drawerWidthCollapsed" }, | ||
)<DrawerProps & MUIStyledCommonProps<Theme> & Pick<MenuProps, "drawerWidth" | "drawerWidthCollapsed">>( | ||
({ theme, open, variant, drawerWidth, drawerWidthCollapsed }) => { | ||
const { headerHeight } = React.useContext(MasterLayoutContext); | ||
|
||
export const styles = (theme: Theme) => | ||
createStyles<MenuClassKey, MenuProps>({ | ||
drawer: { | ||
"& [class*='MuiDrawer-paper']": { | ||
backgroundColor: "#fff", | ||
}, | ||
"& [class*='MuiPaper-root']": { | ||
flexGrow: 1, | ||
overflowX: "hidden", | ||
return { | ||
...(variant === "permanent" && { | ||
backgroundColor: theme.palette.common.white, | ||
flexShrink: 0, | ||
whiteSpace: "nowrap", | ||
boxSizing: "border-box", | ||
...(open ? openedMixin(theme, drawerWidth) : closedMixin(theme, variant, drawerWidth, drawerWidthCollapsed)), | ||
}), | ||
"& .MuiDrawer-paper": { | ||
backgroundColor: theme.palette.common.white, | ||
...(variant === "permanent" && { | ||
top: headerHeight, | ||
height: `calc(100% - ${headerHeight}px)`, | ||
}), | ||
...(open ? openedMixin(theme, drawerWidth) : closedMixin(theme, variant, drawerWidth, drawerWidthCollapsed)), | ||
}, | ||
"& [class*='MuiDrawer-paperAnchorLeft']": { | ||
"& .MuiDrawer-paperAnchorLeft": { | ||
borderRight: "none", | ||
}, | ||
"&$permanent": { | ||
"&$open": { | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
"& [class*='MuiPaper-root']": { | ||
transition: theme.transitions.create("margin", { | ||
easing: theme.transitions.easing.sharp, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
}, | ||
}, | ||
"&$closed": { | ||
transition: theme.transitions.create("width", { | ||
easing: theme.transitions.easing.easeOut, | ||
duration: theme.transitions.duration.leavingScreen, | ||
}), | ||
"& [class*='MuiPaper-root']": { | ||
transition: theme.transitions.create("margin", { | ||
easing: theme.transitions.easing.easeOut, | ||
duration: theme.transitions.duration.enteringScreen, | ||
}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}, | ||
); | ||
|
||
export type MenuClassKey = "drawer" | "permanent" | "temporary" | "open" | "closed"; | ||
|
||
export const styles = () => { | ||
return createStyles<MenuClassKey, MenuProps>({ | ||
drawer: {}, | ||
permanent: {}, | ||
temporary: {}, | ||
open: {}, | ||
closed: { | ||
"&$permanent": { | ||
"& [class*='MuiPaper']": { | ||
boxShadow: "none", | ||
}, | ||
}, | ||
}, | ||
closed: {}, | ||
}); | ||
}; |
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