Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added loader for shorten btn #73

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/MaterialButtonSuccess.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from 'react';
import styled from 'styled-components';
import { CircularProgress } from '@material-ui/core';

function MaterialButtonSuccess(props) {
return (
<Container {...props}>
<Shorten>{props.shorten || 'Shorten'}</Shorten>
<Shorten>
{props.loading ? (
<CircularProgress size={20} />
) : (
props.shorten || ('Shorten')
)}
</Shorten>
</Container>
);
}
Expand Down
11 changes: 9 additions & 2 deletions src/screens/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class HomeScreen extends Component {
error: '',
keyword: '',
customUrl: '',

loading: false,
};

handleKeyword = event => {
Expand Down Expand Up @@ -110,6 +110,9 @@ handleCopy = () => {
};

handleSubmit = async event => {
this.setState({
loading: true,
})
event.preventDefault();
const api_fetch = process.env.REACT_APP_API_KEY;

Expand Down Expand Up @@ -192,6 +195,9 @@ handleCopy = () => {
});
}
}
this.setState({
loading: false,
})
};

render() {
Expand Down Expand Up @@ -274,8 +280,9 @@ handleCopy = () => {
cursor: 'pointer',
background: 'rgba(1, 87, 155, 100)',
}}
loading={this.state.loading}
onClick={this.handleSubmit}
></MaterialButtonSuccess>
/>
</Grid>
<Grid item xs />
</Grid>
Expand Down