-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): Added password field visibility toggle (#7368)
* Added password field visibility toggle * improvements to password input field * fix e2e and change tabindex * add missing name=password * remove unnecessary type prop --------- Co-authored-by: Jan108 <dasJan108@gmail.com> Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
- Loading branch information
1 parent
9d3ed71
commit 038e69f
Showing
7 changed files
with
101 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
web/src/lib/components/shared-components/password-field.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<script lang="ts"> | ||
import { mdiEyeOffOutline, mdiEyeOutline } from '@mdi/js'; | ||
import type { HTMLInputAttributes } from 'svelte/elements'; | ||
import Icon from '../elements/icon.svelte'; | ||
interface $$Props extends HTMLInputAttributes { | ||
password: string; | ||
autocomplete: string; | ||
required?: boolean; | ||
onInput?: (value: string) => void; | ||
} | ||
export let password: $$Props['password']; | ||
export let required = true; | ||
export let onInput: $$Props['onInput'] = undefined; | ||
let showPassword = false; | ||
</script> | ||
|
||
<div class="relative w-full"> | ||
<input | ||
{...$$restProps} | ||
class="immich-form-input w-full !pr-12" | ||
type={showPassword ? 'text' : 'password'} | ||
{required} | ||
value={password} | ||
on:input={(e) => { | ||
password = e.currentTarget.value; | ||
onInput?.(password); | ||
}} | ||
/> | ||
|
||
{#if password.length > 0} | ||
<button | ||
type="button" | ||
tabindex="-1" | ||
class="absolute inset-y-0 end-0 px-4 text-gray-700 dark:text-gray-200" | ||
on:click={() => (showPassword = !showPassword)} | ||
title={showPassword ? 'Hide password' : 'Show password'} | ||
> | ||
<Icon path={showPassword ? mdiEyeOffOutline : mdiEyeOutline} size="1.25em" /> | ||
</button> | ||
{/if} | ||
</div> | ||
|
||
<style> | ||
input::-ms-reveal { | ||
display: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters