From 41fbc9edace426a13adad2b5f0a59c2c15d59539 Mon Sep 17 00:00:00 2001 From: Kevin Thomas Date: Mon, 28 Oct 2024 18:19:27 -0700 Subject: [PATCH] feat: migrate Header to tailwindcss, fix beta blurb, fix responsive design of landing page profile statistics --- src/components/Header/Header.tsx | 326 ++++++++++++------ src/components/Header/MobileHeader.tsx | 134 +++++++ src/components/HomeHero/HomeHero.tsx | 2 +- .../ModalContainer/ModalContainer.module.scss | 2 +- src/styles/Home.module.scss | 6 + 5 files changed, 354 insertions(+), 116 deletions(-) create mode 100644 src/components/Header/MobileHeader.tsx diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index dd717e5..ad84af2 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -1,16 +1,17 @@ +/* eslint-disable jsx-a11y/no-static-element-interactions */ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import Link from 'next/link' import Image from 'next/image' -import classNames from 'classnames' import { useRouter } from 'next/router' import { MenuIcon, UserIcon, DiscordIcon } from 'src/components/Icons/icons' import { useCallback, useContext, useEffect, useState } from 'react' -import styles from './Header.module.scss' import { ThemeButton } from '../ThemeButton' -import { AuthContext, ModalContext } from 'src/contexts' +import { AuthContext, ModalContext, WindowSizeContext } from 'src/contexts' export const Header: React.FC = () => { const [showMenu, setShowMenu] = useState(false) + const { isMobile } = useContext(WindowSizeContext) const { user, connectLichess, logout } = useContext(AuthContext) @@ -49,123 +50,127 @@ export const Header: React.FC = () => { }, [router]) const userInfo = user?.lichessId ? ( -
-
- {UserIcon} -
- {user?.displayName} -

View Info

-
+
+ {UserIcon} +
+

{user?.displayName}

+

View Info

-
+
Profile - +
) : ( -
- -
+ ) - const headerContent = ( - <> - -
- Maia Logo -

Maia Chess

-
- -
- {user?.lichessId ? ( -
- -
- - - Play Maia on Lichess - - -
+ const desktopLayout = ( +
+
+ +
+ Maia Logo +

Maia Chess

- ) : ( + +
+ {user?.lichessId ? ( +
+ +
+ + + Play Maia on Lichess + + +
+
+ ) : ( + + Play + + )} + + Analysis + + + Train + + + Bot-or-not + + + Leaderboard + + + Blog + - Play + WATCH - )} - - Analysis - - - Train - - - Bot-or-not - - - Leaderboard - - - Blog - - - WATCH - - - FEEDBACK - + + FEEDBACK + +
-
+
{ {userInfo}
+
+ ) + + const mobileLayout = ( +
+ +
+ Maia Logo +

Maia Chess

+
+ - + {showMenu && ( +
+
+ +
+ Maia Logo +

Maia Chess

+
+ + +
+
+ {user?.lichessId ? ( +
+ +
+ + + Play Maia on Lichess + + +
+
+ ) : ( + + Play + + )} + + Analysis + + + Train + + + Bot-or-not + + + Leaderboard + + + Blog + + + Watch + + + Feedback + +
+
+ + +
{DiscordIcon}
+
+ {userInfo} +
+
+ )} +
) return ( <> -
{headerContent}
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} -
setShowMenu(false)} - > - {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} -
e.stopPropagation()}> - {headerContent} -
+
+ {isMobile ? mobileLayout : desktopLayout}
) diff --git a/src/components/Header/MobileHeader.tsx b/src/components/Header/MobileHeader.tsx new file mode 100644 index 0000000..8b5ff01 --- /dev/null +++ b/src/components/Header/MobileHeader.tsx @@ -0,0 +1,134 @@ +/* eslint-disable jsx-a11y/no-static-element-interactions */ +/* eslint-disable jsx-a11y/click-events-have-key-events */ +import Link from 'next/link' +import Image from 'next/image' +import classNames from 'classnames' +import { useRouter } from 'next/router' + +import styles from './Header.module.scss' + +type Props = { + use + showMenu: boolean + setShowMenu: (show: boolean) => void +} + +export const MobileHeader: React.FC = ({ showMenu, setShowMenu }: Props) => { + const router = useRouter() + return ( + + ) +} + +//
+//
+// +//
+// Maia Logo +//

Maia Chess

+//
+// +//
+// {user?.lichessId ? ( +//
+// +//
+// +// +// Play Maia on Lichess +// +// +//
+//
+// ) : ( +// +// Play +// +// )} +// +// Analysis +// +// +// Train +// +// +// Bot-or-not +// +// +// Leaderboard +// +// +// Blog +// +// +// WATCH +// +// +// FEEDBACK +// +//
+//
+//
+// +// +// {DiscordIcon} +// +// {userInfo} +//
+// +//
diff --git a/src/components/HomeHero/HomeHero.tsx b/src/components/HomeHero/HomeHero.tsx index 386dc0b..549f556 100644 --- a/src/components/HomeHero/HomeHero.tsx +++ b/src/components/HomeHero/HomeHero.tsx @@ -161,7 +161,7 @@ function BetaBlurb() { return ( <> {user?.lichessId ? ( -
+
{SunIcon}

Maia Chess is in private beta

diff --git a/src/components/modals/ModalContainer/ModalContainer.module.scss b/src/components/modals/ModalContainer/ModalContainer.module.scss index 844673c..81e6e04 100644 --- a/src/components/modals/ModalContainer/ModalContainer.module.scss +++ b/src/components/modals/ModalContainer/ModalContainer.module.scss @@ -8,7 +8,7 @@ top: 0; bottom: 0; width: 100vw; - z-index: 8; + z-index: 100; @include themed-styles { background-color: rgba(themed-colour(backdrop), 0.9); diff --git a/src/styles/Home.module.scss b/src/styles/Home.module.scss index bcbccd3..6d2f392 100644 --- a/src/styles/Home.module.scss +++ b/src/styles/Home.module.scss @@ -112,6 +112,12 @@ display: flex; flex-direction: row; + @include mobile { + flex-grow: 1; + flex-direction: column; + gap: 16px; + } + @include themed-styles { background-color: rgba(themed-colour('text-primary'), 0.05); }