Skip to content

Commit ba34458

Browse files
committed
changes if state to be more readable
1 parent a2fb50a commit ba34458

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

browser/components/MarkdownSplitEditor.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ class MarkdownSplitEditor extends React.Component {
159159
const {config, value, storageKey, noteKey, linesHighlighted, isStacking} = this.props
160160
const storage = findStorage(storageKey)
161161

162-
const editorStyle = {}
163-
const previewStyle = {}
164-
const sliderStyle = {}
162+
let editorStyle = {}
163+
let previewStyle = {}
164+
let sliderStyle = {}
165165

166166
let editorFontSize = parseInt(config.editor.fontSize, 10)
167167
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
@@ -171,21 +171,29 @@ class MarkdownSplitEditor extends React.Component {
171171
if (!(editorStyle.fontSize > 0 && editorStyle.fontSize < 132)) editorIndentSize = 4
172172
editorStyle.indentSize = editorIndentSize
173173

174-
if (isStacking) {
175-
editorStyle.width = 100 + '%'
176-
editorStyle.height = this.state.codeEditorHeightInPercent + '%'
177-
previewStyle.width = 100 + '%'
178-
previewStyle.height = (100 - this.state.codeEditorHeightInPercent) + '%'
179-
sliderStyle.left = 0
180-
sliderStyle.top = this.state.codeEditorHeightInPercent + '%'
181-
} else {
182-
editorStyle.width = this.state.codeEditorWidthInPercent + '%'
183-
editorStyle.height = 100 + '%'
184-
previewStyle.width = (100 - this.state.codeEditorWidthInPercent) + '%'
185-
previewStyle.height = 100 + '%'
186-
sliderStyle.left = this.state.codeEditorWidthInPercent + '%'
187-
sliderStyle.top = 0
188-
}
174+
editorStyle = Object.assign(editorStyle, isStacking ? {
175+
width: '100%',
176+
height: `${this.state.codeEditorHeightInPercent}%`
177+
} : {
178+
width: `${this.state.codeEditorWidthInPercent}%`,
179+
height: '100%'
180+
})
181+
182+
previewStyle = Object.assign(previewStyle, isStacking ? {
183+
width: '100%',
184+
height: `${100 - this.state.codeEditorHeightInPercent}%`
185+
} : {
186+
width: `${100 - this.state.codeEditorWidthInPercent}%`,
187+
height: '100%'
188+
})
189+
190+
sliderStyle = Object.assign(sliderStyle, isStacking ? {
191+
left: 0,
192+
top: `${this.state.codeEditorHeightInPercent}%`
193+
} : {
194+
left: `${this.state.codeEditorWidthInPercent}%`,
195+
top: 0
196+
})
189197

190198
if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused) previewStyle.pointerEvents = 'none'
191199

0 commit comments

Comments
 (0)