From 81aa0ca06056ed45392c33c3843b0d8b34c8c86a Mon Sep 17 00:00:00 2001 From: Laica-Lunasys Date: Fri, 19 Mar 2021 21:19:31 +0900 Subject: [PATCH] Add themes to Remote/SwitchbotChooser --- .../dash-home/src/components/atoms/Themed.tsx | 36 ++++++++++++++++++- .../components/controller/RemoteChooser.tsx | 20 ++++++----- .../controller/SwitchBotChooser.tsx | 17 +++++---- .../dash-home/src/locales/en/translation.json | 4 ++- .../dash-home/src/locales/ja/translation.json | 4 ++- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/frontend/dash-home/src/components/atoms/Themed.tsx b/frontend/dash-home/src/components/atoms/Themed.tsx index 435c2cb..1aa7eb0 100644 --- a/frontend/dash-home/src/components/atoms/Themed.tsx +++ b/frontend/dash-home/src/components/atoms/Themed.tsx @@ -5,7 +5,9 @@ import { ThemeContext } from '../themes/ThemeProvider'; import { Spinner as BaseSpinner, + Tabs as BaseTabs, Modal, + TabsProps, } from 'react-bootstrap'; export const Icon = (props: any) => { @@ -101,4 +103,36 @@ const DarkModal = styled(Modal)` background-color: #111112; border: none; } -`; \ No newline at end of file +`; + +export const Tabs = (props: TabsProps) => { + const theme = React.useContext(ThemeContext).theme; + return ( + <> + + + + ) +} \ No newline at end of file diff --git a/frontend/dash-home/src/components/controller/RemoteChooser.tsx b/frontend/dash-home/src/components/controller/RemoteChooser.tsx index 8ed8041..77cf369 100644 --- a/frontend/dash-home/src/components/controller/RemoteChooser.tsx +++ b/frontend/dash-home/src/components/controller/RemoteChooser.tsx @@ -1,9 +1,11 @@ import * as React from 'react'; -import { Modal, Button, Tabs, Card, Tab } from 'react-bootstrap'; +import { Modal, Button, Card, Tab } from 'react-bootstrap'; import { Remote } from '../../remote-go/Controller'; import { RemotesResult, fetchRemotes } from '../../remote-go/Remotes'; import { NotifyError } from '../atoms/Notify'; import { useTranslation } from 'react-i18next'; +import { ThemedModal, Tabs } from '../atoms/Themed'; +import { P } from '../atoms/Core'; interface Props { visible: boolean, @@ -36,7 +38,7 @@ const RemoteChooser: React.FC = (props: Props) => { const remotes = allRemotes.get(props.kind.toLowerCase()); if (!remotes) { return ( - = (props: Props) => {

{t("controller.remote.error.unknownKind", { kind: props.kind })}

-
+ ); } @@ -59,7 +61,7 @@ const RemoteChooser: React.FC = (props: Props) => { Object.keys(remotes).forEach((vendor: string) => remotes[vendor].sort()) return ( - = (props: Props) => { {t("controller.remote.chooser", { kind: props.kind })} - + {/* Generate kind of vendor/models array... */} {Object.keys(remotes).map((vendor: string) => { return ( @@ -79,9 +81,9 @@ const RemoteChooser: React.FC = (props: Props) => { {/* Models Card... */} {remotes[vendor].map((model: string) => { return ( - +
- {model} +

{model}

- +
) })} @@ -101,7 +103,7 @@ const RemoteChooser: React.FC = (props: Props) => { })}
-
+ ) } diff --git a/frontend/dash-home/src/components/controller/SwitchBotChooser.tsx b/frontend/dash-home/src/components/controller/SwitchBotChooser.tsx index c338b97..cb233cf 100644 --- a/frontend/dash-home/src/components/controller/SwitchBotChooser.tsx +++ b/frontend/dash-home/src/components/controller/SwitchBotChooser.tsx @@ -1,6 +1,9 @@ import * as React from 'react'; import { Modal, Button, Form } from 'react-bootstrap'; +import { useTranslation } from 'react-i18next'; import { SwitchBot } from '../../remote-go/Controller'; +import { P } from '../atoms/Core'; +import { ThemedModal } from '../atoms/Themed'; interface Props { initialState?: SwitchBot, @@ -10,6 +13,8 @@ interface Props { } const SwitchBotChooser: React.FC = (props: Props) => { + const { t } = useTranslation(); + // TODO: Macアドレスの記入とコマンドの設定(ドロップダウンで 'press', 'on', 'off' の設定を行えるようにする) const [switchBot, setSwitchBot] = React.useState(() => { return { @@ -31,7 +36,7 @@ const SwitchBotChooser: React.FC = (props: Props) => { return ( - = (props: Props) => { >
- SwitchBot Settings... + {t("controller.switchbot.chooser")} {/* Mac Address */} - MAC Address +

{t("controller.switchbot.mac")}

= (props: Props) => { {/* Type */} - Type +

Type

= (props: Props) => {
-
+ ) } diff --git a/frontend/dash-home/src/locales/en/translation.json b/frontend/dash-home/src/locales/en/translation.json index aa27350..deed5a2 100644 --- a/frontend/dash-home/src/locales/en/translation.json +++ b/frontend/dash-home/src/locales/en/translation.json @@ -94,7 +94,9 @@ } }, "switchbot": { - "openSettings": "Open Switchbot Settings..." + "openSettings": "Open Switchbot Settings...", + "chooser": "Switchbot Settings", + "mac": "MAC Address" }, "entry": { "name": { diff --git a/frontend/dash-home/src/locales/ja/translation.json b/frontend/dash-home/src/locales/ja/translation.json index 59f4f7c..bb66613 100644 --- a/frontend/dash-home/src/locales/ja/translation.json +++ b/frontend/dash-home/src/locales/ja/translation.json @@ -94,7 +94,9 @@ } }, "switchbot": { - "openSettings": "Switchbotの設定を開く" + "openSettings": "Switchbotの設定を開く", + "chooser": "Switchbotの設定", + "mac": "MACアドレス" }, "entry": { "name": {