-
Notifications
You must be signed in to change notification settings - Fork 6
feat: suggest downloading the mobile app #813
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
Open
leanmendoza
wants to merge
7
commits into
master
Choose a base branch
from
feat/mobile-app-download
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
77e8175
feat: suggest downloading the mobile app
leanmendoza ea077b6
Merge branch 'master' into feat/mobile-app-download
leanmendoza aec17f4
apply review
leanmendoza fdf5ea8
use ui2
leanmendoza 48c6bc3
fix eslint/prettier
leanmendoza 09ee2a1
clean up
leanmendoza 289338e
show only PlayStore (Android) badge
leanmendoza 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
93 changes: 93 additions & 0 deletions
93
src/components/MobileDownloadModal/MobileDownloadModal.tsx
This file contains hidden or 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,93 @@ | ||
| import React, { useCallback, useMemo, useState } from "react" | ||
|
|
||
| import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" | ||
| import { | ||
| Content, | ||
| ImageContainer, | ||
| StyledDescription, | ||
| StyledTitle, | ||
| } from "decentraland-ui2/dist/components/Modal/DownloadModal/DownloadModal.styled" | ||
| import { ExplorerJumpIn } from "decentraland-ui2/dist/components/Modal/DownloadModal/ExplorerJumpIn" | ||
leanmendoza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import { dclModal } from "decentraland-ui2" | ||
|
|
||
| import { MobileStoreBadges } from "../MobileStoreBadges/MobileStoreBadges" | ||
|
|
||
| const { Modal } = dclModal | ||
|
|
||
| export interface MobileDownloadModalProps { | ||
| open: boolean | ||
| onClose: () => void | ||
| } | ||
|
|
||
| export const MobileDownloadModal: React.FC<MobileDownloadModalProps> = ({ | ||
| open, | ||
| onClose, | ||
| }) => { | ||
| const l = useFormatMessage() | ||
|
|
||
| return ( | ||
| <Modal open={open} size="tiny" title=" " onClose={onClose}> | ||
| <Content> | ||
| <ImageContainer> | ||
| <ExplorerJumpIn /> | ||
| </ImageContainer> | ||
| <StyledTitle variant="h2"> | ||
| {l("components.modal.download.title")} | ||
| </StyledTitle> | ||
| <StyledDescription variant="body1"> | ||
| {l("components.modal.mobile_download.description")} | ||
| </StyledDescription> | ||
| <MobileStoreBadges size="large" /> | ||
| </Content> | ||
| </Modal> | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Wraps children (e.g., <JumpIn>) and intercepts clicks on mobile | ||
| * to show a custom modal with store badges instead of the built-in DownloadModal. | ||
| */ | ||
| export function useIsMobileDevice() { | ||
| return useMemo( | ||
| () => | ||
| typeof navigator !== "undefined" && | ||
| /iPhone|iPad|iPod|Android/i.test(navigator.userAgent), | ||
| [] | ||
| ) | ||
| } | ||
leanmendoza marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export function MobileJumpInWrapper({ | ||
| isMobile: isMobileProp, | ||
| children, | ||
| }: { | ||
| isMobile?: boolean | ||
| children: React.ReactNode | ||
| }) { | ||
| const isMobileDevice = useIsMobileDevice() | ||
| const isMobile = isMobileProp ?? isMobileDevice | ||
| const [showModal, setShowModal] = useState(false) | ||
|
|
||
| const handleCapture = useCallback( | ||
| (e: React.MouseEvent) => { | ||
| if (isMobile) { | ||
| e.stopPropagation() | ||
| e.preventDefault() | ||
| setShowModal(true) | ||
| } | ||
| }, | ||
| [isMobile] | ||
| ) | ||
|
|
||
| return ( | ||
| <> | ||
| <div onClickCapture={handleCapture} style={{ display: "contents" }}> | ||
| {children} | ||
| </div> | ||
| <MobileDownloadModal | ||
| open={showModal} | ||
| onClose={() => setShowModal(false)} | ||
| /> | ||
| </> | ||
| ) | ||
| } | ||
This file contains hidden or 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,69 @@ | ||
| import React from "react" | ||
|
|
||
| import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" | ||
|
|
||
| import appStoreBadge from "../../images/app-store-badge.svg" | ||
| import googlePlayBadge from "../../images/google-play-badge.svg" | ||
| import { MOBILE_APP } from "../../modules/mobileApp" | ||
|
|
||
| interface MobileStoreBadgesProps { | ||
| size?: "small" | "large" | ||
| className?: string | ||
| style?: React.CSSProperties | ||
| } | ||
|
|
||
| const containerStyle: React.CSSProperties = { | ||
| display: "flex", | ||
| flexDirection: "row", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| gap: "12px", | ||
| width: "100%", | ||
| } | ||
|
|
||
| const linkStyle: React.CSSProperties = { | ||
| display: "inline-flex", | ||
| alignItems: "center", | ||
| textDecoration: "none", | ||
| transition: "opacity 0.2s ease", | ||
| } | ||
leanmendoza marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const MobileStoreBadges = React.memo( | ||
| ({ size = "small", className, style }: MobileStoreBadgesProps) => { | ||
| const l = useFormatMessage() | ||
| const imgHeight = size === "small" ? "40px" : "48px" | ||
|
|
||
| return ( | ||
| <div className={className} style={{ ...containerStyle, ...style }}> | ||
leanmendoza marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <a | ||
| href={MOBILE_APP.IOS_STORE_URL} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| aria-label={l("components.mobile_store_badges.download_ios")} | ||
| style={linkStyle} | ||
| > | ||
| <img | ||
| src={appStoreBadge} | ||
| alt={l("components.mobile_store_badges.download_ios")} | ||
| style={{ height: imgHeight }} | ||
| /> | ||
| </a> | ||
| <a | ||
| href={MOBILE_APP.ANDROID_STORE_URL} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| aria-label={l("components.mobile_store_badges.download_android")} | ||
| style={linkStyle} | ||
| > | ||
| <img | ||
| src={googlePlayBadge} | ||
| alt={l("components.mobile_store_badges.download_android")} | ||
| style={{ height: imgHeight }} | ||
| /> | ||
| </a> | ||
| </div> | ||
| ) | ||
| } | ||
| ) | ||
|
|
||
| export { MobileStoreBadges } | ||
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.