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,6 +216,7 @@ class Editor extends React.Component {
resetDefaultSettings={this.resetDefaultSettings} resetDefaultSettings={this.resetDefaultSettings}
/> />
<div className="buttons"> <div className="buttons">
{this.props.tweet && (
<Button <Button
className="tweetButton" className="tweetButton"
onClick={this.upload} onClick={this.upload}
@ -226,6 +224,7 @@ class Editor extends React.Component {
color="#57b5f9" color="#57b5f9"
style={{ marginRight: '8px' }} 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