Skip to content

Commit a24b5f6

Browse files
committed
Fix admin sidebar scrolling and visual inconsistencies
What: 1. Removes much of the AI styling changes. 2. Changes the custom admin theme to inherit properties from the default theme. 3. Removes the sidebar text color override for mobile. 4. Fixes the issue with the sliding section of the light theme color at the top of the sidebar and ensures the dark theme color extends to the bottom of the sidebar (regardless of browser zoom). 5. Restores the appBar hiding functionality for desktop/large screens. 6. Fixes the issues with the sidebar scrolling by removing the scrolling wrapper and instead overriding the default react-admin sidebar with a custom version that has scrolling indicators that display whenever there is hidden content (either above or below the shown content). Why: 1. The AI styling changes seem to be unnecessary and to have contributed to the visual inconsistencies/glitches. 2. Custom themes inheriting properties from the default theme is recommended in the React Admin documentation[1]. 3. The sidebar text color override for mobile is no longer needed (and causes readability issues) now that the background color is the same for both mobile and desktop. 4. It looks better to have the sidebar be a single consistent color from top to bottom. 5. This keeps the behavior of the appBar the same as it was before the Update storybook PR (Hubs-Foundation#6563) 6. There were two scrolling areas, which caused the scrolling to appear erratic, and the scrolling indicators weren't updated live (live updates ensures that people are always aware when the content can be scrolled and in which direction). [1] https://marmelab.com/react-admin/doc/3.19/Theming.html#sidebar-customization
1 parent a21f8d4 commit a24b5f6

File tree

4 files changed

+311
-331
lines changed

4 files changed

+311
-331
lines changed

admin/src/admin.js

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "./utils/ita";
1616
import { detectIdle } from "./utils/idle-detector";
1717
import { connectToReticulum } from "hubs/src/utils/phoenix-utils";
18-
import { Admin, Layout, Resource, Notification } from "react-admin";
18+
import { AppBar, Admin, Layout, Resource, Notification, defaultTheme, Sidebar } from "react-admin";
1919
import { postgrestClient, postgrestAuthenticatior } from "./utils/postgrest-data-provider";
2020
import { AdminMenu } from "./react-components/admin-menu";
2121
import { SceneList, SceneEdit } from "./react-components/scenes";
@@ -34,9 +34,12 @@ import { ContentCDN } from "./react-components/content-cdn";
3434
import { ImportContent } from "./react-components/import-content";
3535
import { AutoEndSessionDialog } from "./react-components/auto-end-session-dialog";
3636
import registerTelemetry from "hubs/src/telemetry";
37-
import { createTheme } from "@material-ui/core/styles";
37+
import { createTheme, withStyles } from "@material-ui/core/styles";
3838
import { UnauthorizedPage } from "./react-components/unauthorized";
3939
import { store } from "hubs/src/utils/store-instance";
40+
import classNames from "classnames";
41+
import KeyboardArrowUpIcon from "@material-ui/icons/KeyboardArrowUp";
42+
import KeyboardArrowDownIcon from "@material-ui/icons/KeyboardArrowDown";
4043

4144
const qs = new URLSearchParams(location.hash.split("?")[1]);
4245

@@ -72,24 +75,13 @@ const CustomNotification = props => {
7275
let itaSchemas;
7376

7477
const theme = createTheme({
78+
...defaultTheme,
7579
components: {
7680
MuiDrawer: {
7781
styleOverrides: {
7882
paper: {
7983
backgroundColor: "#222222",
80-
minHeight: "100vh",
81-
position: "sticky",
82-
top: 0,
83-
overflowX: "hidden"
84-
}
85-
}
86-
},
87-
MuiAppBar: {
88-
styleOverrides: {
89-
root: {
90-
position: "sticky",
91-
top: 0,
92-
zIndex: 1100
84+
minHeight: "100vh"
9385
}
9486
}
9587
}
@@ -261,6 +253,58 @@ const mountUI = async (retPhxChannel, customRoutes, layout) => {
261253
</IntlProvider>
262254
);
263255
};
256+
const HiddenAppBar = withStyles({
257+
hideOnDesktop: {
258+
"@media (min-width: 768px) and (min-height: 480px)": {
259+
display: "none"
260+
}
261+
}
262+
})(props => {
263+
const { classes, ...other } = props;
264+
return <AppBar {...other} className={classes.hideOnDesktop} />;
265+
});
266+
267+
const AdminSidebar = withStyles({
268+
sidebarScrollingIndicator: {
269+
position: "sticky",
270+
display: "none",
271+
alignItems: "center",
272+
justifyContent: "center",
273+
color: "#aaaaaa",
274+
pointerEvents: "none",
275+
zIndex: 9999,
276+
transition: "opacity 0.5s ease",
277+
opacity: 1
278+
},
279+
topIndicator: {
280+
top: 0,
281+
background: "linear-gradient(to bottom, rgba(0, 0, 0, 1.0) 0%, rgba(34, 34, 34, 0.7) 70%, transparent 100%)"
282+
},
283+
bottomIndicator: {
284+
bottom: 0,
285+
background: "linear-gradient(to top, rgba(0, 0, 0, 1.0) 0%, rgba(34, 34, 34, 0.7) 70%, transparent 100%)"
286+
}
287+
})(props => {
288+
const { classes, ...other } = props;
289+
return (
290+
<Sidebar className="adminSidebar">
291+
<div
292+
className={classNames("adminSidebarTopIndicator", classes.sidebarScrollingIndicator, classes.topIndicator)}>
293+
<KeyboardArrowUpIcon />
294+
</div>
295+
{other.children}
296+
<div
297+
className={classNames(
298+
"adminSidebarBottomIndicator",
299+
classes.sidebarScrollingIndicator,
300+
classes.bottomIndicator
301+
)}
302+
>
303+
<KeyboardArrowDownIcon />
304+
</div>
305+
</Sidebar>
306+
);
307+
});
264308

265309
document.addEventListener("DOMContentLoaded", async () => {
266310
const socket = await connectToReticulum();
@@ -328,13 +372,13 @@ document.addEventListener("DOMContentLoaded", async () => {
328372
);
329373
}
330374

331-
// Use standard React Admin Layout - will revisit gap issue in v4 upgrade
332375
const layout = props => (
333376
<Layout
334377
{...props}
335378
className="global_background"
336-
appBar={() => null}
379+
appBar={HiddenAppBar}
337380
menu={props => <AdminMenu {...props} services={schemaCategories} />}
381+
sidebar={AdminSidebar}
338382
/>
339383
);
340384

0 commit comments

Comments
 (0)