Merge branch 'canvas/doing-stuff' into 'main'
some small changes See merge request vkuchenik/website-framework!51
This commit is contained in:
@@ -6,14 +6,15 @@ import Account from "./views/Account"
|
|||||||
import Settings from "./views/Settings"
|
import Settings from "./views/Settings"
|
||||||
import Home from "./views/Home";
|
import Home from "./views/Home";
|
||||||
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
||||||
|
import { chakra } from "@chakra-ui/react";
|
||||||
|
|
||||||
export default function Canvas({...props}) {
|
export default function Canvas({...props}) {
|
||||||
const { view } = props;
|
const { view } = props;
|
||||||
return (
|
return (
|
||||||
<>
|
<chakra.div width="100%">
|
||||||
{/* Check if view is a tab inside the Canvas Header */}
|
{/* Check if view is a tab inside the Canvas Header */}
|
||||||
{ DASHBOARD_VIEWS.includes(view) && (
|
{ DASHBOARD_VIEWS.includes(view) && (
|
||||||
<Home width="100%" height="100%" {...props}/>
|
<Home {...props}/>
|
||||||
)}
|
)}
|
||||||
{view === "global" && <GlobalMap />}
|
{view === "global" && <GlobalMap />}
|
||||||
{view === "regional" && <RegionalMap />}
|
{view === "regional" && <RegionalMap />}
|
||||||
@@ -21,6 +22,6 @@ export default function Canvas({...props}) {
|
|||||||
{view === "admin" && <Admin />}
|
{view === "admin" && <Admin />}
|
||||||
{view === "account" && <Account />}
|
{view === "account" && <Account />}
|
||||||
{view === "settings" && <Settings />}
|
{view === "settings" && <Settings />}
|
||||||
</>
|
</chakra.div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,27 @@
|
|||||||
import Widget from "./Widget";
|
import Widget from "./Widget";
|
||||||
import { Text } from "@chakra-ui/react";
|
import { HStack, Box, Field, Input, Button } from "@chakra-ui/react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
export default function AlertLevel({id, isEditable, isDelete, DeleteWidget}) {
|
export default function AlertLevel({id, isEditable, isDelete, DeleteWidget}) {
|
||||||
|
const { register, handleSubmit } = useForm();
|
||||||
|
const onSubmit = (data) => console.log(data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget id={id} title="Alert Level" isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}>
|
<Widget id={id} title="Alert Level" isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}>
|
||||||
<Text>Input volcano and country</Text>
|
<Box
|
||||||
|
as="form"
|
||||||
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
p={2}
|
||||||
|
>
|
||||||
|
<Field.Root orientation="horizontal" align>
|
||||||
|
<HStack spacing={4} align="center" width="100%">
|
||||||
|
<Field.Label whiteSpace="nowrap" width="100%">Country Name</Field.Label>
|
||||||
|
<Input {...register("countryname")} placeholder="Enter country name"/>
|
||||||
|
</HStack>
|
||||||
|
</Field.Root>
|
||||||
|
</Box>
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -16,11 +16,11 @@ export default function Widget({ id, title, isEditable, isDelete, DeleteWidget,
|
|||||||
</>
|
</>
|
||||||
):(
|
):(
|
||||||
<>
|
<>
|
||||||
<Text className="widget-handle" fontWeight="bold">{title}</Text>
|
<Text display="flex" alignItems="center" height="32px" className="widget-handle" fontWeight="bold">{title}</Text>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</chakra.div>
|
</chakra.div>
|
||||||
<chakra.div css={styles.canvas} >
|
<chakra.div height="100%">
|
||||||
{children}
|
{children}
|
||||||
</chakra.div>
|
</chakra.div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default function Home({...props}) {
|
|||||||
const DeleteWidget = (ID) => {
|
const DeleteWidget = (ID) => {
|
||||||
console.log("Deleting widget with id: ", ID);
|
console.log("Deleting widget with id: ", ID);
|
||||||
setLayout(layout => layout.filter(w => w.i !== ID));
|
setLayout(layout => layout.filter(w => w.i !== ID));
|
||||||
// add removal for widgetArray here
|
setWidgetArray(widgetArray => widgetArray.filter(w => w.i !== ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
const DeleteAll = () => {
|
const DeleteAll = () => {
|
||||||
@@ -89,8 +89,8 @@ export default function Home({...props}) {
|
|||||||
return (
|
return (
|
||||||
/* HEADER */
|
/* HEADER */
|
||||||
<Tabs.Root
|
<Tabs.Root
|
||||||
width={width}
|
width="100%"
|
||||||
height={height}
|
height="100%"
|
||||||
lazyMount
|
lazyMount
|
||||||
value={ view }
|
value={ view }
|
||||||
variant="line"
|
variant="line"
|
||||||
@@ -110,6 +110,7 @@ export default function Home({...props}) {
|
|||||||
pt={3}
|
pt={3}
|
||||||
align="center"
|
align="center"
|
||||||
justify="space-between"
|
justify="space-between"
|
||||||
|
width="100%"
|
||||||
>
|
>
|
||||||
<Tabs.List>
|
<Tabs.List>
|
||||||
<Tabs.Trigger value="mydashboard" fontSize="lg">
|
<Tabs.Trigger value="mydashboard" fontSize="lg">
|
||||||
@@ -129,7 +130,7 @@ export default function Home({...props}) {
|
|||||||
</Tabs.Trigger>
|
</Tabs.Trigger>
|
||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<HStack >
|
<HStack width="258px" justifyContent="flex-end">
|
||||||
{isEditable ? (
|
{isEditable ? (
|
||||||
<>
|
<>
|
||||||
<SaveButton onSave={ onSave } />
|
<SaveButton onSave={ onSave } />
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet
|
|||||||
return (
|
return (
|
||||||
<chakra.div width="100%">
|
<chakra.div width="100%">
|
||||||
<ResponsiveGridLayout
|
<ResponsiveGridLayout
|
||||||
|
useCSSTransforms={false} // remove the sliding animation of the widgets
|
||||||
className="layout"
|
className="layout"
|
||||||
layout={layout}
|
layout={layout}
|
||||||
cols={12} // Total columns in grid
|
cols={12} // Total columns in grid
|
||||||
@@ -39,7 +40,7 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet
|
|||||||
{merged.map((item) => {
|
{merged.map((item) => {
|
||||||
const Widget = item.widget;
|
const Widget = item.widget;
|
||||||
return (
|
return (
|
||||||
<Flex key={item.i} css={styles.root} height="100%" >
|
<Flex key={item.i} css={styles.root} boxShadow={isEditable ? "md":undefined} height="100%" >
|
||||||
<Widget id={item.i} isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}/>
|
<Widget id={item.i} isEditable={isEditable} isDelete={isDelete} DeleteWidget={DeleteWidget}/>
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
|
|||||||
+5
-1
@@ -71,7 +71,8 @@ const widgetRecipe = defineSlotRecipe({
|
|||||||
border: "1px solid",
|
border: "1px solid",
|
||||||
borderColor: "{base300}",
|
borderColor: "{base300}",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
height: "100%"
|
height: "100%",
|
||||||
|
position: "fixed"
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
flexShrink: "0",
|
flexShrink: "0",
|
||||||
@@ -152,6 +153,9 @@ const config = defineConfig({
|
|||||||
filter: "invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%)",
|
filter: "invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%)",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
".react-grid-item": {
|
||||||
|
transition: "none !important"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
semanticTokens: {
|
semanticTokens: {
|
||||||
|
|||||||
Reference in New Issue
Block a user