saleor-dashboard/src/components/ExtendedPageHeader/ExtendedPageHeader.tsx

74 lines
1.5 KiB
TypeScript
Raw Normal View History

2019-10-30 14:34:24 +00:00
import { makeStyles } from "@material-ui/core/styles";
2019-08-09 11:14:35 +00:00
import classNames from "classnames";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
2019-11-13 12:56:51 +00:00
const useStyles = makeStyles(
theme => ({
action: {
flex: "0 0 auto",
[theme.breakpoints.down("sm")]: {
marginTop: theme.spacing()
}
},
block: {
[theme.breakpoints.down("sm")]: {
"&&": {
display: "block"
}
}
},
grid: {
padding: theme.spacing(2)
},
menuButton: {
flex: "0 0 auto",
marginLeft: -theme.spacing(2),
marginRight: theme.spacing(3),
marginTop: -theme.spacing(2)
},
root: {
alignItems: "center",
display: "flex",
marginBottom: theme.spacing(3)
},
subtitle: {
alignItems: "center",
display: "flex",
marginBottom: theme.spacing(2)
},
title: {
flex: 1,
paddingBottom: theme.spacing(2)
2019-11-04 19:31:23 +00:00
}
2019-11-13 12:56:51 +00:00
}),
{
name: "ExtendedPageHeader"
2019-10-30 14:34:24 +00:00
}
2019-11-13 12:56:51 +00:00
);
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
interface ExtendedPageHeaderProps {
2019-06-19 14:40:52 +00:00
children?: React.ReactNode;
className?: string;
2019-11-13 12:56:51 +00:00
inline?: boolean;
2019-06-19 14:40:52 +00:00
title?: React.ReactNode;
}
2019-10-30 14:34:24 +00:00
const ExtendedPageHeader: React.FC<ExtendedPageHeaderProps> = props => {
2019-11-13 12:56:51 +00:00
const { children, className, inline, title } = props;
2019-10-30 14:34:24 +00:00
const classes = useStyles(props);
return (
2019-11-13 12:56:51 +00:00
<div
className={classNames(classes.root, className, {
[classes.block]: !inline
})}
>
2019-06-19 14:40:52 +00:00
{title}
<div className={classes.action}>{children}</div>
</div>
2019-10-30 14:34:24 +00:00
);
};
2019-06-19 14:40:52 +00:00
ExtendedPageHeader.displayName = "ExtendedPageHeader";
export default ExtendedPageHeader;