diff --git a/.changeset/calm-bees-care.md b/.changeset/calm-bees-care.md new file mode 100644 index 0000000000..20bbd65b8b --- /dev/null +++ b/.changeset/calm-bees-care.md @@ -0,0 +1,5 @@ +--- +'@graphcommerce/next-ui': patch +--- + +Wrap the logo in a div on the homepage to prevent redirection. diff --git a/packages/next-ui/LayoutParts/Logo.tsx b/packages/next-ui/LayoutParts/Logo.tsx index 4ff874dc2c..2da4aedf4f 100644 --- a/packages/next-ui/LayoutParts/Logo.tsx +++ b/packages/next-ui/LayoutParts/Logo.tsx @@ -5,6 +5,7 @@ import { SxProps, Theme, unstable_composeClasses as composeClasses, + Box, } from '@mui/material' import { useRouter } from 'next/router' import { forwardRef } from 'react' @@ -22,12 +23,7 @@ const getLogoUtilityClass = (slot: string) => generateUtilityClass(name, slot) const useUtilityClasses = ({ classes }: LogoClassProps) => composeClasses({ logo: ['logo'], parent: ['parent'] }, getLogoUtilityClass, classes) -/** Creating styled components */ -const LogoContainer = styled(NextLink, { - name, - slot: 'parent', - overridesResolver: (_props, styles) => styles.parent, -})(({ theme }) => ({ +const commonLogoStyles: SxProps = { height: '100%', width: 'max-content', display: 'flex', @@ -35,12 +31,13 @@ const LogoContainer = styled(NextLink, { margin: '0 auto', justifyContent: 'center', pointerEvents: 'all', - [theme.breakpoints.up('md')]: { - display: 'flex', - margin: 'unset', - justifyContent: 'left', - }, -})) +} + +const LogoContainer = styled(NextLink, { + name, + slot: 'parent', + overridesResolver: (_props, styles) => styles.parent, +})() export type LogoProps = { href?: `/${string}` @@ -51,7 +48,6 @@ export type LogoProps = { export const Logo = forwardRef((props, ref) => { const { href = '/', image, sx } = props const router = useRouter() - const classes = useUtilityClasses(props) const img = ( @@ -63,13 +59,17 @@ export const Logo = forwardRef((props, ref) => { /> ) - return router.asPath.split('?')[0] === '/' ? ( - - {img} - - ) : ( - + const shouldRedirect = router.asPath.split('?')[0] !== href + + return ( + {img} - + ) })