diff --git a/components/BackgroundSelect.js b/components/BackgroundSelect.js
index 52af9b3..85c28fa 100644
--- a/components/BackgroundSelect.js
+++ b/components/BackgroundSelect.js
@@ -10,7 +10,7 @@ import { parseRGBA, capitalizeFirstLetter } from '../lib/util'
class BackgroundSelect extends React.PureComponent {
constructor(props) {
super(props)
- this.state = { isVisible: false, selectedTab: 'color', mounted: false }
+ this.state = { isVisible: false, mounted: false }
this.toggle = this.toggle.bind(this)
this.selectTab = this.selectTab.bind(this)
this.handlePickColor = this.handlePickColor.bind(this)
@@ -69,9 +69,9 @@ class BackgroundSelect extends React.PureComponent {
- {['color', 'image'].map((tab, i) => (
+ {['color', 'image'].map(tab => (
@@ -94,118 +94,120 @@ class BackgroundSelect extends React.PureComponent {
-
+ `}
+
)
}
diff --git a/components/Button.js b/components/Button.js
index 3a17b7c..9d02a1c 100644
--- a/components/Button.js
+++ b/components/Button.js
@@ -12,24 +12,26 @@ export default props => (
}}
>
{props.title}
-
+ button > span {
+ font-size: 14px;
+ line-height: 1;
+ }
+ `}
+
)
diff --git a/components/Carbon.js b/components/Carbon.js
index e2e06f6..60d2e1e 100644
--- a/components/Carbon.js
+++ b/components/Carbon.js
@@ -1,23 +1,14 @@
-import { EOL } from 'os'
import * as hljs from 'highlight.js'
import React, { PureComponent } from 'react'
import Spinner from 'react-spinner'
import ResizeObserver from 'resize-observer-polyfill'
-import toHash from 'tohash'
import debounce from 'lodash.debounce'
import ms from 'ms'
import WindowControls from '../components/WindowControls'
import Watermark from '../components/svg/Watermark'
import CodeMirror from '../lib/react-codemirror'
-import {
- COLORS,
- DEFAULT_LANGUAGE,
- LANGUAGES,
- LANGUAGE_MODE_HASH,
- LANGUAGE_NAME_HASH,
- DEFAULT_SETTINGS
-} from '../lib/constants'
+import { COLORS, LANGUAGE_MODE_HASH, LANGUAGE_NAME_HASH, DEFAULT_SETTINGS } from '../lib/constants'
class Carbon extends PureComponent {
constructor(props) {
@@ -130,120 +121,122 @@ class Carbon extends PureComponent {
-
+ top: 0px;
+ right: 0px;
+ bottom: 0px;
+ left: 0px;
+ }
+
+ #container .alpha {
+ position: absolute;
+ top: 0px;
+ right: 0px;
+ bottom: 0px;
+ left: 0px;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==);
+ }
+
+ #container :global(.cm-s-dracula .CodeMirror-cursor) {
+ border-left: solid 2px #159588;
+ }
+
+ #container :global(.cm-s-solarized) {
+ box-shadow: none;
+ }
+
+ #container :global(.cm-s-solarized.cm-s-light) {
+ text-shadow: #eee8d5 0 1px;
+ }
+
+ #container :global(.CodeMirror-gutters) {
+ background-color: unset;
+ border-right: none;
+ }
+
+ #container :global(.CodeMirror__container) {
+ min-width: inherit;
+ position: relative;
+ z-index: 1;
+ border-radius: 5px;
+ ${config.dropShadow
+ ? `box-shadow: 0 ${config.dropShadowOffsetY} ${
+ config.dropShadowBlurRadius
+ } rgba(0, 0, 0, 0.55)`
+ : ''};
+ }
+
+ #container :global(.CodeMirror__container .CodeMirror) {
+ height: auto;
+ min-width: inherit;
+ padding: 18px 18px;
+ ${config.lineNumbers ? 'padding-left: 12px;' : ''} border-radius: 5px;
+ font-family: ${config.fontFamily}, monospace !important;
+ font-size: ${config.fontSize};
+ font-variant-ligatures: contextual;
+ font-feature-settings: 'calt' 1;
+ user-select: none;
+ }
+
+ #container :global(.CodeMirror-scroll) {
+ overflow: hidden !important;
+ }
+
+ #container :global(.window-theme__sharp > .CodeMirror) {
+ border-radius: 0px;
+ }
+
+ #container :global(.window-theme__bw > .CodeMirror) {
+ border: 2px solid ${COLORS.SECONDARY};
+ }
+
+ #container :global(.window-controls + .CodeMirror__container > .CodeMirror) {
+ padding-top: 48px;
+ }
+ `}
+
)
}
@@ -254,24 +247,26 @@ class Carbon extends PureComponent {
{content}
-
+
)
}
diff --git a/components/Collapse.js b/components/Collapse.js
index ceb7ea9..d925d7b 100644
--- a/components/Collapse.js
+++ b/components/Collapse.js
@@ -1,6 +1,5 @@
import React from 'react'
import Toggle from './Toggle'
-import Arrowdown from './svg/Arrowdown'
class Collapse extends React.Component {
constructor(props) {
diff --git a/components/Dropdown.js b/components/Dropdown.js
index 4cdf825..4c71cbe 100644
--- a/components/Dropdown.js
+++ b/components/Dropdown.js
@@ -10,13 +10,10 @@ class Dropdown extends PureComponent {
inputValue: this.props.selected.name,
itemsToShow: this.props.list
}
- userInputtedValue = ''
onUserAction = changes => {
this.setState(({ inputValue, itemsToShow }) => {
- const clearUserInput = changes.hasOwnProperty('isOpen')
-
- if (changes.hasOwnProperty('inputValue')) {
+ if (Object.prototype.hasOwnProperty.call(changes, 'inputValue')) {
if (changes.type === Downshift.stateChangeTypes.keyDownEscape) {
inputValue = this.userInputtedValue
} else {
@@ -30,7 +27,7 @@ class Dropdown extends PureComponent {
: this.props.list
if (
- changes.hasOwnProperty('highlightedIndex') &&
+ Object.prototype.hasOwnProperty.call(changes, 'highlightedIndex') &&
(changes.type === Downshift.stateChangeTypes.keyDownArrowUp ||
changes.type === Downshift.stateChangeTypes.keyDownArrowDown)
) {
@@ -38,7 +35,7 @@ class Dropdown extends PureComponent {
this.props.onChange(itemsToShow[changes.highlightedIndex])
}
- if (changes.hasOwnProperty('isOpen')) {
+ if (Object.prototype.hasOwnProperty.call(changes, 'isOpen')) {
this.userInputtedValue = ''
// clear on open
@@ -56,6 +53,8 @@ class Dropdown extends PureComponent {
})
}
+ userInputtedValue = ''
+
render() {
const { button, color, list, selected, onChange } = this.props
@@ -122,13 +121,15 @@ const DropdownContainer = ({ children, innerRef, minWidth, ...rest }) => {
return (
{children}
-
+
)
}
@@ -150,40 +151,42 @@ const SelectedItem = ({ getButtonProps, getInputProps, children, isOpen, color,
className="dropdown-display-text"
/>
)}
-
+
-
+ .dropdown-display-text {
+ flex-grow: 1;
+ color: ${itemColor};
+ background: transparent;
+ border: none;
+ outline: none;
+ font-size: inherit;
+ font-family: inherit;
+ }
+ .is-open > .dropdown-arrow {
+ transform: rotate(180deg);
+ }
+ `}
+
)
}
@@ -192,15 +195,17 @@ const ListItems = ({ children, color }) => {
return (
)
}
@@ -212,27 +217,29 @@ const ListItem = ({ children, color, isHighlighted, isSelected, ...rest }) => {
{children}
{isSelected ? : null}
-
+ .dropdown-list-item:hover {
+ background: ${COLORS.HOVER};
+ }
+ .dropdown-list-item-text {
+ flex-grow: 1;
+ color: ${itemColor};
+ }
+ `}
+
)
}
diff --git a/components/ExportSizeSelect.js b/components/ExportSizeSelect.js
index 93624a9..4318ee9 100644
--- a/components/ExportSizeSelect.js
+++ b/components/ExportSizeSelect.js
@@ -1,7 +1,6 @@
import React from 'react'
-import { COLORS } from '../lib/constants'
import Checkmark from './svg/Checkmark'
-import { EXPORT_SIZES } from '../lib/constants'
+import { EXPORT_SIZES, COLORS } from '../lib/constants'
export default class extends React.Component {
constructor(props) {
@@ -22,12 +21,16 @@ export default class extends React.Component {
}
renderExportSizes() {
- return EXPORT_SIZES.map((exportSize, i) => {
- return (
-
- {exportSize.name}
- {this.props.selected === exportSize.id ? : null}
-
-
- )
- })
+ `}
+
+
+ ))
}
render() {
@@ -63,25 +66,27 @@ export default class extends React.Component {
{selectedExportSize.name}
{this.renderExportSizes()}
-
+
)
}
diff --git a/components/FontSelect.js b/components/FontSelect.js
index 6f612d2..8af01fe 100644
--- a/components/FontSelect.js
+++ b/components/FontSelect.js
@@ -21,28 +21,30 @@ export default class extends React.Component {
}
renderListItems() {
- return FONTS.map((font, i) => (
-
+ return FONTS.map(font => (
+
{font.name}
{this.props.selected === font.id ? : null}
-
+
))
}
@@ -59,25 +61,27 @@ export default class extends React.Component {
{selectedFont.name}
{this.renderListItems()}
-
+
)
}
diff --git a/components/Footer.js b/components/Footer.js
index 830f79f..d3a6c89 100644
--- a/components/Footer.js
+++ b/components/Footer.js
@@ -4,7 +4,7 @@ import { COLORS } from '../lib/constants'
const Footer = () => (
)
diff --git a/components/Header.js b/components/Header.js
index cc061cc..5bd713d 100644
--- a/components/Header.js
+++ b/components/Header.js
@@ -14,25 +14,27 @@ const Header = ({ enableHeroText }) => (
) : null}
-
+ h2 {
+ text-align: center;
+ }
+ `}
+
)
diff --git a/components/ImagePicker.js b/components/ImagePicker.js
index 6912d1b..1102049 100644
--- a/components/ImagePicker.js
+++ b/components/ImagePicker.js
@@ -1,9 +1,7 @@
import React from 'react'
import ReactCrop, { makeAspectCrop } from 'react-image-crop'
-import Slider from './Slider'
import RandomImage from './RandomImage'
-import { COLORS } from '../lib/constants'
import { fileToDataURL } from '../lib/util'
const getCroppedImg = (imageDataURL, pixelCrop) => {
@@ -12,7 +10,7 @@ const getCroppedImg = (imageDataURL, pixelCrop) => {
canvas.height = pixelCrop.height
const ctx = canvas.getContext('2d')
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
const image = new Image()
image.src = imageDataURL
image.onload = () => {
@@ -47,7 +45,7 @@ export default class extends React.Component {
}
componentWillReceiveProps(nextProps) {
- if (this.state.crop && this.props.aspectRatio != nextProps.aspectRatio) {
+ if (this.state.crop && this.props.aspectRatio !== nextProps.aspectRatio) {
// update crop for editor container aspect-ratio change
this.setState({
crop: makeAspectCrop(
@@ -61,20 +59,17 @@ export default class extends React.Component {
}
}
- selectImage(e) {
- const file = e.target ? e.target.files[0] : e
-
- return fileToDataURL(file).then(dataURL =>
- this.props.onChange({ backgroundImage: dataURL, backgroundImageSelection: null })
- )
+ async onDragEnd() {
+ if (this.state.pixelCrop) {
+ const croppedImg = await getCroppedImg(this.props.imageDataURL, this.state.pixelCrop)
+ this.props.onChange({ backgroundImageSelection: croppedImg })
+ }
}
- removeImage() {
- this.setState(INITIAL_STATE, () => {
- this.props.onChange({
- backgroundImage: null,
- backgroundImageSelection: null
- })
+ onCropChange(crop, pixelCrop) {
+ this.setState({
+ crop: { ...crop, aspect: this.props.aspectRatio },
+ pixelCrop
})
}
@@ -93,18 +88,21 @@ export default class extends React.Component {
})
}
- onCropChange(crop, pixelCrop) {
- this.setState({
- crop: { ...crop, aspect: this.props.aspectRatio },
- pixelCrop
- })
+ selectImage(e) {
+ const file = e.target ? e.target.files[0] : e
+
+ return fileToDataURL(file).then(dataURL =>
+ this.props.onChange({ backgroundImage: dataURL, backgroundImageSelection: null })
+ )
}
- async onDragEnd() {
- if (this.state.pixelCrop) {
- const croppedImg = await getCroppedImg(this.props.imageDataURL, this.state.pixelCrop)
- this.props.onChange({ backgroundImageSelection: croppedImg })
- }
+ removeImage() {
+ this.setState(INITIAL_STATE, () => {
+ this.props.onChange({
+ backgroundImage: null,
+ backgroundImageSelection: null
+ })
+ })
}
render() {
@@ -125,31 +123,33 @@ export default class extends React.Component {
-
+
)
@@ -174,31 +174,33 @@ export default class extends React.Component {
keepSelection
/>
-
+
)
}
@@ -206,11 +208,13 @@ export default class extends React.Component {
return (
)
}
diff --git a/components/Language.js b/components/Language.js
index ffc18cf..090abcc 100644
--- a/components/Language.js
+++ b/components/Language.js
@@ -1,5 +1,4 @@
import React from 'react'
-import { Controls, ControlsBW } from './svg/Controls'
export default ({ language }) => (
diff --git a/components/Meta.js b/components/Meta.js
index 644bd48..70b4516 100644
--- a/components/Meta.js
+++ b/components/Meta.js
@@ -1,5 +1,5 @@
import Head from 'next/head'
-import { THEMES, COLORS } from '../lib/constants'
+import { THEMES } from '../lib/constants'
import Reset from './style/Reset'
import Font from './style/Font'
import Typography from './style/Typography'
@@ -39,11 +39,11 @@ export default () => (
/>
- {THEMES.filter(t => t.hasStylesheet !== false).map((theme, i) => (
+ {THEMES.filter(t => t.hasStylesheet !== false).map(theme => (
(
-
+
)
diff --git a/components/Overlay.js b/components/Overlay.js
index 353cd12..9f3f53a 100644
--- a/components/Overlay.js
+++ b/components/Overlay.js
@@ -2,25 +2,27 @@ const Overlay = props => (
{props.isOver ?
{props.title}
: null}
{props.children}
-
+ .dnd-overlay {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ width: 100%;
+ height: 100%;
+ z-index: 999;
+ position: absolute;
+ top: 0;
+ left: 0;
+ background: rgba(0, 0, 0, 0.85);
+ }
+ `}
+
)
diff --git a/components/Page.js b/components/Page.js
index 9071455..4b41a63 100644
--- a/components/Page.js
+++ b/components/Page.js
@@ -11,13 +11,15 @@ export default ({ children, enableHeroText }) => (
-
+
)
diff --git a/components/RandomImage.js b/components/RandomImage.js
index 737d65f..458e1ed 100644
--- a/components/RandomImage.js
+++ b/components/RandomImage.js
@@ -10,9 +10,8 @@ const WALLPAPER_COLLECTION_ID = 136026
const RANDOM_WALLPAPER_URL = `https://source.unsplash.com/collection/${WALLPAPER_COLLECTION_ID}/240x320`
const largerImage = url => url.replace(/w=\d+/, 'w=1920').replace(/&h=\d+/, '')
-const smallerImage = url => url.replace(/w=\d+/, 'w=240')
-export default class extends React.Component {
+export default class RandomImage extends React.Component {
constructor(props) {
super(props)
this.state = { cacheIndex: 0, loading: false }
@@ -22,9 +21,6 @@ export default class extends React.Component {
this.nextImage = this.nextImage.bind(this)
}
- cache = []
- imageUrls = {}
-
// fetch images in browser (we require window.FileReader)
componentDidMount() {
// clear cache when remounted
@@ -39,7 +35,7 @@ export default class extends React.Component {
const res = await axios.get(`${RANDOM_WALLPAPER_URL}?sig=${sig}`, { responseType: 'blob' })
// image already in cache?
- if (this.imageUrls[res.request.responseURL]) return
+ if (this.imageUrls[res.request.responseURL]) return undefined
this.imageUrls[res.request.responseURL] = true
return {
@@ -48,6 +44,9 @@ export default class extends React.Component {
}
}
+ cache = []
+ imageUrls = {}
+
selectImage() {
this.setState({ loading: true })
axios
@@ -85,27 +84,29 @@ export default class extends React.Component {
Try Another
{this.state.loading && }
-
+
)
}
diff --git a/components/Settings.js b/components/Settings.js
index 877f3ee..1c634fd 100644
--- a/components/Settings.js
+++ b/components/Settings.js
@@ -116,62 +116,64 @@ class Settings extends React.Component {
/>
-
+ .settings-settings > :global(div):first-child,
+ .settings-settings > :global(div):last-child,
+ .settings-settings > :global(.collapse) {
+ border-bottom: none;
+ }
+ `}
+
)
}
diff --git a/components/Slider.js b/components/Slider.js
index 45ff3f4..d9f03b6 100644
--- a/components/Slider.js
+++ b/components/Slider.js
@@ -27,49 +27,51 @@ export default class extends React.Component {
-
+ .slider-bg {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ pointer-events: none;
+ height: 32px;
+ width: 100%;
+ background: rgba(255, 255, 255, 0.165);
+ }
+ `}
+
)
}
diff --git a/components/ThemeSelect.js b/components/ThemeSelect.js
index aaed33c..f25b05c 100644
--- a/components/ThemeSelect.js
+++ b/components/ThemeSelect.js
@@ -18,30 +18,32 @@ export default class extends React.Component {
}
renderThemes() {
- return WINDOW_THEMES.map((theme, i) => {
+ return WINDOW_THEMES.map(theme => {
const Img = WINDOW_THEMES_MAP[theme]
return (
-
+ .selected :global(svg) {
+ border-radius: 3px;
+ border: solid 2px ${COLORS.SECONDARY};
+ }
+ `}
+
)
})
@@ -52,22 +54,24 @@ export default class extends React.Component {
Window theme
{this.renderThemes()}
-
+ .themes {
+ display: flex;
+ flex-direction: row;
+ width: 100%;
+ }
+ `}
+
)
}
diff --git a/components/Toggle.js b/components/Toggle.js
index 0a8fece..0fac015 100644
--- a/components/Toggle.js
+++ b/components/Toggle.js
@@ -13,19 +13,21 @@ export default class extends React.Component {
render() {
return (
-
+
{this.props.label}
{this.props.enabled ? : null}
-
+
)
}
diff --git a/components/Toolbar.js b/components/Toolbar.js
index 869d64f..464c50f 100644
--- a/components/Toolbar.js
+++ b/components/Toolbar.js
@@ -1,27 +1,30 @@
import React from 'react'
+
const Toolbar = props => (
{props.children}
-
+ #toolbar > :global(div):last-child {
+ margin-right: 0px;
+ }
+ `}
+
)
diff --git a/components/WindowPointer.js b/components/WindowPointer.js
index 8bea34f..cd83bec 100644
--- a/components/WindowPointer.js
+++ b/components/WindowPointer.js
@@ -3,17 +3,19 @@ import React from 'react'
export default ({ fromLeft }) => (
)
diff --git a/components/style/Font.js b/components/style/Font.js
index ced1d96..0bf5ed9 100644
--- a/components/style/Font.js
+++ b/components/style/Font.js
@@ -1,91 +1,93 @@
export default () => (
-
+ /* latin */
+ @font-face {
+ font-family: 'Ubuntu Mono';
+ font-style: normal;
+ font-weight: 400;
+ src: local('Ubuntu Mono'), local('UbuntuMono-Regular'),
+ url(//fonts.gstatic.com/s/ubuntumono/v7/ViZhet7Ak-LRXZMXzuAfkYgp9Q8gbYrhqGlRav_IXfk.woff2)
+ format('woff2');
+ unicode-range: U + 0000-00ff, U + 0131, U + 0152-0153, U + 02bb-02bc, U + 02c6, U + 02da,
+ U + 02dc, U + 2000-206f, U + 2074, U + 20ac, U + 2122, U + 2212, U + 2215;
+ }
+ `}
+
)
diff --git a/components/style/Reset.js b/components/style/Reset.js
index 337b551..2755b71 100644
--- a/components/style/Reset.js
+++ b/components/style/Reset.js
@@ -1,195 +1,197 @@
import { COLORS } from '../../lib/constants'
export default () => (
-
+ .link:hover {
+ color: ${COLORS.PRIMARY};
+ background: none;
+ }
+ `}
+
)
diff --git a/components/style/Typography.js b/components/style/Typography.js
index dd5a8dd..9192bde 100644
--- a/components/style/Typography.js
+++ b/components/style/Typography.js
@@ -1,178 +1,180 @@
export default () => (
-
+ .mt0 {
+ margin-top: 0;
+ }
+ .mb0 {
+ margin-bottom: 0;
+ }
+ .mt1 {
+ margin-top: var(--x1);
+ }
+ .mb1 {
+ margin-bottom: var(--x1);
+ }
+ .mt2 {
+ margin-top: var(--x2);
+ }
+ .mb2 {
+ margin-bottom: var(--x2);
+ }
+ .mt3 {
+ margin-top: var(--x3);
+ }
+ .mb3 {
+ margin-bottom: var(--x3);
+ }
+ .mt4 {
+ margin-top: var(--x4);
+ }
+ .mb4 {
+ margin-bottom: var(--x4);
+ }
+ .mt5 {
+ margin-top: var(--x5);
+ }
+ .mb5 {
+ margin-bottom: var(--x5);
+ }
+ .mt6 {
+ margin-top: var(--x6);
+ }
+ .mb6 {
+ margin-bottom: var(--x6);
+ }
+
+ .mx {
+ max-width: var(--mx);
+ }
+ .bold {
+ font-weight: bold;
+ }
+ `}
+
)
diff --git a/handlers/image.js b/handlers/image.js
index 90c903c..2ca2cf6 100644
--- a/handlers/image.js
+++ b/handlers/image.js
@@ -1,22 +1,23 @@
+/* global domtoimage */
const PORT = parseInt(process.env.PORT, 10) || 3000
const ARBITRARY_WAIT_TIME = 500
module.exports = browser => async (req, res) => {
- let page = await browser.newPage()
- let state = req.body.state
+ const page = await browser.newPage()
+ const { state } = req.body
if (!state) res.status(400).send()
try {
await page.goto(`http://localhost:${PORT}?state=${state}`)
- await page.addScriptTag({ path: `./lib/customDomToImage.js` })
+ await page.addScriptTag({ path: './lib/customDomToImage.js' })
// wait for page to detect language
await delay(ARBITRARY_WAIT_TIME)
const targetElement = await page.$('#export-container')
- let dataUrl = await page.evaluate(target => {
+ const dataUrl = await page.evaluate(target => {
const config = {
style: {
transform: 'scale(2)',
diff --git a/handlers/twitter.js b/handlers/twitter.js
index e72b7c8..d1b0599 100644
--- a/handlers/twitter.js
+++ b/handlers/twitter.js
@@ -30,7 +30,7 @@ const respondFail = (res, err) => {
}
console.error(`Error: ${err.message || JSON.stringify(err, null, 2)}`)
- res.status(500).send()
+ return res.status(500).send()
}
module.exports = (req, res) => {
@@ -38,7 +38,7 @@ module.exports = (req, res) => {
return res.status(400).send()
}
- uploadImage(req.body.data)
+ return uploadImage(req.body.data)
.then(uploadTweet)
.then(extractImageUrl)
.then(respondSuccess.bind(null, res))
diff --git a/lib/api.js b/lib/api.js
index 7a37b8a..067bbb6 100644
--- a/lib/api.js
+++ b/lib/api.js
@@ -30,7 +30,7 @@ async function image(state) {
return axios.post(`${DOMAIN}/image`, { state }).then(res => res.data.dataUrl)
}
-const getGist = uid => {
+function getGist(uid) {
return gistClient
.get(`/gists/${uid}`)
.then(res => res.data)
@@ -41,10 +41,10 @@ const getGist = uid => {
// private
function openTwitterUrl(twitterUrl) {
- const width = 575,
- height = 400
+ const width = 575
+ const height = 400
const left = (window.outerWidth - width) / 2
- const right = (window.outerHeight - height) / 2
+ const top = (window.outerHeight - height) / 2
const opts = `status=1,width=${width},height=${height},top=${top},left=${left}`
window.open(twitterUrl, 'twitter', opts)
diff --git a/lib/colors.js b/lib/colors.js
index 54a6b21..a93bee3 100644
--- a/lib/colors.js
+++ b/lib/colors.js
@@ -1,4 +1,4 @@
-const colors = new Set([
+export const colors = new Set([
'indian red',
'crimson',
'lightpink',
@@ -595,6 +595,5 @@ const colors = new Set([
'whitesmoke'
])
-export const validateColor = (str = '') => {
- return /#\d{3,6}|rgba{0,1}\(.*?\)/gi.test(str) || colors.has(str.toLowerCase())
-}
+export const validateColor = (str = '') =>
+ /#\d{3,6}|rgba{0,1}\(.*?\)/gi.test(str) || colors.has(str.toLowerCase())
diff --git a/lib/routing.js b/lib/routing.js
index afc644c..e1ab391 100644
--- a/lib/routing.js
+++ b/lib/routing.js
@@ -73,22 +73,21 @@ const keysToQuery = keys =>
export const getQueryStringState = query => {
if (query.state) {
return deserializeState(query.state)
- } else {
- const state = mapper.map(mappings, query)
- deserializeCode(state)
+ }
- Object.keys(state).forEach(key => {
- if (state[key] === '') state[key] = undefined
- })
+ const state = mapper.map(mappings, query)
+ deserializeCode(state)
- return state
- }
+ Object.keys(state).forEach(key => {
+ if (state[key] === '') state[key] = undefined
+ })
+
+ return state
}
export const updateQueryString = state => {
- // If react_perf is set as a queryParm, don't update
if (history.location.search.indexOf('react_perf') < 0) {
- let mappedState = mapper.map(reverseMappings, state)
+ const mappedState = mapper.map(reverseMappings, state)
serializeCode(mappedState)
history.replace({
diff --git a/lib/util.js b/lib/util.js
index 42a9b18..2738693 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -1,4 +1,5 @@
import morph from 'morphmorph'
+
const KEY = 'CARBON_STATE'
const assign = morph.assign(KEY)
@@ -6,7 +7,9 @@ const assign = morph.assign(KEY)
const parse = v => {
try {
return JSON.parse(v)
- } catch (e) {}
+ } catch (e) {
+ // pass
+ }
}
const escapeHtml = s => {
@@ -27,10 +30,9 @@ export const capitalizeFirstLetter = s => s.charAt(0).toUpperCase() + s.slice(1)
export const range = n => [...Array(n).keys()]
-export const fileToDataURL = blob => {
- return new Promise(res => {
+export const fileToDataURL = blob =>
+ new Promise(res => {
const reader = new FileReader()
reader.onload = e => res(e.target.result)
reader.readAsDataURL(blob)
})
-}
diff --git a/pages/_document.js b/pages/_document.js
index acd4368..c11f0d5 100644
--- a/pages/_document.js
+++ b/pages/_document.js
@@ -1,4 +1,5 @@
import Document, { Head, Main, NextScript } from 'next/document'
+
export default class extends Document {
render() {
return (
diff --git a/pages/about.js b/pages/about.js
index a4eb128..9e36e61 100644
--- a/pages/about.js
+++ b/pages/about.js
@@ -1,7 +1,4 @@
import Page from '../components/Page'
-import Meta from '../components/Meta'
-import Header from '../components/Header'
-import Footer from '../components/Footer'
import { COLORS } from '../lib/constants'
export default () => (
@@ -13,7 +10,10 @@ export default () => (
You know all of those code screenshots you see on Twitter? Although the code's
usually impressive, we saw room for improvement in the aesthetic department. Carbon is the
easiest way to create beautiful images of your source code. So what are you waiting for?
- Go impress all of your followers with your newfound design prowess.
🎨
+ Go impress all of your followers with your newfound design prowess.{' '}
+
+ 🎨
+
@@ -23,12 +23,11 @@ export default () => (
@@ -56,24 +55,26 @@ export default () => (
-
+ .about {
+ max-width: 632px;
+ }
+ `}
+
)
diff --git a/pages/editor.js b/pages/editor.js
index 9761a79..0d1f2f0 100644
--- a/pages/editor.js
+++ b/pages/editor.js
@@ -14,7 +14,6 @@ import Settings from '../components/Settings'
import Toolbar from '../components/Toolbar'
import Overlay from '../components/Overlay'
import Carbon from '../components/Carbon'
-import ArrowDown from '../components/svg/Arrowdown'
import api from '../lib/api'
import {
THEMES,
@@ -23,14 +22,11 @@ import {
LANGUAGE_MIME_HASH,
LANGUAGE_MODE_HASH,
LANGUAGE_NAME_HASH,
- DEFAULT_LANGUAGE,
DEFAULT_THEME,
DEFAULT_EXPORT_SIZE,
COLORS,
- EXPORT_SIZES,
EXPORT_SIZES_HASH,
DEFAULT_CODE,
- DEFAULT_BG_COLOR,
DEFAULT_SETTINGS
} from '../lib/constants'
import { getQueryStringState, updateQueryString, serializeState } from '../lib/routing'
@@ -106,10 +102,10 @@ class Editor extends React.Component {
}
getCarbonImage({ format, type } = { format: 'png' }) {
- //if safari, get image from api
+ // if safari, get image from api
if (
- navigator.userAgent.indexOf('Safari') != -1 &&
- navigator.userAgent.indexOf('Chrome') == -1 &&
+ navigator.userAgent.indexOf('Safari') !== -1 &&
+ navigator.userAgent.indexOf('Chrome') === -1 &&
format === 'png'
) {
const encodedState = serializeState(this.state)
@@ -266,19 +262,21 @@ class Editor extends React.Component {
)}
-
+ .buttons {
+ display: flex;
+ margin-left: auto;
+ }
+ `}
+
)
}
diff --git a/pages/index.js b/pages/index.js
index 56dd891..2916278 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -1,2 +1,3 @@
import Editor from './editor'
+
export default Editor