saleor-dashboard/src/components/PageHeader/PageHeader.tsx
Dominik Żegleń 416d7d87f6
Improve theming (#1020)
* Remove unused code

* Move theme to separate directory

* Separate types

* Separate shadows

* Separate shadows

* Rename types

* Modularize code

* Do not pollute prototypes

* Fix missing import

* Aliast mui styles

* Import theming internally

* Fix types

* Fix override type
2021-03-30 09:40:18 +02:00

56 lines
1.3 KiB
TypeScript

import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@saleor/theme";
import React from "react";
import ExtendedPageHeader from "../ExtendedPageHeader";
import Skeleton from "../Skeleton";
const useStyles = makeStyles(
theme => ({
root: {
display: "flex"
},
title: {
[theme.breakpoints.down("sm")]: {
fontSize: 20,
marginTop: theme.spacing(2),
padding: 0
},
alignSelf: "flex-start",
flex: 1,
fontSize: 24
}
}),
{ name: "PageHeader" }
);
interface PageHeaderProps {
children?: React.ReactNode;
className?: string;
inline?: boolean;
title?: React.ReactNode;
}
const PageHeader: React.FC<PageHeaderProps> = props => {
const { children, className, inline, title } = props;
const classes = useStyles(props);
return (
<ExtendedPageHeader
testId="page-header"
className={className}
inline={inline}
title={
<Typography className={classes.title} variant="h5">
{title !== undefined ? title : <Skeleton style={{ width: "10em" }} />}
</Typography>
}
>
<div className={classes.root}>{children}</div>
</ExtendedPageHeader>
);
};
PageHeader.displayName = "PageHeader";
export default PageHeader;