Skip to content

Commit 37f008b

Browse files
authored
feat: shows an unsupported browser message when using Safari (#549)
1 parent 3bd6128 commit 37f008b

File tree

7 files changed

+95
-30
lines changed

7 files changed

+95
-30
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@vitejs/plugin-react-swc": "^3.6.0",
7474
"autoprefixer": "^10.4.17",
7575
"cross-env": "^7.0.3",
76-
"cypress": "^12.17.4",
76+
"cypress": "13.7.1",
7777
"cypress-file-upload": "^5.0.8",
7878
"eslint": "^8.56.0",
7979
"eslint-config-prettier": "^8.10.0",

src/ui/components/App.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// SPDX-License-Identifier: GPL-3.0-only
33

44
import { Outlet } from 'react-router';
5-
import { AwaitApis } from 'ui/components';
5+
import { AwaitApis, CheckBrowserSupport } from 'ui/components';
66
import {
77
ApiContextProvider,
88
DatabaseContextProvider,
9-
TransactionsContextProvider,
109
ThemeContextProvider,
10+
TransactionsContextProvider,
1111
} from 'ui/contexts';
1212
import { Sidebar } from 'ui/layout/sidebar';
1313

@@ -20,9 +20,11 @@ export default function App() {
2020
{/* we want the sidebar outside the outlet to prevent flickering in quicklinks */}
2121
<div className="relative inset-0 flex min-h-screen overflow-hidden text-black dark:bg-gray-900 dark:text-white md:fixed md:flex-row">
2222
<Sidebar />
23-
<AwaitApis>
24-
<Outlet />
25-
</AwaitApis>
23+
<CheckBrowserSupport>
24+
<AwaitApis>
25+
<Outlet />
26+
</AwaitApis>
27+
</CheckBrowserSupport>
2628
</div>
2729
</TransactionsContextProvider>
2830
</DatabaseContextProvider>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2022-2024 @paritytech/contracts-ui authors & contributors
2+
// SPDX-License-Identifier: GPL-3.0-only
3+
4+
import type { HTMLAttributes } from 'react';
5+
import { useMemo } from 'react';
6+
import { UnsupportedBrowserMessage } from './common/UnsupportedBrowserMessage';
7+
8+
export function CheckBrowserSupport({
9+
children,
10+
}: HTMLAttributes<HTMLDivElement>): React.ReactElement {
11+
const isSafari = useMemo(() => {
12+
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
13+
}, []);
14+
15+
if (isSafari) {
16+
return <UnsupportedBrowserMessage />;
17+
} else {
18+
return <>{children}</>;
19+
}
20+
}

src/ui/components/common/Info.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2022-2024 @paritytech/contracts-ui authors & contributors
2+
// SPDX-License-Identifier: GPL-3.0-only
3+
4+
import { InformationCircleIcon } from '@heroicons/react/solid';
5+
import { classes } from 'lib/util';
6+
7+
type Props = React.HTMLProps<HTMLDivElement>;
8+
9+
export function Info({ children, className }: Props) {
10+
return (
11+
<div className={classes('page-error', className)} data-cy="error-card">
12+
<div>
13+
<InformationCircleIcon className="mb-1 h-10 w-10 text-blue-400" />
14+
{children}
15+
</div>
16+
</div>
17+
);
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2022-2024 @paritytech/contracts-ui authors & contributors
2+
// SPDX-License-Identifier: GPL-3.0-only
3+
4+
import { Info } from './Info';
5+
6+
const SuggestedBrowsers = [
7+
['Mozilla Firefox', 'https://www.mozilla.org/firefox'],
8+
['Brave Browser', 'https://brave.com/'],
9+
['Google Chrome', 'https://www.google.com/chrome/'],
10+
];
11+
12+
export function UnsupportedBrowserMessage() {
13+
return (
14+
<Info>
15+
<div>Unsupported Browser</div>
16+
17+
<div className="text-left">
18+
<p className="mb-3">
19+
We currently do not support Apple's Safari browser. We recommend using this DApp with one
20+
of the following browsers:
21+
</p>
22+
<div className="flex flex-col gap-2">
23+
{SuggestedBrowsers.map(([title, url]) => (
24+
<a className="hover:underline" href={url} key={title} rel="noreferrer" target="_blank">
25+
{`> ${title}`}
26+
</a>
27+
))}
28+
</div>
29+
</div>
30+
</Info>
31+
);
32+
}

src/ui/components/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export * from './homepage';
99
export * from './instantiate';
1010
export * from './message';
1111
export * from './AwaitApis';
12+
export * from './CheckBrowserSupport';

yarn.lock

+16-24
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ __metadata:
331331
languageName: node
332332
linkType: hard
333333

334-
"@cypress/request@npm:2.88.12":
335-
version: 2.88.12
336-
resolution: "@cypress/request@npm:2.88.12"
334+
"@cypress/request@npm:^3.0.0":
335+
version: 3.0.1
336+
resolution: "@cypress/request@npm:3.0.1"
337337
dependencies:
338338
aws-sign2: ~0.7.0
339339
aws4: ^1.8.0
@@ -348,12 +348,12 @@ __metadata:
348348
json-stringify-safe: ~5.0.1
349349
mime-types: ~2.1.19
350350
performance-now: ^2.1.0
351-
qs: ~6.10.3
351+
qs: 6.10.4
352352
safe-buffer: ^5.1.2
353353
tough-cookie: ^4.1.3
354354
tunnel-agent: ^0.6.0
355355
uuid: ^8.3.2
356-
checksum: 2c6fbf7f3127d41bffca8374beaa8cf95450495a8a077b00309ea9d94dd2a4da450a77fe038e8ad26c97cdd7c39b65c53c850f8338ce9bc2dbe23ce2e2b48329
356+
checksum: 7175522ebdbe30e3c37973e204c437c23ce659e58d5939466615bddcd58d778f3a8ea40f087b965ae8b8138ea8d102b729c6eb18c6324f121f3778f4a2e8e727
357357
languageName: node
358358
linkType: hard
359359

@@ -2031,13 +2031,6 @@ __metadata:
20312031
languageName: node
20322032
linkType: hard
20332033

2034-
"@types/node@npm:^16.18.39":
2035-
version: 16.18.79
2036-
resolution: "@types/node@npm:16.18.79"
2037-
checksum: 60450f0966efad08719d60052991691c7ec42174ac81f750876ce2798f5ba2fa298ab6b66ae427c557b6daad3e2c128c8c61059d0080578beefe2d0925a79d3f
2038-
languageName: node
2039-
linkType: hard
2040-
20412034
"@types/parse-json@npm:^4.0.0":
20422035
version: 4.0.2
20432036
resolution: "@types/parse-json@npm:4.0.2"
@@ -2935,7 +2928,7 @@ __metadata:
29352928
languageName: node
29362929
linkType: hard
29372930

2938-
"buffer@npm:^5.6.0":
2931+
"buffer@npm:^5.7.1":
29392932
version: 5.7.1
29402933
resolution: "buffer@npm:5.7.1"
29412934
dependencies:
@@ -3400,7 +3393,7 @@ __metadata:
34003393
buffer: ^6.0.3
34013394
copy-to-clipboard: ^3.3.3
34023395
cross-env: ^7.0.3
3403-
cypress: ^12.17.4
3396+
cypress: 13.7.1
34043397
cypress-file-upload: ^5.0.8
34053398
date-fns: ^2.30.0
34063399
dexie: ^3.2.4
@@ -3541,19 +3534,18 @@ __metadata:
35413534
languageName: node
35423535
linkType: hard
35433536

3544-
"cypress@npm:^12.17.4":
3545-
version: 12.17.4
3546-
resolution: "cypress@npm:12.17.4"
3537+
"cypress@npm:13.7.1":
3538+
version: 13.7.1
3539+
resolution: "cypress@npm:13.7.1"
35473540
dependencies:
3548-
"@cypress/request": 2.88.12
3541+
"@cypress/request": ^3.0.0
35493542
"@cypress/xvfb": ^1.2.4
3550-
"@types/node": ^16.18.39
35513543
"@types/sinonjs__fake-timers": 8.1.1
35523544
"@types/sizzle": ^2.3.2
35533545
arch: ^2.2.0
35543546
blob-util: ^2.0.2
35553547
bluebird: ^3.7.2
3556-
buffer: ^5.6.0
3548+
buffer: ^5.7.1
35573549
cachedir: ^2.3.0
35583550
chalk: ^4.1.0
35593551
check-more-types: ^2.24.0
@@ -3571,7 +3563,7 @@ __metadata:
35713563
figures: ^3.2.0
35723564
fs-extra: ^9.1.0
35733565
getos: ^3.2.1
3574-
is-ci: ^3.0.0
3566+
is-ci: ^3.0.1
35753567
is-installed-globally: ~0.4.0
35763568
lazy-ass: ^1.6.0
35773569
listr2: ^3.8.3
@@ -3590,7 +3582,7 @@ __metadata:
35903582
yauzl: ^2.10.0
35913583
bin:
35923584
cypress: bin/cypress
3593-
checksum: c9c79f5493b23e9c8cfb92d45d50ea9d0fae54210dde203bfa794a79436faf60108d826fe9007a7d67fddf7919802ad8f006b7ae56c5c198c75d5bc85bbc851b
3585+
checksum: f6c3cafdc53f5737d3b981c9e8ace574398bc999c47e87bb8c8855052b6aa53c140d8361484b573f600acbcbcc113aad4c97a6953878e8c82f0a43864b58e17c
35943586
languageName: node
35953587
linkType: hard
35963588

@@ -5435,7 +5427,7 @@ __metadata:
54355427
languageName: node
54365428
linkType: hard
54375429

5438-
"is-ci@npm:^3.0.0":
5430+
"is-ci@npm:^3.0.1":
54395431
version: 3.0.1
54405432
resolution: "is-ci@npm:3.0.1"
54415433
dependencies:
@@ -7967,7 +7959,7 @@ __metadata:
79677959
languageName: node
79687960
linkType: hard
79697961

7970-
"qs@npm:~6.10.3":
7962+
"qs@npm:6.10.4":
79717963
version: 6.10.4
79727964
resolution: "qs@npm:6.10.4"
79737965
dependencies:

0 commit comments

Comments
 (0)