Skip to content

Commit

Permalink
Add actions prop to ItemTableAppBar to use ItemTableAppBarAction comp…
Browse files Browse the repository at this point in the history
…onents
  • Loading branch information
campb303 committed Jul 16, 2021
1 parent 59518c6 commit ebb4e11
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/components/ItemTableAppBar/ItemTableAppBar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import PropTypes from 'prop-types';
import {makeStyles, Tooltip, Typography, AppBar, Toolbar, IconButton, Zoom, useTheme} from "@material-ui/core"
import DarkModeIcon from '@material-ui/icons/Brightness4';
import LightModeIcon from '@material-ui/icons/Brightness7';
import {makeStyles, Typography, AppBar, Toolbar, useTheme} from "@material-ui/core"
import ItemTableAppBarAction from "../ItemTableAppBarAction";


export default function ItemTableAppBar({ title, setDarkMode }){
export default function ItemTableAppBar({ title, actions }){

const theme = useTheme();
const useStyles = makeStyles((theme) => ({
Expand All @@ -17,9 +16,6 @@ export default function ItemTableAppBar({ title, setDarkMode }){
},
}));
const classes = useStyles(theme);
const darkMode = theme.palette.type === "dark"

const toggleDarkMode = () => setDarkMode(!darkMode);

return(
<>
Expand All @@ -29,15 +25,7 @@ export default function ItemTableAppBar({ title, setDarkMode }){
{title}
</Typography>

<Tooltip title={"Turn " + (darkMode ? "off" : "on") + " dark mode"}
arrow
onClick={toggleDarkMode}
TransitionComponent={Zoom}
>
<IconButton color="inherit">
{darkMode ? <DarkModeIcon /> : <LightModeIcon />}
</IconButton>
</Tooltip>
{actions}
</Toolbar>
</AppBar>
</>
Expand All @@ -47,10 +35,11 @@ export default function ItemTableAppBar({ title, setDarkMode }){
ItemTableAppBar.propTypes = {
/** The title of the app bar. */
"title": PropTypes.string,
/** Function to toggle darkMode. */
"setDarkMode": PropTypes.func.isRequired,
/** Array of <a href="/?path=/docs/components-itemtableappbaraction">ItemTableAppBarActions</a>. */
"actions": PropTypes.arrayOf(ItemTableAppBarAction),
};

ItemTableAppBar.defaultProps = {
"title": ""
"title": "",
"actions": []
};

0 comments on commit ebb4e11

Please sign in to comment.