From fcbca1722f31f32633a57bc5048f46c9da057d87 Mon Sep 17 00:00:00 2001 From: Ryan Cohen Date: Tue, 17 Jan 2023 18:00:15 +0900 Subject: [PATCH] feat: new mobile menu (#3251) --- src/components/Discover/index.tsx | 6 +- src/components/Layout/MobileMenu/index.tsx | 206 +++++++++++++++++++++ src/components/Layout/Sidebar/index.tsx | 10 +- src/components/Layout/index.tsx | 29 +-- src/components/MovieDetails/index.tsx | 2 +- src/components/TvDetails/index.tsx | 2 +- src/styles/globals.css | 20 +- 7 files changed, 252 insertions(+), 23 deletions(-) create mode 100644 src/components/Layout/MobileMenu/index.tsx diff --git a/src/components/Discover/index.tsx b/src/components/Discover/index.tsx index f7f5aeb7..c3c43a21 100644 --- a/src/components/Discover/index.tsx +++ b/src/components/Discover/index.tsx @@ -153,12 +153,12 @@ const Discover = () => { leave="transition-opacity duration-300" leaveFrom="opacity-100" leaveTo="opacity-0" - className="fixed bottom-8 right-8 z-50 flex items-center" + className="absolute-bottom-shift fixed right-6 z-50 flex items-center sm:bottom-8" > @@ -171,7 +171,7 @@ const Discover = () => { leave="transition duration-300 transform" leaveFrom="opacity-100 translate-y-0" leaveTo="opacity-0 translate-y-6" - className="fixed bottom-0 right-0 left-0 z-50 flex flex-col items-center justify-end space-x-0 space-y-2 border-t border-gray-700 bg-gray-800 bg-opacity-80 p-4 backdrop-blur sm:flex-row sm:space-y-0 sm:space-x-3" + className="safe-shift-edit-menu fixed right-0 left-0 z-50 flex flex-col items-center justify-end space-x-0 space-y-2 border-t border-gray-700 bg-gray-800 bg-opacity-80 p-4 backdrop-blur sm:bottom-0 sm:flex-row sm:space-y-0 sm:space-x-3" > + )} + + + + ); +}; + +export default MobileMenu; diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index de2fd8cd..4baf56a6 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -17,7 +17,7 @@ import { useRouter } from 'next/router'; import { Fragment, useRef } from 'react'; import { defineMessages, useIntl } from 'react-intl'; -const messages = defineMessages({ +export const menuMessages = defineMessages({ dashboard: 'Discover', browsemovies: 'Movies', browsetv: 'Series', @@ -35,7 +35,7 @@ interface SidebarProps { interface SidebarLinkProps { href: string; svgIcon: React.ReactNode; - messagesKey: keyof typeof messages; + messagesKey: keyof typeof menuMessages; activeRegExp: RegExp; as?: string; requiredPermission?: Permission | Permission[]; @@ -192,7 +192,7 @@ const Sidebar = ({ open, setClosed }: SidebarProps) => { > {sidebarLink.svgIcon} {intl.formatMessage( - messages[sidebarLink.messagesKey] + menuMessages[sidebarLink.messagesKey] )} @@ -253,7 +253,9 @@ const Sidebar = ({ open, setClosed }: SidebarProps) => { data-testid={sidebarLink.dataTestId} > {sidebarLink.svgIcon} - {intl.formatMessage(messages[sidebarLink.messagesKey])} + {intl.formatMessage( + menuMessages[sidebarLink.messagesKey] + )} ); diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index d9353575..b30b9712 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -1,3 +1,4 @@ +import MobileMenu from '@app/components/Layout/MobileMenu'; import SearchInput from '@app/components/Layout/SearchInput'; import Sidebar from '@app/components/Layout/Sidebar'; import UserDropdown from '@app/components/Layout/UserDropdown'; @@ -6,8 +7,7 @@ import type { AvailableLocale } from '@app/context/LanguageContext'; import useLocale from '@app/hooks/useLocale'; import useSettings from '@app/hooks/useSettings'; import { useUser } from '@app/hooks/useUser'; -import { Bars3BottomLeftIcon } from '@heroicons/react/24/outline'; -import { ArrowLeftIcon } from '@heroicons/react/24/solid'; +import { ArrowLeftIcon, Bars3BottomLeftIcon } from '@heroicons/react/24/solid'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; @@ -56,6 +56,9 @@ const Layout = ({ children }: LayoutProps) => {
setSidebarOpen(false)} /> +
+ +
@@ -68,17 +71,17 @@ const Layout = ({ children }: LayoutProps) => { WebkitBackdropFilter: isScrolled ? 'blur(5px)' : undefined, }} > - -
+
+