Skip to content

Commit

Permalink
Merge pull request #181 from ton-blockchain/ton-connect-btn-fix
Browse files Browse the repository at this point in the history
connect button
  • Loading branch information
EmelyanenkoK authored Jun 22, 2023
2 parents c6e97b2 + 3c8d811 commit df26ff7
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/components/AddSourcesBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AppButton } from "./AppButton";
import { SECTIONS, STEPS, usePublishStore } from "../lib/usePublishSteps";
import { CircularProgress, Fade } from "@mui/material";
import { useTonAddress } from "@tonconnect/ui-react";
import { StyledTonConnectButton } from "./TopBar";
import ConnectButton from "./ConnectButton";

const ContentBox = styled(Box)({
padding: "15px 24px",
Expand Down Expand Up @@ -48,7 +48,7 @@ export function AddSourcesBlock() {
{hasFiles() && (
<CenteringBox sx={{ justifyContent: "center" }} mt={3} mb="9px">
{!walletAddress ? (
<StyledTonConnectButton />
<ConnectButton />
) : !data?.result?.msgCell ? (
<AppButton
disabled={!hasFiles()}
Expand Down
22 changes: 22 additions & 0 deletions src/components/ConnectButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useTonConnectUI } from "@tonconnect/ui-react";
import React from "react";
import { AppButton } from "./AppButton";

function ConnectButton() {
const [tonConnect] = useTonConnectUI();
return (
<AppButton
background="#1976d2"
hoverBackground="#156cc2"
height={37}
fontSize={14}
fontWeight={700}
textColor="#fff"
type="button"
onClick={() => tonConnect.connectWallet()}>
Connect wallet
</AppButton>
);
}

export default ConnectButton;
15 changes: 2 additions & 13 deletions src/components/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import github from "../assets/github-dark.svg";
import { AppLogo, GitLogo, LinkWrapper } from "./TopBar.styled";
import icon from "../assets/icon.svg";
import { useNavigatePreserveQuery } from "../lib/useNavigatePreserveQuery";
import { TonConnectButton, useTonAddress } from "@tonconnect/ui-react";
import { useTonAddress } from "@tonconnect/ui-react";
import { StyledTonConnectButton } from "../styles";

interface MobileMenuProps {
closeMenu?: () => void;
Expand Down Expand Up @@ -51,15 +52,3 @@ export function MobileMenu({ closeMenu, showMenu }: MobileMenuProps) {
</Drawer>
);
}

const StyledTonConnectButton = styled(TonConnectButton)(({ theme }) => ({
button: {
background: theme.palette.primary.main,
"*": { color: "white" },
svg: {
"*": {
stroke: "white",
},
},
},
}));
15 changes: 2 additions & 13 deletions src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { IconButton, styled, useMediaQuery, useTheme } from "@mui/material";
import MenuRoundedIcon from "@mui/icons-material/MenuRounded";
import { MobileMenu } from "./MobileMenu";
import { useNavigatePreserveQuery } from "../lib/useNavigatePreserveQuery";
import { TonConnectButton } from "@tonconnect/ui-react";
import { StyledTonConnectButton } from "../styles";

export function TopBar() {
const { pathname } = useLocation();

const theme = useTheme();
const navigate = useNavigatePreserveQuery();
const headerSpacings = useMediaQuery(theme.breakpoints.down("lg"));
Expand Down Expand Up @@ -73,15 +74,3 @@ export function TopBar() {
</TopBarWrapper>
);
}

export const StyledTonConnectButton = styled(TonConnectButton)(({ theme }) => ({
button: {
background: theme.palette.primary.main,
"*": { color: "white" },
svg: {
"*": {
stroke: "white",
},
},
},
}));
4 changes: 2 additions & 2 deletions src/components/admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SourcesRegistry from "./SourcesRegistry";
import { VerifierRegistry } from "./VerifierRegistry";
import { FlexBoxRow } from "../Getters.styled";
import { Footer } from "../Footer";
import { StyledTonConnectButton } from "../TopBar";
import ConnectButton from "../ConnectButton";

export function Admin() {
return (
Expand All @@ -16,7 +16,7 @@ export function Admin() {
px: 4,
}}>
<h1>Admin</h1>
<StyledTonConnectButton />
<ConnectButton />
</FlexBoxRow>
<SourcesRegistry />
<VerifierRegistry />
Expand Down
4 changes: 2 additions & 2 deletions src/components/admin/ContractInteract.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, TextField } from "@mui/material";
import { useState } from "react";
import { Address, beginCell, Builder } from "ton";
import ConnectButton from "../ConnectButton";
import Spacer from "../Spacer";
import { StyledTonConnectButton } from "../TopBar";

function CellBuilder() {
const [state, setState] = useState<{
Expand Down Expand Up @@ -86,7 +86,7 @@ function ContractInteract() {
maxWidth: 1100,
padding: 40,
}}>
<StyledTonConnectButton />
<ConnectButton />
<Spacer space={35} />
<TextField required id="outlined-required" label="Contract address" fullWidth />
<TextField required id="outlined-required" label="Value" fullWidth type={"number"} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/tactDeployer/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CenteringBox } from "../Common.styled";
import { githubLink } from "../../const";
import { TopBarContent, LinkWrapper, AppLogo, ContentColumn, GitLogo } from "../TopBar.styled";
import { styled } from "@mui/material/styles";
import { StyledTonConnectButton } from "../TopBar";
import { StyledTonConnectButton } from "../../styles";

interface TopBarWrapperProps {
isMobile: boolean;
Expand Down
14 changes: 14 additions & 0 deletions src/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { styled } from "@mui/material";
import { TonConnectButton } from "@tonconnect/ui-react";

export const StyledTonConnectButton = styled(TonConnectButton)(({ theme }) => ({
button: {
background: theme.palette.primary.main,
"*": { color: "white" },
svg: {
"*": {
stroke: "white",
},
},
},
}));

0 comments on commit df26ff7

Please sign in to comment.