Skip to content

Commit dd87801

Browse files
authored
feat: atrium as telegram mini app (#90)
* feat: atrium as telegram mini app * chore: docker
1 parent 4ad2046 commit dd87801

38 files changed

+961
-336
lines changed

.github/workflows/docker-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set matrix
2727
id: set-matrix
2828
run: |
29-
APPS=("web-app" "web-storefront" "web-parser")
29+
APPS=("web-app" "web-storefront" "web-parser" "atrium-telegram")
3030
CHANGED=()
3131
3232
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then

.github/workflows/docker-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Set package in env
3434
id: set-package
3535
run: |
36-
APPS=("web-app" "web-storefront" "web-parser")
36+
APPS=("web-app" "web-storefront" "web-parser" "atrium-telegram")
3737
MATCH="${{ steps.regex-match.outputs.match }}"
3838
3939
if [ -z "$MATCH" ]; then

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ build/
1616
.nitro/
1717
.data/
1818
.storage/
19+
.cert/
1920

2021
### Node ###
2122
node_modules/

apps/atrium-telegram/.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Main database
2+
DATABASE_URL=
3+
4+
# Telegram
5+
NUXT_TELEGRAM_ADMIN_ID=
6+
NUXT_TELEGRAM_ATRIUM_BOT_ID=
7+
NUXT_TELEGRAM_ATRIUM_BOT_TOKEN=
8+
NUXT_TELEGRAM_DEV_BOT_TOKEN=
9+
NUXT_TELEGRAM_TEAM_GROUP_ID=
10+
11+
# App version
12+
VERSION=
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
export default defineAppConfig({
2+
ui: {
3+
button: {
4+
slots: {
5+
base: 'font-semibold',
6+
},
7+
variants: {
8+
size: {
9+
xl: {
10+
base: 'px-4 py-3 font-semibold',
11+
},
12+
},
13+
variant: {
14+
gradient: 'text-white bg-linear-to-br from-secondary-400 to-secondary-500 hover:opacity-90 disabled:from-neutral-300 disabled:to-neutral-400 aria-disabled:from-neutral-300 aria-disabled:to-neutral-400 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary',
15+
},
16+
color: {
17+
secondary: '!text-white disabled:!bg-inverted/25',
18+
},
19+
},
20+
},
21+
tabs: {
22+
variants: {
23+
variant: {
24+
pill: {
25+
trigger: 'data-[state=active]:!text-white',
26+
},
27+
gradient: {
28+
list: 'bg-elevated rounded-lg',
29+
trigger: 'data-[state=active]:bg-linear-to-br from-lime-300 to-lime-500 data-[state=active]:text-neutral-950 flex-1 w-full',
30+
indicator: 'rounded-md shadow-xs',
31+
},
32+
},
33+
},
34+
},
35+
modal: {
36+
slots: {
37+
content: 'divide-y-0',
38+
header: 'pb-0 min-h-12',
39+
title: 'text-lg/5 font-semibold',
40+
},
41+
},
42+
navigationMenu: {
43+
slots: {
44+
link: 'text-sm',
45+
},
46+
},
47+
toast: {
48+
slots: {
49+
title: 'text-lg/6',
50+
description: 'leading-4',
51+
icon: 'shrink-0 size-7',
52+
},
53+
},
54+
card: {
55+
slots: {
56+
body: 'p-4 sm:p-4',
57+
},
58+
},
59+
},
60+
})

apps/atrium-telegram/app/app.vue

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<UApp
3+
:locale="locales[locale]"
4+
:tooltip="{ delayDuration: 0 }"
5+
class="min-h-svh"
6+
>
7+
<NuxtLoadingIndicator :color="false" class="bg-primary h-[2px]" />
8+
<NuxtLayout>
9+
<NuxtPage />
10+
</NuxtLayout>
11+
</UApp>
12+
</template>
13+
14+
<script setup lang="ts">
15+
import * as locales from '@nuxt/ui/locale'
16+
import { retrieveLaunchParams } from '@telegram-apps/sdk-vue'
17+
18+
const { locale } = useI18n()
19+
20+
const lang = computed(() => locales[locale.value].code)
21+
const dir = computed(() => locales[locale.value].dir)
22+
23+
useHead({
24+
htmlAttrs: {
25+
lang,
26+
dir,
27+
},
28+
})
29+
30+
// App
31+
const isDev = (retrieveLaunchParams().startParam === 'debug' || import.meta.env.DEV) ?? false
32+
await init({
33+
debug: false,
34+
eruda: isDev,
35+
mockForMacOS: false,
36+
})
37+
38+
// Init Stores
39+
const user = useUserStore()
40+
41+
// Auto Update Online
42+
let interval: NodeJS.Timeout
43+
44+
onMounted(async () => {
45+
await Promise.all([
46+
user.updateOnline(),
47+
user.update(),
48+
])
49+
50+
interval = setInterval(async () => {
51+
await Promise.all([
52+
user.updateOnline(),
53+
user.update(),
54+
])
55+
}, 30000)
56+
})
57+
58+
onUnmounted(() => {
59+
clearInterval(interval)
60+
})
61+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1, h2, h3, h4, h5, h6 {
2+
font-family: var(--font-headers);
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { initDataRaw as _initDataRaw, initDataState as _initDataState, useSignal } from '@telegram-apps/sdk-vue'
2+
3+
function _useTelegram() {
4+
const initDataRaw = useSignal(_initDataRaw)
5+
const initDataState = useSignal(_initDataState)
6+
7+
return {
8+
initDataRaw,
9+
initDataState,
10+
}
11+
}
12+
13+
export const useTelegram = createSharedComposable(_useTelegram)

apps/atrium-telegram/app/error.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<div class="flex flex-col max-w-sm mx-auto mt-32 text-center items-center">
3+
<h1 class="text-4xl font-bold mb-4">
4+
{{ $t('error.title') }} {{ error?.statusCode }}
5+
</h1>
6+
<p>{{ error?.statusMessage }}</p>
7+
8+
<UButton
9+
variant="solid"
10+
size="xl"
11+
class="mt-12 w-full justify-center"
12+
@click="handleError"
13+
>
14+
{{ $t('common.to-home') }}
15+
</UButton>
16+
</div>
17+
</template>
18+
19+
<script setup lang="ts">
20+
const { error } = defineProps<{ error: {
21+
statusCode: number
22+
statusMessage?: string
23+
} }>()
24+
25+
function handleError() {
26+
clearError({ redirect: '/' })
27+
}
28+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<slot />
3+
</template>

0 commit comments

Comments
 (0)