Skip to content

Commit

Permalink
Create DappMode type
Browse files Browse the repository at this point in the history
In some cases we render different content layouts etc depnding on
whether it is an embedded or standalone application. Here we introduce
the `DappMode` type to simplify code and organize the dapp modes.
  • Loading branch information
r-czajkowski committed Nov 13, 2024
1 parent b98b7bf commit 2594b25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion dapp/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react"
import { Outlet } from "react-router-dom"
import { Flex, VStack } from "@chakra-ui/react"
import { useIsEmbed, useMobileMode } from "#/hooks"
import { DappMode } from "#/types"
import DocsDrawer from "./DocsDrawer"
import Header from "./Header"
import ModalRoot from "./ModalRoot"
Expand All @@ -10,7 +11,7 @@ import MobileModeBanner from "./MobileModeBanner"
import Footer from "./Footer"

const PADDING = "2.5rem" // 40px
const PAGE_MAX_WIDTH = {
const PAGE_MAX_WIDTH: Record<DappMode, string> = {
standalone: "63rem", // 1008px
"ledger-live": "63rem", // 1008px
}
Expand Down
21 changes: 10 additions & 11 deletions dapp/src/components/WelcomeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ import {
Highlight,
} from "@chakra-ui/react"
import { H3, TextSm } from "#/components/shared/Typography"
import { BaseModalProps } from "#/types"
import { BaseModalProps, DappMode } from "#/types"
import { EmbedApp } from "#/utils/referralProgram"
import { useIsEmbed } from "#/hooks"
import withBaseModal from "./ModalRoot/withBaseModal"
import step1Video from "../assets/videos/welcome-steps/welcome-step-1.mp4"
import step2Video from "../assets/videos/welcome-steps/welcome-step-2.mp4"
import step3Video from "../assets/videos/welcome-steps/welcome-step-3.mp4"

const embeddedAppToContent: Record<EmbedApp, () => ReactElement> = {
const dappModeToContent: Record<DappMode, () => ReactElement> = {
standalone: () => (
<>
Acre makes earning rewards with your BTC simple and secure. Dedicated to
everyone, it&apos;s fun and easy to use. No advanced knowledge required.
</>
),
"ledger-live": () => (
<Highlight query="Ledger Live">
Acre makes earning rewards with your BTC simple and secure. Tailored for
Expand All @@ -46,15 +52,8 @@ const steps = [
</H3>
),
content: (embeddedApp?: EmbedApp) =>
embeddedApp ? (
embeddedAppToContent[embeddedApp]()
) : (
<>
Acre makes earning rewards with your BTC simple and secure. Dedicated
to everyone, it&apos;s fun and easy to use. No advanced knowledge
required.
</>
),
dappModeToContent[embeddedApp ?? "standalone"](),

video: step1Video,
},
{
Expand Down
3 changes: 3 additions & 0 deletions dapp/src/types/dapp-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { EmbedApp } from "#/utils/referralProgram"

export type DappMode = EmbedApp | "standalone"
1 change: 1 addition & 0 deletions dapp/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from "./error"
export * from "./status"
export * from "./orangekit"
export * from "./ledgerLive"
export * from "./dapp-mode"

0 comments on commit 2594b25

Please sign in to comment.