added more typings and some layout fixes

This commit is contained in:
Sebastian Sdorra
2018-07-12 08:23:24 +02:00
parent ed077f704f
commit bf62eee4d5
10 changed files with 37 additions and 27 deletions

View File

@@ -1,16 +1,17 @@
//@flow //@flow
import React from "react"; import React from "react";
import type { Me } from "../types/me";
type Props = { type Props = {
me: any me: Me
}; };
class Footer extends React.Component<Props> { class Footer extends React.Component<Props> {
render() { render() {
return ( return (
<footer class="footer"> <footer className="footer">
<div class="container is-centered"> <div className="container is-centered">
<p class="has-text-centered">{this.props.me.username}</p> <p className="has-text-centered">{this.props.me.username}</p>
</div> </div>
</footer> </footer>
); );

View File

@@ -24,7 +24,7 @@ class Notification extends React.Component<Props> {
} }
render() { render() {
const { type, children, onClose } = this.props; const { type, children } = this.props;
return ( return (
<div className={classNames("notification", "is-" + type)}> <div className={classNames("notification", "is-" + type)}>
{this.renderCloseButton()} {this.renderCloseButton()}

View File

@@ -5,8 +5,8 @@ import classNames from "classnames";
type Props = { type Props = {
value: string, value: string,
disabled: boolean, disabled?: boolean,
isLoading: boolean, isLoading?: boolean,
large?: boolean, large?: boolean,
fullWidth?: boolean fullWidth?: boolean
}; };

View File

@@ -13,6 +13,10 @@
margin: 0 !important; margin: 0 !important;
padding: 0 0 0 3.8em !important; } padding: 0 0 0 3.8em !important; }
html, body {
background-color: whitesmoke;
height: 100%; }
/*! bulma.io v0.7.1 | MIT License | github.com/jgthms/bulma */ /*! bulma.io v0.7.1 | MIT License | github.com/jgthms/bulma */
@keyframes spinAround { @keyframes spinAround {
from { from {

View File

@@ -10,7 +10,6 @@ import "./App.css";
import Header from "../components/Header"; import Header from "../components/Header";
import PrimaryNavigation from "../components/PrimaryNavigation"; import PrimaryNavigation from "../components/PrimaryNavigation";
import Loading from "../components/Loading"; import Loading from "../components/Loading";
import Notification from "../components/Notification";
import Footer from "../components/Footer"; import Footer from "../components/Footer";
import ErrorNotification from "../components/ErrorNotification"; import ErrorNotification from "../components/ErrorNotification";
@@ -28,27 +27,25 @@ class App extends Component<Props> {
render() { render() {
const { me, loading, error } = this.props; const { me, loading, error } = this.props;
let content = []; let content;
let navigation; let navigation;
if (loading) { if (loading) {
content.push(<Loading />); content = <Loading />;
} else if (error) { } else if (error) {
// TODO add error page instead of plain notification // TODO add error page instead of plain notification
content.push(<ErrorNotification error={error} />); content = <ErrorNotification error={error} />;
} else if (!me) { } else if (!me) {
content.push(<Login />); content = <Login />;
} else { } else {
content.push(<Main />, <Footer me={me} />); content = <Main me={me} />;
navigation = <PrimaryNavigation />; navigation = <PrimaryNavigation />;
} }
return ( return (
<div className="App"> <div className="App">
<Header>{navigation}</Header> <Header>{navigation}</Header>
{content.map(c => { {content}
return c;
})}
</div> </div>
); );
} }

View File

@@ -26,5 +26,10 @@ $blue: #33B2E8;
padding: 0 0 0 3.8em !important; padding: 0 0 0 3.8em !important;
} }
html, body {
background-color: whitesmoke;
height: 100%;
}
// 6. Import the rest of Bulma // 6. Import the rest of Bulma
@import "bulma/bulma"; @import "bulma/bulma";

View File

@@ -72,6 +72,7 @@ class Login extends React.Component<Props, State> {
render() { render() {
const { classes, loading, error } = this.props; const { classes, loading, error } = this.props;
return ( return (
<section className="hero has-background-light"> <section className="hero has-background-light">
<div className="hero-body"> <div className="hero-body">

View File

@@ -8,29 +8,27 @@ import { Route, withRouter } from "react-router";
import Repositories from "../repositories/containers/Repositories"; import Repositories from "../repositories/containers/Repositories";
import Users from "../users/containers/Users"; import Users from "../users/containers/Users";
import { Switch } from "react-router-dom"; import { Switch } from "react-router-dom";
import Footer from "../components/Footer";
const styles = { import type { Me } from "../types/me";
content: {
paddingTop: "60px"
}
};
type Props = { type Props = {
classes: any me: Me
}; };
class Main extends React.Component<Props> { class Main extends React.Component<Props> {
render() { render() {
const { classes } = this.props; const { me } = this.props;
return ( return (
<div className={classNames("container", classes.content)}> <div>
<Switch> <Switch>
<Route exact path="/" component={Repositories} /> <Route exact path="/" component={Repositories} />
<Route path="/users" component={Users} /> <Route path="/users" component={Users} />
</Switch> </Switch>
<Footer me={me} />
</div> </div>
); );
} }
} }
export default withRouter(injectSheet(styles)(Main)); export default withRouter(Main);

View File

@@ -1,6 +1,6 @@
//@flow //@flow
import { apiClient, NOT_AUTHENTICATED_ERROR } from "../apiclient"; import { apiClient, NOT_AUTHENTICATED_ERROR } from "../apiclient";
import type { Me } from "../types/me";
const AUTHENTICATION_INFO_URL = "/me"; const AUTHENTICATION_INFO_URL = "/me";
@@ -15,7 +15,7 @@ export function meRequest() {
}; };
} }
export function meSuccess(user: any) { export function meSuccess(user: Me) {
return { return {
type: ME_AUTHENTICATED_SUCCESS, type: ME_AUTHENTICATED_SUCCESS,
payload: user payload: user

4
scm-ui/src/types/me.js Normal file
View File

@@ -0,0 +1,4 @@
// @flow
export type Me = {
username: string
};