1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-16 03:06:27 +00:00

changes if state to be more readable

This commit is contained in:
Callum Booth
2019-06-10 20:27:55 +01:00
parent a2fb50a71c
commit ba34458feb

View File

@@ -159,9 +159,9 @@ class MarkdownSplitEditor extends React.Component {
const {config, value, storageKey, noteKey, linesHighlighted, isStacking} = this.props const {config, value, storageKey, noteKey, linesHighlighted, isStacking} = this.props
const storage = findStorage(storageKey) const storage = findStorage(storageKey)
const editorStyle = {} let editorStyle = {}
const previewStyle = {} let previewStyle = {}
const sliderStyle = {} let sliderStyle = {}
let editorFontSize = parseInt(config.editor.fontSize, 10) let editorFontSize = parseInt(config.editor.fontSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14 if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
@@ -171,21 +171,29 @@ class MarkdownSplitEditor extends React.Component {
if (!(editorStyle.fontSize > 0 && editorStyle.fontSize < 132)) editorIndentSize = 4 if (!(editorStyle.fontSize > 0 && editorStyle.fontSize < 132)) editorIndentSize = 4
editorStyle.indentSize = editorIndentSize editorStyle.indentSize = editorIndentSize
if (isStacking) { editorStyle = Object.assign(editorStyle, isStacking ? {
editorStyle.width = 100 + '%' width: '100%',
editorStyle.height = this.state.codeEditorHeightInPercent + '%' height: `${this.state.codeEditorHeightInPercent}%`
previewStyle.width = 100 + '%' } : {
previewStyle.height = (100 - this.state.codeEditorHeightInPercent) + '%' width: `${this.state.codeEditorWidthInPercent}%`,
sliderStyle.left = 0 height: '100%'
sliderStyle.top = this.state.codeEditorHeightInPercent + '%' })
} else {
editorStyle.width = this.state.codeEditorWidthInPercent + '%' previewStyle = Object.assign(previewStyle, isStacking ? {
editorStyle.height = 100 + '%' width: '100%',
previewStyle.width = (100 - this.state.codeEditorWidthInPercent) + '%' height: `${100 - this.state.codeEditorHeightInPercent}%`
previewStyle.height = 100 + '%' } : {
sliderStyle.left = this.state.codeEditorWidthInPercent + '%' width: `${100 - this.state.codeEditorWidthInPercent}%`,
sliderStyle.top = 0 height: '100%'
} })
sliderStyle = Object.assign(sliderStyle, isStacking ? {
left: 0,
top: `${this.state.codeEditorHeightInPercent}%`
} : {
left: `${this.state.codeEditorWidthInPercent}%`,
top: 0
})
if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused) previewStyle.pointerEvents = 'none' if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused) previewStyle.pointerEvents = 'none'