Rename and Restructure
+ took out extra 'layout' directory. + 'Canvas' postfix removed from all files in the views directory. + "WidgetCanvas" renamed to "MyDashboard"
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { IoIosArrowBack } from "react-icons/io";
|
||||
import { Menu, Portal } from "@chakra-ui/react";
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import AlertLevel from "./AlertLevelWidget";
|
||||
|
||||
export default function AddWidgetMenu({onAddWidget, widgetArray, setWidgetArray}) {
|
||||
function appendWidget(name) {
|
||||
const newID = uuid(); // could be replaced with something else like guid
|
||||
setWidgetArray([ // updating widget array containing info on the types of widgets
|
||||
...widgetArray,
|
||||
{i: newID, widget: name}
|
||||
]);
|
||||
onAddWidget(newID); // updating array containing info on layout of widgets
|
||||
}
|
||||
|
||||
return (
|
||||
<Menu.Root>
|
||||
<Menu.TriggerItem>
|
||||
<IoIosArrowBack /> Add Widget
|
||||
</Menu.TriggerItem>
|
||||
<Portal>
|
||||
<Menu.Positioner>
|
||||
<Menu.Content>
|
||||
<Menu.Item
|
||||
value="AlertLevel"
|
||||
onClick={() => appendWidget(AlertLevel)}
|
||||
>
|
||||
Alert Level
|
||||
</Menu.Item>
|
||||
</Menu.Content>
|
||||
</Menu.Positioner>
|
||||
</Portal>
|
||||
</Menu.Root>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user