diff --git a/.vscode/.snippet.code-snippets b/.vscode/.snippet.code-snippets
index f4961fc..a072b93 100644
--- a/.vscode/.snippet.code-snippets
+++ b/.vscode/.snippet.code-snippets
@@ -15,5 +15,27 @@
"`}"
],
"description": "Log output to console"
+ },
+ "React Functional Component": {
+ "scope": "typescriptreact",
+ "prefix": "rfc",
+ "body": [
+ "import * as React from 'react';",
+ "import { FunctionComponent } from 'react';",
+ "",
+ "const $TM_FILENAME_BASE: FunctionComponent = () => {",
+ "\treturn (",
+ "\t\t
-
-
-
-
-
- {context.texts.Mancala}
-
-
-
-
- {renderNewGameButton(context, game, onNewGameClick, userKeyWhoLeave, crashMessage)}
- {game &&
- !userKeyWhoLeave &&
- !crashMessage &&
- (game?.state === "playing" || game?.state === "initial") && (
-
- )}
-
+
+ {children}
+ `}
)
}
export default HeaderBar;
-
-const ThemeSwitchMenu: FunctionComponent<{ context: Context, textColor: string }> = (props) => {
- const { context, textColor } = props;
- const menuButton =
- light_mode
- ;
- const menuItems = context.themeManager.themes.map((theme, index) => {
- const themeBackground = context.themeManager.theme.background;
- return (
-
- );
- })
- return (
-
-
-
-
- );
-}
-
diff --git a/src/components/Row.tsx b/src/components/Row.tsx
new file mode 100644
index 0000000..bc0db42
--- /dev/null
+++ b/src/components/Row.tsx
@@ -0,0 +1,20 @@
+import * as React from 'react';
+import { FunctionComponent } from 'react';
+
+const Row: FunctionComponent = ({children}) => {
+ return (
+
+ {children}
+
+
+ );
+}
+
+export default Row;
\ No newline at end of file
diff --git a/src/components/headerbar/HeaderbarIcon.tsx b/src/components/headerbar/HeaderbarIcon.tsx
new file mode 100644
index 0000000..b012df0
--- /dev/null
+++ b/src/components/headerbar/HeaderbarIcon.tsx
@@ -0,0 +1,22 @@
+import * as React from "react";
+import { FunctionComponent } from "react";
+//@ts-ignore
+import MancalaIcon from "jsx:../../mancala.svg";
+
+const HeaderbarIcon: FunctionComponent = () => {
+ return (
+
+
+
+
+ );
+}
+
+export default HeaderbarIcon;
\ No newline at end of file
diff --git a/src/components/headerbar/HeaderbarTitle.tsx b/src/components/headerbar/HeaderbarTitle.tsx
new file mode 100644
index 0000000..2da3039
--- /dev/null
+++ b/src/components/headerbar/HeaderbarTitle.tsx
@@ -0,0 +1,18 @@
+import * as React from 'react';
+import { FunctionComponent } from 'react';
+import { Context } from '../../context/context';
+
+const HeaderbarTitle: FunctionComponent<{ title: string, color: string }> = ({ title, color }) => {
+ return (
+
+ {title}
+
+
+ );
+}
+
+export default HeaderbarTitle;
\ No newline at end of file
diff --git a/src/components/headerbar/ThemeSwitchMenu.tsx b/src/components/headerbar/ThemeSwitchMenu.tsx
new file mode 100644
index 0000000..73cb535
--- /dev/null
+++ b/src/components/headerbar/ThemeSwitchMenu.tsx
@@ -0,0 +1,59 @@
+import { Menu, MenuItem } from "@szhsin/react-menu";
+import * as React from "react";
+import { FunctionComponent } from "react";
+import { Context } from "../../context/context";
+import "@szhsin/react-menu/dist/index.css";
+import "@szhsin/react-menu/dist/transitions/slide.css"
+
+const ThemeSwitchMenu: FunctionComponent<{ context: Context, textColor: string }> = (props) => {
+ const { context, textColor } = props;
+ const menuButton =
+ light_mode
+ ;
+ const menuItems = context.themeManager.themes.map((theme, index) => {
+ const themeBackground = context.themeManager.theme.background;
+ return (
+
+ );
+ })
+ return (
+
+
+
+
+ );
+}
+
+export default ThemeSwitchMenu;
\ No newline at end of file
diff --git a/src/routes/Home.tsx b/src/routes/Home.tsx
index 1ffb2f4..9592e52 100644
--- a/src/routes/Home.tsx
+++ b/src/routes/Home.tsx
@@ -22,6 +22,11 @@ import { Theme } from "../theme/Theme";
import HeaderBar from "../components/HeaderBar";
import FloatingPanel from "../components/FloatingPanel";
import PageContainer from "../components/PageContainer";
+import Row from "../components/Row";
+import HeaderbarIcon from "../components/headerbar/HeaderbarIcon";
+import HeaderbarTitle from "../components/headerbar/HeaderbarTitle";
+import ThemeSwitchMenu from "../components/headerbar/ThemeSwitchMenu";
+import Button from "../components/Button";
type ConnectionState = "connecting" | "error" | "connected" | "reconnecting";
@@ -184,19 +189,31 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => {
context.themeManager.theme.textColor,
context.themeManager.theme.textLightColor
);
-
+ const textColorOnAppBar = getColorByBrightness(
+ context.themeManager.theme.appBarBgColor,
+ context.themeManager.theme.textColor,
+ context.themeManager.theme.textLightColor
+ );
+ const renderNewGameBtn = userKeyWhoLeave || !game || (game && game.state == "ended");
return (
{connectionStateText()}
-
+
+
+
+
+
+
+
+
+
+