-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Welcome component #836
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a2469bd
Add Welcome component
r-czajkowski 82e8809
Display welcome modal in correct order
r-czajkowski 1cb59fa
Remove unnecessary color definition
r-czajkowski 1197034
Use style props shorthands and style tokens
r-czajkowski b5fc3b7
Use `Highlight` component
r-czajkowski 7da4627
Organize video assets by purpose
r-czajkowski a81659e
Update modal theme
r-czajkowski ba5363e
Update dir structure
r-czajkowski fa3a21a
Merge branch 'main' into welcome-component
r-czajkowski 5906791
Update size `xl` for modal component
r-czajkowski 9c0e740
Update Welcome component
r-czajkowski 10562fc
Update wlecome steps videos
r-czajkowski 4912e15
Update `WelcomeModal` component
r-czajkowski 3b192c4
Remove unused component and hook
r-czajkowski de3545a
Update Modal theme
r-czajkowski 7fa4943
Move router utils to already existing utils file§
r-czajkowski b98b7bf
Update access page loader
r-czajkowski 2594b25
Create `DappMode` type
r-czajkowski 8471acd
Merge branch 'main' into welcome-component
r-czajkowski 6b30218
Merge branch 'main' into welcome-component
r-czajkowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 was deleted.
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,83 +1,193 @@ | ||
import React from "react" | ||
import React, { ReactElement } from "react" | ||
import { | ||
Button, | ||
ModalBody, | ||
ModalHeader, | ||
VStack, | ||
Image, | ||
Box, | ||
Flex, | ||
ModalCloseButton, | ||
Stepper, | ||
Step, | ||
StepIndicator, | ||
ModalFooter, | ||
useSteps, | ||
SimpleGrid, | ||
StepIndicatorProps, | ||
UseStepsReturn, | ||
Highlight, | ||
} from "@chakra-ui/react" | ||
import { H5, TextLg, TextMd, TextSm } from "#/components/shared/Typography" | ||
import { useModal } from "#/hooks" | ||
import confettiWebp from "#/assets/webps/confetti.webp" | ||
import { BENEFITS } from "#/constants" | ||
import { H3, TextSm } from "#/components/shared/Typography" | ||
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" | ||
|
||
function WelcomeModalBase() { | ||
const { closeModal } = useModal() | ||
const handleCloseModal = () => { | ||
closeModal() | ||
} | ||
const dappModeToContent: Record<DappMode, () => ReactElement> = { | ||
standalone: () => ( | ||
<> | ||
Acre makes earning rewards with your BTC simple and secure. Dedicated to | ||
everyone, it'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 | ||
Ledger Live everyone, it's fun and easy to use. No advanced knowledge | ||
required. | ||
</Highlight> | ||
), | ||
} | ||
|
||
const steps = [ | ||
{ | ||
id: 0, | ||
title: ( | ||
<H3 fontWeight="semibold"> | ||
Activate your BTC,{" "} | ||
<Box as="span" display="block" color="orange.30"> | ||
earn rewards | ||
</Box> | ||
</H3> | ||
), | ||
content: (embeddedApp?: EmbedApp) => | ||
dappModeToContent[embeddedApp ?? "standalone"](), | ||
|
||
video: step1Video, | ||
}, | ||
{ | ||
id: 1, | ||
title: ( | ||
<H3 fontWeight="semibold"> | ||
<Box as="span" display="block" color="orange.30"> | ||
Battle-tested{" "} | ||
</Box> | ||
in the market | ||
</H3> | ||
), | ||
content: () => ( | ||
<Highlight query="tBTC"> | ||
Acre is powered by tBTC, the trusted Bitcoin bridge that secured over | ||
half a billion dollars in BTC. No centralized custodians, everything is | ||
fully on-chain. | ||
</Highlight> | ||
), | ||
video: step2Video, | ||
}, | ||
{ | ||
id: 2, | ||
title: ( | ||
<H3 fontWeight="semibold"> | ||
One dashboard{" "} | ||
<Box as="span" display="block" color="orange.30"> | ||
endless rewards | ||
</Box> | ||
</H3> | ||
), | ||
content: () => ( | ||
<Highlight query="Acre Points Program"> | ||
As a depositor, you're automatically in the Acre Points Program. | ||
Enjoy daily points drops and exclusive partner rewards. Start stacking | ||
those points! | ||
</Highlight> | ||
), | ||
video: step3Video, | ||
}, | ||
] | ||
|
||
const stepIndicatorStyleProps: StepIndicatorProps = { | ||
sx: { | ||
"[data-status=active] &": { | ||
opacity: 1, | ||
w: "4", | ||
rounded: "6", | ||
_after: { | ||
content: '""', | ||
position: "absolute", | ||
opacity: "0.15", | ||
w: "4", | ||
h: "2.5", | ||
rounded: "5", | ||
left: "1.5", | ||
bgColor: "orange.50", | ||
}, | ||
}, | ||
"&[data-status=complete], [data-status=incomplete] &": { | ||
bgColor: "orange.50", | ||
}, | ||
}, | ||
border: "none", | ||
w: "2.5", | ||
h: "2.5", | ||
rounded: "50%", | ||
bgColor: "orange.50", | ||
position: "relative", | ||
opacity: "0.15", | ||
} | ||
|
||
function WelcomeModalBase({ closeModal }: BaseModalProps) { | ||
// Cast to fix eslint error: `unbound-method`. | ||
const { activeStep, goToNext } = useSteps({ | ||
index: 0, | ||
count: steps.length, | ||
}) as UseStepsReturn & { goToNext: () => void } | ||
const { embeddedApp } = useIsEmbed() | ||
|
||
const isLastStep = activeStep + 1 === steps.length | ||
const activeStepData = steps[activeStep] | ||
|
||
return ( | ||
<> | ||
<ModalHeader | ||
display="flex" | ||
flexDirection="column" | ||
alignItems="center" | ||
gap={3} | ||
pb={8} | ||
> | ||
<H5 color="brand.400" fontWeight="semibold"> | ||
Welcome to your dashboard! | ||
</H5> | ||
<TextMd color="grey.600">It is time to stack up the rewards!</TextMd> | ||
</ModalHeader> | ||
<ModalBody gap={10}> | ||
<Button size="lg" fontWeight="bold" onClick={handleCloseModal}> | ||
Claim rewards | ||
</Button> | ||
<Flex | ||
gap={4} | ||
justifyContent="center" | ||
alignItems="flex-start" | ||
overflow="visible" | ||
> | ||
{BENEFITS.map(({ name, description, imageSrc }) => ( | ||
// 13.25rem -> 212px | ||
<VStack key={name} w="13.25rem"> | ||
<Box | ||
w="100%" | ||
h="7.5rem" // 120px | ||
border="1px solid white" | ||
borderRadius="xl" | ||
bgImage={confettiWebp} | ||
bgSize="cover" | ||
bgBlendMode="multiply" | ||
bgColor="gold.200" | ||
display="flex" | ||
alignItems="flex-end" | ||
> | ||
<Image | ||
src={imageSrc} | ||
maxW="7.5rem" // 120px | ||
mx="auto" | ||
/> | ||
</Box> | ||
<TextLg fontWeight="bold" color="grey.700"> | ||
{name} | ||
</TextLg> | ||
<TextSm px={1} color="grey.600"> | ||
{description} | ||
</TextSm> | ||
</VStack> | ||
))} | ||
</Flex> | ||
</ModalBody> | ||
<ModalCloseButton /> | ||
<SimpleGrid columns={2} templateColumns="1fr auto"> | ||
<Box> | ||
<ModalHeader gap={3} pb={8}> | ||
<TextSm mb="12" color="neutral.70"> | ||
Welcome to Acre, | ||
</TextSm> | ||
{activeStepData.title} | ||
</ModalHeader> | ||
<ModalBody textAlign="left" display="block" color="brown.80" px="10"> | ||
{activeStepData.content(embeddedApp)} | ||
</ModalBody> | ||
<ModalFooter | ||
display="flex" | ||
flexDirection="row" | ||
justifyContent="space-between" | ||
mt="14" | ||
> | ||
<Stepper index={activeStep} gap="3"> | ||
{steps.map((step) => ( | ||
<Step key={step.id}> | ||
<StepIndicator {...stepIndicatorStyleProps} /> | ||
</Step> | ||
))} | ||
</Stepper> | ||
<Button | ||
variant={isLastStep ? undefined : "outline"} | ||
onClick={isLastStep ? closeModal : goToNext} | ||
> | ||
{isLastStep ? "Get started" : "Skip"} | ||
</Button> | ||
</ModalFooter> | ||
</Box> | ||
<Box | ||
as="video" | ||
src={activeStepData.video} | ||
width="xs" | ||
height="full" | ||
autoPlay | ||
muted | ||
objectFit="cover" | ||
roundedRight="xl" | ||
/> | ||
</SimpleGrid> | ||
</> | ||
) | ||
} | ||
|
||
const WelcomeModal = withBaseModal(WelcomeModalBase, { size: "xl" }) | ||
const WelcomeModal = withBaseModal(WelcomeModalBase, { | ||
size: "xl", | ||
}) | ||
export default WelcomeModal |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably update the Chakra package, see here. But let's leave it as it is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. But it's not a good time to update main packages just before the release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add it to our backlog.