This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.vue
85 lines (79 loc) · 2.02 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script setup lang="ts">
// Initialize store
await Promise.all([
await useShop().init(),
await useLocalization().localize(),
await useCart().retrieveCart(),
])
// Log Apollo errors to console
useNuxtApp().hook('apollo:error', (error) => {
console.error(error)
})
const isShopValid = computed(() => !!useShop().shop.value?.id || false)
const colors = computed(() => ({
primaryBg: useUtils().hexToStrippedRgb(useShop().shop.value?.brand?.colors.primary[0].background || '#111827'),
primaryFg: useUtils().hexToStrippedRgb(useShop().shop.value?.brand?.colors.primary[0].foreground || '#F3F4F6'),
secondaryBg: useUtils().hexToStrippedRgb(useShop().shop.value?.brand?.colors.secondary[0].background || '#1F2937'),
secondaryFg: useUtils().hexToStrippedRgb(useShop().shop.value?.brand?.colors.secondary[0].foreground || '#F3F4F6'),
}))
const { shop } = useShop()
useHead({
titleTemplate: (titleChunk?: string) => titleChunk
? `${titleChunk} | ${shop.value?.name}`
: (shop.value?.name || 'Shopify Nuxt'),
style: [
{
children: `
@layer base {
:root {
--primary-background: ${colors.value.primaryBg};
--primary-foreground: ${colors.value.primaryFg};
--secondary-background: ${colors.value.secondaryBg};
--secondary-foreground: ${colors.value.secondaryFg};
}
}
`,
},
],
})
</script>
<template>
<div>
<template v-if="isShopValid">
<NuxtLayout>
<NuxtPage>
<slot />
</NuxtPage>
</NuxtLayout>
</template>
<div v-else>
<p>Unable to retrieve shop data from Shopify</p>
</div>
</div>
</template>
<style lang="postcss">
html {
@apply font-sans;
}
h1,h2,h3,h4,h5,h6 {
@apply font-bold;
}
h1 {
@apply text-2xl md:text-3xl lg:text-4xl;
}
h2 {
@apply text-xl md:text-2xl lg:text-3xl;
}
h3 {
@apply text-lg md:text-xl lg:text-2xl;
}
h4 {
@apply text-base md:text-lg lg:text-xl;
}
h5 {
@apply text-sm md:text-base lg:text-lg;
}
h6 {
@apply text-sm lg:text-base;
}
</style>