Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/components/app/nav/nav-desktop.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<script setup lang="ts">
// Emits
const emits = defineEmits<{
toggleLocaleModal: []
toggleSearchMenu: []
toggleCartDrawer: []
}>()

// Links
const navLinksLeft = [
{ label: 'Shop', path: '/collections/latest' },
Expand All @@ -19,24 +26,17 @@ const countryCode = computed(() => shopStore.buyerCountryCode)
const currencySymbol = computed(() => shopStore.buyerCurrencySymbol)
const cartTotalItems = computed(() => cartStore.lineItemCount)

// Emits
const emit = defineEmits<{
toggleLocaleModal: []
toggleSearchMenu: []
toggleCartDrawer: []
}>()

// Emit events
const toggleLocaleModal = () => {
emit('toggleLocaleModal')
emits('toggleLocaleModal')
}

const toggleSearchMenu = () => {
emit('toggleSearchMenu')
emits('toggleSearchMenu')
}

const toggleCartDrawer = () => {
emit('toggleCartDrawer')
emits('toggleCartDrawer')
}
</script>

Expand Down
20 changes: 10 additions & 10 deletions app/components/app/nav/nav-mobile.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<script setup lang="ts">
import { useCartStore } from '@/stores/cart'

// Stores
const cartStore = useCartStore()

// Computed
const cartTotalItems = computed(() => cartStore.lineItemCount)

// Emits
const emit = defineEmits<{
const emits = defineEmits<{
toggleMobileMenu: []
toggleSearchMenu: []
toggleCartDrawer: []
}>()

// Stores
const cartStore = useCartStore()

// Computed
const cartTotalItems = computed(() => cartStore.lineItemCount)

// Emit events
const toggleMobileMenu = () => {
emit('toggleMobileMenu')
emits('toggleMobileMenu')
}

const toggleSearchMenu = () => {
emit('toggleSearchMenu')
emits('toggleSearchMenu')
}

const toggleCartDrawer = () => {
emit('toggleCartDrawer')
emits('toggleCartDrawer')
}
</script>

Expand Down
24 changes: 12 additions & 12 deletions app/components/shopify/filter/filter-menu-desktop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ const props = defineProps<{
activeFilterCount: number
}>()

// Route
const route = useRoute()

// Stores
const appStore = useAppStore()

// Emits
const emit = defineEmits<{
const emits = defineEmits<{
closeFilter: []
setSortOption: [sortValue: string | null]
setFilterOption: [filterName: string, filterValue: string]
clearAllFilters: []
}>()

// Route
const route = useRoute()

// Stores
const appStore = useAppStore()

// Emit events
const closeFilter = () => {
emit('closeFilter')
emits('closeFilter')
}

const setSortOption = (sortValue: string | null) => {
emit('setSortOption', sortValue)
emits('setSortOption', sortValue)
}

const setFilterOption = (filterName: string, filterValue: string) => {
emit('setFilterOption', filterName, filterValue)
emits('setFilterOption', filterName, filterValue)
}

const clearAllFilters = () => {
emit('clearAllFilters')
emits('clearAllFilters')
}
</script>

Expand Down Expand Up @@ -89,7 +89,7 @@ const clearAllFilters = () => {
</h3>
<div class="flex flex-col">
<button
v-for="option in props.sortOptions"
v-for="(option, index) in props.sortOptions"
:key="index"
:class="{ underline: route.query.sort === option.value || (option.value === null && !route.query.sort) }"
class="max-w-fit normal-case decoration-dotted decoration-1 underline-offset-[3px] hover:underline"
Expand Down
22 changes: 11 additions & 11 deletions app/components/shopify/filter/filter-menu-mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ const props = defineProps<{
activeFilterCount: number
}>()

// Route
const route = useRoute()

// Stores
const appStore = useAppStore()

// Emits
const emit = defineEmits<{
const emits = defineEmits<{
closeFilter: []
setSortOption: [sortValue: string | null]
setFilterOption: [filterName: string, filterValue: string]
clearAllFilters: []
}>()

// Route
const route = useRoute()

// Stores
const appStore = useAppStore()

// Emit events
const closeFilter = () => {
emit('closeFilter')
emits('closeFilter')
}

const setSortOption = (sortValue: string | null) => {
emit('setSortOption', sortValue)
emits('setSortOption', sortValue)
}

const setFilterOption = (filterName: string, filterValue: string) => {
emit('setFilterOption', filterName, filterValue)
emits('setFilterOption', filterName, filterValue)
}

const clearAllFilters = () => {
emit('clearAllFilters')
emits('clearAllFilters')
}
</script>

Expand Down
12 changes: 6 additions & 6 deletions app/components/shopify/product/form/form-size-options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const props = defineProps<{
selectedSize: string
}>()

// Emits
const emits = defineEmits<{
setSizeOption: [size: string]
}>()

// Computed
const sizeOption = computed(() => getSizeOption(props.product.options))

Expand All @@ -25,14 +30,9 @@ const productSizes = computed(() => {
}))
})

// Emits
const emit = defineEmits<{
setSizeOption: [size: string]
}>()

// Emit events
const setSizeOption = (size: string) => {
emit('setSizeOption', size)
emits('setSizeOption', size)
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion app/components/shopify/product/product-media-gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mediaIndex = ref<number>(0)
// Actions
const toggleLightbox = (index: number) => {
mediaIndex.value = index
appStore.toggle('mediaLightbox')
appStore.toggle('mediaLightbox', true)
}

// Watchers
Expand Down
25 changes: 12 additions & 13 deletions app/components/shopify/product/product-media-lightbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,24 @@ const closeLightbox = () => {
appStore.toggle('mediaLightbox', false)
}

// State
const mediaRefs = ref<HTMLElement[]>([])

watchEffect(() => {
const selectedMediaItem = mediaRefs.value[props.mediaIndex]
selectedMediaItem?.scrollIntoView()
})
// Refs
const mediaRefs = useTemplateRef('mediaRefs')

// Watchers
const { escape } = useMagicKeys()

watch(
() => props.mediaIndex,
async (index) => {
await nextTick()
const el = mediaRefs.value?.[index]
el?.scrollIntoView()
},
)

if (escape) {
watch(escape, closeLightbox)
}

// Cleanup
onBeforeUnmount(() => {
closeLightbox()
})
</script>

<template>
Expand All @@ -55,8 +54,8 @@ onBeforeUnmount(() => {
<div class="flex flex-col overflow-auto size-full">
<div
v-for="(media, index) in productMedia"
ref="mediaRefs"
:key="media.id"
ref="mediaRefs"
class="aspect-square cursor-zoom-out"
@click="closeLightbox"
>
Expand Down
31 changes: 16 additions & 15 deletions app/components/shopify/search/search-menu-desktop.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<script setup lang="ts">
import type { ProductFragment } from '@@/types/shopify-storefront'

// Model bindings
const searchQuery = defineModel<string>()

// Props
const props = defineProps<{
products: ProductFragment[]
}>()

// Emits
const emits = defineEmits<{
submitQuery: []
closeSearch: []
}>()

// Model bindings
const searchQuery = defineModel<string>()

// Stores
const appStore = useAppStore()

Expand All @@ -19,25 +25,20 @@ const defaulSearchLinks = [
{ label: 'Womens Pants', path: '/' },
]

// State
const input = ref<HTMLInputElement | null>(null)

// Emits
const emit = defineEmits<{
submitQuery: []
closeSearch: []
}>()

// Emit events
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
emit('submitQuery')
emits('submitQuery')
}
}

const closeSearch = () => {
emit('closeSearch')
emits('closeSearch')
}

// Refs
const input = useTemplateRef('inputRef')

// Watchers
watch(
() => appStore.searchMenu,
Expand Down Expand Up @@ -69,7 +70,7 @@ watch(
<div class="flex flex-col gap-6 w-full px-6 pt-16 pb-10 mx-auto xl:max-w-6xl">
<div class="relative w-full">
<input
ref="input"
ref="inputRef"
v-model="searchQuery"
type="text"
name="searchInput"
Expand Down
26 changes: 13 additions & 13 deletions app/components/shopify/search/search-menu-mobile.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<script setup lang="ts">
import type { ProductFragment } from '@@/types/shopify-storefront'

// Model bindings
const searchQuery = defineModel<string>()

// Props
const props = defineProps<{
products: ProductFragment[]
}>()

// Stores
const appStore = useAppStore()

// State
const input = ref<HTMLInputElement | null>(null)

// Emits
const emit = defineEmits<{
const emits = defineEmits<{
submitQuery: []
closeSearch: []
}>()

// Model bindings
const searchQuery = defineModel<string>()

// Stores
const appStore = useAppStore()

// Emit events
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
emit('submitQuery')
emits('submitQuery')
}
}

const closeSearch = () => {
emit('closeSearch')
emits('closeSearch')
}

// Refs
const input = useTemplateRef('inputRef')

// Watchers
watch(
() => appStore.searchMenu,
Expand Down Expand Up @@ -62,7 +62,7 @@ watch(
<div class="flex flex-col gap-10 size-full px-5">
<div class="relative flex">
<input
ref="input"
ref="inputRef"
v-model="searchQuery"
type="text"
name="searchInput"
Expand Down
Loading