Skip to content

Commit b0c7b9d

Browse files
committed
fix: show translation links on mobile
1 parent 60d1ab0 commit b0c7b9d

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

app/app.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
class="-mx-2.5"
1414
orientation="vertical"
1515
/>
16+
<template v-if="pageLinks.length">
17+
<USeparator class="my-2" />
18+
<UNavigationMenu
19+
class="-mx-2.5"
20+
:items="pageLinks"
21+
orientation="vertical"
22+
/>
23+
</template>
1624
</template>
1725
</UHeader>
1826

@@ -66,6 +74,9 @@ useSeoMeta({
6674
: "NWS Translate",
6775
});
6876
77+
const pageStore = usePageStore();
78+
const pageLinks = computed(() => pageStore.pageLinks);
79+
6980
const items: NavigationMenuItem[] = [
7081
{
7182
icon: "i-lucide:file-input",

app/pages/translate.vue

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
<template #left>
44
<UPageAside>
55
<template #top>
6-
<UInput v-model="search" placeholder="Filter..." />
6+
<UInput v-model="search" placeholder="Filter...">
7+
<template v-if="search?.length" #trailing>
8+
<UButton
9+
size="sm"
10+
variant="link"
11+
color="neutral"
12+
icon="i-lucide-circle-x"
13+
aria-label="Verwijder filter"
14+
@click="search = ''"
15+
/>
16+
</template>
17+
</UInput>
718
</template>
819
<UPageLinks :links="links" />
920
</UPageAside>
@@ -12,12 +23,18 @@
1223
<UPageHeader :title="title" :description="description" />
1324

1425
<UPageBody>
26+
<UInputMenu
27+
virtualize
28+
:items="menuItems"
29+
placeholder="Zoeken..."
30+
:filter-fields="['value', 'text', 'reference']"
31+
/>
1532
<NuxtPage />
1633
</UPageBody>
1734
</UPage>
1835
</template>
1936
<script setup lang="ts">
20-
import type { PageAnchor } from "@nuxt/ui";
37+
import type { InputMenuItem } from "@nuxt/ui";
2138
2239
const title = "Vertalen";
2340
const description = "Vertaal op deze pagina de teksten.";
@@ -33,7 +50,7 @@ const importStore = useImportStore();
3350
3451
const search = ref("");
3552
36-
const links = computed((): PageAnchor[] =>
53+
const links = computed((): PageLink[] =>
3754
importStore.keys
3855
.filter((key) => {
3956
if (!search.value || search.value.trim().length < 3) return true;
@@ -52,4 +69,26 @@ const links = computed((): PageAnchor[] =>
5269
to: `/translate/${key}`,
5370
})),
5471
);
72+
73+
const menuItems = computed((): InputMenuItem[] =>
74+
links.value.map((link) => ({
75+
label: link.label,
76+
onSelect: () => {
77+
navigateTo(link.to);
78+
},
79+
reference: importStore.references[link.label],
80+
text: importStore.translations[link.label],
81+
value: link.label,
82+
})),
83+
);
84+
85+
const pageStore = usePageStore();
86+
87+
watchImmediate(links, (links) => {
88+
pageStore.pageLinks = links;
89+
});
90+
91+
onBeforeUnmount(() => {
92+
pageStore.pageLinks = [];
93+
});
5594
</script>

app/stores/page.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type State = {
2+
pageLinks: PageLink[];
3+
};
4+
5+
export const usePageStore = defineStore("page", {
6+
persist: false,
7+
state: (): State => ({
8+
pageLinks: [],
9+
}),
10+
});

shared/types/general.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type PageLink = {
2+
label: string;
3+
to: string;
4+
};

0 commit comments

Comments
 (0)