Add view and setView props in order to successfully pass state from Sidebar to the Canvas inside Dashboard

This commit is contained in:
Daniel S. Hansen
2025-07-23 11:35:28 -07:00
parent b432c8a8ec
commit 0ec105d9ec
3 changed files with 21 additions and 14 deletions
+7 -3
View File
@@ -2,12 +2,16 @@ import { Global, css } from "@emotion/react";
import Header from './Header/Header.jsx';
import Sidebar from './Sidebar/Sidebar.jsx';
import Canvas from './Canvas/Canvas.jsx';
import { Grid, GridItem, useRecipe, Box } from '@chakra-ui/react';
import { Grid, GridItem, useRecipe } from '@chakra-ui/react';
import { useState } from 'react';
export default function Dashboard() {
const recipe = useRecipe({ key: "canvas" });
const styles = recipe();
// Lifted State - defaults to widget dashboard
const [view, setView] = useState("widget");
return (
<>
<Global // change the background color of widget shadow when moving
@@ -37,10 +41,10 @@ export default function Dashboard() {
<Header />
</GridItem>
<GridItem colSpan={1}>
<Sidebar />
<Sidebar onChangeView={ setView } />
</GridItem>
<GridItem colSpan={1} width="100%">
<Canvas />
<Canvas view={ view }/>
</GridItem>
</Grid>
</>