-
Notifications
You must be signed in to change notification settings - Fork 68
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
14 changed files
with
765 additions
and
243 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,40 +1,60 @@ | ||
import { isRGB, type RGB as RGBType } from '@tma.js/sdk-react'; | ||
import { isRGB } from '@tma.js/sdk-react'; | ||
import { | ||
Checkbox, | ||
Section, | ||
Subheadline, | ||
Text, | ||
} from '@telegram-apps/telegram-ui'; | ||
import type { FC, ReactNode } from 'react'; | ||
|
||
import { RGB } from '@/components/RGB/RGB.tsx'; | ||
import { Link } from '@/components/Link/Link.tsx'; | ||
|
||
import './DisplayData.css'; | ||
|
||
export interface DisplayDataRow { | ||
title: string; | ||
value?: RGBType | string | boolean | ReactNode; | ||
} | ||
export type DisplayDataRow = | ||
& { title: string } | ||
& ( | ||
| { type: 'link'; value?: string } | ||
| { value: ReactNode } | ||
) | ||
|
||
export interface DisplayDataProps { | ||
header?: ReactNode; | ||
footer?: ReactNode; | ||
rows: DisplayDataRow[]; | ||
} | ||
|
||
export const DisplayData: FC<DisplayDataProps> = ({ rows }) => ( | ||
<div> | ||
{rows.map(({ title, value }, idx) => { | ||
export const DisplayData: FC<DisplayDataProps> = ({ header, rows }) => ( | ||
<Section> | ||
{header && <Section.Header className="display-data__header"> | ||
{header} | ||
</Section.Header>} | ||
{rows.map((item, idx) => { | ||
let valueNode: ReactNode; | ||
|
||
if (value === undefined) { | ||
if (item.value === undefined) { | ||
valueNode = <i>empty</i>; | ||
} else if (typeof value === 'string' && isRGB(value)) { | ||
valueNode = <RGB color={value} />; | ||
} else if (typeof value === 'boolean') { | ||
valueNode = value ? '✔️' : '❌'; | ||
} else { | ||
valueNode = value; | ||
if ('type' in item) { | ||
valueNode = <Link to={item.value}>Open</Link>; | ||
} else if (typeof item.value === 'string') { | ||
valueNode = isRGB(item.value) | ||
? <RGB color={item.value}/> | ||
: item.value; | ||
} else if (typeof item.value === 'boolean') { | ||
valueNode = <Checkbox checked={item.value} disabled/>; | ||
} else { | ||
valueNode = item.value; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="display-data__line" key={idx}> | ||
<span className="display-data__line-title">{title}</span> | ||
<span className="display-data__line-value">{valueNode}</span> | ||
<Subheadline className="display-data__line-title" level={'2'}>{item.title}</Subheadline> | ||
<Text className="display-data__line-value">{valueNode}</Text> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</Section> | ||
); |
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,25 +1,5 @@ | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
line-height: 1.5; | ||
|
||
background: var(--tg-theme-secondary-bg-color, white); | ||
color: var(--tg-theme-text-color, black); | ||
} | ||
|
||
blockquote { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
blockquote p { | ||
padding: 15px; | ||
background: #eee; | ||
border-radius: 5px; | ||
} | ||
|
||
pre { | ||
overflow: auto; | ||
} |
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,30 +1,42 @@ | ||
import { Section, Cell, Image } from '@telegram-apps/telegram-ui'; | ||
import type { FC } from 'react'; | ||
|
||
import { Link } from '@/components/Link/Link.tsx'; | ||
import { Page } from '@/components/Page/Page.tsx'; | ||
import { routes } from '@/navigation/routes.tsx'; | ||
|
||
import tonSvg from './ton.svg'; | ||
|
||
import './IndexPage.css'; | ||
|
||
export const IndexPage: FC = () => ( | ||
<Page title="Home Page"> | ||
<p> | ||
This page is a home page in this boilerplate. You can use the links below to visit other | ||
pages with their own functionality. | ||
</p> | ||
<ul className="index-page__links"> | ||
{routes.map(({ path, title, icon }) => title && ( | ||
<li className="index-page__link-item" key={path}> | ||
<Link className="index-page__link" to={path}> | ||
{icon && ( | ||
<i className="index-page__link-icon"> | ||
{icon} | ||
</i> | ||
)} | ||
{title} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</Page> | ||
); | ||
export const IndexPage: FC = () => { | ||
return ( | ||
<> | ||
<Section | ||
header="Features" | ||
footer="You can use these pages to learn more about features, provided by Telegram Mini Apps and other useful projects" | ||
> | ||
<Link to="/ton-connect"> | ||
<Cell | ||
before={<Image src={tonSvg} style={{ backgroundColor: '#007AFF' }}/>} | ||
subtitle="Connect your TON wallet" | ||
> | ||
TON Connect | ||
</Cell> | ||
</Link> | ||
</Section> | ||
<Section | ||
header="Application Launch Data" | ||
footer="These pages help developer to learn more about current launch information" | ||
> | ||
<Link to="/init-data"> | ||
<Cell subtitle="User data, chat information, technical data">Init Data</Cell> | ||
</Link> | ||
<Link to="/launch-params"> | ||
<Cell subtitle="Platform identifier, Mini Apps version, etc.">Launch Parameters</Cell> | ||
</Link> | ||
<Link to="/theme-params"> | ||
<Cell subtitle="Telegram application palette information">Theme Parameters</Cell> | ||
</Link> | ||
</Section> | ||
</> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.