Skip to content

Commit bebfe7e

Browse files
committed
rename files to minimize change scope
1 parent 83040b7 commit bebfe7e

File tree

4 files changed

+83
-76
lines changed

4 files changed

+83
-76
lines changed

entry.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import { UserInterface } from "./lib/Views/UserInterface";
2-
import Variables from "./lib/Styles/variables.scss";
3-
import { createRoot } from "react-dom/client";
1+
import { renderUi } from "./lib/Views/root";
42

5-
const container = document.getElementById("ui");
6-
const root = createRoot(container);
7-
8-
root.render(<UserInterface themeOverrides={Variables} />);
3+
renderUi();

lib/Views/TerriaUserInterface.jsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

lib/Views/UserInterface.jsx

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
import PropTypes from "prop-types";
2-
import React, { Suspense } from "react";
3-
import { useSyncExternalStore } from "react";
4-
import "./global.scss";
5-
import { Loader } from "./Loader";
6-
import { terriaStore } from "./terriaStore";
2+
import RelatedMaps from "terriajs/lib/ReactViews/RelatedMaps/RelatedMaps";
3+
import { MenuLeft } from "terriajs/lib/ReactViews/StandardUserInterface/customizable/Groups";
4+
import MenuItem from "terriajs/lib/ReactViews/StandardUserInterface/customizable/MenuItem";
5+
import StandardUserInterface from "terriajs/lib/ReactViews/StandardUserInterface/StandardUserInterface";
6+
import version from "../../version";
77

8-
// Lazy load the entire TerriaUserInterface component
9-
const LazyTerriaUserInterface = React.lazy(() =>
10-
import("./TerriaUserInterface").then((module) => ({
11-
default: module.TerriaUserInterface
12-
}))
13-
);
14-
15-
export const UserInterface = ({ themeOverrides }) => {
16-
const { terria, viewState, status } = useSyncExternalStore(
17-
terriaStore.subscribe,
18-
terriaStore.getSnapshot
19-
);
20-
21-
if (status === "loading") {
22-
return <Loader />;
23-
}
8+
export const TerriaUserInterface = ({ terria, viewState, themeOverrides }) => {
9+
const relatedMaps = viewState.terria.configParameters.relatedMaps;
10+
const aboutButtonHrefUrl =
11+
viewState.terria.configParameters.aboutButtonHrefUrl;
2412

2513
return (
26-
<Suspense fallback={<Loader />}>
27-
<LazyTerriaUserInterface
28-
terria={terria}
29-
viewState={viewState}
30-
themeOverrides={themeOverrides}
31-
/>
32-
</Suspense>
14+
<StandardUserInterface
15+
terria={terria}
16+
viewState={viewState}
17+
themeOverrides={themeOverrides}
18+
version={version}
19+
>
20+
<MenuLeft>
21+
{aboutButtonHrefUrl ? (
22+
<MenuItem
23+
caption="About"
24+
href={aboutButtonHrefUrl}
25+
key="about-link"
26+
/>
27+
) : null}
28+
{relatedMaps && relatedMaps.length > 0 ? (
29+
<RelatedMaps relatedMaps={relatedMaps} />
30+
) : null}
31+
</MenuLeft>
32+
</StandardUserInterface>
3333
);
3434
};
3535

36-
UserInterface.propTypes = {
36+
TerriaUserInterface.propTypes = {
37+
terria: PropTypes.object.isRequired,
38+
viewState: PropTypes.object.isRequired,
3739
themeOverrides: PropTypes.object
3840
};

lib/Views/root.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import PropTypes from "prop-types";
2+
import React, { Suspense, useSyncExternalStore } from "react";
3+
import "./global.scss";
4+
import { Loader } from "./Loader";
5+
import { terriaStore } from "./terriaStore";
6+
import Variables from "../Styles/variables.scss";
7+
import { createRoot } from "react-dom/client";
8+
9+
// Lazy load the entire TerriaUserInterface component
10+
const LazyTerriaUserInterface = React.lazy(() =>
11+
import("./UserInterface").then((module) => ({
12+
default: module.TerriaUserInterface
13+
}))
14+
);
15+
16+
const Root = ({ themeOverrides }) => {
17+
const { terria, viewState, status } = useSyncExternalStore(
18+
terriaStore.subscribe,
19+
terriaStore.getSnapshot
20+
);
21+
22+
if (status === "loading") {
23+
return <Loader />;
24+
}
25+
26+
return (
27+
<Suspense fallback={<Loader />}>
28+
<LazyTerriaUserInterface
29+
terria={terria}
30+
viewState={viewState}
31+
themeOverrides={themeOverrides}
32+
/>
33+
</Suspense>
34+
);
35+
};
36+
37+
Root.propTypes = {
38+
themeOverrides: PropTypes.object
39+
};
40+
41+
export const renderUi = () => {
42+
const container = document.getElementById("ui");
43+
if (!container) {
44+
console.error("Container element with id 'ui' not found.");
45+
return;
46+
}
47+
48+
const root = createRoot(container);
49+
root.render(<Root themeOverrides={Variables} />);
50+
};

0 commit comments

Comments
 (0)