the LayoutPanels
component helps create a 2 to 3 panel layout commonly used with mapping applications (this does not include other app layout like the header and footer). Panels can be toggled open and closed with overridable button tabs. Optionally panels can also be configured to have width resized by the user dragging an inner edge.
You can preview the LayoutPanels Storybook here and view an example app here.
Content for the main non-panel content. Typically where the map would go.
Optional override to manually control panel visibility from consuming code.
Config option to allow the user to drag a panel's inner edge to resize width.
Config option to allow the user to open and close.
Optional override to manually control panel visibility from consuming code.
Config option to allow the user to drag a panel's inner edge to resize width.
Config option to allow the user to open and close.
Optional override to manually control panel visibility from consuming code.
CSS classname to override panel styles.
Content for the left panel
Optional override default visibility toggle button.
CSS classname to overide panel styles.
Content for the right panel
Optional override default visibility toggle button.
Optional override to manually control panel visibility from consuming code.
Optional override to manually control panel visibility from consuming code.
Optional override to manually control panel visibility from consuming code.
CSS classname to overide panel styles.
Content for the subpanel
-
Set up a React app. For example run
yarn create vite appName --template react-ts
and follow instructions for setting up a React app as documented here. The install guide assumes you are using modern React and Vite. -
Copy the
LayoutPanels
folder insrc/components
in this repo into your codebase. If you are starting from scratch with the above example, you might put thisLayoutPanels
component into your project'ssrc
orsrc/components
folder. -
Add
vitest
and@testing-library
to your project.yarn add -D vitest @testing-library/jest-dom @testing-library/react @testing-library/user-event
. Or optionally, but less ideal, you can remove any test files copied in the previous step. -
Add Sass.
yarn add -D sass
. -
Add supporting type dependencies to your project.
yarn add -D @types/react-dom @types/react
-
Configure testing and other types in your typescript config file.
compilerOptions.types
should includevitest/globals
and@testing-library/jest-dom
-
Ensure the container the
LayoutPanels
component renders in has width and height set.LayoutPanels
will fit to the dimensions of its parent and will not work properly if its ancestors don't have dimensions set properly to accommodate this. Typically the aim ofLayoutPanels
would be to fill any remainder of the screen not taken up by a header and footer.- For convenience you can copy a
LayoutApp
folder fromsrc/components/
and paste it into your app. You may use this as a parent toLayoutPanels
. It has the following optional props for header and footer content:footerContent
headerContent
- For convenience you can copy a
- make sure you are using the right node version (check
.nvmrc
or runnvm use
) - run
yarn install
- run
yarn dev
- run
yarn storybook
- Our current folder structure and location of code is to prioritize easy copy pasting of the LayoutPanels component. This is due to the nature of our consulting work and this abstraction being produced and maintained in a side-of-the-desk capacity. We're experimenting with this approach to prevent blocking project work and also prevent rushed and reactionary PR requests to this repo.