Skip to content

Commit 9e9762c

Browse files
committed
feat: replace div width GhostButton to improve a11y
1 parent 2ec1c96 commit 9e9762c

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

src/components/GhostButton.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<van-button size="small" plain type="primary">
3+
<slot />
4+
</van-button>
5+
</template>
6+
7+
<style scoped>
8+
.van-button {
9+
--van-button-border-width: 0;
10+
--van-button-plain-background: opacity;
11+
}
12+
</style>

src/pages/forgot-password/index.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { useRouter } from 'vue-router'
33
import type { FieldRule } from 'vant'
44
import { useUserStore } from '@/stores'
5+
import vw from '@/utils/inline-px-to-vw'
56
67
const { t } = useI18n()
78
const router = useRouter()
@@ -69,10 +70,6 @@ async function getCode() {
6970
7071
isGettingCode.value = false
7172
}
72-
73-
function handleBackLogin() {
74-
router.push({ name: 'login' })
75-
}
7673
</script>
7774

7875
<template>
@@ -134,9 +131,9 @@ function handleBackLogin() {
134131
</div>
135132
</van-form>
136133

137-
<div class="mt-16 text-12 text-[var(--van-primary-color)]" @click="handleBackLogin">
134+
<GhostButton to="login" block :style="{ 'margin-top': vw(8) }">
138135
{{ $t('forgot-password.backToLogin') }}
139-
</div>
136+
</GhostButton>
140137
</div>
141138
</template>
142139

src/pages/login/index.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useUserStore } from '@/stores'
44
55
import logo from '~/images/logo.svg'
66
import logoDark from '~/images/logo-dark.svg'
7+
import vw from '@/utils/inline-px-to-vw'
78
89
const { t } = useI18n()
910
const router = useRouter()
@@ -49,20 +50,12 @@ async function login(values: any) {
4950
loading.value = false
5051
}
5152
}
52-
53-
function handleReset() {
54-
router.push({ name: 'forgot-password' })
55-
}
56-
57-
function handleRegister() {
58-
router.push({ name: 'register' })
59-
}
6053
</script>
6154

6255
<template>
6356
<div class="m-x-a w-7xl text-center">
6457
<div class="mb-32 mt-20">
65-
<van-image :src="dark ? logoDark : logo" class="h-120 w-120" />
58+
<van-image :src="dark ? logoDark : logo" class="h-120 w-120" alt="brand logo" />
6659
</div>
6760

6861
<van-form :model="postData" :rules="rules" validate-trigger="onSubmit" @submit="login">
@@ -97,13 +90,13 @@ function handleRegister() {
9790
</div>
9891
</van-form>
9992

100-
<div class="mt-16 text-12 text-[var(--van-primary-color)]" @click="handleRegister">
93+
<GhostButton block to="register" :style="{ 'margin-top': vw(18) }">
10194
{{ $t('login.sign-up') }}
102-
</div>
95+
</GhostButton>
10396

104-
<div class="mt-16 text-12 text-[var(--van-primary-color)]" @click="handleReset">
97+
<GhostButton block to="forgot-password">
10598
{{ $t('login.forgot-password') }}
106-
</div>
99+
</GhostButton>
107100
</div>
108101
</template>
109102

src/pages/register/index.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { useRouter } from 'vue-router'
33
import type { FieldRule } from 'vant'
44
import { useUserStore } from '@/stores'
5+
import vw from '@/utils/inline-px-to-vw'
56
67
const { t } = useI18n()
78
const router = useRouter()
@@ -73,10 +74,6 @@ async function getCode() {
7374
7475
isGettingCode.value = false
7576
}
76-
77-
function handleBackLogin() {
78-
router.push({ name: 'login' })
79-
}
8077
</script>
8178

8279
<template>
@@ -147,9 +144,9 @@ function handleBackLogin() {
147144
</div>
148145
</van-form>
149146

150-
<div class="mt-16 text-12 text-[var(--van-primary-color)]" @click="handleBackLogin">
147+
<GhostButton to="login" block :style="{ 'margin-top': vw(8) }">
151148
{{ $t('register.backToLogin') }}
152-
</div>
149+
</GhostButton>
153150
</div>
154151
</template>
155152

src/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {}
88
declare module 'vue' {
99
export interface GlobalComponents {
1010
Chart: typeof import('./../components/Chart/index.vue')['default']
11+
GhostButton: typeof import('./../components/GhostButton.vue')['default']
1112
NavBar: typeof import('./../components/NavBar.vue')['default']
1213
RouterLink: typeof import('vue-router')['RouterLink']
1314
RouterView: typeof import('vue-router')['RouterView']

0 commit comments

Comments
 (0)