Skip to content
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

feat:WebSerialAPIに対応していないブラウザで開くと警告のモーダルを出す #331

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
"ソースコードを非表示": "Hide source code",
"エラーの詳細を見る": "Click to view error details",
"クリックして閉じる": "Click to close",
"コマンド": "Command"
"コマンド": "Command",
"このブラウザはサポートされていません": "This Browser is Not Supported",
"対応するブラウザを使ってください": "Your current browser does not support some of the features of this website.\nTo use all the features of this site, please use a desktop browser like Google Chrome or Microsoft Edge."
}
4 changes: 3 additions & 1 deletion i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@
"ソースコードを非表示": "ソースコードを非表示",
"エラーの詳細を見る": "エラーの詳細を見る",
"クリックして閉じる": "クリックして閉じる",
"コマンド": "コマンド"
"コマンド": "コマンド",
"このブラウザはサポートされていません": "このブラウザはサポートされていません",
"対応するブラウザを使ってください": "お使いのブラウザではこのウェブサイトの一部機能が正しく動作しません。\nこのサイトのすべての機能を利用するためには、パソコンのGoogle ChromeやMicrosoft Edgeなどのブラウザを使用してください。"
kiharu3112 marked this conversation as resolved.
Show resolved Hide resolved
}
43 changes: 43 additions & 0 deletions src/components/UnsupportedBrowserModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Modal, ModalClose, Sheet } from "@mui/joy";
import { Typography } from "@mui/material";
import { useState } from "react";
import { useTranslation } from "react-i18next";

export const UnsupportedBrowserModal = () => {
const [open, setOpen] = useState(true);
tufusa marked this conversation as resolved.
Show resolved Hide resolved
const [t] = useTranslation();

return (
<Modal
open={open}
onClose={() => setOpen(false)}
sx={{
width: "90%",
minWidth: "500px",
m: "auto",
alignContent: "center",
}}
>
<Sheet variant="outlined" sx={{ borderRadius: "0.5rem" }}>
<Typography
fontFamily={"'M PLUS Rounded 1c', sans-serif"}
variant="h4"
m={1}
alignItems={"center"}
kiharu3112 marked this conversation as resolved.
Show resolved Hide resolved
>
{t("このブラウザはサポートされていません")}
</Typography>
<ModalClose variant="plain" sx={{ m: 0.5 }} />

<Typography
fontFamily={"'M PLUS Rounded 1c', sans-serif"}
fontSize="sm"
m={"0.5rem"}
whiteSpace={"pre-line"}
>
{t("対応するブラウザを使ってください")}
</Typography>
</Sheet>
</Modal>
);
};
5 changes: 5 additions & 0 deletions src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CompilerSelector } from "components/CompilerSelector";
import { ControlButton } from "components/ControlButton";
import { Log } from "components/Log";
import { SourceCodeTab } from "components/SourceCodeTab";
import { UnsupportedBrowserModal } from "components/UnsupportedBrowserModal";
import { useCompile } from "hooks/useCompile";
import { useQuery } from "hooks/useQuery";
import { Version, useVersions } from "hooks/useVersions";
Expand Down Expand Up @@ -225,8 +226,12 @@ export const Home = () => {
i18n.changeLanguage(locale);
}, [i18n]);

// WebSerialAPIに対応するブラウザかどうかを確認する
const supported = "serial" in navigator;
kiharu3112 marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
{!supported && <UnsupportedBrowserModal />}
kiharu3112 marked this conversation as resolved.
Show resolved Hide resolved
<Box
sx={{
mb: "0.5rem",
Expand Down