Skip to content

Commit 5079942

Browse files
committed
styled components
1 parent cc7d6ef commit 5079942

File tree

6 files changed

+48
-58
lines changed

6 files changed

+48
-58
lines changed

Diff for: src/app/views/about/About.js

+14-28
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,26 @@
22

33
// #region imports
44
import React, { PureComponent } from 'react';
5-
import PropTypes from 'prop-types';
6-
import classnames from 'classnames';
7-
import styles from './about.scss';
5+
import { type Match, type Location, type RouterHistory } from 'react-router';
86
// #endregion
97

108
// #region flow types
11-
type Props = any;
12-
type State = any;
13-
// #endregion
9+
type Props = {
10+
match: Match,
11+
location: Location,
12+
history: RouterHistory,
13+
14+
currentView: string,
15+
enterAbout: () => any,
16+
leaveAbout: () => any,
17+
18+
...any,
19+
};
1420

15-
// #region constants
16-
// IMPORTANT: we need to bind classnames to CSSModule generated classes:
17-
const cx = classnames.bind(styles);
21+
type State = any;
1822
// #endregion
1923

2024
class About extends PureComponent<Props, State> {
21-
static propTypes = {
22-
// react-router 4:
23-
match: PropTypes.object.isRequired,
24-
location: PropTypes.object.isRequired,
25-
history: PropTypes.object.isRequired,
26-
27-
// views
28-
currentView: PropTypes.string.isRequired,
29-
enterAbout: PropTypes.func.isRequired,
30-
leaveAbout: PropTypes.func.isRequired,
31-
};
32-
33-
state = {
34-
viewEntersAnim: true,
35-
};
36-
3725
// #region lifecycle
3826
componentDidMount() {
3927
const { enterAbout } = this.props;
@@ -46,10 +34,8 @@ class About extends PureComponent<Props, State> {
4634
}
4735

4836
render() {
49-
const { viewEntersAnim } = this.state;
50-
5137
return (
52-
<div className={cx({ 'view-enter': viewEntersAnim })}>
38+
<div>
5339
<h1>About</h1>
5440
</div>
5541
);

Diff for: src/app/views/about/about.scss

Whitespace-only changes.

Diff for: src/app/views/home/Home.js

-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import React, { PureComponent } from 'react';
55
import { type Match, type Location, type RouterHistory } from 'react-router';
66
import Jumbotron from '../../components/jumbotron/Jumbotron';
7-
// import classnames from 'classnames';
87
import { Link } from 'react-router-dom';
9-
// import styles from './home.scss';
108
// #endregion
119

1210
// #region flow types
@@ -43,11 +41,6 @@ export type Props = {
4341
export type State = any;
4442
// #endregion
4543

46-
// #region constants
47-
// IMPORTANT: we need to bind classnames to CSSModule generated classes:
48-
// const cx = classnames.bind(styles);
49-
// #endregion
50-
5144
class Home extends PureComponent<Props, State> {
5245
// #region lifecycle
5346
componentDidMount() {

Diff for: src/app/views/home/home.scss

Whitespace-only changes.

Diff for: src/app/views/login/Login.js

+34-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Link } from 'react-router-dom';
77
import { ErrorAlert } from '../../components';
88
import * as UserAuthTypes from '../../redux/modules/userAuth.types';
99
import { type Match, type Location, type RouterHistory } from 'react-router';
10-
// import styles from './login.scss';
10+
import styled from 'styled-components';
1111
// #endregion
1212

1313
// #region flow types
@@ -55,9 +55,11 @@ export type State = {
5555
};
5656
// #endregion
5757

58-
// #region constants
59-
// IMPORTANT: we need to bind classnames to CSSModule generated classes:
60-
// const cx = classnames.bind(styles);
58+
// #region styled components
59+
const LoginButton = styled.button`
60+
margin-left: 10px;
61+
`;
62+
6163
// #endregion
6264

6365
class Login extends PureComponent<Props, State> {
@@ -131,13 +133,13 @@ class Login extends PureComponent<Props, State> {
131133
<Link className="btn btn-default" to={'/'}>
132134
Cancel
133135
</Link>
134-
<button
135-
className="btn btn-primary loginButton"
136+
<LoginButton
137+
className="btn btn-primary"
136138
disabled={mutationLoading}
137139
onClick={this.handlesOnLogin}
138140
>
139141
Login
140-
</button>
142+
</LoginButton>
141143
</div>
142144
</div>
143145
</fieldset>
@@ -155,22 +157,32 @@ class Login extends PureComponent<Props, State> {
155157
}
156158
// #endregion
157159

158-
handlesOnEmailChange = event => {
159-
event.preventDefault();
160-
// should add some validator before setState in real use cases
161-
this.setState({ email: event.target.value });
160+
handlesOnEmailChange = (event: SyntheticEvent<>) => {
161+
if (event) {
162+
event.preventDefault();
163+
// should add some validator before setState in real use cases
164+
// $FlowIgnore
165+
this.setState({ email: event.target.value });
166+
}
162167
};
163168

164-
handlesOnPasswordChange = event => {
165-
event.preventDefault();
166-
// should add some validator before setState in real use cases
167-
this.setState({ password: event.target.value });
169+
handlesOnPasswordChange = (event: SyntheticEvent<>) => {
170+
if (event) {
171+
event.preventDefault();
172+
// should add some validator before setState in real use cases
173+
this.setState({
174+
// $FlowIgnore
175+
password: event.target.value,
176+
});
177+
}
168178
};
169179

170-
handlesOnLogin = async event => {
171-
event.preventDefault();
172-
const { loginUser, history } = this.props;
180+
handlesOnLogin = async (event: SyntheticEvent<>) => {
181+
if (event) {
182+
event.preventDefault();
183+
}
173184

185+
const { loginUser, history } = this.props;
174186
const { email, password } = this.state;
175187

176188
const user = {
@@ -186,8 +198,10 @@ class Login extends PureComponent<Props, State> {
186198
}
187199
};
188200

189-
closeError = event => {
190-
event.preventDefault();
201+
closeError = (event: SyntheticEvent<>) => {
202+
if (event) {
203+
event.preventDefault();
204+
}
191205
const { resetLogError } = this.props;
192206
resetLogError();
193207
};

Diff for: src/app/views/login/login.scss

-3
This file was deleted.

0 commit comments

Comments
 (0)