Skip to content

Commit d3d360b

Browse files
authored
feat: feedback service (#95)
1 parent 84ea455 commit d3d360b

10 files changed

Lines changed: 96 additions & 64 deletions

File tree

apps/atrium-telegram/app/assets/css/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--ui-secondary: var(--tg-theme-link-color);
44
--ui-border: var(--tg-theme-section-separator-color);
55
--ui-text: var(--tg-theme-text-color);
6+
--ui-text-muted: var(--tg-theme-hint-color);
67
--ui-bg: var(--tg-theme-section-bg-color);
78

89
--ui-color-neutral-400: var(--tg-theme-subtitle-text-color);
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
<template>
22
<button
33
class="p-3 tg-bg-button w-full rounded-2xl font-medium cursor-pointer active:scale-95 duration-200"
4-
@click="handleClick"
4+
@click="vibrate"
55
>
66
<slot />
77
</button>
88
</template>
99

1010
<script setup lang="ts">
11-
import { hapticFeedback } from '@telegram-apps/sdk-vue'
12-
13-
function handleClick() {
14-
if (hapticFeedback.impactOccurred.isAvailable()) {
15-
hapticFeedback.impactOccurred('light')
16-
}
17-
}
11+
const { vibrate } = useFeedback()
1812
</script>
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<template>
2-
<div class="flex flex-col gap-4 justify-center items-center h-full min-h-40 border-2 border-default border-dashed rounded-lg">
2+
<div class="flex flex-col gap-4 justify-center items-center h-full min-h-40 border border-default border-dashed rounded-lg">
33
<UIcon :name="icon" class="size-10 text-muted/50" />
44

55
<UButton
66
size="md"
77
variant="solid"
88
color="secondary"
99
:label="label"
10+
:ui="{
11+
label: 'font-medium',
12+
}"
13+
@click="vibrate"
1014
/>
1115
</div>
1216
</template>
1317

1418
<script setup lang="ts">
1519
defineProps<{ label: string, icon: string }>()
20+
21+
const { vibrate } = useFeedback()
1622
</script>

apps/atrium-telegram/app/components/Navigation.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
</template>
3232

3333
<script setup lang="ts">
34-
import { hapticFeedback } from '@telegram-apps/sdk-vue'
35-
3634
const { t } = useI18n()
35+
const { vibrate } = useFeedback()
3736
const router = useRouter()
3837
3938
const mainRoutes = computed(() => [
@@ -64,10 +63,7 @@ const mainRoutes = computed(() => [
6463
])
6564
6665
function handleClick(path: string) {
67-
if (hapticFeedback.impactOccurred.isAvailable()) {
68-
hapticFeedback.impactOccurred('light')
69-
}
70-
66+
vibrate()
7167
router.push(path)
7268
}
7369
</script>

apps/atrium-telegram/app/components/TaskCard.vue

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
</template>
2525
</UPopover>
2626
</template>
27-
<UTooltip v-else-if="canComplete" text="Задача выполнена?">
28-
<UCheckbox
29-
v-model="checkbox"
30-
color="secondary"
31-
variant="list"
32-
size="xl"
33-
icon="i-lucide-check"
34-
class="mt-1.5 duration-200 motion-preset-bounce"
35-
@change="onStartCompleting"
36-
/>
37-
</UTooltip>
27+
<UCheckbox
28+
v-else-if="canComplete"
29+
v-model="checkbox"
30+
color="secondary"
31+
variant="list"
32+
size="xl"
33+
icon="i-lucide-check"
34+
class="mt-1.5 duration-200 motion-preset-bounce"
35+
@change="onStartCompleting"
36+
/>
3837
<UCheckbox
3938
v-else
4039
v-model="checkbox"
@@ -65,8 +64,9 @@
6564
}"
6665
class="group/task duration-200 motion-preset-bounce cursor-pointer"
6766
:class="[
68-
isFocused && 'border border-secondary',
67+
isFocused && 'border border-secondary/25',
6968
]"
69+
@click="vibrate"
7070
>
7171
<div class="flex flex-col gap-2 items-start">
7272
<div class="flex flex-col gap-1 items-start text-left">
@@ -116,7 +116,7 @@ const { task } = defineProps<{
116116
}>()
117117
118118
const { t } = useI18n()
119-
const toast = useToast()
119+
const { vibrate } = useFeedback()
120120
const actionToast = useActionToast()
121121
const taskStore = useTaskStore()
122122
const userStore = useUserStore()
@@ -140,7 +140,6 @@ const canFocus = computed(() => task.performerId === userStore.id && !isComplete
140140
const isFocused = computed(() => task.id === performer.value?.focusedTaskId)
141141
142142
const checkbox = ref(false)
143-
const toastId = ref(`task-close-${task.id}`)
144143
145144
const items = computed<DropdownMenuItem[]>(() => {
146145
const menuItems: DropdownMenuItem[] = [
@@ -195,21 +194,14 @@ async function onUnfocus() {
195194
}
196195
197196
function onStartCompleting() {
197+
vibrate()
198+
198199
if (!checkbox.value) {
199200
return
200201
}
201202
202203
modalCompleteTask.open({ taskId: task.id })
203204
204205
checkbox.value = false
205-
206-
toast.add({
207-
id: toastId.value,
208-
title: 'Закрываем задачу?',
209-
description: 'Сразу как успешную или есть что добавить? Заполните форму.',
210-
color: 'secondary',
211-
type: 'foreground',
212-
duration: 5000,
213-
})
214206
}
215207
</script>

apps/atrium-telegram/app/components/TaskList.vue

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,21 @@
5454
</div>
5555

5656
<div v-if="canEdit" class="flex flex-row gap-2">
57-
<UTooltip :text="`Редактировать проект «${list?.name`">
58-
<UButton
59-
variant="outline"
60-
color="neutral"
61-
size="md"
62-
icon="i-lucide-pencil"
63-
@click="modalUpdateTaskList.open({ listId })"
64-
/>
65-
</UTooltip>
57+
<UButton
58+
variant="outline"
59+
color="neutral"
60+
size="md"
61+
icon="i-lucide-pencil"
62+
@click="handleEditTaskList"
63+
/>
6664

67-
<UTooltip :text="`${$t('app.create.task.button')} в проекте «${list?.name`">
68-
<UButton
69-
variant="solid"
70-
color="secondary"
71-
size="md"
72-
icon="i-lucide-plus"
73-
@click="modalCreateTask.open({ performerId: userStore.id, listId })"
74-
/>
75-
</UTooltip>
65+
<UButton
66+
variant="solid"
67+
color="secondary"
68+
size="md"
69+
icon="i-lucide-plus"
70+
@click="handleCreateTask"
71+
/>
7672
</div>
7773
</div>
7874

@@ -103,6 +99,7 @@ const { listId, currentUserId } = defineProps<{
10399
currentUserId: string
104100
}>()
105101
102+
const { vibrate } = useFeedback()
106103
const userStore = useUserStore()
107104
const taskStore = useTaskStore()
108105
@@ -129,4 +126,14 @@ const canEdit = computed(() => list.value?.chat?.members.some((member) => member
129126
const overlay = useOverlay()
130127
const modalCreateTask = overlay.create(ModalCreateTask)
131128
const modalUpdateTaskList = overlay.create(ModalUpdateTaskList)
129+
130+
function handleEditTaskList() {
131+
vibrate()
132+
modalUpdateTaskList.open({ listId })
133+
}
134+
135+
function handleCreateTask() {
136+
vibrate()
137+
modalCreateTask.open({ performerId: userStore.id, listId })
138+
}
132139
</script>

apps/atrium-telegram/app/components/TasksTodaySwitch.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
root: 'flex-row-reverse items-center',
1010
label: 'mr-3 text-base/5 md:text-lg/5 font-semibold',
1111
}"
12+
@change="vibrate"
1213
/>
1314
</template>
1415

1516
<script setup lang="ts">
17+
const { vibrate } = useFeedback()
1618
const taskStore = useTaskStore()
1719
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { hapticFeedback } from '@telegram-apps/sdk-vue'
2+
3+
function _useFeedback() {
4+
function vibrate() {
5+
if (hapticFeedback.impactOccurred.isAvailable()) {
6+
hapticFeedback.impactOccurred('light')
7+
}
8+
}
9+
10+
return {
11+
vibrate,
12+
}
13+
}
14+
15+
export const useFeedback = createSharedComposable(_useFeedback)

apps/atrium-telegram/app/pages/index.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
<PageContainer :back="false">
33
<div class="flex flex-col md:flex-row gap-6 md:gap-2 md:items-center md:justify-between">
44
<div class="flex flex-row gap-3.5 items-center">
5-
<UTooltip :text="$t('app.update.user-photo.button')">
6-
<UAvatar
7-
:src="userStore?.avatarUrl ?? undefined"
8-
class="size-14 cursor-pointer hover:scale-95 active:scale-90 duration-200"
9-
@click="modalUploadUserAvatar.open()"
10-
/>
11-
</UTooltip>
5+
<UAvatar
6+
:src="userStore?.avatarUrl ?? undefined"
7+
class="size-14 cursor-pointer hover:scale-95 active:scale-90 duration-200"
8+
@click="handleUploadUserAvatar"
9+
/>
1210

1311
<div class="flex flex-col gap-1">
1412
<h2 class="text-xl/6 md:text-2xl lg:text-3xl font-bold tracking-tight">
@@ -42,7 +40,7 @@
4240
</div>
4341
</div>
4442

45-
<div class="mb-32 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4">
43+
<div class="mb-20 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4">
4644
<TaskList
4745
v-for="taskList in myLists"
4846
:key="taskList.id"
@@ -63,6 +61,8 @@
6361
import { ModalCreateTaskList, ModalUploadUserAvatar } from '#components'
6462
import { getLocalTimeZone, isToday, parseDate } from '@internationalized/date'
6563
64+
const { vibrate } = useFeedback()
65+
6666
const overlay = useOverlay()
6767
const modalCreateTaskList = overlay.create(ModalCreateTaskList)
6868
const modalUploadUserAvatar = overlay.create(ModalUploadUserAvatar)
@@ -77,6 +77,11 @@ const myLists = computed(() =>
7777
)
7878
const myTodayTasks = computed(() => myLists.value.flatMap((taskList) => taskList.tasks.filter((task) => !task.completedAt && task.date && isToday(parseDate(task.date), getLocalTimeZone()))))
7979
80+
function handleUploadUserAvatar() {
81+
vibrate()
82+
modalUploadUserAvatar.open()
83+
}
84+
8085
useHead({
8186
title: 'Суши Атриум',
8287
})

apps/atrium-telegram/i18n/locales/ru-RU.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"app": {
88
"home": "Пространство",
99
"create": {
10+
"task": {
11+
"button": "Создать задачу",
12+
"title": "Создание задачи"
13+
},
1014
"task-list": {
1115
"button": "Создать проект",
1216
"title": "Создание проекта"
@@ -16,6 +20,16 @@
1620
"user-photo": {
1721
"button": "Обновить фото",
1822
"title": "Обновление фото пользователя"
23+
},
24+
"task": {
25+
"button": "Обновить задачу",
26+
"title": "Обновление задачи",
27+
"completion": "Закрытие задачи",
28+
"close": "Закрыть задачу"
29+
},
30+
"task-list": {
31+
"button": "Обновить проект",
32+
"title": "Обновление проекта"
1933
}
2034
}
2135
}

0 commit comments

Comments
 (0)