make input size changeable
This commit is contained in:
parent
407fb22a0e
commit
3e259872b3
@ -10,16 +10,31 @@
|
|||||||
export let placeholder: string | null = null;
|
export let placeholder: string | null = null;
|
||||||
export let required = false;
|
export let required = false;
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
|
export let size: 'xs' | 'sm' | 'md' | 'lg' = 'md';
|
||||||
|
|
||||||
export let inputElement: HTMLInputElement | undefined = undefined;
|
export let inputElement: HTMLInputElement | undefined = undefined;
|
||||||
|
|
||||||
let initialType = type;
|
let initialType = type;
|
||||||
|
|
||||||
|
let passwordEyeSize = {
|
||||||
|
xs: '14',
|
||||||
|
sm: '18',
|
||||||
|
md: '24',
|
||||||
|
lg: '30'
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- the cursor-not-allowed class must be set here because a disabled button does not respect the 'cursor' css property -->
|
<!-- the cursor-not-allowed class must be set here because a disabled button does not respect the 'cursor' css property -->
|
||||||
<div class={type === 'submit' && disabled ? 'cursor-not-allowed' : ''}>
|
<div class={type === 'submit' && disabled ? 'cursor-not-allowed' : ''}>
|
||||||
{#if type === 'submit'}
|
{#if type === 'submit'}
|
||||||
<input class="btn" {id} type="submit" {disabled} bind:value bind:this={inputElement} />
|
<input
|
||||||
|
class={`btn btn-${size}`}
|
||||||
|
{id}
|
||||||
|
type="submit"
|
||||||
|
{disabled}
|
||||||
|
bind:value
|
||||||
|
bind:this={inputElement}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<div>
|
<div>
|
||||||
{#if $$slots.label}
|
{#if $$slots.label}
|
||||||
@ -34,6 +49,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<div class="relative flex items-center" class:sm:max-w-[16rem]={type !== 'checkbox'}>
|
<div class="relative flex items-center" class:sm:max-w-[16rem]={type !== 'checkbox'}>
|
||||||
<input
|
<input
|
||||||
|
class={type === 'checkbox' ? `checkbox-${size}` : `input-${size}`}
|
||||||
class:checkbox={type === 'checkbox'}
|
class:checkbox={type === 'checkbox'}
|
||||||
class:input,input-bordered,w-[100%]={type !== 'checkbox'}
|
class:input,input-bordered,w-[100%]={type !== 'checkbox'}
|
||||||
class:pr-11={initialType === 'password'}
|
class:pr-11={initialType === 'password'}
|
||||||
@ -61,9 +77,17 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if type === 'password'}
|
{#if type === 'password'}
|
||||||
<IconSolid name="eye-slash-solid" />
|
<IconSolid
|
||||||
|
name="eye-slash-solid"
|
||||||
|
width={passwordEyeSize[size]}
|
||||||
|
height={passwordEyeSize[size]}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<IconSolid name="eye-solid" />
|
<IconSolid
|
||||||
|
name="eye-solid"
|
||||||
|
width={passwordEyeSize[size]}
|
||||||
|
height={passwordEyeSize[size]}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
bind:value={admin.username}
|
bind:value={admin.username}
|
||||||
disabled={!permissions.adminWrite() || !admin.edit}
|
disabled={!permissions.adminWrite() || !admin.edit}
|
||||||
|
size="sm"
|
||||||
/></td
|
/></td
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
@ -123,6 +124,7 @@
|
|||||||
bind:value={admin.password}
|
bind:value={admin.password}
|
||||||
placeholder="Neues Passwort..."
|
placeholder="Neues Passwort..."
|
||||||
disabled={!permissions.adminWrite() || !admin.edit}
|
disabled={!permissions.adminWrite() || !admin.edit}
|
||||||
|
size="sm"
|
||||||
/></td
|
/></td
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
@ -137,7 +139,7 @@
|
|||||||
{#if admin.edit}
|
{#if admin.edit}
|
||||||
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!permissions.adminWrite()}
|
disabled={!permissions.adminWrite()}
|
||||||
on:click={async (e) => {
|
on:click={async (e) => {
|
||||||
await buttonTriggeredRequest(
|
await buttonTriggeredRequest(
|
||||||
@ -153,12 +155,12 @@
|
|||||||
admin.edit = false;
|
admin.edit = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconOutline name="check-outline" width="24" height="24" />
|
<IconOutline name="check-outline" width="18" height="18" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!permissions.adminWrite()}
|
disabled={!permissions.adminWrite()}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
admin.username = admin.before.username;
|
admin.username = admin.before.username;
|
||||||
@ -167,13 +169,13 @@
|
|||||||
admin.edit = false;
|
admin.edit = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconOutline name="no-symbol-outline" width="24" height="24" />
|
<IconOutline name="no-symbol-outline" width="18" height="18" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!permissions.adminWrite()}
|
disabled={!permissions.adminWrite()}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
admin.edit = true;
|
admin.edit = true;
|
||||||
@ -184,16 +186,16 @@
|
|||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconOutline name="pencil-square-outline" width="24" height="24" />
|
<IconOutline name="pencil-square-outline" width="18" height="18" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
<span class="w-min" class:cursor-not-allowed={!permissions.adminWrite()}>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!permissions.adminWrite()}
|
disabled={!permissions.adminWrite()}
|
||||||
on:click={(e) => buttonTriggeredRequest(e, deleteAdmin(admin.id))}
|
on:click={(e) => buttonTriggeredRequest(e, deleteAdmin(admin.id))}
|
||||||
>
|
>
|
||||||
<IconOutline name="trash-outline" width="24" height="24" />
|
<IconOutline name="trash-outline" width="18" height="18" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
@ -203,8 +205,8 @@
|
|||||||
{/each}
|
{/each}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{data.admins.length}</td>
|
<td>{data.admins.length}</td>
|
||||||
<td><Input type="text" bind:value={newAdminUsername} /></td>
|
<td><Input type="text" bind:value={newAdminUsername} size="sm" /></td>
|
||||||
<td><Input type="password" bind:value={newAdminPassword} /></td>
|
<td><Input type="password" bind:value={newAdminPassword} size="sm" /></td>
|
||||||
<td
|
<td
|
||||||
><Badges
|
><Badges
|
||||||
bind:value={newAdminPermissions}
|
bind:value={newAdminPermissions}
|
||||||
@ -220,7 +222,7 @@
|
|||||||
!newAdminPassword}
|
!newAdminPassword}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="btn btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!permissions.adminWrite() || !newAdminUsername || !newAdminPassword}
|
disabled={!permissions.adminWrite() || !newAdminUsername || !newAdminPassword}
|
||||||
on:click={async (e) => {
|
on:click={async (e) => {
|
||||||
await buttonTriggeredRequest(
|
await buttonTriggeredRequest(
|
||||||
@ -232,7 +234,7 @@
|
|||||||
newAdminPermissions = [];
|
newAdminPermissions = [];
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconOutline name="user-plus-outline" width="24" height="24" />
|
<IconOutline name="user-plus-outline" width="18" height="18" />
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user