Browse Source

Use Button component to show password for improved accessibility

Signed-off-by: Christopher Ng <chrng8@gmail.com>
tags/v25.0.0beta1
Christopher Ng 1 year ago
parent
commit
8aaac57ee6

+ 0
- 11
core/css/guest.css View File

width: 219px; width: 219px;
padding-right: 40px; padding-right: 40px;
} }
.toggle-password {
position: absolute;
top: 1px;
right: 5px;
padding: 14px;
height: 16px;
}
.toggle-password:hover,
.toggle-password:focus {
opacity: .6;
}
input.login { input.login {
width: 260px; width: 260px;
height: 50px; height: 50px;

+ 37
- 13
core/src/components/login/LoginForm.vue View File

required> required>
<label for="password" <label for="password"
class="infield">{{ t('Password') }}</label> class="infield">{{ t('Password') }}</label>
<a href="#" class="toggle-password" @click.stop.prevent="togglePassword">
<img :src="toggleIcon" :alt="t('core', 'Toggle password visibility')">
</a>
<Button class="toggle-password"
type="tertiary-no-background"
:aria-label="isPasswordHidden ? t('core', 'Show password') : t('core', 'Hide password')"
@click.stop.prevent="togglePassword">
<template #icon>
<Eye v-if="isPasswordHidden" :size="20" />
<EyeOff v-else :size="20" />
</template>
</Button>
</p> </p>


<LoginButton :loading="loading" /> <LoginButton :loading="loading" />


<script> <script>
import jstz from 'jstimezonedetect' import jstz from 'jstimezonedetect'
import { generateUrl, imagePath } from '@nextcloud/router'

import Button from '@nextcloud/vue/dist/Components/Button'
import Eye from 'vue-material-design-icons/Eye'
import EyeOff from 'vue-material-design-icons/EyeOff'

import LoginButton from './LoginButton' import LoginButton from './LoginButton'
import {
generateUrl,
imagePath,
} from '@nextcloud/router'


export default { export default {
name: 'LoginForm', name: 'LoginForm',
components: { LoginButton },

components: {
Button,
Eye,
EyeOff,
LoginButton,
},

props: { props: {
username: { username: {
type: String, type: String,
default: false, default: false,
}, },
}, },

data() { data() {
return { return {
loading: false, loading: false,
passwordInputType: 'password', passwordInputType: 'password',
} }
}, },

computed: { computed: {
apacheAuthFailed() { apacheAuthFailed() {
return this.errors.indexOf('apacheAuthFailed') !== -1 return this.errors.indexOf('apacheAuthFailed') !== -1
userDisabled() { userDisabled() {
return this.errors.indexOf('userdisabled') !== -1 return this.errors.indexOf('userdisabled') !== -1
}, },
toggleIcon() {
return imagePath('core', 'actions/toggle.svg')
},
loadingIcon() { loadingIcon() {
return imagePath('core', 'loading-dark.gif') return imagePath('core', 'loading-dark.gif')
}, },
loginActionUrl() { loginActionUrl() {
return generateUrl('login') return generateUrl('login')
}, },
isPasswordHidden() {
return this.passwordInputType === 'password'
},
}, },

mounted() { mounted() {
if (this.username === '') { if (this.username === '') {
this.$refs.user.focus() this.$refs.user.focus()
this.$refs.password.focus() this.$refs.password.focus()
} }
}, },

methods: { methods: {
togglePassword() { togglePassword() {
if (this.passwordInputType === 'password') { if (this.passwordInputType === 'password') {
} }
</script> </script>


<style scoped>

<style lang="scss" scoped>
.toggle-password {
position: absolute;
top: 6px;
right: 10px;
color: var(--color-text-lighter);
}
</style> </style>

+ 2
- 2
dist/core-common.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/core-common.js.map
File diff suppressed because it is too large
View File


+ 2
- 2
dist/core-login.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/core-login.js.map
File diff suppressed because it is too large
View File


Loading…
Cancel
Save