Add button when no widgets populate the canvas
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
import { Box, Heading } from '@chakra-ui/react'
|
||||||
|
|
||||||
|
export default function FirstWidgetButton() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
p={6}
|
||||||
|
m={4}
|
||||||
|
borderRadius="md"
|
||||||
|
boxShadow="md"
|
||||||
|
border="2px dashed"
|
||||||
|
borderColor="gray.300"
|
||||||
|
bg="gray.50"
|
||||||
|
textAlign="center"
|
||||||
|
cursor="pointer"
|
||||||
|
_hover = {{
|
||||||
|
bg: "gray.100",
|
||||||
|
borderColor: "gray.400",
|
||||||
|
boxShadow: "lg",
|
||||||
|
}}
|
||||||
|
transition="all 0.2s ease-in-out"
|
||||||
|
>
|
||||||
|
<Heading fontWeight="bold" fontSize="xl" color="gray.700">
|
||||||
|
Add First Widget
|
||||||
|
</Heading>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import GridLayout, { WidthProvider } from 'react-grid-layout';
|
import GridLayout, { WidthProvider } from 'react-grid-layout';
|
||||||
import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react';
|
import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react';
|
||||||
import CustomResizeHandle from '../../CanvasComponents/CustomResizeHandle';
|
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}) {
|
||||||
console.log("rendering MyDashboard");
|
console.log("rendering MyDashboard");
|
||||||
@@ -24,6 +25,22 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( !widgetArray.length ) {
|
||||||
|
return (
|
||||||
|
<Flex
|
||||||
|
key="first-widget"
|
||||||
|
align="center"
|
||||||
|
justify="center"
|
||||||
|
height="300px"
|
||||||
|
w="100%"
|
||||||
|
bg="gray.150"
|
||||||
|
borderRadius="md"
|
||||||
|
>
|
||||||
|
<FirstWidgetButton />
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<chakra.div width="100%">
|
<chakra.div width="100%">
|
||||||
<ResponsiveGridLayout
|
<ResponsiveGridLayout
|
||||||
@@ -41,14 +58,18 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet
|
|||||||
position="relative"
|
position="relative"
|
||||||
resizeHandle={<CustomResizeHandle isVisable={isEditable} />}
|
resizeHandle={<CustomResizeHandle isVisable={isEditable} />}
|
||||||
>
|
>
|
||||||
{merged.map((item) => {
|
|
||||||
const Widget = item.widget;
|
{ merged.map((item) => {
|
||||||
return (
|
const Widget = item.widget;
|
||||||
<Flex key={item.i} css={styles.root} boxShadow="md" height="100%" >
|
return (
|
||||||
<Widget id={item.i} isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}/>
|
<Flex key={item.i} css={styles.root} boxShadow="md" height="100%" >
|
||||||
</Flex>
|
<Widget id={item.i} isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}/>
|
||||||
)
|
</Flex>
|
||||||
})}
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</ResponsiveGridLayout>
|
</ResponsiveGridLayout>
|
||||||
</chakra.div>
|
</chakra.div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -94,13 +94,14 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<ColorModeButton
|
<ColorModeButton
|
||||||
onClick={
|
onClick={
|
||||||
() => {
|
() => {
|
||||||
setDarkMode(!darkMode);
|
setDarkMode(!darkMode);
|
||||||
toggleColorMode();
|
toggleColorMode();
|
||||||
}}
|
}}
|
||||||
position="absolute"
|
position="absolute"
|
||||||
bottom="2"/>
|
bottom="2"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user