Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Improve scroll bars #2715

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions frontend/src/components/App/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,27 @@ export default function Layout({}: LayoutProps) {
>
{t('Skip to main content')}
</Link>
<Box sx={{ display: 'flex', [theme.breakpoints.down('sm')]: { display: 'block' } }}>
<Box
sx={{
display: 'flex',
overflow: 'auto',
paddingTop: { sm: '64px', xs: '72px' },
height: '100vh',
}}
>
<VersionDialog />
<CssBaseline enableColorScheme />
<TopBar />
<Sidebar />
<Main id="main" sx={{ flexGrow: 1, marginLeft: 'initial' }}>
<Main
id="main"
sx={{
flexGrow: 1,
marginLeft: 'initial',
overflow: 'auto',
[theme.breakpoints.down('sm')]: { marginTop: { xs: '-12px', sm: '-8px' } },
}}
>
{allClusters &&
!!clusterInURL &&
!Object.keys(allClusters).includes(getCluster() || '') ? (
Expand All @@ -217,7 +232,7 @@ export default function Layout({}: LayoutProps) {
)}
<AlertNotification />
<Box>
<Div sx={theme.mixins.toolbar} />
<Div />
<Container {...containerProps}>
<NavigationTabs />
{arePluginsLoaded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation1 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-1nczbvg-MuiPaper-root-MuiAppBar-root"
>
<div
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-b3zdwt-MuiToolbar-root"
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1g5gxk7-MuiToolbar-root"
>
<svg
fill="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation1 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-1nczbvg-MuiPaper-root-MuiAppBar-root"
>
<div
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-b3zdwt-MuiToolbar-root"
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1g5gxk7-MuiToolbar-root"
>
<svg
fill="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation1 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-1nczbvg-MuiPaper-root-MuiAppBar-root"
>
<div
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-b3zdwt-MuiToolbar-root"
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1g5gxk7-MuiToolbar-root"
>
<svg
fill="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation1 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-1nczbvg-MuiPaper-root-MuiAppBar-root"
>
<div
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-b3zdwt-MuiToolbar-root"
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1g5gxk7-MuiToolbar-root"
>
<svg
fill="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation1 MuiAppBar-root MuiAppBar-colorPrimary MuiAppBar-positionFixed mui-fixed css-1nczbvg-MuiPaper-root-MuiAppBar-root"
>
<div
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-b3zdwt-MuiToolbar-root"
class="MuiToolbar-root MuiToolbar-gutters MuiToolbar-regular css-1g5gxk7-MuiToolbar-root"
>
<svg
fill="none"
Expand Down
33 changes: 23 additions & 10 deletions frontend/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export const PureSidebar = memo(
linkArea,
}: PureSidebarProps) => {
const { t } = useTranslation();
const listContainerRef = React.useRef<HTMLDivElement | null>(null);
const [isOverflowing, setIsOverflowing] = React.useState(false);
const adjustedDrawerWidthClosed = isOverflowing ? 84 : 72;
const temporarySideBarOpen = open === true && isTemporaryDrawer && openUserSelected === true;

// The large sidebar does not open in medium view (600-960px).
Expand Down Expand Up @@ -276,8 +279,10 @@ export const PureSidebar = memo(
})}
/>
<Grid
ref={listContainerRef}
sx={{
height: '100%',
overflowY: 'auto',
}}
container
direction="column"
Expand Down Expand Up @@ -336,6 +341,23 @@ export const PureSidebar = memo(
}
: {};

React.useEffect(() => {
const el = listContainerRef.current;
if (!el) {
return;
}

const observer = new ResizeObserver(() => {
setIsOverflowing(el.scrollHeight > el.clientHeight);
});

observer.observe(el);

setIsOverflowing(el.scrollHeight > el.clientHeight);

return () => observer.disconnect();
}, [items]);

return (
<Box component="nav" aria-label={t('translation|Navigation')}>
<Drawer
Expand All @@ -362,16 +384,7 @@ export const PureSidebar = memo(
duration: theme.transitions.duration.leavingScreen,
}),
overflowX: 'hidden',
width: '56px',
[theme.breakpoints.down('xs')]: {
background: 'initial',
},
[theme.breakpoints.down('sm')]: {
width: theme.spacing(0),
},
[theme.breakpoints.up('sm')]: {
width: '72px',
},
width: `${adjustedDrawerWidthClosed}px`,
background: theme.palette.sidebarBg,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
class="MuiBox-root css-0"
>
<div
class="MuiDrawer-root MuiDrawer-docked css-1p9jtjb-MuiDrawer-docked"
class="MuiDrawer-root MuiDrawer-docked css-1g0cdoa-MuiDrawer-docked"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft css-12i7wg6-MuiPaper-root-MuiDrawer-paper"
>
<div
class="MuiBox-root css-6r4z7i"
class="MuiBox-root css-dak3i4"
/>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-tf9pd2-MuiGrid-root"
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-opqjvv-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft css-12i7wg6-MuiPaper-root-MuiDrawer-paper"
>
<div
class="MuiBox-root css-6r4z7i"
class="MuiBox-root css-dak3i4"
/>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-tf9pd2-MuiGrid-root"
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-opqjvv-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
class="MuiBox-root css-0"
>
<div
class="MuiDrawer-root MuiDrawer-docked css-1p9jtjb-MuiDrawer-docked"
class="MuiDrawer-root MuiDrawer-docked css-1g0cdoa-MuiDrawer-docked"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft css-12i7wg6-MuiPaper-root-MuiDrawer-paper"
>
<div
class="MuiBox-root css-6r4z7i"
class="MuiBox-root css-dak3i4"
/>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-tf9pd2-MuiGrid-root"
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-opqjvv-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft css-12i7wg6-MuiPaper-root-MuiDrawer-paper"
>
<div
class="MuiBox-root css-6r4z7i"
class="MuiBox-root css-dak3i4"
/>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-tf9pd2-MuiGrid-root"
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-opqjvv-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
class="MuiPaper-root MuiPaper-elevation MuiPaper-elevation0 MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft css-12i7wg6-MuiPaper-root-MuiDrawer-paper"
>
<div
class="MuiBox-root css-6r4z7i"
class="MuiBox-root css-dak3i4"
/>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-tf9pd2-MuiGrid-root"
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-column MuiGrid-wrap-xs-nowrap css-opqjvv-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item css-13i4rnv-MuiGrid-root"
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const commonRules = {
xl: 1920,
},
},
mixins: {
toolbar: {
minHeight: 64,
'@media (max-width:600px)': {
minHeight: 60,
},
},
},
palette: {
primary: {
contrastText: '#fff',
Expand Down
Loading