add show hide password

This commit is contained in:
Dede Fuji Abdul 2023-10-16 09:42:21 +07:00
parent 36fa184716
commit 4ee87a0aa9
2 changed files with 89 additions and 8 deletions

View File

@ -802,6 +802,34 @@ select {
top: 100%; top: 100%;
} }
.top-\[50\%\] {
top: 50%;
}
.bottom-0 {
bottom: 0px;
}
.\!bottom-0 {
bottom: 0px !important;
}
.\!right-0 {
right: 0px !important;
}
.\!top-0 {
top: 0px !important;
}
.bottom-auto {
bottom: auto;
}
.top-auto {
top: auto;
}
.z-10 { .z-10 {
z-index: 10; z-index: 10;
} }
@ -859,6 +887,26 @@ select {
margin-bottom: auto; margin-bottom: auto;
} }
.mx-4 {
margin-left: 1rem;
margin-right: 1rem;
}
.mx-3 {
margin-left: 0.75rem;
margin-right: 0.75rem;
}
.\!mx-3 {
margin-left: 0.75rem !important;
margin-right: 0.75rem !important;
}
.\!my-auto {
margin-top: auto !important;
margin-bottom: auto !important;
}
.\!mt-0 { .\!mt-0 {
margin-top: 0px !important; margin-top: 0px !important;
} }
@ -1067,6 +1115,11 @@ select {
height: 80vh; height: 80vh;
} }
.h-fit {
height: -moz-fit-content;
height: fit-content;
}
.max-h-0 { .max-h-0 {
max-height: 0px; max-height: 0px;
} }
@ -1445,6 +1498,10 @@ select {
--tw-divide-opacity: 0.1; --tw-divide-opacity: 0.1;
} }
.justify-self-center {
justify-self: center;
}
.overflow-hidden { .overflow-hidden {
overflow: hidden; overflow: hidden;
} }
@ -1724,6 +1781,14 @@ select {
--tw-bg-opacity: 0.8; --tw-bg-opacity: 0.8;
} }
.fill-gray-500 {
fill: #6b7280;
}
.fill-primary-500 {
fill: #035b71;
}
.p-1 { .p-1 {
padding: 0.25rem; padding: 0.25rem;
} }

View File

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'
defineProps({ const props = defineProps({
type: { type: {
type: String, type: String,
default: "text", default: "text",
@ -25,19 +26,34 @@ defineProps({
type: String, type: String,
default: "", default: "",
} }
}); })
const emit = defineEmits(['update:value']); const emit = defineEmits(['update:value'])
const updateValue = (event: Event) => { const updateValue = (event: Event) => {
const value = (event.target as HTMLInputElement).value; const value = (event.target as HTMLInputElement).value;
emit('update:value', value); emit('update:value', value)
}; }
const inputType = ref(props.type)
const switchInputType = () => {
inputType.value = inputType.value == 'password' ? 'text' : 'password'
}
</script> </script>
<template> <template>
<input autocomplete="off" :type="type" :placeholder="placeholder" :value="value" @input="updateValue($event)" <div :class="['relative w-full overflow-hidden rounded-lg bg-gray-50 ', className]">
:disabled="disabled" :readonly="readonly" <input autocomplete="off" :type="inputType" :placeholder="placeholder" :value="value" @input="updateValue($event)"
:class="['w-full px-4 py-2 text-sm leading-6 placeholder:text-gray-400 text-gray-900 border-0 border-transparent rounded-lg outline-0 bg-gray-50 focus:outline-0 focus:border-0 focus:ring-0', className]" /> :disabled="disabled" :readonly="readonly"
:class="['w-full px-4 py-2 text-sm leading-6 placeholder:text-gray-400 text-gray-900 border-0 border-transparent rounded-lg outline-0 bg-gray-50 focus:outline-0 focus:border-0 focus:ring-0']" />
<span @click="switchInputType" v-if="type == 'password'"
class="absolute top-0 bottom-0 right-0 mx-3 my-auto cursor-pointer h-fit">
<svg width="20" height="20" viewBox="0 0 20 20"
:class="[inputType == 'password' ? 'fill-gray-500' : 'fill-primary-500']">
<path
d="M19.3211 9.74688C19.2937 9.68516 18.632 8.21719 17.1609 6.74609C15.2008 4.78594 12.725 3.75 9.99999 3.75C7.27499 3.75 4.79921 4.78594 2.83905 6.74609C1.36796 8.21719 0.703118 9.6875 0.678899 9.74688C0.643362 9.82681 0.625 9.91331 0.625 10.0008C0.625 10.0883 0.643362 10.1748 0.678899 10.2547C0.706243 10.3164 1.36796 11.7836 2.83905 13.2547C4.79921 15.2141 7.27499 16.25 9.99999 16.25C12.725 16.25 15.2008 15.2141 17.1609 13.2547C18.632 11.7836 19.2937 10.3164 19.3211 10.2547C19.3566 10.1748 19.375 10.0883 19.375 10.0008C19.375 9.91331 19.3566 9.82681 19.3211 9.74688ZM9.99999 15C7.5953 15 5.49452 14.1258 3.75546 12.4023C3.0419 11.6927 2.43483 10.8836 1.95312 10C2.4347 9.11636 3.04179 8.30717 3.75546 7.59766C5.49452 5.87422 7.5953 5 9.99999 5C12.4047 5 14.5055 5.87422 16.2445 7.59766C16.9595 8.307 17.5679 9.11619 18.0508 10C17.4875 11.0516 15.0336 15 9.99999 15ZM9.99999 6.25C9.25831 6.25 8.53329 6.46993 7.9166 6.88199C7.29992 7.29404 6.81927 7.87971 6.53544 8.56494C6.25162 9.25016 6.17735 10.0042 6.32205 10.7316C6.46674 11.459 6.82389 12.1272 7.34834 12.6517C7.87279 13.1761 8.54097 13.5333 9.2684 13.6779C9.99583 13.8226 10.7498 13.7484 11.4351 13.4645C12.1203 13.1807 12.7059 12.7001 13.118 12.0834C13.5301 11.4667 13.75 10.7417 13.75 10C13.749 9.00576 13.3535 8.05253 12.6505 7.34949C11.9475 6.64645 10.9942 6.25103 9.99999 6.25ZM9.99999 12.5C9.50554 12.5 9.02219 12.3534 8.61107 12.0787C8.19994 11.804 7.87951 11.4135 7.69029 10.9567C7.50107 10.4999 7.45157 9.99723 7.54803 9.51227C7.64449 9.02732 7.88259 8.58186 8.23222 8.23223C8.58186 7.8826 9.02731 7.6445 9.51227 7.54804C9.99722 7.45157 10.4999 7.50108 10.9567 7.6903C11.4135 7.87952 11.804 8.19995 12.0787 8.61107C12.3534 9.0222 12.5 9.50555 12.5 10C12.5 10.663 12.2366 11.2989 11.7678 11.7678C11.2989 12.2366 10.663 12.5 9.99999 12.5Z" />
</svg>
</span>
</div>
</template> </template>