ISSUE-011 - Hooked up Redux. Switched to using embedded route. Using central store to keep track of menu height information. Refactored fullscreen calculations.
This commit is contained in:
1 parent
3add2f3237
commit
f3e4ac318c
5 files changed
+33
-11
No files matched your search
+14
-1
@@ -1,11 +1,24 @@
|
|||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
|
|
||||||
|
import { useDimensions } from "./utils/hooks";
|
||||||
|
import { setMenuDimensions } from "./features/pageDimensions/pageDimensionsSlice";
|
||||||
|
|
||||||
import { MainMenu } from "./components/Menu";
|
import { MainMenu } from "./components/Menu";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const [ref, { height }] = useDimensions<HTMLDivElement>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Make sure to not dispatch during a render.
|
||||||
|
dispatch(setMenuDimensions({ height }));
|
||||||
|
}, [height]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<MainMenu />
|
<MainMenu ref={ref} />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { RootState } from "../../types/state";
|
||||||
|
|
||||||
|
export const menuSelector = (state: RootState) => state.pageDimensions.menu;
|
||||||
+2
-1
@@ -20,8 +20,9 @@ ReactDOM.render(
|
|||||||
<GlobalFonts />
|
<GlobalFonts />
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<App />} />
|
<Route path="/" element={<App />} >
|
||||||
<Route path="/broadcast" element={<Broadcast />} />
|
<Route path="/broadcast" element={<Broadcast />} />
|
||||||
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
import { FullScreenContainer } from "./styles";
|
import { FullScreenContainer } from "./styles";
|
||||||
import { Layout } from "../components/Broadcast/Layout";
|
import { Layout } from "../components/Broadcast/Layout";
|
||||||
import { MainMenu } from "../components/Menu";
|
import { menuSelector } from "../features/pageDimensions/pageDimensionsSelector";
|
||||||
import { useDimensions } from "../utils/hooks";
|
|
||||||
|
|
||||||
export default function Broadcast() {
|
export default function Broadcast() {
|
||||||
const [ref, { height }] = useDimensions<HTMLDivElement>();
|
const { height } = useSelector(menuSelector);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FullScreenContainer minHeight={700} minWidth={900}>
|
<FullScreenContainer minHeight={700} minWidth={900} heightCutoff={height}>
|
||||||
<MainMenu ref={ref}/>
|
<Layout />
|
||||||
<Layout headerHeight={height} />
|
|
||||||
</FullScreenContainer>
|
</FullScreenContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,21 @@ import styled from "styled-components";
|
|||||||
type FullScreenContainerProps = {
|
type FullScreenContainerProps = {
|
||||||
minHeight?: number,
|
minHeight?: number,
|
||||||
minWidth?: number,
|
minWidth?: number,
|
||||||
}
|
heightCutoff?: number,
|
||||||
|
widthCutoff?: number,
|
||||||
|
};
|
||||||
|
|
||||||
export const FullScreenContainer = styled.div<FullScreenContainerProps>`
|
export const FullScreenContainer = styled.div<FullScreenContainerProps>`
|
||||||
--minHeight: ${({ minHeight = 0 }) => `${minHeight}px`};
|
--minHeight: ${({ minHeight = 0 }) => `${minHeight}px`};
|
||||||
--minWidth: ${({ minWidth = 0 }) => `${minWidth}px`};
|
--minWidth: ${({ minWidth = 0 }) => `${minWidth}px`};
|
||||||
--overflowY: ${({ minHeight }) => minHeight ? "scroll" : "hidden" };
|
--overflowY: ${({ minHeight }) => minHeight ? "scroll" : "hidden" };
|
||||||
--overflowX: ${({ minWidth }) => minWidth ? "scroll" : "hidden" };
|
--overflowX: ${({ minWidth }) => minWidth ? "scroll" : "hidden" };
|
||||||
|
--heightCutoff: ${({ heightCutoff = 0 }) => `${heightCutoff}px`};
|
||||||
|
--widthCutoff: ${({ widthCutoff = 0 }) => `${widthCutoff}px`};
|
||||||
|
|
||||||
height: 100vh;
|
position: relative;
|
||||||
width: 100%;
|
height: calc(100vh - var(--heightCutoff));
|
||||||
|
width: calc(100vw - var(--widthCutoff));
|
||||||
|
|
||||||
/* Demand a minimum width/height and scroll to support them. */
|
/* Demand a minimum width/height and scroll to support them. */
|
||||||
min-height: var(--minHeight);
|
min-height: var(--minHeight);
|
||||||
|
|||||||
Reference in new issue
Block a user