Skip to content

Commit

Permalink
feat: Hide main menu when loading [PT-185596483]
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmartin committed Jul 13, 2023
1 parent 5bdd4c2 commit 31675fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/components/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
display: flex;
}

.loading {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
font-size: 2em;
}

.app {
display: flex;
flex-direction: column;
Expand Down
6 changes: 5 additions & 1 deletion src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const App = () => {
const currentSequenceIndex = useRef(0);
const animationInterval = useRef<number>();
const { graph, updateGraph, setGraph } = useGraph();
const { dragging, outputToDataset, viewMode, setViewMode, notifyStateIsDirty } = useCODAP({
const { dragging, outputToDataset, viewMode, setViewMode, notifyStateIsDirty, loadState } = useCODAP({
onCODAPDataChanged: updateGraph,
getGraph: useCallback(() => graph, [graph]),
setGraph
Expand Down Expand Up @@ -351,6 +351,10 @@ export const App = () => {
notifyStateIsDirty();
};

if (loadState === "loading") {
return <div className="loading">Loading ...</div>;
}

if (!viewMode) {
return (
<div className={clsx("app")}>
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/use-codap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type UseCODAPOptions = {
};

export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph}: UseCODAPOptions) => {
const [loadState, setLoadState] = useState<"loading"|"loaded">("loading");
const [initialized, setInitialized] = useState(false);
const [dragging, setDragging] = useState(false);
const [attribute, setAttribute] = useState<CODAPAttribute|undefined>(undefined);
Expand Down Expand Up @@ -77,6 +78,8 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph}: UseCODAPOptio
}, [onCODAPDataChanged]);

const setPluginState = useCallback((values: any) => {
setLoadState("loaded");

if (values?.viewMode) {
setViewMode(values.viewMode);

Expand Down Expand Up @@ -260,6 +263,7 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph}: UseCODAPOptio
outputToDataset,
viewMode,
setViewMode,
notifyStateIsDirty
notifyStateIsDirty,
loadState
};
};

0 comments on commit 31675fd

Please sign in to comment.