Skip to content

Commit

Permalink
Allow using template outside of Telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
heyqbnk committed May 28, 2024
1 parent 9adeedb commit 0c758b1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@telegram-apps/telegram-ui": "^2.1.3",
"@tma.js/react-router-integration": "^2.0.0",
"@tma.js/sdk-react": "^2.1.4",
"@tma.js/react-router-integration": "^4.0.0",
"@tma.js/sdk-react": "^2.2.1",
"@tonconnect/ui-react": "^2.0.2",
"eruda": "^3.0.1",
"react": "^18.2.0",
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 44 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,51 @@
import ReactDOM from 'react-dom/client';
import { mockTelegramEnv } from '@tma.js/sdk-react';

import { Root } from '@/components/Root';

import '@telegram-apps/telegram-ui/dist/styles.css';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(<Root />);
// This line of code allows us to safely launch the application even outside
// the Telegram application. It will also only be applied in development mode, not in
// production.
if (import.meta.env.DEV) {
mockTelegramEnv({
themeParams: {
accentTextColor: '#6ab2f2',
bgColor: '#17212b',
buttonColor: '#5288c1',
buttonTextColor: '#ffffff',
destructiveTextColor: '#ec3942',
headerBgColor: '#17212b',
hintColor: '#708499',
linkColor: '#6ab3f3',
secondaryBgColor: '#232e3c',
sectionBgColor: '#17212b',
sectionHeaderTextColor: '#6ab3f3',
subtitleTextColor: '#708499',
textColor: '#f5f5f5',
},
initData: {
authDate: new Date(1716922846000),
chatInstance: '8428209589180549439',
chatType: 'sender',
hash: '89d6079ad6762351f38c6dbbc41bb53048019256a9443988af7a48bcad16ba31',
startParam: 'debug',
user: {
allowsWriteToPm: true,
firstName: 'Andrew',
id: 99281932,
isPremium: true,
languageCode: 'en',
lastName: 'Rogue',
username: 'rogue',
},
},
initDataRaw: 'user=%7B%22id%22%3A99281932%2C%22first_name%22%3A%22Andrew%22%2C%22last_name%22%3A%22Rogue%22%2C%22username%22%3A%22rogue%22%2C%22language_code%22%3A%22en%22%2C%22is_premium%22%3Atrue%2C%22allows_write_to_pm%22%3Atrue%7D&chat_instance=8428209589180549439&chat_type=sender&start_param=debug&auth_date=1716922846&hash=89d6079ad6762351f38c6dbbc41bb53048019256a9443988af7a48bcad16ba31',
version: '7.2',
platform: 'tdesktop',
});
}

ReactDOM.createRoot(document.getElementById('root')!).render(<Root/>);

0 comments on commit 0c758b1

Please sign in to comment.