nuxt-telegram-mini-app 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -10
- package/app/assets/css/main.css +1 -1
- package/app/components/tg/Button.vue +4 -3
- package/app/components/tg/Cell.vue +1 -1
- package/app/components/tg/Content.vue +1 -0
- package/app/pages/index.vue +16 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,29 +226,46 @@ Nuxt Layers provide a way to extend and customize Nuxt applications by sharing c
|
|
|
226
226
|
|
|
227
227
|
### Using This Template as a Layer
|
|
228
228
|
|
|
229
|
-
To use this Telegram Mini App template as a layer in another Nuxt project:
|
|
229
|
+
To use this Telegram Mini App template as a layer in another Nuxt project, install it as an NPM package:
|
|
230
230
|
|
|
231
|
-
1. **
|
|
231
|
+
1. **Install the NPM package**:
|
|
232
232
|
```bash
|
|
233
|
-
|
|
233
|
+
npm install nuxt-telegram-mini-app
|
|
234
|
+
# or
|
|
235
|
+
yarn add nuxt-telegram-mini-app
|
|
236
|
+
# or
|
|
237
|
+
pnpm add nuxt-telegram-mini-app
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
2. **Configure your Nuxt project** to extend this layer:
|
|
241
|
+
```ts
|
|
242
|
+
// nuxt.config.ts
|
|
243
|
+
export default defineNuxtConfig({
|
|
244
|
+
extends: [
|
|
245
|
+
'nuxt-telegram-mini-app'
|
|
246
|
+
],
|
|
247
|
+
// Your custom config here
|
|
248
|
+
})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Alternatively, if you prefer to use a local clone or git dependency:
|
|
252
|
+
```bash
|
|
253
|
+
# Clone as a subdirectory
|
|
234
254
|
git clone https://github.com/patricktobias86/nuxt-telegram-mini-app.git layers/telegram-app
|
|
235
255
|
|
|
236
|
-
#
|
|
237
|
-
# In your project's package.json:
|
|
256
|
+
# Or add as git dependency in package.json:
|
|
238
257
|
# "dependencies": {
|
|
239
258
|
# "nuxt-telegram-mini-app": "github:patricktobias86/nuxt-telegram-mini-app"
|
|
240
259
|
# }
|
|
241
260
|
```
|
|
242
261
|
|
|
243
|
-
|
|
262
|
+
Then configure:
|
|
244
263
|
```ts
|
|
245
264
|
// nuxt.config.ts
|
|
246
265
|
export default defineNuxtConfig({
|
|
247
266
|
extends: [
|
|
248
|
-
|
|
249
|
-
'
|
|
250
|
-
// Or npm package
|
|
251
|
-
// 'nuxt-telegram-mini-app'
|
|
267
|
+
'./layers/telegram-app'
|
|
268
|
+
// or 'nuxt-telegram-mini-app' for git dependency
|
|
252
269
|
],
|
|
253
270
|
// Your custom config here
|
|
254
271
|
})
|
package/app/assets/css/main.css
CHANGED
|
@@ -40,7 +40,7 @@ html, body {
|
|
|
40
40
|
overscroll-behavior: contain;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.tg-bg { background-color: var(
|
|
43
|
+
.tg-bg { background-color: var(---tg-theme-bg-color); }
|
|
44
44
|
.tg-secondary-bg { background-color: var(--tg-theme-secondary-bg-color); }
|
|
45
45
|
.tg-section-bg { background-color: var(--tg-theme-section-bg-color); }
|
|
46
46
|
.tg-link, a { color: var(--tg-theme-link-color); }
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div class="px-3">
|
|
3
|
+
<component :is="tag" v-bind="bind" :class="classes" :disabled="disabled || loading" @click="onClick">
|
|
3
4
|
<Icon v-if="loading" name="i-heroicons-arrow-path-20-solid" class="h-5 w-5 animate-spin" />
|
|
4
5
|
<Icon v-if="icon && iconPosition === 'left' && !loading" :name="icon" class="h-5 w-5" />
|
|
5
6
|
<span>{{ title }}</span>
|
|
6
7
|
<Icon v-if="icon && iconPosition === 'right' && !loading" :name="icon" class="h-5 w-5" />
|
|
7
8
|
</component>
|
|
9
|
+
</div>
|
|
8
10
|
</template>
|
|
9
11
|
|
|
10
12
|
<script setup lang="ts">
|
|
11
13
|
import { computed } from 'vue'
|
|
12
|
-
import { shareURL } from '~/composables/telegram'
|
|
13
|
-
import { useHapticFeedback } from '~/composables/telegram'
|
|
14
|
+
import { shareURL, useHapticFeedback } from '~/composables/telegram'
|
|
14
15
|
|
|
15
16
|
const props = withDefaults(defineProps<{
|
|
16
17
|
title: string
|
|
@@ -79,7 +79,7 @@ const bgClass = computed(() => props.tone === 'secondary' ? 'bg-secondaryBg' : '
|
|
|
79
79
|
const showChevron = computed(() => props.chevron ?? isLink.value)
|
|
80
80
|
|
|
81
81
|
const rootClass = computed(() => [
|
|
82
|
-
'w-full flex items-center gap-3
|
|
82
|
+
'w-full flex items-center gap-3 p-4',
|
|
83
83
|
bgClass.value,
|
|
84
84
|
props.border ? 'border-b border-sectionSeparator last:border-b-0' : '',
|
|
85
85
|
(isLink.value || props.clickable) ? 'hover:bg-secondaryBg transition-colors' : '',
|
package/app/pages/index.vue
CHANGED
|
@@ -10,12 +10,10 @@
|
|
|
10
10
|
<TgCell
|
|
11
11
|
title="Navigation Demo"
|
|
12
12
|
subtitle="Use the bottom navigation bar to navigate"
|
|
13
|
-
icon="
|
|
13
|
+
icon="heroicons:clipboard-solid"
|
|
14
14
|
/>
|
|
15
|
-
<TgButton title="Demo Button" status="primary" haptic @click="() => haptic.impactOccurred('medium')" />
|
|
16
|
-
<TgButton title="Toggle Main Button" status="primary" haptic="selection" @click="toggleMain" />
|
|
17
15
|
<TgCell
|
|
18
|
-
title="
|
|
16
|
+
title="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo."
|
|
19
17
|
/>
|
|
20
18
|
<template #append>
|
|
21
19
|
Use the navigation bar at the bottom to switch between pages.
|
|
@@ -24,15 +22,14 @@
|
|
|
24
22
|
|
|
25
23
|
<TgSection title="Haptic Feedback" inset>
|
|
26
24
|
<TgCell title="Supported" :description="hapticSupported" icon="i-heroicons-bolt-20-solid" :border="false" />
|
|
27
|
-
<div class="p-4 grid grid-cols-1 sm:grid-cols-3 gap-2">
|
|
28
|
-
<TgButton title="Impact" :disabled="!hapticSupportedBool" @click="haptic.impactOccurred('medium')" />
|
|
29
|
-
<TgButton title="Notification" :disabled="!hapticSupportedBool" @click="haptic.notificationOccurred('success')" />
|
|
30
|
-
<TgButton title="Selection" :disabled="!hapticSupportedBool" @click="haptic.selectionChanged()" />
|
|
31
|
-
<!-- Example using TgButton's built-in haptic prop -->
|
|
32
|
-
<TgButton title="Built-in Haptic (medium)" haptic="impact-medium" />
|
|
33
|
-
</div>
|
|
34
25
|
</TgSection>
|
|
35
26
|
|
|
27
|
+
<TgButton title="Impact" :disabled="!hapticSupportedBool" @click="haptic.impactOccurred('medium')" />
|
|
28
|
+
<TgButton title="Notification" :disabled="!hapticSupportedBool" @click="haptic.notificationOccurred('success')" />
|
|
29
|
+
<TgButton title="Selection" :disabled="!hapticSupportedBool" @click="haptic.selectionChanged()" />
|
|
30
|
+
<!-- Example using TgButton's built-in haptic prop -->
|
|
31
|
+
<TgButton title="Built-in Haptic (medium)" haptic="impact-medium" />
|
|
32
|
+
|
|
36
33
|
<TgSection title="Init Data" inset>
|
|
37
34
|
<TgCell title="User" :description="initUser" icon="i-heroicons-user-20-solid" />
|
|
38
35
|
<TgCell title="Query ID" :description="initQueryId" />
|
|
@@ -42,10 +39,6 @@
|
|
|
42
39
|
<TgSection title="Mini App" inset>
|
|
43
40
|
<TgCell title="Supported" :description="miniSupported" icon="i-heroicons-check-badge-20-solid" />
|
|
44
41
|
<TgCell title="Dark" :description="miniDark" />
|
|
45
|
-
<div class="p-4 grid grid-cols-1 sm:grid-cols-2 gap-2">
|
|
46
|
-
<TgButton title="Header = bg" :disabled="!miniSupportedBool" haptic @click="mini.setHeaderColor('bg_color')" />
|
|
47
|
-
<TgButton title="BG = bg" :disabled="!miniSupportedBool" haptic @click="mini.setBackgroundColor('bg_color')" />
|
|
48
|
-
</div>
|
|
49
42
|
</TgSection>
|
|
50
43
|
|
|
51
44
|
<ClientOnly>
|
|
@@ -69,16 +62,18 @@
|
|
|
69
62
|
<TgCell title="Height" :description="viewportHeight" />
|
|
70
63
|
<TgCell title="Stable Height" :description="viewportStableHeight" />
|
|
71
64
|
<TgCell title="Expanded" :description="String(viewport.expanded.value ?? false)" :border="false" />
|
|
72
|
-
<div class="p-4 grid grid-cols-1 sm:grid-cols-3 gap-2">
|
|
73
|
-
<TgButton title="Expand" haptic @click="viewport.expand" />
|
|
74
|
-
<TgButton title="Fullscreen" haptic="impact-light" @click="onRequestFullscreen" />
|
|
75
|
-
<TgButton title="Exit FS" haptic="impact-light" @click="onExitFullscreen" />
|
|
76
|
-
</div>
|
|
77
65
|
</TgSection>
|
|
66
|
+
|
|
67
|
+
<div class="grid grid-cols-1 sm:grid-cols-3 gap-2">
|
|
68
|
+
<TgButton title="Expand" haptic @click="viewport.expand" />
|
|
69
|
+
<TgButton title="Fullscreen" haptic="impact-light" @click="onRequestFullscreen" />
|
|
70
|
+
<TgButton title="Exit FS" haptic="impact-light" @click="onExitFullscreen" />
|
|
71
|
+
</div>
|
|
72
|
+
|
|
78
73
|
</ClientOnly>
|
|
79
74
|
|
|
80
75
|
<TgSection title="Links" inset>
|
|
81
|
-
<div class="p-4 grid grid-cols-1 sm:grid-cols-3
|
|
76
|
+
<div class="p-4 grid grid-cols-1 sm:grid-cols-3">
|
|
82
77
|
<TgButton title="Open Link" haptic @click="openLink('https://t.me/n')" />
|
|
83
78
|
<TgButton title="Open Telegram" haptic @click="openTelegramLink('https://t.me/nuxt_tg_demo_bot')" />
|
|
84
79
|
<TgButton title="Share URL" haptic="notification-success" :share-url="shareUrl" />
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-telegram-mini-app",
|
|
3
3
|
"description": "Structure and configurations for building a Telegram Mini App using Nuxt and TailWind, hosted on Netlify.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "nuxt build",
|