Files
SCM-Manager/scm-ui/ui-components/src/layout/Title.tsx

33 lines
713 B
TypeScript
Raw Normal View History

2019-12-12 16:25:33 +01:00
import React, { FC, useEffect } from "react";
import classNames from "classnames";
type Props = {
title?: string;
2019-12-12 16:25:33 +01:00
customPageTitle?: string;
preventRefreshingPageTitle?: boolean;
className?: string;
};
const Title: FC<Props> = ({ title, preventRefreshingPageTitle, customPageTitle, className }) => {
2019-12-12 16:25:33 +01:00
useEffect(() => {
if (!preventRefreshingPageTitle) {
if (customPageTitle) {
document.title = customPageTitle;
} else if (title) {
document.title = title;
}
}
2019-12-12 16:25:33 +01:00
});
if (title) {
return <h1 className={classNames("title", className)}>{title}</h1>;
}
2019-12-12 16:25:33 +01:00
return null;
};
Title.defaultProps = {
preventRefreshingPageTitle: false
};
export default Title;