Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add drag and drop to Dashboard layouts #1322

Merged
merged 18 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions app/components/chart-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Theme } from "@mui/material";
import { Box, BoxProps, Theme } from "@mui/material";
import { makeStyles } from "@mui/styles";
import capitalize from "lodash/capitalize";
import React from "react";
Expand All @@ -14,7 +14,7 @@ const useStyles = makeStyles((theme: Theme) => ({
},
panelLayoutTall: {
display: "grid",
gridTemplateColumns: "repeat(2, 1fr)",
gridTemplateColumns: "repeat(2, 50%)",
gap: theme.spacing(4),

"& > :nth-child(3n - 2)": {
Expand All @@ -32,6 +32,7 @@ const useStyles = makeStyles((theme: Theme) => ({
borderColor: theme.palette.divider,
overflow: "hidden",
width: "auto",
height: "100%",
},
}));

Expand All @@ -58,21 +59,26 @@ export const ChartPanelLayout = (props: ChartPanelLayoutProps) => {
);
};

type ChartPanelProps = React.PropsWithChildren<{
export type ChartWrapperProps = BoxProps & {
editing?: boolean;
layout?: Layout;
}>;
};

export const ChartWrapper = (props: ChartPanelProps) => {
const { children, editing, layout } = props;
const classes = useStyles();
export const ChartWrapper = React.forwardRef<HTMLDivElement, ChartWrapperProps>(
(props, ref) => {
const { children, editing, layout, ...rest } = props;
const classes = useStyles();

return (
<>
{(editing || layout?.type === "tab") && <ChartSelectionTabs />}
<Box className={classes.chartWrapper} sx={{ minHeight: [150, 300, 500] }}>
{children}
return (
<Box ref={ref} {...rest}>
{(editing || layout?.type === "tab") && <ChartSelectionTabs />}
<Box
className={classes.chartWrapper}
sx={{ minHeight: [150, 300, 500] }}
>
{children}
</Box>
</Box>
</>
);
};
);
}
);
Loading
Loading