diff --git a/docs/src/modules/components/Link.tsx b/docs/src/modules/components/Link.tsx index 21823bdb4263b3..ce49eb3ae1abe1 100644 --- a/docs/src/modules/components/Link.tsx +++ b/docs/src/modules/components/Link.tsx @@ -2,10 +2,19 @@ import * as React from 'react'; import clsx from 'clsx'; import { useRouter } from 'next/router'; import NextLink, { LinkProps as NextLinkProps } from 'next/link'; -import { styled } from '@mui/material/styles'; import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link'; +import { styled } from '@mui/material/styles'; import { useUserLanguage } from 'docs/src/modules/utils/i18n'; +/** + * File to keep in sync with: + * + * - /docs/src/modules/components/Link.tsx + * - /examples/nextjs/src/Link.tsx + * - /examples/nextjs-with-typescript/src/Link.tsx + * - /examples/nextjs-with-styled-components-typescript/src/Link.tsx + */ + interface NextLinkComposedProps extends Omit, 'href'>, Omit { @@ -14,8 +23,6 @@ interface NextLinkComposedProps href?: NextLinkProps['href']; } -const Anchor = styled('a')({ cursor: 'pointer' }); - const NextLinkComposed = React.forwardRef( function NextLinkComposed(props, ref) { const { to, linkAs, href, replace, scroll, shallow, prefetch, locale, ...other } = props; @@ -31,12 +38,15 @@ const NextLinkComposed = React.forwardRef - + {/* eslint-disable-next-line jsx-a11y/anchor-has-content */} + ); }, ); +const Anchor = styled('a')({}); + export type LinkProps = { activeClassName?: string; as?: NextLinkProps['as']; @@ -70,14 +80,14 @@ const Link = React.forwardRef(function Link(props, if (isExternal) { if (noLinkStyle) { - return ; + return ; } - return ; + return ; } if (noLinkStyle) { - return ; + return ; } let linkAs = linkAsProp || (href as string); diff --git a/examples/nextjs-with-styled-components-typescript/src/Link.tsx b/examples/nextjs-with-styled-components-typescript/src/Link.tsx index 3a86c99b7266fb..d129f5c17aadf8 100644 --- a/examples/nextjs-with-styled-components-typescript/src/Link.tsx +++ b/examples/nextjs-with-styled-components-typescript/src/Link.tsx @@ -1,9 +1,9 @@ -/* eslint-disable jsx-a11y/anchor-has-content */ import * as React from 'react'; import clsx from 'clsx'; import { useRouter } from 'next/router'; import NextLink, { LinkProps as NextLinkProps } from 'next/link'; import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link'; +import { styled } from '@mui/material/styles'; interface NextLinkComposedProps extends Omit, 'href'>, @@ -15,8 +15,7 @@ interface NextLinkComposedProps export const NextLinkComposed = React.forwardRef( function NextLinkComposed(props, ref) { - const { to, linkAs, href, replace, scroll, passHref, shallow, prefetch, locale, ...other } = - props; + const { to, linkAs, href, replace, scroll, shallow, prefetch, locale, ...other } = props; return ( + {/* eslint-disable-next-line jsx-a11y/anchor-has-content */} ); }, ); +const Anchor = styled('a')({}); + export type LinkProps = { activeClassName?: string; as?: NextLinkProps['as']; @@ -67,14 +68,14 @@ const Link = React.forwardRef(function Link(props, if (isExternal) { if (noLinkStyle) { - return ; + return ; } - return ; + return ; } if (noLinkStyle) { - return ; + return ; } return ( diff --git a/examples/nextjs-with-typescript/src/Link.tsx b/examples/nextjs-with-typescript/src/Link.tsx index 3a86c99b7266fb..d129f5c17aadf8 100644 --- a/examples/nextjs-with-typescript/src/Link.tsx +++ b/examples/nextjs-with-typescript/src/Link.tsx @@ -1,9 +1,9 @@ -/* eslint-disable jsx-a11y/anchor-has-content */ import * as React from 'react'; import clsx from 'clsx'; import { useRouter } from 'next/router'; import NextLink, { LinkProps as NextLinkProps } from 'next/link'; import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link'; +import { styled } from '@mui/material/styles'; interface NextLinkComposedProps extends Omit, 'href'>, @@ -15,8 +15,7 @@ interface NextLinkComposedProps export const NextLinkComposed = React.forwardRef( function NextLinkComposed(props, ref) { - const { to, linkAs, href, replace, scroll, passHref, shallow, prefetch, locale, ...other } = - props; + const { to, linkAs, href, replace, scroll, shallow, prefetch, locale, ...other } = props; return ( + {/* eslint-disable-next-line jsx-a11y/anchor-has-content */} ); }, ); +const Anchor = styled('a')({}); + export type LinkProps = { activeClassName?: string; as?: NextLinkProps['as']; @@ -67,14 +68,14 @@ const Link = React.forwardRef(function Link(props, if (isExternal) { if (noLinkStyle) { - return ; + return ; } - return ; + return ; } if (noLinkStyle) { - return ; + return ; } return ( diff --git a/examples/nextjs/src/Link.js b/examples/nextjs/src/Link.js index 7e304f4ef85e89..d6f6b14e917779 100644 --- a/examples/nextjs/src/Link.js +++ b/examples/nextjs/src/Link.js @@ -1,14 +1,13 @@ -/* eslint-disable jsx-a11y/anchor-has-content */ import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { useRouter } from 'next/router'; import NextLink from 'next/link'; import MuiLink from '@mui/material/Link'; +import { styled } from '@mui/material/styles'; export const NextLinkComposed = React.forwardRef(function NextLinkComposed(props, ref) { - const { to, linkAs, href, replace, scroll, passHref, shallow, prefetch, locale, ...other } = - props; + const { to, linkAs, href, replace, scroll, shallow, prefetch, locale, ...other } = props; return ( + {/* eslint-disable-next-line jsx-a11y/anchor-has-content */} ); @@ -38,6 +37,8 @@ NextLinkComposed.propTypes = { to: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired, }; +const Anchor = styled('a')({}); + // A styled version of the Next.js Link component: // https://nextjs.org/docs/#with-link const Link = React.forwardRef(function Link(props, ref) { @@ -62,7 +63,7 @@ const Link = React.forwardRef(function Link(props, ref) { if (isExternal) { if (noLinkStyle) { - return ; + return ; } return ;