Improve text area and long form height settings
This commit is contained in:
parent
26970971db
commit
9aa1e5cf43
|
@ -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}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue