-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { notifications } from "@mantine/notifications"; | ||
import { detect } from "detect-browser"; | ||
import { useEffect } from "react"; | ||
|
||
export function BrowserWarning() { | ||
useEffect(() => { | ||
const browser = detect(); | ||
|
||
// Browser version are based loosely on support for SIMD, OffscreenCanvas. | ||
// | ||
// https://caniuse.com/?search=simd | ||
// https://caniuse.com/?search=OffscreenCanvas | ||
if (browser === null || browser.version === null) { | ||
console.log("Failed to detect browser"); | ||
notifications.show({ | ||
title: "Could not detect browser version", | ||
message: | ||
"Your browser version could not be detected. It may not be supported.", | ||
autoClose: false, | ||
color: "red", | ||
}); | ||
} else { | ||
const version = parseFloat(browser.version); | ||
console.log(`Detected ${browser.name} version ${version}`); | ||
if ( | ||
(browser.name === "chrome" && version < 91) || | ||
(browser.name === "edge" && version < 91) || | ||
(browser.name === "firefox" && version < 89) || | ||
(browser.name === "opera" && version < 77) || | ||
(browser.name === "safari" && version < 16.4) | ||
) | ||
notifications.show({ | ||
title: "Unsuppported browser", | ||
message: `Your browser (${browser.name.slice(0, 1).toUpperCase() + browser.name.slice(1)}/${browser.version}) is outdated, which may cause problems. Consider updating.`, | ||
autoClose: false, | ||
color: "red", | ||
}); | ||
} | ||
}); | ||
return null; | ||
} |
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