Skip to content

Commit

Permalink
Extract <CustomTabPanel/>.
Browse files Browse the repository at this point in the history
  • Loading branch information
junhaoliao committed Sep 17, 2024
1 parent db82737 commit b9ebe1d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from "react";

import {
DialogContent,
DialogTitle,
TabPanel,
Typography,
} from "@mui/joy";


interface CustomTabPanelProps {
children: React.ReactNode,
tabName: string,
title: string,
}

/**
* Renders a customized tab panel to be extended for displaying extra information in the sidebar.
*
* @param props
* @param props.children
* @param props.tabName
* @param props.title
* @return
*/
const CustomTabPanel = ({children, tabName, title}: CustomTabPanelProps) => {
return (
<TabPanel value={tabName}>
<DialogTitle>
<Typography
fontSize={14}
fontWeight={400}
level={"body-md"}
textTransform={"uppercase"}
>
{title}
</Typography>
</DialogTitle>
<DialogContent>
{children}
</DialogContent>
</TabPanel>
);
};


export default CustomTabPanel;
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {useContext} from "react";

import {
DialogContent,
DialogTitle,
Divider,
List,
TabPanel,
} from "@mui/joy";

import AbcIcon from "@mui/icons-material/Abc";
Expand All @@ -14,6 +11,7 @@ import StorageIcon from "@mui/icons-material/Storage";
import {StateContext} from "../../../contexts/StateContextProvider";
import {formatSizeInBytes} from "../../../utils/units";
import CustomListItem from "../../CustomListItem";
import CustomTabPanel from "./CustomTabPanel";
import {TAB_NAME} from "./index";

import "./index.css";
Expand All @@ -28,22 +26,22 @@ const FileInfoTab = () => {
const {fileName, originalFileSizeInBytes} = useContext(StateContext);

return (
<TabPanel value={TAB_NAME.FILE_INFO}>
<DialogTitle>File Info</DialogTitle>
<DialogContent>
<List>
<CustomListItem
content={fileName}
icon={<AbcIcon/>}
title={"File Info"}/>
<Divider/>
<CustomListItem
content={formatSizeInBytes(originalFileSizeInBytes)}
icon={<StorageIcon/>}
title={"Original Size"}/>
</List>
</DialogContent>
</TabPanel>
<CustomTabPanel
tabName={TAB_NAME.FILE_INFO}
title={"File Info"}
>
<List>
<CustomListItem
content={fileName}
icon={<AbcIcon/>}
title={"File Info"}/>
<Divider/>
<CustomListItem
content={formatSizeInBytes(originalFileSizeInBytes)}
icon={<StorageIcon/>}
title={"Original Size"}/>
</List>
</CustomTabPanel>
);
};

Expand Down

0 comments on commit b9ebe1d

Please sign in to comment.