diff --git a/src/app/globals.css b/src/app/globals.css index 63ee3eb..982f8dd 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -103,3 +103,23 @@ textarea { button[type="submit"] { background-color: #cefff3; } + +.demo-dapp-container { + padding: 40px 0; +} + +/* Small screens (smartphones) - Portrait and Landscape */ +@media only screen and (max-width: 767px) { + .demo-dapp-container { + padding: 20px; + } + /* Your mobile styles here */ +} + +/* Extra small screens (smaller smartphones) */ +@media only screen and (max-width: 480px) { + /* Your styles for very small devices */ + .demo-dapp-container { + padding: 16px; + } +} diff --git a/src/app/page.tsx b/src/app/page.tsx index 5d64aee..cdc1443 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,20 +1,21 @@ "use client" -import { publicProvider, StarknetConfig } from "@starknet-react/core" -import { mainnet, sepolia } from "@starknet-react/chains" -import { constants } from "starknet" -import { CHAIN_ID } from "@/constants" -import { connectors } from "@/connectors" import { StarknetDapp } from "@/components/StarknetDapp" import { Flex } from "@/components/ui/Flex" +import { connectors } from "@/connectors" +import { CHAIN_ID } from "@/constants" +import { mainnet, sepolia } from "@starknet-react/chains" +import { publicProvider, StarknetConfig } from "@starknet-react/core" +import { constants } from "starknet" export default function Home() { const chains = [ CHAIN_ID === constants.NetworkName.SN_MAIN ? mainnet : sepolia, ] const providers = publicProvider() + return ( - + {/* eslint-disable @typescript-eslint/no-explicit-any */} { - //useWaitForTx() - - return ( - - - - - - - - - ) -} +const StarknetDapp = () => ( + + + + + + + + +) export { StarknetDapp } diff --git a/src/components/ui/Accordion.tsx b/src/components/ui/Accordion.tsx index 7a70a37..b7c8054 100644 --- a/src/components/ui/Accordion.tsx +++ b/src/components/ui/Accordion.tsx @@ -48,7 +48,7 @@ const Accordion: FC = ({
{accordionItems.map((item, index) => ( handleClick(index)} diff --git a/src/components/ui/Flex.tsx b/src/components/ui/Flex.tsx index 231341d..981169e 100644 --- a/src/components/ui/Flex.tsx +++ b/src/components/ui/Flex.tsx @@ -1,11 +1,16 @@ import { CSSProperties, FC, ReactNode } from "react" interface FlexProps extends CSSProperties { + className?: string children: ReactNode } -const Flex: FC = ({ children, ...props }) => { - return
{children}
+const Flex: FC = ({ children, className, ...props }) => { + return ( +
+ {children} +
+ ) } export { Flex } diff --git a/src/connectors/index.ts b/src/connectors/index.ts index 15dbc75..60439d3 100644 --- a/src/connectors/index.ts +++ b/src/connectors/index.ts @@ -3,22 +3,35 @@ import { isInArgentMobileAppBrowser, ArgentMobileConnector, } from "starknetkit/argentMobile" +import { + BraavosMobileConnector, + isInBraavosMobileAppBrowser, +} from "starknetkit/braavosMobile" import { InjectedConnector } from "starknetkit/injected" import { WebWalletConnector } from "starknetkit/webwallet" -export const connectors = isInArgentMobileAppBrowser() - ? [ - ArgentMobileConnector.init({ - options: { - url: typeof window !== "undefined" ? window.location.href : "", - dappName: "Example dapp", - chainId: CHAIN_ID, - }, - }), - ] - : [ - new InjectedConnector({ options: { id: "argentX" } }), - new InjectedConnector({ options: { id: "braavos" } }), +const isMobileDevice = () => { + if (typeof window === "undefined") { + return false + } + + // Primary method: User Agent + Touch support check + const userAgent = navigator.userAgent.toLowerCase() + const isMobileUA = + /android|webos|iphone|ipad|ipod|blackberry|windows phone/.test(userAgent) + const hasTouchSupport = + "ontouchstart" in window || navigator.maxTouchPoints > 0 + + // Backup method: Screen size + const isSmallScreen = window.innerWidth <= 768 + + // Combine checks: Must match user agent AND (touch support OR small screen) + return isMobileUA && (hasTouchSupport || isSmallScreen) +} + +export const availableConnectors = () => { + if (isInArgentMobileAppBrowser()) { + return [ ArgentMobileConnector.init({ options: { url: typeof window !== "undefined" ? window.location.href : "", @@ -26,5 +39,26 @@ export const connectors = isInArgentMobileAppBrowser() chainId: CHAIN_ID, }, }), - new WebWalletConnector({ url: ARGENT_WEBWALLET_URL }), ] + } + + if (isInBraavosMobileAppBrowser()) { + return [BraavosMobileConnector.init({})] + } + + return [ + new InjectedConnector({ options: { id: "argentX" } }), + new InjectedConnector({ options: { id: "braavos" } }), + ArgentMobileConnector.init({ + options: { + url: typeof window !== "undefined" ? window.location.href : "", + dappName: "Example dapp", + chainId: CHAIN_ID, + }, + }), + isMobileDevice() ? BraavosMobileConnector.init({}) : null, + new WebWalletConnector({ url: ARGENT_WEBWALLET_URL }), + ].filter((connector) => connector !== null) +} + +export const connectors = availableConnectors()