-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,25 @@ | ||
import { useLaunchParams } from '@tma.js/sdk-react'; | ||
import { List } from '@telegram-apps/telegram-ui'; | ||
import type { FC } from 'react'; | ||
|
||
import { DisplayData } from '@/components/DisplayData/DisplayData.tsx'; | ||
import { Link } from '@/components/Link/Link.tsx'; | ||
import { Page } from '@/components/Page/Page.tsx'; | ||
|
||
export const LaunchParamsPage: FC = () => { | ||
const lp = useLaunchParams(); | ||
|
||
return ( | ||
<DisplayData | ||
header="Launch Params" | ||
footer={ | ||
<> | ||
This page displays application | ||
{' '} | ||
<Link to="https://docs.telegram-mini-apps.com/platform/launch-parameters"> | ||
launch parameters | ||
</Link> | ||
. | ||
</> | ||
} | ||
rows={[ | ||
{ title: 'tgWebAppPlatform', value: lp.platform }, | ||
{ title: 'tgWebAppShowSettings', value: lp.showSettings }, | ||
{ title: 'tgWebAppVersion', value: lp.version }, | ||
{ title: 'tgWebAppBotInline', value: lp.botInline }, | ||
{ title: 'tgWebAppStartParam', value: lp.showSettings }, | ||
{ title: 'tgWebAppData', type: 'link', value: '/init-data' }, | ||
{ title: 'tgWebAppThemeParams', type: 'link', value: '/theme-params' }, | ||
]} | ||
/> | ||
); | ||
|
||
return ( | ||
<Page | ||
title="Launch Params" | ||
disclaimer={( | ||
<> | ||
This page displays application | ||
{' '} | ||
<Link to="https://docs.telegram-mini-apps.com/platform/launch-parameters"> | ||
launch parameters | ||
</Link> | ||
. | ||
</> | ||
)} | ||
> | ||
<List> | ||
<DisplayData | ||
rows={[ | ||
{ title: 'tgWebAppPlatform', value: lp.platform }, | ||
{ title: 'tgWebAppShowSettings', value: lp.showSettings }, | ||
{ title: 'tgWebAppVersion', value: lp.version }, | ||
{ title: 'tgWebAppBotInline', value: lp.botInline }, | ||
{ title: 'tgWebAppStartParam', value: lp.showSettings }, | ||
{ title: 'tgWebAppData', value: <Link to="/init-data">View</Link> }, | ||
{ title: 'tgWebAppThemeParams', value: <Link to="/theme-params">View</Link> }, | ||
{ title: 'tgWebAppData', type: 'link', value: '/init-data' }, | ||
{ title: 'tgWebAppThemeParams', type: 'link', value: '/theme-params' }, | ||
]} | ||
/> | ||
</Page> | ||
</List> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
import { useThemeParams } from '@tma.js/sdk-react'; | ||
import type { FC } from 'react'; | ||
import { List } from '@telegram-apps/telegram-ui'; | ||
|
||
import { DisplayData } from '@/components/DisplayData/DisplayData.tsx'; | ||
import { Link } from '@/components/Link/Link.tsx'; | ||
|
||
export const ThemeParamsPage: FC = () => { | ||
const themeParams = useThemeParams(); | ||
|
||
return ( | ||
<DisplayData | ||
header={ | ||
<> | ||
This page displays current | ||
{' '} | ||
<Link to="https://docs.telegram-mini-apps.com/platform/theming"> | ||
theme parameters | ||
</Link> | ||
. It is reactive, so, changing theme externally will lead to this page updates. | ||
</> | ||
} | ||
rows={ | ||
Object | ||
.entries(themeParams.getState()) | ||
.map(([title, value]) => ({ | ||
title: title | ||
.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`) | ||
.replace(/background/, 'bg'), | ||
value, | ||
})) | ||
} | ||
/> | ||
<List> | ||
<DisplayData | ||
rows={ | ||
Object | ||
.entries(themeParams.getState()) | ||
.map(([title, value]) => ({ | ||
title: title | ||
.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`) | ||
.replace(/background/, 'bg'), | ||
value, | ||
})) | ||
} | ||
/> | ||
</List> | ||
); | ||
}; |