2021-05-22 12:32:32 +03:00
|
|
|
<script>
|
|
|
|
|
export let label;
|
2021-06-26 21:32:42 +03:00
|
|
|
export let placeholder = "Write your answer...";
|
2021-05-22 12:32:32 +03:00
|
|
|
export let value;
|
2021-07-03 19:29:41 +00:00
|
|
|
export let rows = "3";
|
|
|
|
|
export let maxRows;
|
|
|
|
|
|
|
|
|
|
$: minHeight = `${1 + parseInt(rows, 10) * 1.2}em`;
|
|
|
|
|
$: maxHeight = maxRows ? `${1 + maxRows * 1.2}em` : `auto`;
|
2021-05-22 12:32:32 +03:00
|
|
|
</script>
|
|
|
|
|
|
2021-07-03 19:29:41 +00:00
|
|
|
<label class="block w-full relative">
|
2021-06-26 21:32:42 +03:00
|
|
|
{#if label}
|
|
|
|
|
<span class="text-gray-700">{label}</span>
|
|
|
|
|
{/if}
|
2021-07-03 19:29:41 +00:00
|
|
|
|
|
|
|
|
<pre
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
style="min-height: {minHeight}; max-height: {maxHeight}">
|
|
|
|
|
{value + '\n'}
|
|
|
|
|
</pre>
|
|
|
|
|
|
2021-05-22 12:32:32 +03:00
|
|
|
<textarea
|
2021-07-03 19:29:41 +00:00
|
|
|
{rows}
|
2021-05-22 12:32:32 +03:00
|
|
|
{placeholder}
|
|
|
|
|
bind:value
|
2021-07-03 19:29:41 +00:00
|
|
|
class="form-textarea block w-full bg-gray-100 border-t-0 border-l-0 border-r-0 border-b-1"
|
2021-05-22 12:32:32 +03:00
|
|
|
/>
|
2021-06-26 21:32:42 +03:00
|
|
|
|
|
|
|
|
<slot name="iconbutton" />
|
2021-05-22 12:32:32 +03:00
|
|
|
</label>
|
2021-07-03 19:29:41 +00:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
pre,
|
|
|
|
|
textarea {
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
padding: 0.5em;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
border: 1px solid #eee;
|
|
|
|
|
line-height: 1.2;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
top: 0;
|
|
|
|
|
resize: none;
|
|
|
|
|
}
|
|
|
|
|
</style>
|