generated from ton-community/twa-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
202 additions
and
148 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// LeaderboardEntry.ts | ||
export interface LeaderboardEntry { | ||
address: string; | ||
time: number; | ||
playerId: string; | ||
nick: string; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// LeaderboardList.tsx | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { LeaderboardEntry } from './gistService'; | ||
|
||
export const LeaderboardList = styled.ul` | ||
list-style-type: none; | ||
padding: 0; | ||
max-height: 300px; | ||
overflow-y: auto; | ||
background-color: black; | ||
`; | ||
|
||
export const LeaderboardItem = styled.li` | ||
font-size: 13px; | ||
color: white; | ||
margin: 5px 0; | ||
padding: 10px; | ||
background-color: black; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// SaveScoreWindow.tsx | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { StyledButton } from './StyledButton'; | ||
import { TonConnectButton } from "@tonconnect/ui-react"; | ||
|
||
const SaveScoreWindowContainer = styled.div` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
z-index: 10; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const SaveScoreWindowContent = styled.div` | ||
color: white; | ||
background-color: black; | ||
padding: 30px; | ||
border-radius: 10px; | ||
width: 80%; | ||
max-width: 400px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
text-align: center; | ||
`; | ||
|
||
const NickInput = styled.input` | ||
padding: 10px; | ||
margin-top: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
width: 80%; | ||
`; | ||
|
||
interface SaveScoreWindowProps { | ||
onClose: () => void; | ||
onSave: () => void; | ||
nick: string; | ||
setNick: (value: string) => void; | ||
} | ||
|
||
export const SaveScoreWindow: React.FC<SaveScoreWindowProps> = ({ onClose, onSave, nick, setNick }) => { | ||
return ( | ||
<SaveScoreWindowContainer> | ||
<SaveScoreWindowContent> | ||
<p>Connect your wallet to set user Id and save your score:</p> | ||
<TonConnectButton /> | ||
<NickInput | ||
type="text" | ||
placeholder="Enter your nickname" | ||
value={nick} | ||
onChange={(e) => setNick(e.target.value)} | ||
/> | ||
<StyledButton onClick={onSave} style={{ marginTop: '10px' }}>Save Score</StyledButton> | ||
<StyledButton onClick={onClose} style={{ marginTop: '10px' }}>Close</StyledButton> | ||
</SaveScoreWindowContent> | ||
</SaveScoreWindowContainer> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// formatAddress.ts | ||
|
||
export const formatAddress = (address: string): string => { | ||
// Validate address format if necessary, assuming TON addresses are hexadecimal strings | ||
|
||
// Example formatting for TON addresses | ||
const maxLength = 64; // Maximum length of a TON address | ||
const ellipsisThreshold = 9; // Display full address if shorter than or equal to this threshold | ||
|
||
if (address.length <= ellipsisThreshold) { | ||
return address; // Display full address if shorter than or equal to threshold | ||
} else { | ||
return `${address.slice(0, 5)}...${address.slice(-4)}`; // Shorten address with ellipses | ||
} | ||
}; | ||
|
Oops, something went wrong.