Skip to content

Commit 63eb4e9

Browse files
refactor: replace back button implementation with BackButton component across multiple pages
1 parent 5ad0c2c commit 63eb4e9

File tree

7 files changed

+7
-80
lines changed

7 files changed

+7
-80
lines changed

app/pages/about.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import type { Role } from '#server/api/contributors.get'
33
import { SPONSORS } from '~/assets/logos/sponsors'
44
import { OSS_PARTNERS } from '~/assets/logos/oss-partners'
55
6-
const router = useRouter()
7-
const canGoBack = useCanGoBack()
8-
96
useSeoMeta({
107
title: () => `${$t('about.title')} - npmx`,
118
ogTitle: () => `${$t('about.title')} - npmx`,
@@ -57,15 +54,7 @@ const roleLabels = computed(
5754
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
5855
{{ $t('about.heading') }}
5956
</h1>
60-
<button
61-
type="button"
62-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
63-
@click="router.back()"
64-
v-if="canGoBack"
65-
>
66-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
67-
<span class="hidden sm:inline">{{ $t('nav.back') }}</span>
68-
</button>
57+
<BackButton />
6958
</div>
7059
<p class="text-fg-muted text-lg">
7160
{{ $t('tagline') }}

app/pages/accessibility.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ defineOgImageComponent('Default', {
1212
title: () => $t('a11y.title'),
1313
description: () => $t('a11y.welcome', { app: 'npmx' }),
1414
})
15-
16-
const router = useRouter()
17-
const canGoBack = useCanGoBack()
1815
</script>
1916

2017
<template>
@@ -25,15 +22,7 @@ const canGoBack = useCanGoBack()
2522
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
2623
{{ $t('a11y.title') }}
2724
</h1>
28-
<button
29-
type="button"
30-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded shrink-0"
31-
@click="router.back()"
32-
v-if="canGoBack"
33-
>
34-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
35-
<span class="sr-only sm:not-sr-only">{{ $t('nav.back') }}</span>
36-
</button>
25+
<BackButton />
3726
</div>
3827
</header>
3928

app/pages/compare.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ definePageMeta({
88
})
99
1010
const { locale } = useI18n()
11-
const router = useRouter()
12-
const canGoBack = useCanGoBack()
1311
const { copied, copy } = useClipboard({ copiedDuring: 2000 })
1412
1513
// Sync packages with URL query param (stable ref - doesn't change on other query changes)
@@ -171,15 +169,7 @@ useSeoMeta({
171169
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
172170
{{ $t('compare.packages.title') }}
173171
</h1>
174-
<button
175-
type="button"
176-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
177-
@click="router.back()"
178-
v-if="canGoBack"
179-
>
180-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
181-
<span class="hidden sm:inline">{{ $t('nav.back') }}</span>
182-
</button>
172+
<BackButton />
183173
</div>
184174
<p class="text-fg-muted text-lg">
185175
{{ $t('compare.packages.tagline') }}

app/pages/pds.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<script setup lang="ts">
22
import type { AtprotoProfile } from '#shared/types/atproto'
33
4-
const router = useRouter()
5-
const canGoBack = useCanGoBack()
6-
74
useSeoMeta({
85
title: () => `${$t('pds.title')} - npmx`,
96
ogTitle: () => `${$t('pds.title')} - npmx`,
@@ -51,15 +48,7 @@ const totalAccounts = computed(() => pdsUsers.value.length)
5148
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
5249
{{ $t('pds.title') }}
5350
</h1>
54-
<button
55-
type="button"
56-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
57-
@click="router.back()"
58-
v-if="canGoBack"
59-
>
60-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
61-
<span class="hidden sm:inline">{{ $t('nav.back') }}</span>
62-
</button>
51+
<BackButton />
6352
</div>
6453
<p class="text-fg-muted text-lg">
6554
{{ $t('pds.meta_description') }}

app/pages/privacy.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ defineOgImageComponent('Default', {
1313
description: () => $t('privacy_policy.welcome', { app: 'npmx' }),
1414
})
1515
16-
const router = useRouter()
17-
const canGoBack = useCanGoBack()
1816
const buildInfo = useAppConfig().buildInfo
1917
const { locale } = useI18n()
2018
</script>
@@ -27,15 +25,7 @@ const { locale } = useI18n()
2725
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
2826
{{ $t('privacy_policy.title') }}
2927
</h1>
30-
<button
31-
type="button"
32-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
33-
@click="router.back()"
34-
v-if="canGoBack"
35-
>
36-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
37-
<span class="sr-only sm:not-sr-only">{{ $t('nav.back') }}</span>
38-
</button>
28+
<BackButton />
3929
</div>
4030
<i18n-t
4131
keypath="privacy_policy.last_updated"

app/pages/recharging.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ defineOgImageComponent('Default', {
1717
description: () => $t('vacations.meta_description'),
1818
})
1919
20-
const router = useRouter()
21-
const canGoBack = useCanGoBack()
22-
2320
const { data: stats } = useFetch('/api/repo-stats')
2421
2522
/**
@@ -74,15 +71,7 @@ const icons = [
7471
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
7572
{{ $t('vacations.heading') }}
7673
</h1>
77-
<button
78-
type="button"
79-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
80-
@click="router.back()"
81-
v-if="canGoBack"
82-
>
83-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
84-
<span class="sr-only sm:not-sr-only">{{ $t('nav.back') }}</span>
85-
</button>
74+
<BackButton />
8675
</div>
8776
<i18n-t
8877
keypath="vacations.subtitle"

app/pages/settings.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
22
const router = useRouter()
3-
const canGoBack = useCanGoBack()
43
const { settings } = useSettings()
54
const { locale, locales, setLocale: setNuxti18nLocale } = useI18n()
65
const colorMode = useColorMode()
@@ -51,15 +50,7 @@ const setLocale: typeof setNuxti18nLocale = locale => {
5150
<h1 class="font-mono text-3xl sm:text-4xl font-medium">
5251
{{ $t('settings.title') }}
5352
</h1>
54-
<button
55-
type="button"
56-
class="cursor-pointer inline-flex items-center gap-2 p-1.5 -mx-1.5 font-mono text-sm text-fg-muted hover:text-fg transition-colors duration-200 rounded focus-visible:outline-accent/70 shrink-0"
57-
@click="router.back()"
58-
v-if="canGoBack"
59-
>
60-
<span class="i-lucide:arrow-left rtl-flip w-4 h-4" aria-hidden="true" />
61-
<span class="sr-only sm:not-sr-only">{{ $t('nav.back') }}</span>
62-
</button>
53+
<BackButton />
6354
</div>
6455
<p class="text-fg-muted text-lg">
6556
{{ $t('settings.tagline') }}

0 commit comments

Comments
 (0)