Editor refactors (#336)

main
Michael Fix 7 years ago committed by GitHub
parent 2276435fef
commit ce5cc92aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -148,12 +148,9 @@ class Editor extends React.Component {
upload() {
this.setState({ uploading: true })
this.getCarbonImage({ format: 'png' })
.then(api.tweet)
.then(this.props.tweet)
.catch(console.error)
.then(() => this.setState({ uploading: false }))
.catch(err => {
console.error(err)
this.setState({ uploading: false })
})
}
onDrop([file]) {
@ -219,13 +216,15 @@ class Editor extends React.Component {
resetDefaultSettings={this.resetDefaultSettings}
/>
<div className="buttons">
<Button
className="tweetButton"
onClick={this.upload}
title={this.state.uploading ? 'Loading...' : 'Tweet Image'}
color="#57b5f9"
style={{ marginRight: '8px' }}
/>
{this.props.tweet && (
<Button
className="tweetButton"
onClick={this.upload}
title={this.state.uploading ? 'Loading...' : 'Tweet Image'}
color="#57b5f9"
style={{ marginRight: '8px' }}
/>
)}
<Dropdown {...saveButtonOptions} onChange={this.save} />
</div>
</Toolbar>

@ -28,7 +28,7 @@ class Index extends React.Component {
render() {
return (
<Page enableHeroText={true}>
<Editor {...this.props} onUpdate={onEditorUpdate} />
<Editor {...this.props} onUpdate={onEditorUpdate} tweet={api.tweet} />
</Page>
)
}

Loading…
Cancel
Save