Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added toggleButton in login form #114

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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