Skip to content

Commit

Permalink
Fix MC text input styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Apr 3, 2024
1 parent 4ba9dde commit f6a27ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
8 changes: 4 additions & 4 deletions svelte_sprinkles/src/lib/McTextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
}>();
export let id: string | undefined = undefined;
let className: string | undefined = undefined;
// noinspection ReservedWordAsName
export {className as class};
export let inputClass: string | undefined = undefined;
export let containerClass: string | undefined = undefined;
export let placeholders: Record<McTextType, string> | undefined = undefined;
export let value: McText = '';
export let textFormat: McTextType = $dialogueTextFormat;
Expand Down Expand Up @@ -50,7 +49,8 @@
}
</script>
<ResizingInput
class={className}
containerClass={containerClass}
inputClass={inputClass}
id={id}
placeholder={placeholder}
value={importDialogueText(value)}
Expand Down
13 changes: 6 additions & 7 deletions svelte_sprinkles/src/lib/ResizingInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@
export let maxRows: number | undefined;
export let id: string | undefined = undefined;
export let placeholder: string | undefined = undefined;
let className: string | undefined = undefined;
// noinspection ReservedWordAsName
export {className as class};
export let containerClass: string | undefined = undefined;
export let inputClass: string | undefined = undefined;
export let action: Action<HTMLTextAreaElement | HTMLInputElement> = () => {};
$: minHeight = `${1 + minRows * 1.2}em`;
$: maxHeight = maxRows ? `${1 + maxRows * 1.2}em` : `auto`;
</script>

<div class="textarea-container ${className}">
<div class="textarea-container ${containerClass}">
{#if maxRows === undefined || maxRows > 1}
<div
aria-hidden="true"
class="textarea-mirror"
style="min-height: {minHeight}; max-height: {maxHeight}"
>{value + '\n'}</div>
<textarea id={id} placeholder={placeholder} bind:value on:change use:action></textarea>
<textarea id={id} class={inputClass} placeholder={placeholder} bind:value on:change use:action></textarea>
{:else}
<input id={id} placeholder={placeholder} bind:value on:change use:action/>
<input id={id} class={inputClass} placeholder={placeholder} bind:value on:change use:action/>
{/if}
</div>

<style>
.textarea-container {
position: relative;
overflow-x: scroll;
width: 100%;
}
Expand All @@ -45,6 +43,7 @@
}
.textarea-mirror {
visibility: hidden;
white-space: pre-wrap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@
</div>

<style>
.not-dialogue-ending {
overflow-x: auto;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<td class="col-text input-cell">
<McTextInput
value={item.text}
class="table-input"
inputClass="table-input"
textFormat={$dialogueTextFormat}
placeholders={{
[McTextType.PLAIN]: 'Thank you, ...',
Expand Down

0 comments on commit f6a27ba

Please sign in to comment.