File tree Expand file tree Collapse file tree 6 files changed +1511
-167
lines changed
apps/storefront-telegram/app Expand file tree Collapse file tree 6 files changed +1511
-167
lines changed Original file line number Diff line number Diff line change 11<template >
2- <div class =" z-40 sticky top-0 h-fit tg-bg-secondary" >
2+ <div class =" z-40 sticky top-0 h-fit tg-content-safe-area-top tg- bg-secondary" >
33 <div class =" max-w-full overflow-x-scroll snap-x" >
4- <div class =" w-max flex flex-row flex-wrap gap-5 " >
4+ <div class =" py-1 w-max flex flex-row flex-wrap gap-1 " >
55 <div
66 v-for =" category in menuStore.menu?.categories"
7+ :id =" `to-${category.slug}`"
78 :key =" category.id"
8- class =" scroll-ml-6 snap-start"
9+ class =" scroll-ml-24 snap-start text-muted rounded-md"
10+ :class =" { 'tg-text-button bg-primary': visibleCategory === category.slug }"
911 >
10- <button class =" py-2 " @click =" scrollToCategory(category.slug)" >
12+ <button class =" px-3 py-1 " @click =" scrollToCategory(category.slug)" >
1113 {{ category.name }}
1214 </button >
1315 </div >
1820
1921<script setup lang="ts">
2022const { vibrate } = useFeedback ()
23+ const { visibleCategory } = useCatalog ()
2124
2225const menuStore = useMenuStore ()
2326
Original file line number Diff line number Diff line change 11<template >
2- <div class =" flex flex-col gap-3 mb-10" >
3- <h2 :id =" category?.slug" class =" scroll-mt-14 text-2xl/5 font-semibold tracking-tight" >
2+ <div
3+ v-element-visibility =" [
4+ (isVisible) => (isVisible && category?.slug) ? visibleCategory = category.slug : null,
5+ observerOptions,
6+ ]"
7+ class =" flex flex-col gap-3 mb-10"
8+ >
9+ <h2 :id =" category?.slug" class =" scroll-mt-22 text-2xl/5 font-semibold tracking-tight" >
410 {{ category?.name }}
511 </h2 >
612
1622</template >
1723
1824<script setup lang="ts">
25+ import { vElementVisibility } from ' @vueuse/components'
26+
1927const { categoryId } = defineProps <{
2028 categoryId: string
2129}>()
2230
31+ const { visibleCategory, observerOptions } = useCatalog ()
32+
2333const menuStore = useMenuStore ()
2434const category = menuStore .menu ?.categories .find ((c ) => c .id === categoryId )
2535const products = category ?.products .filter ((p ) => p .isAvailableForPurchase && p .variants .length )
Original file line number Diff line number Diff line change 1+ function _useCatalog ( ) {
2+ const visibleCategory = ref < string | null > ( null )
3+
4+ const observerOptions = { rootMargin : '0px 0px -400px 0px' }
5+
6+ const scrollToCategory = useDebounceFn ( ( ) => {
7+ const category = window . document . getElementById ( `to-${ visibleCategory . value } ` )
8+ category ?. scrollIntoView ( { behavior : 'smooth' , block : 'nearest' , inline : 'start' } )
9+ } , 1000 )
10+
11+ watch ( visibleCategory , ( ) => scrollToCategory ( ) )
12+
13+ return {
14+ visibleCategory,
15+ observerOptions,
16+ }
17+ }
18+
19+ export const useCatalog = createSharedComposable ( _useCatalog )
Original file line number Diff line number Diff line change 1313 "@nuxtjs/i18n" : " catalog:" ,
1414 "@unovis/ts" : " catalog:" ,
1515 "@unovis/vue" : " catalog:" ,
16+ "@vueuse/components" : " catalog:" ,
1617 "@vueuse/core" : " catalog:" ,
1718 "@vueuse/integrations" : " catalog:" ,
1819 "@vueuse/nuxt" : " catalog:" ,
You can’t perform that action at this time.
0 commit comments