-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from WalletConnect/feat/change-browser-modal
feat: add change browser modal
- Loading branch information
Showing
5 changed files
with
118 additions
and
18 deletions.
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
54 changes: 54 additions & 0 deletions
54
src/components/utils/ChangeBrowserModal/ChangeBrowserModal.scss
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.ChangeBrowserModal { | ||
padding: 3em; | ||
display: flex; | ||
flex-direction: column; | ||
text-align: center; | ||
align-items: center; | ||
gap: 2em; | ||
position: relative; | ||
|
||
&__close-button { | ||
svg { | ||
color: var(--fg-color-3); | ||
} | ||
} | ||
|
||
&__header { | ||
display: flex; | ||
justify-content: flex-end; | ||
width: 100%; | ||
align-items: center; | ||
} | ||
|
||
&__background { | ||
position: absolute; | ||
z-index: -999; | ||
top: -50%; | ||
left: -50%; | ||
} | ||
|
||
&__icon { | ||
display: block; | ||
width: 3em; | ||
background: white; | ||
width: 4em; | ||
height: 4em; | ||
display: grid; | ||
place-items: center; | ||
padding: 0.75em; | ||
border-radius: 13px; | ||
box-shadow: 0px 8px 32px 17.5px hsla(0, 0%, 0%, 0.12); | ||
} | ||
|
||
&__warning { | ||
color: var(--error-color-1); | ||
} | ||
|
||
&__content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1em; | ||
align-items: center; | ||
text-align: center; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
|
||
import BackgroundImage from '@/assets/IntroBackground.png' | ||
import { Modal } from '@/components/general/Modal/Modal' | ||
import Text from '@/components/general/Text' | ||
import { pwaModalService } from '@/utils/store' | ||
|
||
import './ChangeBrowserModal.scss' | ||
|
||
export const ChangeBrowserModal: React.FC = () => { | ||
return ( | ||
<Modal onCloseModal={pwaModalService.closeModal}> | ||
<div className="ChangeBrowserModal"> | ||
<div className="ChangeBrowserModal__background"> | ||
<img src={BackgroundImage} /> | ||
</div> | ||
<div className="ChangeBrowserModal__icon"> | ||
<img alt="Web3Inbox icon" className="wc-icon" src="/icon.png" /> | ||
</div> | ||
<Text variant={'large-500'}>Change Browser</Text> | ||
<div className="ChangeBrowserModal__content"> | ||
<Text variant="small-500"> | ||
To install the app, you need to add this to your home screen. | ||
</Text> | ||
<Text variant="small-500"> | ||
Please open <span>app.web3inbox.com</span> in Safari and follow the instructions. | ||
</Text> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default ChangeBrowserModal |
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,12 +1,15 @@ | ||
export const isInstalledOnHomescreen = () => { | ||
// on Android and iOS, display mode is set to | ||
// standalone when the app is opened from home screen | ||
const displayIsStandalone = window.matchMedia('(display-mode: standalone)').matches | ||
export const isInstalledOnHomeScreen = window.matchMedia('(display-mode: standalone)').matches | ||
|
||
return displayIsStandalone | ||
} | ||
export const isMobileBrowser = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | ||
|
||
export const isMobileBrowser = () => /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | ||
export const isAppleMobile = /iPhone|iPad|iPod/i.test(navigator.userAgent) | ||
|
||
export const isMobileButNotInstalledOnHomeScreen = () => | ||
isMobileBrowser() && !isInstalledOnHomescreen() | ||
/** | ||
* WARN: Browser check can be tricky and not reliable at some cases. | ||
* Some non-Safari browsers can return the same `userAgent` value as Safari, so it might not be quite possible to detect if the browser is Safari or not. | ||
* There are several fields like `vendor` (deprecated), `userAgent`, `userAgentData`. Some of these are deprecated and some are returning similar values across different browsers like `userAgent`. | ||
* So be aware that is not perfect solution. | ||
*/ | ||
export const isNonSafari = /CriOS|FxiOS/i.test(navigator.userAgent) | ||
|
||
export const isMobileButNotInstalledOnHomeScreen = isMobileBrowser && !isInstalledOnHomeScreen |
0135455
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.
Successfully deployed to the following URLs:
app-web3inbox – ./
app-web3inbox-walletconnect1.vercel.app
app.web3inbox.com
app-web3inbox-git-main-walletconnect1.vercel.app
web3inbox-dev-hidden.vercel.app