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 all 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 version of 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を使用してください。"
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"build": "tsc && vite build",
"build:ceres": "tsc && NODE_OPTIONS=--max-old-space-size=4096 vite build --mode ceres",
"preview": "vite preview",
"prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,md}\"",
"check": "biome check --write",
"check:ci": "biome ci && tsc -p . --noEmit"
},
Expand Down
49 changes: 49 additions & 0 deletions src/components/UnsupportedBrowserModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Modal, ModalClose, Sheet } from "@mui/joy";
import { Typography } from "@mui/material";
import { useState } from "react";
import { useTranslation } from "react-i18next";
interface UnsupportedBrowserModalProps {
defaultOpen: boolean;
}

export const UnsupportedBrowserModal = ({
defaultOpen,
}: UnsupportedBrowserModalProps) => {
const [open, setOpen] = useState(defaultOpen);
const [t] = useTranslation();
return (
<Modal
open={open}
onClose={() => setOpen(false)}
disableAutoFocus
sx={{
width: "90%",
minWidth: "500px",
m: "auto",
alignContent: "center",
maxWidth: "60rem",
}}
>
<Sheet variant="outlined" sx={{ borderRadius: "0.5rem" }}>
<Typography
fontFamily="'M PLUS Rounded 1c', sans-serif"
variant="h5"
m={1}
alignItems="center"
>
{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>
);
};
4 changes: 4 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,11 @@ export const Home = () => {
i18n.changeLanguage(locale);
}, [i18n]);

// WebSerialAPIに対応するブラウザかどうかを確認
const isSupported = "serial" in navigator;
return (
<>
<UnsupportedBrowserModal defaultOpen={!isSupported} />
<Box
sx={{
mb: "0.5rem",
Expand Down
Loading