Skip to content

Commit 327d799

Browse files
committed
fix: Refactor for Nuxt 4 and improve code consistency
Updated app config to reference Nuxt 4, improved code consistency by adding file headers and script setup comments, and removed unused imports from server files. Enhanced accessibility and keyboard support for ButtonBack, and added i18n browser language detection settings. Minor formatting and code style improvements across components and GraphQL files.
1 parent 9fbfd5d commit 327d799

35 files changed

+67
-25
lines changed

app/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export default defineAppConfig({
33
site: {
44
name: 'NuxtCommerce',
5-
description: 'NuxtCommerce is a dynamic e-commerce solution developed with Nuxt 3 and GraphQL, tailored for WooCommerce.',
5+
description: 'NuxtCommerce is a dynamic e-commerce solution developed with Nuxt 4 and GraphQL, tailored for WooCommerce.',
66
},
77
ui: {
88
primary: 'red',

app/app.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
<!--app/app.vue-->
22
<script setup lang="ts">
3-
const { name, description } = useAppConfig().site;
3+
const { site } = useAppConfig();
4+
const { name, description } = site;
45
56
useHead({
6-
htmlAttrs: {
7-
lang: 'en',
8-
},
9-
titleTemplate: titleChunk => (titleChunk ? `${titleChunk} - ${name}` : name),
7+
htmlAttrs: { lang: 'en' },
8+
titleTemplate: (chunk?: string) => (chunk ? `${chunk} - ${name}` : name),
109
});
1110
1211
useSeoMeta({
13-
description: description,
12+
description,
1413
ogType: 'website',
15-
ogImage: 'https://commerce.nuxt.dev/social-card.jpg',
1614
ogSiteName: name,
1715
ogLocale: 'en_US',
16+
ogImage: 'https://commerce.nuxt.dev/social-card.jpg',
1817
twitterCard: 'summary_large_image',
1918
twitterSite: '@zhatlen',
2019
twitterCreator: '@zhatlen',
@@ -26,9 +25,9 @@ useSeoMeta({
2625

2726
<template>
2827
<AppHeader />
29-
<div class="pt-[72px] lg:pt-20 min-h-[calc(100vh-72px)]">
28+
<main class="pt-[72px] lg:pt-20 min-h-[calc(100vh-72px)]">
3029
<NuxtPage />
31-
</div>
30+
</main>
3231
<AppFooter />
3332
<Notivue v-slot="item">
3433
<Notification :item="item" :theme="materialTheme" />

app/components/AppFooter.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/AppFooter.vue-->
12
<script setup>
23
const config = useRuntimeConfig();
34
const colorMode = useColorMode();

app/components/AppHeader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/AppHeader.vue-->
12
<script setup>
23
const router = useRouter();
34
const route = useRoute();

app/components/ButtonBack.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1+
<!--app/components/ButtonBack.vue-->
2+
<script setup lang="ts">
3+
const { t } = useI18n();
4+
const router = useRouter();
5+
6+
const goBack = () => router.back();
7+
const onKey = (e: KeyboardEvent) => {
8+
if (e.key === 'Enter' || e.key === ' ') {
9+
e.preventDefault();
10+
goBack();
11+
}
12+
};
13+
</script>
14+
115
<template>
216
<div class="fixed px-7 mt-0.5 -left-1.5 max-2xl:hidden z-30">
3-
<UTooltip :text="$t('general.go_back')" :open-delay="1500">
4-
<button @click.prevent="useRouter().back()" class="flex p-3 rounded-full dark:bg-black hover:dark:bg-neutral-800 bg-white hover:bg-neutral-200 active:scale-95 transition">
17+
<UTooltip :text="t('general.go_back')" :open-delay="1500">
18+
<button
19+
type="button"
20+
class="flex p-3 rounded-full dark:bg-black hover:dark:bg-neutral-800 bg-white hover:bg-neutral-200 active:scale-95 transition"
21+
:aria-label="t('general.go_back')"
22+
@click="goBack"
23+
@keydown="onKey">
524
<UIcon name="i-iconamoon-arrow-left-1-bold" size="24" />
625
</button>
726
</UTooltip>

app/components/ButtonSelectCategory.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
<!--app/components/ButtonSelectCategory.vue-->
12
<script setup>
23
const categoriesData = ref([]);
34
45
onMounted(async () => {
56
const response = await $fetch('/api/categories');
6-
categoriesData.value = response.productCategories.nodes.filter(
7-
category => category.products.nodes.length && category.children.nodes.length
8-
);
7+
categoriesData.value = response.productCategories.nodes.filter(category => category.products.nodes.length && category.children.nodes.length);
98
});
109
1110
const categories = computed(() => categoriesData.value);

app/components/ButtonSortBy.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/ButtonSortBy.vue-->
12
<script setup>
23
const router = useRouter();
34
const route = useRoute();

app/components/ButtonWishlist.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/ButtonWishlist.vue-->
12
<script setup>
23
const props = defineProps({
34
product: Object,

app/components/CarouselCategories.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/CarouselCategories.vue-->
12
<script setup>
23
const router = useRouter();
34
const route = useRoute();

app/components/Cart.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--app/components/Cart.vue-->
12
<script setup>
23
const { cart, handleRemoveFromCart, removeFromCartButtonStatus } = useCart();
34
const { order } = useCheckout();

0 commit comments

Comments
 (0)