Improve text area and long form height settings

This commit is contained in:
Andrew Kingston 2022-02-07 12:04:21 +00:00
parent 48ce006ac3
commit 587a260c2b
3 changed files with 17 additions and 5 deletions

View File

@ -22,11 +22,23 @@
dispatch("change", event.target.value) dispatch("change", event.target.value)
focus = false focus = false
} }
const getStyleString = (attribute, value) => {
if (!attribute || value == null) {
return ""
}
if (isNaN(value)) {
return `${attribute}:${value};`
}
return `${attribute}:${value}px;`
}
$: heightString = getStyleString("height", height)
$: minHeightString = getStyleString("min-height", minHeight)
</script> </script>
<div <div
style={(height ? `height: ${height}px;` : "") + style={`${heightString}${minHeightString}`}
(minHeight ? `min-height: ${minHeight}px` : "")}
class="spectrum-Textfield spectrum-Textfield--multiline" class="spectrum-Textfield spectrum-Textfield--multiline"
class:is-invalid={!!error} class:is-invalid={!!error}
class:is-disabled={disabled} class:is-disabled={disabled}

View File

@ -3,7 +3,7 @@
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
export let value = null export let value = null
export let height = "300px" export let height = null
export let placeholder = null export let placeholder = null
export let id = null export let id = null
export let fullScreenOffset = 0 export let fullScreenOffset = 0

View File

@ -3,7 +3,7 @@
import "easymde/dist/easymde.min.css" import "easymde/dist/easymde.min.css"
import { onMount } from "svelte" import { onMount } from "svelte"
export let height = "300px" export let height = null
export let scroll = true export let scroll = true
export let easyMDEOptions = null export let easyMDEOptions = null
export let mde = null export let mde = null
@ -14,7 +14,7 @@
let element let element
onMount(() => { onMount(() => {
height = height || "300px" height = height || "200px"
mde = new EasyMDE({ mde = new EasyMDE({
element, element,
spellChecker: false, spellChecker: false,