diff --git a/components/Editor.js b/components/Editor.js index f684c1b..d0705cb 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -231,10 +231,10 @@ class Editor extends React.Component { } } - export(format = 'png') { + export(format = 'png', options = {}) { const link = document.createElement('a') - const prefix = this.state.filename || 'carbon' + const prefix = options.filename || 'carbon' return this.getCarbonImage({ format, type: 'blob' }).then(url => { if (format !== 'open') { diff --git a/components/ExportMenu.js b/components/ExportMenu.js index 697dc4c..14825a4 100644 --- a/components/ExportMenu.js +++ b/components/ExportMenu.js @@ -45,14 +45,19 @@ const CopyEmbed = withRouter(({ router: { asPath }, mapper, title, margin }) => const popoutStyle = { width: '280px', right: 0 } class ExportMenu extends React.PureComponent { + input = React.createRef() + handleInputChange = ({ target: { name, value } }) => this.props.onChange(name, value) handleExportSizeChange = selectedSize => () => this.props.onChange('exportSize', selectedSize) - handleExport = format => () => this.props.export(format) + handleExport = format => () => + this.props.export(format, { + filename: this.input.current.value + }) render() { - const { exportSize, filename, isVisible, toggleVisibility, disablePNG } = this.props + const { exportSize, isVisible, toggleVisibility, disablePNG } = this.props return (
@@ -77,14 +82,7 @@ class ExportMenu extends React.PureComponent { >
File name - +
Size diff --git a/components/Input.js b/components/Input.js index 78e3f34..d639091 100644 --- a/components/Input.js +++ b/components/Input.js @@ -2,58 +2,64 @@ import React from 'react' import { COLORS } from '../lib/constants' -const Input = ({ - accept, - color = COLORS.SECONDARY, - name, - onChange = () => {}, - placeholder, - title, - type, - value, - align = 'right', - maxLength -}) => { - return ( - - - - - ) -} + input[type='file'] { + cursor: pointer; + outline: none; + } + `} + + + ) + } +) export default Input diff --git a/pages/index.js b/pages/index.js index c55a2cd..897ad3b 100644 --- a/pages/index.js +++ b/pages/index.js @@ -26,7 +26,7 @@ class Index extends React.Component { updateRouteState(this.props.router, state) saveSettings( localStorage, - omit(state, ['code', 'backgroundImage', 'backgroundImageSelection', 'filename', 'themes']) + omit(state, ['code', 'backgroundImage', 'backgroundImageSelection', 'themes']) ) }, 750,