diff --git a/components/Button.js b/components/Button.js index e843596..c8050e1 100644 --- a/components/Button.js +++ b/components/Button.js @@ -5,9 +5,7 @@ import { COLORS } from '../lib/constants' const Button = ({ id, - 'data-cy': cypressElementId, onClick = () => {}, - className = '', background = COLORS.BLACK, color = COLORS.SECONDARY, hoverBackground = COLORS.HOVER, @@ -18,25 +16,19 @@ const Button = ({ border, center, large, - style = {}, flex = 1, padding = 0, margin = 0, - title + title, + Component = 'button', + ...props }) => ( - + ) export default Button diff --git a/components/Settings.js b/components/Settings.js index 7a2b968..fa10b3a 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -9,7 +9,7 @@ import Popout, { managePopout } from './Popout' import Button from './Button' import Presets from './Presets' import { COLORS, DEFAULT_PRESETS } from '../lib/constants' -import { toggle, getPresets, savePresets, generateId } from '../lib/util' +import { toggle, getPresets, savePresets, generateId, fileToJSON } from '../lib/util' import SettingsIcon from './svg/Settings' import * as Arrows from './svg/Arrows' @@ -140,10 +140,42 @@ const TypeSettings = React.memo( const resetButtonStyle = { borderTop: `1px solid ${COLORS.SECONDARY}` } -const MiscSettings = React.memo(({ format, reset }) => { +const MiscSettings = React.memo(({ format, reset, applyPreset, settings }) => { + const input = React.useRef(null) + let download + try { + download = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(settings))}` + } catch (error) { + // pass + } return (
- + +
+ @@ -340,8 +381,17 @@ class Settings extends React.PureComponent { lineHeight={this.props.lineHeight} /> ) - case 'Misc': - return + case 'Misc': { + const settings = this.getSettingsFromProps() + return ( + + ) + } default: return null } diff --git a/lib/util.js b/lib/util.js index eb12562..f48dda2 100644 --- a/lib/util.js +++ b/lib/util.js @@ -68,6 +68,13 @@ export const fileToDataURL = blob => reader.readAsDataURL(blob) }) +export const fileToJSON = blob => + new Promise(res => { + const reader = new FileReader() + reader.onload = e => res(parse(e.target.result)) + reader.readAsText(blob) + }) + export const formatCode = async code => { const prettier = await import('prettier/standalone') const babylonParser = await import('prettier/parser-babylon')