Skip to content

Commit 31cb13d

Browse files
authored
chore: some rework (#146)
1 parent 7ba4945 commit 31cb13d

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

apps/storefront-telegram/app/components/catalog/ClosedNowHeader.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div
3-
v-if="isCatalogPage"
4-
class="tg-safe-area tg-text-button bg-gradient-to-b from-indigo-950 to-indigo-700 motion-preset-slide-down"
3+
v-if="isCatalogPage && !channelStore.isKitchenOpened"
4+
class="tg-safe-area -mb-[calc(var(--tg-viewport-content-safe-area-inset-top)+var(--tg-viewport-safe-area-inset-top))] tg-text-button bg-gradient-to-b from-indigo-950 to-indigo-800 motion-preset-slide-down"
55
>
6-
<div class="px-4 py-4 max-w-[28rem] mx-auto tg-content-safe-area-top">
6+
<div class="p-4 max-w-[28rem] mx-auto tg-content-safe-area-top">
77
<div class="pt-6 flex flex-row items-center gap-2">
88
<UIcon name="i-lucide-moon" class="size-12 motion-preset-oscillate-sm motion-preset-seesaw motion-duration-3000" />
99

@@ -16,10 +16,12 @@
1616
</div>
1717
</div>
1818

19-
<div class="tg-bg-secondary h-6 w-full rounded-t-lg overflow-hidden" />
19+
<div class="tg-bg-secondary h-4 w-full rounded-t-lg overflow-hidden" />
2020
</div>
2121
</template>
2222

2323
<script setup lang="ts">
2424
const { isCatalogPage } = useNavigation()
25+
26+
const channelStore = useChannelStore()
2527
</script>

apps/storefront-telegram/app/composables/useCatalog.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
function _useCatalog() {
22
const visibleCategory = ref<string | null>(null)
3+
const lastVisibleCategory = ref<string | null>(null)
34

45
const observerOptions = { rootMargin: '0px 0px 200px 0px' }
56

6-
const scrollToCategoryInHorizontalMenu = useDebounceFn(() => {
7+
function scrollToCategoryInHorizontalMenu() {
8+
if (!visibleCategory.value || lastVisibleCategory.value === visibleCategory.value) {
9+
return
10+
}
11+
12+
lastVisibleCategory.value = visibleCategory.value
13+
714
const category = window.document.getElementById(`to-${visibleCategory.value}`)
8-
category?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' })
9-
}, 800)
15+
if (!category) {
16+
return
17+
}
18+
19+
category.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' })
20+
}
1021

11-
watch(visibleCategory, () => scrollToCategoryInHorizontalMenu())
22+
onMounted(() => {
23+
// Activate scroll watcher after some time
24+
setTimeout(() => {
25+
lastVisibleCategory.value = visibleCategory.value
26+
setInterval(scrollToCategoryInHorizontalMenu, 250)
27+
}, 2000)
28+
})
1229

1330
function scrollToCategory(slug: string) {
1431
const category = window.document.getElementById(slug)

apps/storefront-telegram/app/stores/channel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const useChannelStore = defineStore('channel', () => {
1515
const selectedKitchenId = ref<string | undefined>('m68foq9qtpsxd69eayom7bjn') // Фрунзе
1616
const selectedKitchen = computed(() => kitchens.value.find((kitchen) => kitchen.id === selectedKitchenId.value))
1717

18+
const isKitchenOpened = computed(() => false)
19+
1820
const initDataRaw = useSignal(_initDataRaw)
1921

2022
async function update() {
@@ -53,6 +55,7 @@ export const useChannelStore = defineStore('channel', () => {
5355

5456
selectedKitchenId,
5557
selectedKitchen,
58+
isKitchenOpened,
5659

5760
update,
5861
}

0 commit comments

Comments
 (0)