diff --git a/client/src/components/Canvas/CanvasComponents/FirstWidgetButton.jsx b/client/src/components/Canvas/CanvasComponents/FirstWidgetButton.jsx new file mode 100644 index 0000000..849cfc2 --- /dev/null +++ b/client/src/components/Canvas/CanvasComponents/FirstWidgetButton.jsx @@ -0,0 +1,50 @@ +import { Box, Heading, Center, Menu, Portal, Flex } from '@chakra-ui/react' +import AlertLevel from './AlertLevelWidget' +// import AddWidgetMenu from './AddWidgetMenu'; + +export default function FirstWidgetButton({ appendWidget }) { + return ( + + + + Add First Widget + + + + + + appendWidget(AlertLevel, 3, 6, 3, 6, 3, 6)} + > + Alert Level + + CO2 + IVANS + Plume Heights + Alert Level Changes + + + + + ); +} \ No newline at end of file diff --git a/client/src/components/Canvas/views/Home.jsx b/client/src/components/Canvas/views/Home.jsx index 095816c..d44c8c4 100644 --- a/client/src/components/Canvas/views/Home.jsx +++ b/client/src/components/Canvas/views/Home.jsx @@ -11,7 +11,6 @@ import { SaveButton } from "../CanvasComponents/SaveButton"; import DeleteAllButton from "../CanvasComponents/DeleteAllButton"; import { v4 as uuid } from 'uuid'; - export default function Home({...props}) { // deconstructing props const { view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView, onCancel, @@ -99,7 +98,7 @@ export default function Home({...props}) { } // Prop Forwarding - const MyDashboardProps = { layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray }; + const MyDashboardProps = { layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray, appendWidget }; const settingsButtonProps = { onEditWidgets, onDeleteWidgets, appendWidget }; return ( diff --git a/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx b/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx index fcd364f..dd1cefd 100644 --- a/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx +++ b/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx @@ -1,8 +1,9 @@ import GridLayout, { WidthProvider } from 'react-grid-layout'; import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react'; import CustomResizeHandle from '../../CanvasComponents/CustomResizeHandle'; +import FirstWidgetButton from '../../CanvasComponents/FirstWidgetButton'; -export default function MyDashboard({layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray}) { +export default function MyDashboard({layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray, appendWidget}) { console.log("rendering MyDashboard"); const recipe = useSlotRecipe({ key: "widget" }); const styles = recipe(); // using root recipe for widget below @@ -24,6 +25,23 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet }); }; + // Show large 'Add Widget' button when dashboard is empty + if ( !widgetArray.length ) { + return ( + + + + ); + } + + // Show responsive grid of widgets return ( } > - {merged.map((item) => { - const Widget = item.widget; - return ( - - - - ) - })} + { merged.map((item) => { + const Widget = item.widget; + return ( + + + + ); + }) + } ); diff --git a/client/src/components/Sidebar/Sidebar.jsx b/client/src/components/Sidebar/Sidebar.jsx index f79fcd1..51f6380 100644 --- a/client/src/components/Sidebar/Sidebar.jsx +++ b/client/src/components/Sidebar/Sidebar.jsx @@ -94,13 +94,14 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) { ) })} { - setDarkMode(!darkMode); - toggleColorMode(); - }} - position="absolute" - bottom="2"/> + onClick={ + () => { + setDarkMode(!darkMode); + toggleColorMode(); + }} + position="absolute" + bottom="2" + /> ); } \ No newline at end of file