mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
added page component
This commit is contained in:
46
scm-ui/src/components/Page.js
Normal file
46
scm-ui/src/components/Page.js
Normal file
@@ -0,0 +1,46 @@
|
||||
//@flow
|
||||
import * as React from "react";
|
||||
import Loading from "./Loading";
|
||||
import ErrorNotification from "./ErrorNotification";
|
||||
|
||||
type Props = {
|
||||
title: string,
|
||||
subtitle?: string,
|
||||
loading?: boolean,
|
||||
error?: Error,
|
||||
children: React.Node
|
||||
};
|
||||
|
||||
class Page extends React.Component<Props> {
|
||||
render() {
|
||||
const { title, error } = this.props;
|
||||
return (
|
||||
<section className="section">
|
||||
<div className="container">
|
||||
<h1 className="title">{title}</h1>
|
||||
{this.renderSubtitle()}
|
||||
<ErrorNotification error={error} />
|
||||
{this.renderContent()}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
renderSubtitle() {
|
||||
const { subtitle } = this.props;
|
||||
if (subtitle) {
|
||||
return <h2 className="subtitle">Users</h2>;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
renderContent() {
|
||||
const { loading, children } = this.props;
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
export default Page;
|
||||
Reference in New Issue
Block a user