Skip to content

Commit

Permalink
Remove presets
Browse files Browse the repository at this point in the history
  • Loading branch information
boyvanamstel committed Oct 13, 2020
1 parent a58337a commit 0dd2edf
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 329 deletions.
174 changes: 0 additions & 174 deletions components/Presets.js

This file was deleted.

56 changes: 4 additions & 52 deletions components/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import Input from './Input'
import Toggle from './Toggle'
import Popout, { managePopout } from './Popout'
import Button from './Button'
import Presets from './Presets'
import MenuButton from './MenuButton'
import { COLORS, DEFAULT_PRESETS, DEFAULT_SETTINGS, DEFAULT_WIDTHS } from '../lib/constants'
import { toggle, getPresets, savePresets, fileToJSON } from '../lib/util'
import { COLORS, DEFAULT_SETTINGS, DEFAULT_WIDTHS } from '../lib/constants'
import { fileToJSON } from '../lib/util'
import SettingsIcon from './svg/Settings'

function KeyboardShortcut({ trigger, handle }) {
Expand Down Expand Up @@ -263,25 +262,14 @@ const invalidSetting = (v, k) =>

class Settings extends React.PureComponent {
state = {
presets: DEFAULT_PRESETS,
selectedMenu: 'Window',
showPresets: true,
previousSettings: null,
widthChanging: false,
}

settingsRef = React.createRef()
menuRef = React.createRef()

componentDidMount() {
const storedPresets = getPresets(localStorage) || []
this.setState(({ presets }) => ({
presets: [...storedPresets, ...presets],
}))
}

togglePresets = () => this.setState(toggle('showPresets'))

selectMenu = selectedMenu => () => this.setState({ selectedMenu })

handleWidthChanging = () => {
Expand Down Expand Up @@ -317,32 +305,6 @@ class Settings extends React.PureComponent {

getSettingsFromProps = () => omitBy(this.props, invalidSetting)

applyPreset = preset => {
const previousSettings = this.getSettingsFromProps()

this.props.applyPreset(preset)

this.setState({ previousSettings })
}

undoPreset = () => {
this.props.applyPreset({ ...this.state.previousSettings, id: null })
this.setState({ previousSettings: null })
}

removePreset = id => {
if (this.props.preset === id) {
this.props.onChange('preset', null)
this.setState({ previousSettings: null })
}
this.setState(
({ presets }) => ({ presets: presets.filter(p => p.id !== id) }),
this.savePresets
)
}

savePresets = () => savePresets(this.state.presets.filter(p => p.custom))

renderContent = () => {
switch (this.state.selectedMenu) {
case 'Window':
Expand Down Expand Up @@ -395,8 +357,8 @@ class Settings extends React.PureComponent {
}

render() {
const { selectedMenu, showPresets, presets, previousSettings, widthChanging } = this.state
const { preset, isVisible, toggleVisibility } = this.props
const { isVisible, toggleVisibility } = this.props
const { selectedMenu, widthChanging } = this.state

return (
<div className="settings-container" ref={this.settingsRef}>
Expand All @@ -422,16 +384,6 @@ class Settings extends React.PureComponent {
left: widthChanging ? this.settingPosition.left : 'initial',
}}
>
<Presets
show={showPresets}
presets={presets}
selected={preset}
toggle={this.togglePresets}
apply={this.applyPreset}
undo={this.undoPreset}
remove={this.removePreset}
applied={!!previousSettings}
/>
<div className="settings-bottom">
<div className="settings-menu" ref={this.menuRef} tabIndex={-1}>
<MenuButton name="Window" select={this.selectMenu} selected={selectedMenu} />
Expand Down
95 changes: 0 additions & 95 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,98 +1091,3 @@ export const DEFAULT_WIDTHS = {
minWidth: 320,
maxWidth: 1280,
}

export const DEFAULT_PRESETS = [
{
...DEFAULT_SETTINGS,
icon: '/static/presets/4.png',
id: 'preset:4',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(74,144,226,1)',
dropShadow: false,
theme: 'material',
fontFamily: 'Fira Code',
lineHeight: '152%',
icon: '/static/presets/7.png',
id: 'preset:7',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(248,231,28,1)',
dropShadow: false,
theme: 'blackboard',
fontFamily: 'Fira Code',
lineHeight: '152%',
icon: '/static/presets/8.png',
id: 'preset:8',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(182,162,145,1)',
dropShadow: false,
theme: 'zenburn',
windowTheme: 'bw',
lineHeight: '152%',
icon: '/static/presets/9.png',
id: 'preset:9',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(121,72,185,1)',
dropShadow: false,
theme: 'verminal',
windowTheme: 'bw',
fontFamily: 'Fira Code',
fontSize: '14px',
lineHeight: '143%',
icon: '/static/presets/0.png',
id: 'preset:0',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(239,40,44,1)',
theme: 'one-light',
lineHeight: '143%',
icon: '/static/presets/1.png',
id: 'preset:1',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(31,129,109,1)',
dropShadow: false,
theme: 'night-owl',
lineHeight: '143%',
windowControls: false,
icon: '/static/presets/2.png',
id: 'preset:2',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(249,237,212,1)',
theme: 'twilight',
fontFamily: 'IBM Plex Mono',
lineHeight: '143%',
icon: '/static/presets/3.png',
id: 'preset:3',
},

{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(222,171,99,1)',
theme: 'duotone-dark',
icon: '/static/presets/5.png',
id: 'preset:5',
},
{
...DEFAULT_SETTINGS,
backgroundColor: 'rgba(187,187,187,1)',
dropShadowOffsetY: '3px',
dropShadowBlurRadius: '13px',
theme: 'solarized light',
windowTheme: 'sharp',
icon: '/static/presets/6.png',
id: 'preset:6',
},
]
Loading

0 comments on commit 0dd2edf

Please sign in to comment.