feat: migrate to @tma.js/sdk-react for Telegram Mini App

- Add useTelegramSDK hook with reactive signals for viewport, safe area, fullscreen
- Migrate TelegramAdapter to use SDK components (backButton, mainButton, hapticFeedback, cloudStorage, themeParams, popup)
- Update Login, TelegramRedirect to use SDK helpers
- Update PlatformProvider, api/client to use centralized SDK functions
- Simplify useTelegramWebApp as backward-compatible wrapper
- Add automatic CSS variable binding for theme and viewport
This commit is contained in:
c0mrade
2026-02-01 20:13:50 +03:00
parent 55ae55f4af
commit edb5be09ae
14 changed files with 736 additions and 513 deletions

View File

@@ -45,14 +45,17 @@ import {
const FALLBACK_NAME = import.meta.env.VITE_APP_NAME || 'Cabinet';
const FALLBACK_LOGO = import.meta.env.VITE_APP_LOGO || 'V';
import type { TelegramPlatform } from '@/hooks/useTelegramSDK';
interface AppHeaderProps {
mobileMenuOpen: boolean;
setMobileMenuOpen: (open: boolean) => void;
onCommandPaletteOpen: () => void;
headerHeight: number;
isFullscreen: boolean;
safeAreaInset: { top: number; bottom: number };
contentSafeAreaInset: { top: number; bottom: number };
safeAreaInset: { top: number; bottom: number; left: number; right: number };
contentSafeAreaInset: { top: number; bottom: number; left: number; right: number };
telegramPlatform?: TelegramPlatform;
wheelEnabled?: boolean;
referralEnabled?: boolean;
hasContests?: boolean;
@@ -67,6 +70,7 @@ export function AppHeader({
isFullscreen,
safeAreaInset,
contentSafeAreaInset,
telegramPlatform,
wheelEnabled,
referralEnabled,
hasContests,
@@ -178,7 +182,7 @@ export function AppHeader({
className="glass fixed left-0 right-0 top-0 z-50 shadow-lg shadow-black/10 lg:hidden"
style={{
paddingTop: isFullscreen
? `${Math.max(safeAreaInset.top, contentSafeAreaInset.top) + 45}px`
? `${Math.max(safeAreaInset.top, contentSafeAreaInset.top) + (telegramPlatform === 'android' ? 0 : 45)}px`
: undefined,
}}
>