Skip to content

Commit

Permalink
Updated documentation, fixed styling bug, and update to use useTheme …
Browse files Browse the repository at this point in the history
…hook
  • Loading branch information
Christian Thomas Elfreich committed Oct 19, 2020
1 parent 4e3715e commit 3299840
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/components/ItemViewAppBar/ItemViewAppBar.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React, { useEffect } from "react";
import { useHistory } from "react-router-dom";
import PropTypes from "prop-types";
import {makeStyles, Tooltip, Typography, AppBar, Toolbar, IconButton, Zoom} from "@material-ui/core"
import {makeStyles, Tooltip, Typography, AppBar, Toolbar, IconButton, Zoom, useTheme} from "@material-ui/core"
import CloseItemViewIcon from '@material-ui/icons/ChevronRight';


export default function ItemViewAppBar({ title, theme, setSidebarOpen }){
export default function ItemViewAppBar({ title, setSidebarOpen }){

useEffect(() => {
setSidebarOpen(true)
return () => setSidebarOpen(false)
});

const theme = useTheme();
const useStyles = makeStyles((theme) => ({
closeButton: {
marginRight: theme.spacing(3),
Expand All @@ -21,19 +23,26 @@ export default function ItemViewAppBar({ title, theme, setSidebarOpen }){
appBarRoot: {
width: "inherit",
position: "inherit"
},
paddingToolbar: {
position: "absolute"
}
}));

const classes = useStyles(theme);

const history = useHistory();

return(
<>
<AppBar position="fixed" color="secondary" elevation={2} classes={{root: classes.appBarRoot}}>

<Toolbar variant="dense">
<Tooltip title={"Close Item"}
arrow
onClick={() => setSidebarOpen(false)}
onClick={() =>
{
history.push("/");
}}
TransitionComponent={Zoom}
>
<IconButton color="inherit" className={classes.closeButton}>
Expand All @@ -46,14 +55,13 @@ export default function ItemViewAppBar({ title, theme, setSidebarOpen }){
</Typography>
</Toolbar>
</AppBar>
<Toolbar variant="dense"/>
<Toolbar classes={{root: classes.paddingToolbar}} variant="dense"/>
</>
);
}

ItemViewAppBar.propTypes = {
/** The webqueue2 MUI theme. */
"theme": PropTypes.object.isRequired,

/** Function to toggle sidebar open. */
"setSidebarOpen": PropTypes.func.isRequired,
/** The title of the app bar. */
Expand Down
4 changes: 2 additions & 2 deletions src/components/ItemViewAppBar/ItemViewAppBar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const theme = webqueue2Theme(false);

const [sidebarOpen, setSidebarOpen] = useState(false);

<ItemViewAppBar title="ce 100" setSidebarOpen={setSidebarOpen} theme={theme} />
<ItemViewAppBar title="ce 100" setSidebarOpen={setSidebarOpen} />
```

```jsx static
<ItemViewAppBar title={"ce 100"} setSidebarOpen={someFunc} theme={theme} />
<ItemViewAppBar title={"ce 100"} setSidebarOpen={someFunc} />
```

0 comments on commit 3299840

Please sign in to comment.