1
0
Fork 0
mirror of synced 2024-10-01 09:38:55 +13:00

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)
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>
<div
style={(height ? `height: ${height}px;` : "") +
(minHeight ? `min-height: ${minHeight}px` : "")}
style={`${heightString}${minHeightString}`}
class="spectrum-Textfield spectrum-Textfield--multiline"
class:is-invalid={!!error}
class:is-disabled={disabled}

View file

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

View file

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