From 61e187199e944203afe92d67dc03fe5c5a1eecfa Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Mon, 7 Nov 2022 15:48:27 -0500 Subject: [PATCH] Add search to mobile, fix light mode drawer background --- website/src/components/layout/Header.tsx | 7 ++-- website/src/components/layout/Logo.tsx | 39 +++---------------- .../layout/mobile-drawer/NavigationDrawer.tsx | 21 ++++++---- .../src/components/layout/search/Search.tsx | 12 ++++++ website/src/styles/theme.ts | 4 +- 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/website/src/components/layout/Header.tsx b/website/src/components/layout/Header.tsx index da1d0a51..d5852f39 100644 --- a/website/src/components/layout/Header.tsx +++ b/website/src/components/layout/Header.tsx @@ -5,7 +5,7 @@ import MenuIcon from '@mui/icons-material/Menu'; import AppBar from '@mui/material/AppBar'; import Button from '@mui/material/Button'; import IconButton from '@mui/material/IconButton'; -import { styled } from '@mui/material/styles'; +import { styled, useTheme } from '@mui/material/styles'; import Toolbar from '@mui/material/Toolbar'; import Link from 'next/link'; import { useCallback, useMemo, useState } from 'react'; @@ -106,6 +106,7 @@ interface HeaderProps { } const Header = ({ mode, docsGroups, searchablePages, toggleColorMode }: HeaderProps) => { + const theme = useTheme(); const [mobileOpen, setMobileOpen] = useState(false); const handleDrawerToggle = useCallback(() => { @@ -151,10 +152,10 @@ const Header = ({ mode, docsGroups, searchablePages, toggleColorMode }: HeaderPr - + ( - ({ theme, $inDrawer }) => ` - display: flex; - align-items: center; - - ${ - !$inDrawer - ? ` - ${theme.breakpoints.down('lg')} { - position: absolute; - left: 50%; - transform: translate(-50%, 0); - } - ` - : '' - } - `, -); +const StyledImageLink = styled('a')` + display: flex; + align-items: center; +`; const StyledImage = styled(Image)` cursor: pointer; `; -interface LogoProps { - inDrawer?: boolean; -} - -const Logo = ({ inDrawer = false }: LogoProps) => { +const Logo = () => { return ( - + diff --git a/website/src/components/layout/mobile-drawer/NavigationDrawer.tsx b/website/src/components/layout/mobile-drawer/NavigationDrawer.tsx index 17f0de46..45372dea 100644 --- a/website/src/components/layout/mobile-drawer/NavigationDrawer.tsx +++ b/website/src/components/layout/mobile-drawer/NavigationDrawer.tsx @@ -12,14 +12,19 @@ import type { MenuItem } from '../../../interface'; const DRAWER_WIDTH = 300; const StyledDrawerContents = styled('div')` - padding-top: 16px; text-align: center; `; -const StyledLogoWrapper = styled('div')` - display: flex; - justify-content: center; -`; +const StyledLogoWrapper = styled('div')( + ({ theme }) => ` + display: flex; + justify-content: center; + padding: 16px 0; + background: ${ + theme.palette.mode === 'light' ? theme.palette.primary.main : theme.palette.background.paper + }; + `, +); interface NavigationDrawerProps { items: MenuItem[]; @@ -39,9 +44,9 @@ const NavigationDrawer = ({ items, mobileOpen, onMobileOpenToggle }: NavigationD () => ( - + - + {items.map(item => ( @@ -84,7 +89,7 @@ const NavigationDrawer = ({ items, mobileOpen, onMobileOpenToggle }: NavigationD boxSizing: 'border-box', width: '80%', maxWidth: DRAWER_WIDTH, - background: '#2e3034', + background: theme.palette.background.paper, }, '& .MuiListSubheader-root': { textAlign: 'left', diff --git a/website/src/components/layout/search/Search.tsx b/website/src/components/layout/search/Search.tsx index 84cb64fa..c6a867b0 100644 --- a/website/src/components/layout/search/Search.tsx +++ b/website/src/components/layout/search/Search.tsx @@ -3,6 +3,7 @@ import Button from '@mui/material/Button'; import { styled } from '@mui/material/styles'; import Typography from '@mui/material/Typography'; import { useCallback, useState } from 'react'; +import IconButton from '@mui/material/IconButton'; import SearchModal from './SearchModal'; @@ -33,6 +34,14 @@ const StyledSearchPlaceholderBox = styled(Button)( `, ); +const StyledIconButton = styled(IconButton)( + ({ theme }) => ` + ${theme.breakpoints.up('lg')} { + display: none; + } + `, +); + export interface SearchProps { searchablePages: SearchablePage[]; } @@ -65,6 +74,9 @@ const Search = ({ searchablePages }: SearchProps) => { Search the docs + + + ); diff --git a/website/src/styles/theme.ts b/website/src/styles/theme.ts index 972c0235..25bb1450 100644 --- a/website/src/styles/theme.ts +++ b/website/src/styles/theme.ts @@ -13,10 +13,10 @@ const useCreateTheme = (mode: PaletteMode) => { ? { mode, primary: { - main: '#3764be', + main: '#1b72de', }, secondary: { - main: '#3764be', + main: '#1b72de', }, background: { default: '#f9f9f9',