Skip to content

Commit fd5819b

Browse files
authored
fix: APP-877 project page without header (#2796)
1 parent 5233d1e commit fd5819b

File tree

21 files changed

+87
-167
lines changed

21 files changed

+87
-167
lines changed

web-marketplace/src/clients/regen/Regen.Providers.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
'use client';
22

33
import { ChainWrapper } from 'app/ChainWrapper';
4+
import { usePathname } from 'next/navigation';
45

56
import { LedgerProviderWithWallet } from 'ledger';
67
import { WalletProvider } from 'lib/wallet/wallet';
78

9+
import { LayoutFooter } from 'components/layout/Layout.Footer';
10+
import { LayoutHeader } from 'components/layout/Layout.Header';
11+
812
type Props = {
913
children: React.ReactNode;
1014
};
1115

1216
export const RegenProviders = ({ children }: Props) => {
17+
const pathname = usePathname();
18+
const isFullScreen =
19+
pathname.startsWith('/dashboard') ||
20+
pathname.startsWith('/organizations/create') ||
21+
pathname.startsWith('/project-pages/');
1322
return (
1423
<ChainWrapper>
1524
<WalletProvider>
16-
<LedgerProviderWithWallet>{children}</LedgerProviderWithWallet>
25+
<LedgerProviderWithWallet>
26+
{/* TODO: When the /dashboard has been migrated, the LayoutHeader and LayoutFooter
27+
should be in a layout component for non-dashboard pages */}
28+
<div className="min-h-screen flex flex-col">
29+
{!isFullScreen && <LayoutHeader />}
30+
<main className="flex-1">{children}</main>
31+
{!isFullScreen && <LayoutFooter />}
32+
</div>
33+
</LedgerProviderWithWallet>
1734
</WalletProvider>
1835
</ChainWrapper>
1936
);

web-marketplace/src/clients/regen/Regen.Routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export const getRegenRoutes = ({
266266
<>
267267
{/* Main routes WITH header/footer */}
268268
<Route
269-
element={<RegistryLayout showHeaderFooter />}
269+
element={<RegistryLayout />}
270270
loader={registryLayoutLoader({
271271
queryClient: reactQueryClient,
272272
apolloClient,

web-marketplace/src/components/atoms/HeaderNavLink.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { useLocation } from 'react-router-dom';
1+
import { usePathname } from 'next/navigation';
22

33
import {
44
NavLinkProps,
55
useNavLinkStyles,
66
} from 'web-components/src/components/header/components/NavLink';
77
import { cn } from 'web-components/src/utils/styles/cn';
88

9-
import { ReactRouterMuiLink as Link } from './Link';
9+
import { useCurrentLocale } from 'lib/i18n/hooks/useCurrentLocale';
10+
import { ensureLocalePrefix } from 'lib/i18n/utils/ensureLocalePrefix';
11+
12+
import { normalizePath, PROFILES_PATH } from './HeaderNavLink.utils';
13+
import { Link } from './Link';
1014

1115
/**
1216
* Renders a header `Link` with the navlink styles applied.
@@ -18,20 +22,23 @@ export const HeaderNavLink: React.FC<React.PropsWithChildren<NavLinkProps>> = ({
1822
className,
1923
disabled,
2024
}) => {
21-
const { pathname } = useLocation();
22-
const isActive = pathname === href;
23-
const { classes } = useNavLinkStyles({ isActive: !!isActive, disabled });
25+
const pathname = usePathname();
26+
const locale = useCurrentLocale();
27+
const hrefWithLocale = ensureLocalePrefix(href, locale);
28+
const normalizedPathname = normalizePath(pathname);
29+
const normalizedHref = normalizePath(hrefWithLocale);
30+
const isProfileLink = normalizedHref.includes(PROFILES_PATH);
31+
const isActive =
32+
normalizedPathname === normalizedHref ||
33+
(isProfileLink && normalizedPathname.startsWith(`${normalizedHref}/`));
34+
const { classes } = useNavLinkStyles({ isActive, disabled });
2435

2536
const handleDisabledButtonClick = (
2637
e: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
2738
) => {
2839
e.preventDefault();
2940
};
3041

31-
/**
32-
* Use the React Router-based link to keep SPA navigation in sync.
33-
*/
34-
3542
return (
3643
<Link
3744
href={href}

web-marketplace/src/components/atoms/HomeIconLink.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import { Box } from '@mui/material';
33

44
import RegenMarketIcon from 'web-components/src/components/icons/RegenMarketIcon';
55

6-
import { ReactRouterMuiLink as Link } from './Link';
6+
import { useCurrentLocale } from 'lib/i18n/hooks/useCurrentLocale';
7+
import { DEFAULT_LOCALE } from 'lib/i18n/locales';
8+
9+
import { Link } from './Link';
710

811
/**
912
* A clickable logo that links to the homepage (`/`).
1013
* It renders the `RegenMarketIcon` with a specified color.
1114
*/
1215
export const HomeIconLink = ({ color }: { color: string }) => {
16+
const locale = useCurrentLocale();
17+
const href = locale === DEFAULT_LOCALE ? '/' : `/${locale}`;
1318
return (
14-
<Link href="/">
19+
<Link href={href}>
1520
<Box
1621
sx={{
1722
width: { xs: 62, md: 117 },

web-marketplace/src/components/atoms/Link.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const NextLinkBehavior = React.forwardRef<
4343
ReactRouterLinkBehavior.displayName = 'ReactRouterLinkBehavior';
4444
// eslint-disable-next-line lingui/no-unlocalized-strings
4545
NextLinkBehavior.displayName = 'NextLinkBehavior';
46-
4746
const createMuiLink = (
4847
internalComponent: React.ElementType,
4948
{ applyLocalePrefix = true }: { applyLocalePrefix?: boolean } = {},
@@ -52,13 +51,15 @@ const createMuiLink = (
5251
({ href, children, target, ...linkProps }, ref) => {
5352
const locale = useCurrentLocale();
5453
if (!href || typeof href !== 'string') {
55-
// @ts-expect-error
56-
return <Box {...linkProps}>{children}</Box>;
54+
return (
55+
<Box {...linkProps} component="span">
56+
{children}
57+
</Box>
58+
);
5759
}
5860

5961
const isInternalLink = (href: string): boolean =>
6062
!!href && href.startsWith('/');
61-
// const hasAnchor = href?.includes('#');
6263

6364
const internalHref =
6465
applyLocalePrefix && isInternalLink(href)

web-marketplace/src/components/atoms/RegistryIconLink.legacy.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

web-marketplace/src/components/atoms/RegistryNavLink.legacy.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

web-marketplace/src/components/atoms/RegistryNavLink.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

web-marketplace/src/components/atoms/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ export * from './KeplrRoute';
66
export * from './Link';
77
export * from './LinkWithArrow';
88
export * from './OptimizedImage';
9-
export * from './RegistryIconLink.legacy';
10-
export * from './RegistryNavLink.legacy';
119
export * from './SanityButton';
1210
export * from './StatusLabel';

web-marketplace/src/components/layout/Layout.Footer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
'use client';
22

3-
import { useLocation } from 'react-router-dom';
43
import { msg } from '@lingui/core/macro';
54
import { useLingui } from '@lingui/react';
65
import { Trans } from '@lingui/react/macro';
76
import { URL_REGISTRY_TERMS_SERVICE, URL_WEB_PRIVACY } from 'config/globals';
7+
import { usePathname } from 'next/navigation';
88

99
import {
1010
Footer,
1111
FooterItemProps as FooterItem,
1212
} from 'web-components/src/components/footer/footer-new';
1313

1414
import { HomeIconLink } from 'components/atoms/HomeIconLink';
15-
import { ReactRouterMuiLink as Link } from 'components/atoms/Link';
15+
import { Link } from 'components/atoms/Link';
1616

1717
export const LayoutFooter = () => {
1818
const { _ } = useLingui();
19-
const { pathname } = useLocation();
19+
const pathname = usePathname();
2020
const isHidden =
2121
/^\/project-pages$/.test(pathname) ||
2222
/^\/project\/[^\/]+\/buy$/.test(pathname);

0 commit comments

Comments
 (0)