Skip to content

Commit 752c04f

Browse files
committed
feat: Change logo based on selected theme (light, dark) & update site configuration structure
1 parent 072dfcf commit 752c04f

File tree

11 files changed

+71
-38
lines changed

11 files changed

+71
-38
lines changed

app/app.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// app/app.config.ts
22
export default defineAppConfig({
3-
siteName: 'NuxtCommerce',
4-
siteDescription: 'NuxtCommerce is a dynamic e-commerce solution developed with Nuxt 3 and GraphQL, tailored for WooCommerce.',
3+
site: {
4+
name: 'NuxtCommerce',
5+
description: 'NuxtCommerce is a dynamic e-commerce solution developed with Nuxt 3 and GraphQL, tailored for WooCommerce.',
6+
logo: {
7+
light: 'logo-light.svg',
8+
dark: 'logo-dark.svg',
9+
}
10+
},
511
ui: {
612
primary: 'red',
713
gray: 'neutral',

app/app.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<!--app/app.vue-->
22
<script setup lang="ts">
3-
const { siteName, siteDescription } = useAppConfig();
3+
const { name, description } = useAppConfig().site;
44
55
useHead({
66
htmlAttrs: {
77
lang: 'en',
88
},
9-
titleTemplate: titleChunk => (titleChunk ? `${titleChunk} - ${siteName}` : siteName),
9+
titleTemplate: titleChunk => (titleChunk ? `${titleChunk} - ${name}` : name),
1010
});
1111
1212
useSeoMeta({
13-
description: siteDescription,
13+
description: description,
1414
ogType: 'website',
1515
ogImage: 'https://commerce.nuxt.dev/social-card.jpg',
16-
ogSiteName: siteName,
16+
ogSiteName: name,
1717
ogLocale: 'en_US',
1818
twitterCard: 'summary_large_image',
1919
twitterSite: '@zhatlen',
2020
twitterCreator: '@zhatlen',
2121
twitterImage: 'https://commerce.nuxt.dev/social-card.jpg',
22-
keywords: `${siteName}, ecommerce, nuxt, woocommerce`,
22+
keywords: `${name}, ecommerce, nuxt, woocommerce`,
2323
viewport: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover',
2424
});
2525
</script>

app/components/AppHeader.vue

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script setup>
22
const router = useRouter();
33
const route = useRoute();
4+
const colorMode = useColorMode()
5+
const { light, dark } = useAppConfig().site.logo
6+
47
const searchQuery = ref((route.query.q || '').toString());
58
const searchResults = ref([]);
69
const isLoading = ref(false);
@@ -28,6 +31,11 @@ async function fetch() {
2831
2932
onMounted(fetch);
3033
34+
const logoUrl = computed(() => {
35+
const logo = colorMode.value === 'dark' ? light : dark
36+
return "/" + logo.replace(/^\/+/g, '')
37+
})
38+
3139
const throttledFetch = useDebounceFn(async () => {
3240
await fetch();
3341
}, 300);
@@ -56,14 +64,18 @@ onClickOutside(onClickOutsideRef, event => {
5664
<div class="flex w-full flex-row items-center px-3 lg:px-5 h-[72px] lg:h-20 z-40 fixed bg-white/85 dark:bg-black/85 backdrop-blur-sm dark:backdrop-blur-lg">
5765
<div class="flex flex-row w-full flex-nowrap items-center gap-2">
5866
<NuxtLink
59-
aria-label="Home"
60-
class="flex items-center justify-center min-w-[52px] min-h-[52px] max-lg:min-w-12 max-lg:min-h-12 hover:bg-black/5 hover:dark:bg-white/15 max-lg:dark:bg-white/15 max-lg:bg-black/5 max-lg:hover:bg-black/10 max-lg:hover:dark:bg-white/20 rounded-2xl max-lg:rounded-full transition active:scale-95"
61-
:to="localePath('/')">
62-
<svg viewBox="0 0 30.72 30.72" class="rounded-lg max-lg:rounded-full bg-[#b31015] w-8 h-8">
63-
<path
64-
d="M -1e-4,1e-4 H 15.3296 C 14.7944,0.0047 14.2692,0.1464 13.8054,0.4117 13.334,0.6813 12.9429,1.0691 12.6707,1.536 L -1e-4,23.2893 Z m 15.3807,0 h 15.3392 v 5.1132 c -0.4077,-0.1874 -0.8524,-0.2855 -1.304,-0.2855 -0.5439,0 -1.0786,0.142 -1.5494,0.4116 -0.4711,0.2696 -0.8623,0.6577 -1.1341,1.1245 L 23.7908,11.4167 18.0395,1.536 C 17.7674,1.0691 17.376,0.6813 16.9048,0.4117 16.4411,0.1464 15.9158,0.0047 15.3806,1e-4 Z M 30.7198,13.6563 V 25.8989 H 26.6036 L 23.791,30.7198 H 11.8305 c 4.2401,-0.0117 7.3693,-1.8658 9.5244,-5.4729 l 5.2487,-9.0088 2.8114,-4.8214 z M 11.6157,25.8941 4.1115,25.8924 15.3602,6.5839 l 5.6126,9.6542 -3.7579,6.4525 c -1.4357,2.348 -3.0668,3.2035 -5.5992,3.2035 z"
65-
fill="#ed3237" />
66-
</svg>
67+
aria-label="Home"
68+
class="flex items-center justify-center min-w-[52px] min-h-[52px] max-lg:min-w-12 max-lg:min-h-12 hover:bg-black/5 hover:dark:bg-white/15 max-lg:dark:bg-white/15 max-lg:bg-black/5 max-lg:hover:bg-black/10 max-lg:hover:dark:bg-white/20 rounded-2xl max-lg:rounded-full transition active:scale-95 group"
69+
:to="localePath('/')">
70+
<div class="transform-gpu duration-200 ease-in-out group-hover:scale-[130%]">
71+
<img
72+
class="rounded-lg max-lg:rounded-full bg-[#b31015] w-8 h-8"
73+
:src="logoUrl"
74+
alt="Logo"
75+
loading="lazy"
76+
title="logo"
77+
/>
78+
</div>
6779
</NuxtLink>
6880
<NuxtLink
6981
aria-label="Categories"

app/gql/queries/getProduct.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const getProductQuery = gql`
1919
sourceUrl(size: LARGE)
2020
}
2121
}
22-
allPaColor {
22+
allPaStyle {
2323
nodes {
2424
name
2525
}
@@ -37,7 +37,7 @@ export const getProductQuery = gql`
3737
image {
3838
sourceUrl(size: WOOCOMMERCE_THUMBNAIL)
3939
}
40-
allPaColor {
40+
allPaStyle {
4141
nodes {
4242
name
4343
}

app/pages/categories.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--app/pages/categories.vue-->
22
<script setup>
3-
const { siteName } = useAppConfig();
3+
const { name } = useAppConfig().site;
44
const url = useRequestURL();
55
const localePath = useLocalePath();
66
@@ -10,13 +10,13 @@ const canonical = url.origin + url.pathname;
1010
useSeoMeta({
1111
title: 'Categories',
1212
ogTitle: 'Categories',
13-
description: `Browse product categories on ${siteName}.`,
14-
ogDescription: `Browse product categories on ${siteName}.`,
13+
description: `Browse product categories on ${name}.`,
14+
ogDescription: `Browse product categories on ${name}.`,
1515
ogUrl: canonical,
1616
canonical,
17-
keywords: `categories, ${siteName}`,
17+
keywords: `categories, ${name}`,
1818
twitterTitle: 'Categories',
19-
twitterDescription: `Browse product categories on ${siteName}.`,
19+
twitterDescription: `Browse product categories on ${name}.`,
2020
ogImage: 'https://commerce.nuxt.dev/social-card.jpg',
2121
twitterImage: 'https://commerce.nuxt.dev/social-card.jpg',
2222
});

app/pages/favorites.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--app/pages/favorites.vue-->
22
<script setup>
33
const { removeFromList, wishlist } = useWishlist();
4-
const { siteName } = useAppConfig();
4+
const { name } = useAppConfig().site;
55
const url = useRequestURL();
66
const localePath = useLocalePath();
77
@@ -10,13 +10,13 @@ const canonical = url.origin + url.pathname;
1010
useSeoMeta({
1111
title: 'Favorites',
1212
ogTitle: 'Favorites',
13-
description: `Your favorite products saved on ${siteName}.`,
14-
ogDescription: `Your favorite products saved on ${siteName}.`,
13+
description: `Your favorite products saved on ${name}.`,
14+
ogDescription: `Your favorite products saved on ${name}.`,
1515
ogUrl: canonical,
1616
canonical,
17-
keywords: `favorites, wishlist, ${siteName}`,
17+
keywords: `favorites, wishlist, ${name}`,
1818
twitterTitle: 'Favorites',
19-
twitterDescription: `Your favorite products saved on ${siteName}.`,
19+
twitterDescription: `Your favorite products saved on ${name}.`,
2020
ogImage: 'https://commerce.nuxt.dev/social-card.jpg',
2121
twitterImage: 'https://commerce.nuxt.dev/social-card.jpg',
2222
robots: 'noindex, nofollow',

app/pages/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--app/pages/index.vue-->
22
<script setup>
33
const route = useRoute();
4-
const { siteName } = useAppConfig();
4+
const { name } = useAppConfig().site;
55
const url = useRequestURL();
66
const canonical = computed(() => {
77
const base = `${url.origin}${url.pathname}`;
@@ -18,17 +18,17 @@ useHead(() => {
1818
1919
let title = '';
2020
let description = '';
21-
const keywords = new Set(['ecommerce', siteName]);
21+
const keywords = new Set(['ecommerce', name]);
2222
2323
if (category) {
2424
title = `${category} Products`;
25-
description = `Browse ${category} products on ${siteName}.`;
25+
description = `Browse ${category} products on ${name}.`;
2626
keywords.add(category);
2727
}
2828
2929
if (q) {
3030
title = `Search results for "${q}"`;
31-
description = `Search results for "${q}" on ${siteName}.`;
31+
description = `Search results for "${q}" on ${name}.`;
3232
keywords.add(q);
3333
}
3434

app/pages/product/[id].vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const calculateDiscountPercentage = computed(() => {
5858
return Math.round(((salePriceValue - regularPriceValue) / regularPriceValue) * 100);
5959
});
6060
61-
const { siteName } = useAppConfig();
61+
const { name } = useAppConfig();
6262
const url = useRequestURL();
6363
const canonical = url.origin + url.pathname;
6464
const image = computed(() => product.value?.image?.sourceUrl);
@@ -68,10 +68,10 @@ const plainDescription = computed(() => {
6868
});
6969
7070
useHead(() => {
71-
const title = product.value?.name || siteName;
71+
const title = product.value?.name || name;
7272
const description = plainDescription.value;
7373
const img = image.value;
74-
const keywords = [product.value?.name, product.value?.allPaStyle?.nodes?.[0]?.name, siteName].filter(Boolean).join(', ');
74+
const keywords = [product.value?.name, product.value?.allPaStyle?.nodes?.[0]?.name, name].filter(Boolean).join(', ');
7575
7676
return {
7777
title,
@@ -96,7 +96,7 @@ const productSchema = computed(() => ({
9696
description: plainDescription.value,
9797
image: image.value ? [image.value] : [],
9898
sku: product.value?.sku,
99-
brand: { '@type': 'Brand', name: siteName },
99+
brand: { '@type': 'Brand', name: name },
100100
}));
101101
102102
useHead(() => ({
@@ -178,12 +178,12 @@ const { handleAddToCart, addToCartButtonStatus } = useCart();
178178
:to="localePath(`/product/${vars.slug}-${product.sku.split('-')[0]}`)"
179179
:class="[
180180
'flex w-12 rounded-lg border-2 select-varitaion transition-all duration-200 bg-neutral-200 dark:bg-neutral-800',
181-
vars.allPaColor.nodes[0].name === product.allPaColor.nodes[0].name ? 'selected-varitaion' : 'border-[#9b9b9b] dark:border-[#8c8c8c]',
181+
vars.allPaStyle.nodes[0].name === product.allPaStyle.nodes[0].name ? 'selected-varitaion' : 'border-[#9b9b9b] dark:border-[#8c8c8c]',
182182
]">
183183
<NuxtImg
184-
:alt="vars.allPaColor.nodes[0].name"
184+
:alt="vars.allPaStyle.nodes[0].name"
185185
:src="vars.image.sourceUrl"
186-
:title="vars.allPaColor.nodes[0].name"
186+
:title="vars.allPaStyle.nodes[0].name"
187187
class="rounded-md border-2 border-white dark:border-black" />
188188
</NuxtLink>
189189
</div>

public/logo-dark.svg

Lines changed: 5 additions & 0 deletions
Loading

public/logo-light.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)