|
|
@ -1,15 +1,27 @@
|
|
|
|
|
|
|
|
// Theirs
|
|
|
|
import React from 'react'
|
|
|
|
import React from 'react'
|
|
|
|
import HTML5Backend from 'react-dnd-html5-backend'
|
|
|
|
import HTML5Backend from 'react-dnd-html5-backend'
|
|
|
|
import { DragDropContext } from 'react-dnd'
|
|
|
|
import { DragDropContext } from 'react-dnd'
|
|
|
|
import domtoimage from 'dom-to-image'
|
|
|
|
import domtoimage from 'dom-to-image'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ours
|
|
|
|
import Page from '../components/Page'
|
|
|
|
import Page from '../components/Page'
|
|
|
|
import ReadFileDropContainer from '../components/ReadFileDropContainer'
|
|
|
|
import ReadFileDropContainer from '../components/ReadFileDropContainer'
|
|
|
|
|
|
|
|
import Button from '../components/Button'
|
|
|
|
|
|
|
|
import Dropdown from '../components/Dropdown'
|
|
|
|
|
|
|
|
import ColorPicker from '../components/ColorPicker'
|
|
|
|
|
|
|
|
import Settings from '../components/Settings'
|
|
|
|
import Toolbar from '../components/Toolbar'
|
|
|
|
import Toolbar from '../components/Toolbar'
|
|
|
|
import Overlay from '../components/Overlay'
|
|
|
|
import Overlay from '../components/Overlay'
|
|
|
|
import Carbon from '../components/Carbon'
|
|
|
|
import Carbon from '../components/Carbon'
|
|
|
|
import api from '../lib/api'
|
|
|
|
import api from '../lib/api'
|
|
|
|
import { THEMES, DEFAULT_LANGUAGE, COLORS, DEFAULT_CODE } from '../lib/constants'
|
|
|
|
import {
|
|
|
|
|
|
|
|
THEMES,
|
|
|
|
|
|
|
|
LANGUAGES,
|
|
|
|
|
|
|
|
DEFAULT_LANGUAGE,
|
|
|
|
|
|
|
|
COLORS,
|
|
|
|
|
|
|
|
DEFAULT_CODE
|
|
|
|
|
|
|
|
} from '../lib/constants'
|
|
|
|
|
|
|
|
|
|
|
|
class Editor extends React.Component {
|
|
|
|
class Editor extends React.Component {
|
|
|
|
/* pathname, asPath, err, req, res */
|
|
|
|
/* pathname, asPath, err, req, res */
|
|
|
@ -88,20 +100,27 @@ class Editor extends React.Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Page enableHeroText>
|
|
|
|
<Page enableHeroText>
|
|
|
|
<div id="editor">
|
|
|
|
<div id="editor">
|
|
|
|
<Toolbar
|
|
|
|
<Toolbar>
|
|
|
|
save={this.save}
|
|
|
|
<Dropdown list={THEMES} onChange={theme => this.setState({ theme: theme.id })}/>
|
|
|
|
upload={this.upload}
|
|
|
|
<Dropdown list={LANGUAGES} onChange={language => this.setState({ language: language.module })}/>
|
|
|
|
uploading={this.state.uploading}
|
|
|
|
<ColorPicker
|
|
|
|
onBGChange={color => this.setState({ background: color })}
|
|
|
|
onChange={color => this.setState({ background: color })}
|
|
|
|
onThemeChange={theme => this.setState({ theme: theme.id })}
|
|
|
|
bg={this.state.background}
|
|
|
|
onLanguageChange={language => this.setState({ language: language.module })}
|
|
|
|
/>
|
|
|
|
onSettingsChange={(key, value) => this.setState({ [key]: value })}
|
|
|
|
<Settings onChange={(key, value) => this.setState({ [key]: value })} enabled={this.state} />
|
|
|
|
bg={this.state.background}
|
|
|
|
<div className="buttons">
|
|
|
|
enabled={this.state}
|
|
|
|
<Button
|
|
|
|
/>
|
|
|
|
className="tweetButton"
|
|
|
|
<ReadFileDropContainer
|
|
|
|
onClick={this.upload}
|
|
|
|
onDrop={droppedContent => this.setState({ code: droppedContent })}
|
|
|
|
title={this.state.uploading ? 'Loading...' : 'Tweet Image'}
|
|
|
|
>
|
|
|
|
color="#57b5f9"
|
|
|
|
|
|
|
|
style={{ marginRight: '8px' }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Button onClick={this.save} title="Save Image" color="#c198fb" />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</Toolbar>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ReadFileDropContainer onDrop={droppedContent => this.setState({ code: droppedContent })}>
|
|
|
|
<Overlay title="Drop your file here to import">
|
|
|
|
<Overlay title="Drop your file here to import">
|
|
|
|
<Carbon config={this.state} updateCode={this.updateCode}>
|
|
|
|
<Carbon config={this.state} updateCode={this.updateCode}>
|
|
|
|
{this.state.code}
|
|
|
|
{this.state.code}
|
|
|
|