Skip to content

Commit 2a74ccd

Browse files
committed
review feedback
1 parent cc5c9ca commit 2a74ccd

File tree

4 files changed

+16
-72
lines changed

4 files changed

+16
-72
lines changed

admin/.storybook/preview.js

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,10 @@
11
import React from "react";
22
import { IntlProvider } from "react-intl";
3-
import { createTheme, ThemeProvider } from "@material-ui/core/styles";
3+
import { ThemeProvider } from "@material-ui/core/styles";
44
import { Provider } from "react-redux";
55
import mockStore from "./mocks/store.js";
66
import "../src/styles/globals.scss";
7-
8-
// Admin theme matching the one in admin.js
9-
const adminTheme = createTheme({
10-
components: {
11-
MuiDrawer: {
12-
styleOverrides: {
13-
paper: {
14-
backgroundColor: "#222222",
15-
minHeight: "100vh",
16-
position: "sticky",
17-
top: 0,
18-
overflowX: "hidden"
19-
}
20-
}
21-
},
22-
MuiAppBar: {
23-
styleOverrides: {
24-
root: {
25-
position: "sticky",
26-
top: 0,
27-
zIndex: 1100
28-
}
29-
}
30-
}
31-
},
32-
palette: {
33-
primary: {
34-
main: "#1700c7"
35-
},
36-
secondary: {
37-
main: "#000000"
38-
}
39-
},
40-
typography: {
41-
fontFamily: "Inter,Arial"
42-
}
43-
});
7+
import { adminTheme } from "../src/admin-theme";
448

459
// Simple messages for preview
4610
const messages = {
@@ -57,8 +21,8 @@ const AdminLayout = ({ children }) => {
5721
<Provider store={mockStore}>
5822
<IntlProvider locale="en" messages={messages}>
5923
<ThemeProvider theme={adminTheme}>
60-
<div style={{ fontFamily: "Inter,Arial", margin: 0, padding: 0 }}>
61-
{children}
24+
<div className="global_background" style={{ fontFamily: "Inter,Arial", margin: 0, padding: 0 }}>
25+
<main style={{ minHeight: "100vh" }}>{children}</main>
6226
</div>
6327
</ThemeProvider>
6428
</IntlProvider>

admin/src/admin.js

Lines changed: 3 additions & 26 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, defaultTheme } from "react-admin";
18+
import { Admin, Layout, Resource, Notification } 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,10 +34,10 @@ 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";
3837
import { UnauthorizedPage } from "./react-components/unauthorized";
3938
import { store } from "hubs/src/utils/store-instance";
4039
import { HiddenAppBar, AdminSidebar } from "./react-components/admin-chrome";
40+
import { adminTheme } from "./admin-theme";
4141

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

@@ -72,30 +72,7 @@ const CustomNotification = props => {
7272

7373
let itaSchemas;
7474

75-
const theme = createTheme({
76-
...defaultTheme,
77-
components: {
78-
MuiDrawer: {
79-
styleOverrides: {
80-
paper: {
81-
backgroundColor: "#222222",
82-
minHeight: "100vh"
83-
}
84-
}
85-
}
86-
},
87-
palette: {
88-
primary: {
89-
main: "#1700c7"
90-
},
91-
secondary: {
92-
main: "#000000"
93-
}
94-
},
95-
typography: {
96-
fontFamily: "Inter,Arial"
97-
}
98-
});
75+
const theme = adminTheme;
9976

10077
class AdminUI extends Component {
10178
static propTypes = {

admin/src/react-components/admin-chrome.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React from "react"; // Required by eslint react/react-in-jsx-scope
22
import classNames from "classnames";
33
import { withStyles } from "@material-ui/core/styles";
44
import KeyboardArrowUpIcon from "@material-ui/icons/KeyboardArrowUp";
@@ -12,8 +12,8 @@ export const HiddenAppBar = withStyles({
1212
}
1313
}
1414
})(props => {
15-
const { classes, ...other } = props;
16-
return <AppBar {...other} className={classes.hideOnDesktop} />;
15+
const { classes, className, ...appBarProps } = props;
16+
return <AppBar {...appBarProps} className={classNames(classes.hideOnDesktop, className)} />;
1717
});
1818

1919
export const AdminSidebar = withStyles({
@@ -37,13 +37,13 @@ export const AdminSidebar = withStyles({
3737
background: "linear-gradient(to top, rgba(0, 0, 0, 1.0) 0%, rgba(34, 34, 34, 0.7) 70%, transparent 100%)"
3838
}
3939
})(props => {
40-
const { classes, ...other } = props;
40+
const { classes, className, children, ...sidebarProps } = props;
4141
return (
42-
<Sidebar className="adminSidebar">
42+
<Sidebar {...sidebarProps} className={classNames("adminSidebar", className)}>
4343
<div className={classNames("adminSidebarTopIndicator", classes.sidebarScrollingIndicator, classes.topIndicator)}>
4444
<KeyboardArrowUpIcon />
4545
</div>
46-
{other.children}
46+
{children}
4747
<div
4848
className={classNames(
4949
"adminSidebarBottomIndicator",

admin/src/react-components/admin-menu.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class Menu extends Component {
155155
return null;
156156
};
157157

158+
// The Drawer that wraps <Sidebar> defers attaching the scrollable `<div>` that actually receives the
159+
// overflow styles until after the first paint. On the initial frame the ancestor walk returns `null`,
160+
// so we retry a handful of times via rAF to ensure we subscribe once Material-UI finishes mounting.
158161
const tryAttach = () => {
159162
if (this.sidebarScrollArea) return; // already attached
160163
const container = this.containerRef.current;

0 commit comments

Comments
 (0)