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%'