Skip to content

Commit

Permalink
added toggleButton in login form
Browse files Browse the repository at this point in the history
  • Loading branch information
PiyushThapaa committed Mar 9, 2024
1 parent 76c7ec6 commit e891aee
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ const userStore = useUserStore()
const email = ref('')
const password = ref('')
const showError = ref(false)
const passwordFieldType = ref("password")
const toggleText = ref("Show")
// router
const router = useRouter()
function togglePasswordVisibility(){
if (passwordFieldType.value==="password") {
passwordFieldType.value = "text";
toggleText.value = "Hide";
}
else {
passwordFieldType.value = "password";
toggleText.value = "Show";
}
}
async function submitLogin() {
loadingStore.contentLoading()
showError.value = false
Expand Down Expand Up @@ -75,24 +88,25 @@ onMounted(() => {

<div>
<label for="password">Password</label>
<div class="mt-2">
<div class="mt-2 relative">
<input
id="password"
v-model="password"
name="password"
type="password"
:type="passwordFieldType"
autocomplete="current-password"
required="true"
class="block w-full"
/>
<p class="text-xs cursor-pointer mt-2.5 absolute inset-y-0 right-0 pr-3" @click="togglePasswordVisibility">{{toggleText}}</p>
</div>
</div>

<div>
<StandardButton
:type="'submit'"
:text="'Login'"
class="btn-primary mt-6 w-full justify-center"
class="btn-primary mt-4 w-full justify-center"
/>
</div>

Expand Down

0 comments on commit e891aee

Please sign in to comment.