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

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

Loading…
Cancel
Save