show password icon in custom input
This commit is contained in:
@@ -180,6 +180,7 @@ td {
|
|||||||
border: none;
|
border: none;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-input-light {
|
.custom-input-light {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
field: {
|
field: {
|
||||||
type: [String, Number, Date]
|
type: [String, Number, Date]
|
||||||
@@ -47,6 +50,17 @@
|
|||||||
|
|
||||||
defineEmits(['update:field'])
|
defineEmits(['update:field'])
|
||||||
|
|
||||||
|
const showPassword = ref(false)
|
||||||
|
|
||||||
|
const computedType = computed(() => {
|
||||||
|
return props.type === 'password' && showPassword.value ? 'text' : props.type
|
||||||
|
})
|
||||||
|
|
||||||
|
const toggleVisibility = () => {
|
||||||
|
showPassword.value = !showPassword.value
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -69,13 +83,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-container">
|
||||||
<input
|
<input
|
||||||
class="custom-input"
|
class="custom-input"
|
||||||
:class="[
|
:class="[
|
||||||
!filled ? 'custom-input-light' : '',
|
!filled ? 'custom-input-light' : '',
|
||||||
// label.includes('*') ? 'border-required' : ''
|
// label.includes('*') ? 'border-required' : ''
|
||||||
]"
|
]"
|
||||||
:type="type"
|
:type="computedType"
|
||||||
:id="name"
|
:id="name"
|
||||||
:name="name"
|
:name="name"
|
||||||
:min="0"
|
:min="0"
|
||||||
@@ -84,13 +99,32 @@
|
|||||||
:disabled="readonly"
|
:disabled="readonly"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:required="required"
|
:required="required"
|
||||||
@input="$event => $emit('update:field', $event.target.value)">
|
:autocomplete="type === 'password' ? 'off' : 'on'"
|
||||||
|
@input="$event => $emit('update:field', $event.target.value)"/>
|
||||||
|
<span
|
||||||
|
v-if="props.type === 'password'"
|
||||||
|
class="toggle-icon"
|
||||||
|
@click="toggleVisibility">
|
||||||
|
<i
|
||||||
|
class="fa-solid fa-eye"
|
||||||
|
v-if="!showPassword"
|
||||||
|
></i>
|
||||||
|
<i
|
||||||
|
class="fa-solid fa-eye-slash"
|
||||||
|
v-else
|
||||||
|
></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<span class="help" v-if="helpText.length > 0">{{ helpText }}</span>
|
<span class="help" v-if="helpText.length > 0">{{ helpText }}</span>
|
||||||
<span class="error-msg" v-if="error">{{ error }}</span>
|
<span class="error-msg" v-if="error">{{ error }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.input-container {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.help {
|
.help {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
@@ -110,6 +144,16 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toggle-icon {
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
.label-text {
|
.label-text {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user