state.name -> state.input

main
raboid 6 years ago committed by Michael Fix
parent d620f0d5aa
commit 6f1f2a1cf1

@ -49,7 +49,7 @@ class Themes extends React.PureComponent {
state = { state = {
themes: THEMES, themes: THEMES,
preset: this.props.theme, preset: this.props.theme,
name: 'Custom Theme', input: 'Custom Theme',
selected: null selected: null
} }
@ -62,8 +62,6 @@ class Themes extends React.PureComponent {
this.setState(({ themes }) => { this.setState(({ themes }) => {
const newThemes = [...storedThemes, ...themes] const newThemes = [...storedThemes, ...themes]
const name = getCustomName(newThemes)
this.selectedTheme = newThemes.find(({ id }) => id === theme) || DEFAULT_THEME this.selectedTheme = newThemes.find(({ id }) => id === theme) || DEFAULT_THEME
if (Object.keys(highlights).length === 0) { if (Object.keys(highlights).length === 0) {
@ -72,7 +70,7 @@ class Themes extends React.PureComponent {
return { return {
themes: newThemes, themes: newThemes,
name input: getCustomName(newThemes)
} }
}) })
} }
@ -82,7 +80,7 @@ class Themes extends React.PureComponent {
const { themes } = this.state const { themes } = this.state
if (prevProps.isVisible && !isVisible) { if (prevProps.isVisible && !isVisible) {
this.setState({ name: getCustomName(themes) }) this.setState({ input: getCustomName(themes) })
update({ highlights: themes.find(({ id }) => id === theme).highlights }) update({ highlights: themes.find(({ id }) => id === theme).highlights })
} }
} }
@ -108,7 +106,7 @@ class Themes extends React.PureComponent {
} }
} }
updateName = ({ target: { value: name } }) => this.setState({ name }) updateInput = ({ target: { value: input } }) => this.setState({ input })
selectHighlight = highlight => () => selectHighlight = highlight => () =>
this.setState(({ selected }) => ({ this.setState(({ selected }) => ({
@ -142,7 +140,7 @@ class Themes extends React.PureComponent {
createTheme = () => { createTheme = () => {
const { highlights, update } = this.props const { highlights, update } = this.props
const { themes, name } = this.state const { themes, input: name } = this.state
const id = `theme:${generateId()}` const id = `theme:${generateId()}`
@ -164,9 +162,9 @@ class Themes extends React.PureComponent {
render() { render() {
const { theme, isVisible, toggleVisibility, highlights } = this.props const { theme, isVisible, toggleVisibility, highlights } = this.props
const { name, themes, selected, preset } = this.state const { input, themes, selected, preset } = this.state
const dropdownValue = isVisible ? { name } : { id: theme, name: this.selectedTheme.name } const dropdownValue = isVisible ? { name: input } : { id: theme, name: this.selectedTheme.name }
const dropdownList = [ const dropdownList = [
{ {
@ -193,14 +191,14 @@ class Themes extends React.PureComponent {
<ThemeCreate <ThemeCreate
key={theme} key={theme}
preset={preset} preset={preset}
name={name} name={input}
theme={theme} theme={theme}
themes={themes} themes={themes}
highlights={highlights} highlights={highlights}
selected={selected} selected={selected}
applyPreset={this.applyPreset} applyPreset={this.applyPreset}
createTheme={this.createTheme} createTheme={this.createTheme}
updateName={this.updateName} updateName={this.updateInput}
selectHighlight={this.selectHighlight} selectHighlight={this.selectHighlight}
updateHighlight={this.updateHighlight} updateHighlight={this.updateHighlight}
/> />

Loading…
Cancel
Save