Skip to content

Commit

Permalink
Fix warnings from svelte-check
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsamant37 committed Oct 28, 2024
1 parent 1f25834 commit 06d568c
Showing 1 changed file with 138 additions and 105 deletions.
243 changes: 138 additions & 105 deletions js/textbox/shared/Textbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -198,102 +198,135 @@

<!-- svelte-ignore a11y-autofocus -->
<label class:container class:show_textbox_border>
<BlockTitle {root} {show_label} {info}>{label}</BlockTitle>

<div class="textbox-container">
<div class="input-container">
{#if lines === 1 && max_lines === 1}
<input
data-testid="textbox"
type={type}
class="scroll-hide"
dir={rtl ? "rtl" : "ltr"}
bind:value
bind:this={el}
{placeholder}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
style={text_align ? "text-align: " + text_align : ""}
/>
{:else}
<textarea
data-testid="textbox"
use:text_area_resize={value}
class="scroll-hide"
dir={rtl ? "rtl" : "ltr"}
class:no-label={!show_label && (submit_btn || stop_btn)}
bind:value
bind:this={el}
{placeholder}
rows={lines}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
on:scroll={handle_scroll}
style={text_align ? "text-align: " + text_align : ""}
/>
{/if}

{#if submit_btn}
<button
class="submit-button"
class:padded-button={submit_btn !== true}
on:click={handle_submit}
>
{#if submit_btn === true}
<Send />
{:else}
{submit_btn}
{/if}
</button>
{/if}

{#if stop_btn}
<button
class="stop-button"
class:padded-button={stop_btn !== true}
on:click={handle_stop}
>
{#if stop_btn === true}
<Square fill="none" stroke_width={2.5} />
{:else}
{stop_btn}
{/if}
</button>
{/if}
</div>

{#if show_copy_button}
{#if copied}
<button
in:fade={{ duration: 300 }}
class="copy-button"
aria-label="Copied"
aria-roledescription="Text copied"
>
<Check />
</button>
{:else}
<button
on:click={handle_copy}
class="copy-button"
aria-label="Copy"
aria-roledescription="Copy text"
>
<Copy />
</button>
{/if}
{/if}
</div>
<BlockTitle {root} {show_label} {info}>{label}</BlockTitle>

<div class="textbox-container">
<div class="input-container">
{#if lines === 1 && max_lines === 1}
{#if type === "text"}
<input
data-testid="textbox"
type="text"
class="scroll-hide"
dir={rtl ? "rtl" : "ltr"}
bind:value
bind:this={el}
{placeholder}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
style={text_align ? "text-align: " + text_align : ""}
/>
{:else if type === "password"}
<input
data-testid="password"
type="password"
class="scroll-hide"
bind:value
bind:this={el}
{placeholder}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
autocomplete=""
/>
{:else if type === "email"}
<input
data-testid="textbox"
type="email"
class="scroll-hide"
bind:value
bind:this={el}
{placeholder}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
autocomplete="email"
/>
{/if}
<textarea
data-testid="textbox"
use:text_area_resize={value}
class="scroll-hide"
dir={rtl ? "rtl" : "ltr"}
class:no-label={!show_label && (submit_btn || stop_btn)}
bind:value
bind:this={el}
{placeholder}
rows={lines}
{disabled}
{autofocus}
maxlength={max_length}
on:keypress={handle_keypress}
on:blur
on:select={handle_select}
on:focus
on:scroll={handle_scroll}
style={text_align ? "text-align: " + text_align : ""}
/>
{/if}
{#if submit_btn}
<button
class="submit-button"
class:padded-button={submit_btn !== true}
on:click={handle_submit}
>
{#if submit_btn === true}
<Send />
{:else}
{submit_btn}
{/if}
</button>
{/if}
{#if stop_btn}
<button
class="stop-button"
class:padded-button={stop_btn !== true}
on:click={handle_stop}
>
{#if stop_btn === true}
<Square fill="none" stroke_width={2.5} />
{:else}
{stop_btn}
{/if}
</button>
{/if}
</div>

{#if show_copy_button}
{#if copied}
<button
in:fade={{ duration: 300 }}
class="copy-button"
aria-label="Copied"
aria-roledescription="Text copied"
>
<Check />
</button>
{:else}
<button
on:click={handle_copy}
class="copy-button"
aria-label="Copy"
aria-roledescription="Copy text"
>
<Copy />
</button>
{/if}
{/if}
</div>
</label>

<style>
Expand All @@ -302,15 +335,15 @@
width: 100%;
}
.textbox-container {
position: relative;
width: 100%;
}
.input-container {
display: flex;
position: relative;
align-items: flex-end;
width: 100%;
}
position: relative;
width: 100%;
}
.input-container {
display: flex;
position: relative;
align-items: flex-end;
width: 100%;
}
input,
textarea {
flex-grow: 1;
Expand Down

0 comments on commit 06d568c

Please sign in to comment.