From 098e30ceda1be365c7993e4086b41841d37512ae Mon Sep 17 00:00:00 2001 From: ZixinShen Date: Mon, 5 Nov 2018 14:28:03 -0800 Subject: [PATCH 1/3] fix linter error --- src/components/ChangePassword.jsx | 8 +-- src/components/Header.jsx | 84 ++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/src/components/ChangePassword.jsx b/src/components/ChangePassword.jsx index 22abe8e..a91fdba 100644 --- a/src/components/ChangePassword.jsx +++ b/src/components/ChangePassword.jsx @@ -12,10 +12,10 @@ import React from 'react'; import { Input, Button, Card, Row, Col, } from 'react-materialize'; -import Header from './Header'; -import LeasingCard from './LeasingCard'; +import Header from './Header.jsx'; -export default class ChangePassword extends React.Component<{}> { +// eslint-disable-next-line react/prefer-stateless-function +class ChangePassword extends React.Component { render() { return (
@@ -40,3 +40,5 @@ export default class ChangePassword extends React.Component<{}> { ); } } + +export default ChangePassword; diff --git a/src/components/Header.jsx b/src/components/Header.jsx index 9b9440c..e936dcf 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -1,8 +1,9 @@ +// @flow + import React from 'react'; -import { Link } from 'react-router-dom'; import { - Navbar, NavItem, Card, Row, Col, Input, Button, + Card, Row, Col, Input, Button, } from 'react-materialize'; // import Login from './Login'; @@ -16,7 +17,8 @@ class Header extends React.Component { } toggle() { - if (this.state.opened) { + const { opened } = this.state; + if (opened) { console.log('close'); this.setState({ opened: false }); } else { @@ -25,32 +27,33 @@ class Header extends React.Component { } } - render() { - function loginDisplay(login) { - if (!login) { - return ( -
- - - - -
- -
-
- ); - } + loginDisplay() { + const { login } = this.state; + if (login) { return (
- + + +
- +
); } + return ( +
+ + +
+ +
+
+ ); + } + render() { const navStyle = { width: '100%', height: '60px', @@ -86,6 +89,8 @@ class Header extends React.Component { backgroundColor: 'white', }; + const { opened } = this.state; + const maskStyle = { position: 'fixed', width: '100%', @@ -95,7 +100,7 @@ class Header extends React.Component { backgroundColor: 'rgba(0,0,0,0.5)', alignItems: 'center', justifyContent: 'center', - display: this.state.opened ? 'flex' : 'none', + display: opened ? 'flex' : 'none', zIndex: '1', }; @@ -106,34 +111,55 @@ class Header extends React.Component { UCSD CSSA 短租平台
- this.toggle()}>登陆 + 搜索房源 发布房源
-
this.toggle()}> -
e.stopPropagation()}> +
this.toggle()} + onKeyDown={() => this.toggle()} + role="presentation" + > +
e.stopPropagation()} + onKeyDown={e => e.stopPropagation()} + role="presentation" + >
- { this.setState({ login: true, }); }} + onKeyDown={() => { + this.setState({ + login: true, + }); + }} >
登录
-
+
- { this.setState({ @@ -142,12 +168,12 @@ class Header extends React.Component { }} >
注册
-
+
- { loginDisplay(this.state.login) } + { this.loginDisplay() }
From 1a90febfd54d536c4af0e6d6c518da71db446dcf Mon Sep 17 00:00:00 2001 From: ZixinShen Date: Wed, 7 Nov 2018 17:49:41 -0800 Subject: [PATCH 2/3] update on css style --- src/components/Header.jsx | 101 +++++++++++------------------- src/components/styles/header.scss | 34 ++++++++++ 2 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 src/components/styles/header.scss diff --git a/src/components/Header.jsx b/src/components/Header.jsx index e936dcf..97ec097 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -1,11 +1,11 @@ // @flow import React from 'react'; +import './styles/header.scss'; import { Card, Row, Col, Input, Button, } from 'react-materialize'; -// import Login from './Login'; class Header extends React.Component { constructor(props) { @@ -16,6 +16,22 @@ class Header extends React.Component { }; } + getStyle() { + const { opened } = this.state; + return { + position: 'fixed', + width: '100%', + height: '100%', + left: '0', + top: '0', + backgroundColor: 'rgba(0,0,0,0.5)', + alignItems: 'center', + justifyContent: 'center', + display: opened ? 'flex' : 'none', + zIndex: '1', + }; + } + toggle() { const { opened } = this.state; if (opened) { @@ -53,83 +69,40 @@ class Header extends React.Component { ); } - render() { - const navStyle = { - width: '100%', - height: '60px', - backgroundColor: 'rgba(186, 0, 0, 1)', - display: 'flex', - zIndex: '1000000', - boxShadow: '0 0 5px rgba(0, 0, 0, 0.3)', - }; - - const navLeftStyle = { - display: 'flex', - }; - - const navRightStyle = { - flexGrow: '1000000', - flexFlow: 'row-reverse', - display: 'flex', - }; - - const navRightItemStyle = { - lineHeight: '60px', - padding: '0 15px', - }; - - const buttonStyle = { - color: 'black', - cursor: 'pointer', - }; - - const loginStyle = { - width: '50%', - height: '60%', - backgroundColor: 'white', - }; - - const { opened } = this.state; - - const maskStyle = { - position: 'fixed', - width: '100%', - height: '100%', - left: '0', - top: '0', - backgroundColor: 'rgba(0,0,0,0.5)', - alignItems: 'center', - justifyContent: 'center', - display: opened ? 'flex' : 'none', - zIndex: '1', - }; + render() { return ( -
-