-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
149 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
|
||
export default function JobMonitorLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return <section>{children}</section>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Icon, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListItemText, | ||
} from "@mui/material"; | ||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; | ||
import { Draggable, Droppable } from "react-beautiful-dnd"; | ||
import React from "react"; | ||
import Link from "next/link"; | ||
import DragIndicatorIcon from "@mui/icons-material/DragIndicator"; | ||
import { StrictModeDroppable } from "./StrictModeDroppable"; | ||
|
||
export default function DrawerItemGroup({ | ||
title, | ||
items, | ||
}: { | ||
title: string; | ||
items: { | ||
title: string; | ||
id: number; | ||
icon: React.ComponentType; | ||
path: string; | ||
}[]; | ||
}) { | ||
return ( | ||
<Accordion sx={{ width: "100%" }} disableGutters> | ||
{/* Accordion summary */} | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
{title} | ||
</AccordionSummary> | ||
{/* Accordion details */} | ||
<StrictModeDroppable droppableId={title}> | ||
{(provided, snapshot) => ( | ||
<AccordionDetails | ||
{...provided.droppableProps} | ||
ref={provided.innerRef} | ||
> | ||
{items.map(({ title, id, icon, path }, index) => ( | ||
<Draggable key={id} draggableId={title} index={index}> | ||
{(provided) => ( | ||
<div> | ||
<ListItemButton | ||
disableGutters | ||
ref={provided.innerRef} | ||
key={title} | ||
component={Link} | ||
href={path} | ||
sx={{ pl: 2, borderRadius: 2, pr: 1 }} | ||
{...provided.draggableProps} | ||
> | ||
<ListItemIcon> | ||
<Icon component={icon} /> | ||
</ListItemIcon> | ||
<ListItemText primary={title} /> | ||
<div {...provided.dragHandleProps}> | ||
<Icon component={DragIndicatorIcon} /> | ||
</div> | ||
</ListItemButton> | ||
</div> | ||
)} | ||
</Draggable> | ||
))} | ||
{provided.placeholder} | ||
</AccordionDetails> | ||
)} | ||
</StrictModeDroppable> | ||
</Accordion> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useEffect, useState } from "react"; | ||
import { Droppable, DroppableProps } from "react-beautiful-dnd"; | ||
export const StrictModeDroppable = ({ children, ...props }: DroppableProps) => { | ||
const [enabled, setEnabled] = useState(false); | ||
useEffect(() => { | ||
const animation = requestAnimationFrame(() => setEnabled(true)); | ||
return () => { | ||
cancelAnimationFrame(animation); | ||
setEnabled(false); | ||
}; | ||
}, []); | ||
if (!enabled) { | ||
return null; | ||
} | ||
return <Droppable {...props}>{children}</Droppable>; | ||
}; |