Previously, you created a GraphCommerce app and started building your custom storefront with GraphCommerce. You're now ready to build a custom header for your app.
In this tutorial, you'll accomplish a series of tasks to add some specific functionality to your app. Your final app will be simple, but you'll learn where to find resources to build more complex features on your own.
You've familiarized yourself with React ↗, Next.js ↗, and Mui ↗. GraphCommerce is a frontend React framework that uses Next.js for server-side rendering.
<Logo />
after
<DesktopNavBar>...</DesktopNavBar>
<Logo />
component in a <Box>
component:<Box
sx={{
display: 'flex',
justifyContent: 'center',
flexGrow: 1,
pointerEvents: 'none',
}}
>
<Logo />
</Box>
'@mui/material'
imports at the
top of the file<DesktopNavBar>...</DesktopNavBar>
component.<SearchLink href='/search' />
with:<PageLink href='/search' passHref>
<Fab aria-label={t`Search`} size='large' color='inherit'>
<IconSvg src={iconSearch} size='large' />
</Fab>
</PageLink>
iconSearch
to the existing imports from '@graphcommerce/next-ui'
at
the top of the file<PageLink href='/service' passHref>
<Fab aria-label={t`Account`} size='large' color='inherit'>
<IconSvg src={iconCustomerService} size='large' />
</Fab>
</PageLink>
In /components/Layout/LayoutNavigation.tsx, remove MenuFab
from the
'@graphcommerce/next-ui'
import
Add import { MenuFab } from './MenuFab'
to the list of imports at the top of
the file
Make a copy of /node_modules/@graphcommerce/next-ui/LayoutParts/MenuFab.tsx and move it to the directory /components/Layout/MenuFab.tsx
Remove the style={{...}}
prop from both the <MotionDiv>
components to
remove the Fab scroll animation
Remove const { opacity, scale, shadowOpacity } = useFabAnimation()
Update all imports:
import {
extendableComponent,
responsiveVal,
iconClose,
iconMenu,
IconSvg,
} from '@graphcommerce/next-ui'
import { styled, Box, Fab, Menu, ListItem, Divider, alpha } from '@mui/material'
import { useRouter } from 'next/router'
import React, { useEffect } from 'react'