mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-06 01:15:28 +02:00
feat: smart sticky expand/hide button (#7201)
This commit is contained in:
parent
ab3cbcfa56
commit
8d898c2ac9
@ -41,9 +41,6 @@ export const StretchContainer = styled(Box)(({ theme }) => ({
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
padding: theme.spacing(2),
|
||||
alignSelf: 'stretch',
|
||||
}));
|
||||
|
||||
export const ScreenHeightBox = styled(Box)(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: theme.spacing(3),
|
||||
@ -64,7 +61,6 @@ export const NavigationSidebar = () => {
|
||||
|
||||
return (
|
||||
<StretchContainer>
|
||||
<ScreenHeightBox>
|
||||
<PrimaryNavigationList
|
||||
mode={mode}
|
||||
onClick={setActiveItem}
|
||||
@ -126,7 +122,6 @@ export const NavigationSidebar = () => {
|
||||
setMode(mode === 'full' ? 'mini' : 'full');
|
||||
}}
|
||||
/>
|
||||
</ScreenHeightBox>
|
||||
</StretchContainer>
|
||||
);
|
||||
};
|
||||
|
@ -5,15 +5,24 @@ import HideIcon from '@mui/icons-material/KeyboardDoubleArrowLeft';
|
||||
import ExpandIcon from '@mui/icons-material/KeyboardDoubleArrowRight';
|
||||
import SettingsIcon from '@mui/icons-material/Settings';
|
||||
|
||||
const ShowHideWrapper = styled(Box, {
|
||||
const ShowHideRow = styled(Box, {
|
||||
shouldForwardProp: (prop) => prop !== 'mode',
|
||||
})<{ mode: NavigationMode }>(({ theme, mode }) => ({
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
padding: theme.spacing(2, 1, 0, mode === 'mini' ? 1.5 : 2),
|
||||
marginTop: 'auto',
|
||||
cursor: 'pointer',
|
||||
position: 'sticky',
|
||||
bottom: theme.spacing(2),
|
||||
width: '100%',
|
||||
}));
|
||||
|
||||
// This component is needed when the sticky item could overlap with nav items. You can replicate it on a short screen.
|
||||
const ShowHideContainer = styled(Box)(({ theme }) => ({
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
alignItems: 'end',
|
||||
}));
|
||||
|
||||
export const ShowHide: FC<{ mode: NavigationMode; onChange: () => void }> = ({
|
||||
@ -21,7 +30,8 @@ export const ShowHide: FC<{ mode: NavigationMode; onChange: () => void }> = ({
|
||||
onChange,
|
||||
}) => {
|
||||
return (
|
||||
<ShowHideWrapper onClick={onChange} mode={mode}>
|
||||
<ShowHideContainer>
|
||||
<ShowHideRow onClick={onChange} mode={mode}>
|
||||
{mode === 'full' && (
|
||||
<Box
|
||||
sx={(theme) => ({
|
||||
@ -44,7 +54,8 @@ export const ShowHide: FC<{ mode: NavigationMode; onChange: () => void }> = ({
|
||||
</Tooltip>
|
||||
)}
|
||||
</IconButton>
|
||||
</ShowHideWrapper>
|
||||
</ShowHideRow>
|
||||
</ShowHideContainer>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user