diff --git a/src/App.tsx b/src/App.tsx index 097017c..49b3fd1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,20 +2,24 @@ import { createStore, StoreProvider } from 'easy-peasy'; import EditorPane from './components/panes/EditorPane'; import NavigationPane from './components/panes/NavigationPane'; import WorkflowsPane from './components/panes/WorkflowsPane'; +import useWindowDimensions from './state/Hooks'; import Store from './state/Store'; -// Workaround for https://github.com/ctrlplusb/easy-peasy/issues/741 -// const StoreProviderOverride = StoreProvider as any; - const App = () => { + const inspectorWidth = 320; + const appWidth = useWindowDimensions(); + return (
-
+
- +
); diff --git a/src/components/panes/EditorPane.tsx b/src/components/panes/EditorPane.tsx index 342c263..28d60c8 100644 --- a/src/components/panes/EditorPane.tsx +++ b/src/components/panes/EditorPane.tsx @@ -26,6 +26,7 @@ const EditorPane = () => { return yml; }; + return (
@@ -75,6 +76,7 @@ const EditorPane = () => { ) : ( diff --git a/src/components/panes/NavigationPane.tsx b/src/components/panes/NavigationPane.tsx index ffc547d..888dee7 100644 --- a/src/components/panes/NavigationPane.tsx +++ b/src/components/panes/NavigationPane.tsx @@ -1,15 +1,22 @@ import { useStoreState } from '../../state/Hooks'; +interface NavigationPaneProps { + width: number; +} + /** * @see * @returns */ -const NavigationPane = () => { +const NavigationPane = ({ width }: NavigationPaneProps) => { const navigation = useStoreState((state) => state.navigation); const NavPage = navigation.component.Component; return ( -
+
); diff --git a/src/state/Hooks.tsx b/src/state/Hooks.tsx index 7f87a68..ff7e96d 100644 --- a/src/state/Hooks.tsx +++ b/src/state/Hooks.tsx @@ -1,4 +1,5 @@ import { createTypedHooks } from 'easy-peasy'; +import { useEffect, useState } from 'react'; import { StoreActions, StoreModel } from './Store'; const typedHooks = createTypedHooks(); @@ -6,3 +7,28 @@ const typedHooks = createTypedHooks(); export const useStoreActions = typedHooks.useStoreActions; export const useStoreDispatch = typedHooks.useStoreDispatch; export const useStoreState = typedHooks.useStoreState; + +function getWindowDimensions() { + const { innerWidth: width, innerHeight: height } = window; + return { + width, + height, + }; +} + +export default function useWindowDimensions() { + const [windowDimensions, setWindowDimensions] = useState( + getWindowDimensions(), + ); + + useEffect(() => { + function handleResize() { + setWindowDimensions(getWindowDimensions()); + } + + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, []); + + return windowDimensions; +}