Skip to content

Commit df77ebd

Browse files
committed
update: Main comp, input style when error occurs.
1 parent ecaf1b5 commit df77ebd

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/pages/Main/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default class Main extends Component {
99
state = {
1010
repositoryInput: '',
1111
repositories: [],
12+
repositoryError: false,
1213
};
1314

1415
handleAddRepository = async (e) => {
@@ -20,11 +21,12 @@ export default class Main extends Component {
2021
repository.lastCommit = moment(repository.pushed_at).fromNow();
2122

2223
this.setState(state => ({
24+
repositoryError: false,
2325
repositoryInput: '',
2426
repositories: [...state.repositories, repository],
2527
}));
2628
} catch (error) {
27-
console.log(error);
29+
this.setState({ repositoryError: true });
2830
}
2931
};
3032

@@ -33,7 +35,7 @@ export default class Main extends Component {
3335
<Container>
3436
<img src={Logo} alt="Github Compare" />
3537

36-
<Form onSubmit={this.handleAddRepository}>
38+
<Form withError={this.state.repositoryError} onSubmit={this.handleAddRepository}>
3739
<input
3840
type="text"
3941
placeholder="usuário/repositório"

src/pages/Main/styles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ export const Form = styled.form`
1818
height: 55px;
1919
padding: 0 20px;
2020
background: #fff;
21-
border: 0;
2221
font-size: 18px;
2322
color: #444;
2423
border-radius: 3px;
24+
25+
border: ${props => (props.withError ? '2px solid #f00' : 0)};
2526
}
2627
2728
button {

0 commit comments

Comments
 (0)