From 64cccc1d90a6f9fd69c18b2bde54ab1d45ae43de Mon Sep 17 00:00:00 2001 From: raboid Date: Wed, 9 Jan 2019 11:09:37 -0500 Subject: [PATCH] Move Presets into separate file --- components/Presets.js | 189 +++++++++++++++++++++++++++++++++++++++++ components/Settings.js | 182 +-------------------------------------- 2 files changed, 190 insertions(+), 181 deletions(-) create mode 100644 components/Presets.js diff --git a/components/Presets.js b/components/Presets.js new file mode 100644 index 0000000..7324481 --- /dev/null +++ b/components/Presets.js @@ -0,0 +1,189 @@ +import React from 'react' + +import Button from './Button' +import { COLORS, DEFAULT_PRESETS } from '../lib/constants' +import * as Arrows from './svg/Arrows' +import Remove from './svg/Remove' + +const removeButtonStyles = { + position: 'absolute', + top: '6px', + right: '6px', + width: '11px', + height: '11px', + borderRadius: '999px' +} + +const Preset = React.memo(({ remove, apply, selected, preset }) => { + const isSelected = preset.id === selected + + return ( +
+ + )} + +
+ ) +}) + +const arrowButtonStyle = { + position: 'absolute', + top: 0, + right: '16px', + height: '100%' +} + +const Presets = React.memo( + ({ show, create, toggle, undo, presets, selected, remove, apply, applied, contentRef }) => { + const customPresetsLength = presets.length - DEFAULT_PRESETS.length + + const disabledCreate = selected != null + + return ( +
+
+ Presets + {show && ( + + )} + +
+ {show && ( +
+ {presets + .filter(p => p.custom) + .map(preset => ( + + ))} + {customPresetsLength > 0 ?
: null} + {presets + .filter(p => !p.custom) + .map(preset => ( + + ))} +
+ )} + {show && applied && ( +
+ Preset applied! + +
+ )} + +
+ ) + } +) + +export default Presets diff --git a/components/Settings.js b/components/Settings.js index 6b2e9bc..f493465 100644 --- a/components/Settings.js +++ b/components/Settings.js @@ -7,11 +7,11 @@ import Slider from './Slider' import Toggle from './Toggle' import Popout from './Popout' import Button from './Button' +import Presets from './Presets' import { COLORS, DEFAULT_PRESETS } from '../lib/constants' import { toggle, getPresets, savePresets } from '../lib/util' import SettingsIcon from './svg/Settings' import * as Arrows from './svg/Arrows' -import Remove from './svg/Remove' const WindowSettings = React.memo( ({ @@ -194,186 +194,6 @@ const MenuButton = React.memo(({ name, select, selected }) => { ) }) -const removeButtonStyles = { - position: 'absolute', - top: '6px', - right: '6px', - width: '11px', - height: '11px', - borderRadius: '999px' -} - -const Preset = React.memo(({ remove, apply, selected, preset }) => { - const isSelected = preset.id === selected - - return ( -
- - )} - -
- ) -}) - -const arrowButtonStyle = { - position: 'absolute', - top: 0, - right: '16px', - height: '100%' -} - -const Presets = React.memo( - ({ show, create, toggle, undo, presets, selected, remove, apply, applied, contentRef }) => { - const customPresetsLength = presets.length - DEFAULT_PRESETS.length - - const disabledCreate = selected != null - - return ( -
-
- Presets - {show && ( - - )} - -
- {show && ( -
- {presets - .filter(p => p.custom) - .map(preset => ( - - ))} - {customPresetsLength > 0 ?
: null} - {presets - .filter(p => !p.custom) - .map(preset => ( - - ))} -
- )} - {show && applied && ( -
- Preset applied! - -
- )} - -
- ) - } -) - const settingButtonStyle = { width: '40px', height: '100%'