Skip to content

Commit

Permalink
EGCETSII#30-feat: implement action bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
JSnow11 committed Dec 19, 2021
1 parent fe68da3 commit 420a5fc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { ReactElement } from "react";

import { Box } from "@mui/system";
import { Divider } from "@mui/material";
import { IconButton } from "components/01-atoms";

type Action = {
title: string;
icon: ReactElement;
onClick?: () => void;
};

const Component = (props: {
selection?: any[];
actions?: ReactElement[];
selectedActions?: Action[];
bulkActions?: Action[];
}) => {
const individualEnabled = React.useMemo(
() => props.selection && props.selection?.length === 1,
[props.selection]
);
const bulkEnabled = React.useMemo(
() => props.selection && props.selection.length >= 1,
[props.selection]
);

return (
<Box
id="actions"
className="inline-block w-1/12 h-screen py-1 md:py-5 xl:py-48 px-2"
>
<Box className="h-full w-12 flex flex-col border rounded p-2 gap-3">
{props.actions}
<Divider />
{props.selectedActions?.map((action, index) => (
<IconButton
key={index}
title={action.title}
icon={action.icon}
onClick={action.onClick}
disabled={!individualEnabled}
/>
))}
<Divider />
{props.bulkActions?.map((action, index) => (
<IconButton
key={index}
title={action.title}
icon={action.icon}
onClick={action.onClick}
disabled={!bulkEnabled}
/>
))}
</Box>
</Box>
);
};

export default Component;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ActionBar from "./actionBar";

export { ActionBar };

0 comments on commit 420a5fc

Please sign in to comment.