Skip to content

Commit

Permalink
feat: update mui link theme styles (#245) (#246)
Browse files Browse the repository at this point in the history
Co-authored-by: Fran McDade <[email protected]>
  • Loading branch information
frano-m and Fran McDade authored Oct 29, 2024
1 parent 4b832ac commit 7f401b8
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/components/Index/components/TitleCell/titleCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TEXT_BODY_400 } from "../../../../theme/common/typography";
import { Link, LinkProps } from "../../../Links/components/Link/link";
import { TitleCell as Cell } from "./titleCell.styles";

export interface TitleCellProps extends LinkProps {
export interface TitleCellProps extends Omit<LinkProps, "title"> {
title: ReactNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Link } from "../../../../../../../Links/components/Link/link";
export const StyledLink = styled(Link)`
&.MuiLink-root {
flex: none;
text-decoration: none !important;
img {
margin: 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import { BaseComponentProps } from "../../../../../../../../theme/common/types";
import {
ImageSrc,
StaticImage,
} from "../../../../../../../common/StaticImage/staticImage";
import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
import { StyledLink } from "./logo.styles";

export interface LogoProps {
export interface LogoProps extends BaseComponentProps {
alt: string;
className?: string;
height?: number;
link: string;
src: ImageSrc;
Expand All @@ -30,6 +30,7 @@ export const Logo = ({
className={className}
label={<StaticImage alt={alt} height={height} src={src} width={width} />}
target={target}
underline="none"
url={link}
/>
);
Expand Down
33 changes: 17 additions & 16 deletions src/components/Links/components/Link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import NLink from "next/link";
import React, { ReactNode } from "react";
import { isValidUrl } from "../../../../common/utils";
import { BaseComponentProps } from "../../../../theme/common/types";
import { CopyToClipboard } from "../../../common/CopyToClipboard/copyToClipboard";
import { TypographyProps } from "../../../common/Typography/common/entities";
import { ANCHOR_TARGET, REL_ATTRIBUTE, Url } from "../../common/entities";
Expand All @@ -16,11 +17,11 @@ import {
} from "../../common/utils";
import { ExploreViewLink } from "./components/ExploreViewLink/exploreViewLink";

export interface LinkProps {
className?: string;
export interface LinkProps
extends BaseComponentProps,
Omit<MLinkProps, "children" | "component"> {
copyable?: boolean;
label: ReactNode /* link label may be an element */;
noWrap?: MLinkProps["noWrap"];
onClick?: () => void;
target?: ANCHOR_TARGET;
TypographyProps?: TypographyProps;
Expand Down Expand Up @@ -55,19 +56,19 @@ export const Link = ({
/* Client-side navigation */
return (
<>
<NLink href={url} legacyBehavior passHref>
<MLink
className={className}
rel={REL_ATTRIBUTE.NO_OPENER}
noWrap={noWrap}
target={target || ANCHOR_TARGET.SELF}
onClick={onClick}
{...TypographyProps}
{...props}
>
{label}
</MLink>
</NLink>
<MLink
className={className}
component={NLink}
href={url}
noWrap={noWrap}
onClick={onClick}
rel={REL_ATTRIBUTE.NO_OPENER}
target={target || ANCHOR_TARGET.SELF}
{...TypographyProps}
{...props}
>
{label}
</MLink>
{copyable && <CopyToClipboard copyStr={url} />}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ export const Alert = styled(MAlert)`
.MuiAlert-message {
${textBodySmall400};
text-align: center;
.MuiLink-root {
color: inherit;
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export const CookieBanner = styled(Banner)`
.MuiLink-root {
color: inherit;
text-decoration: underline;
&:hover {
text-decoration: none;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import React, { forwardRef, Fragment, ReactNode } from "react";
import { FLAG } from "../../../../../hooks/useFeatureFlag/common/entities";
import { setLocalStorage } from "../../../../../hooks/useLocalStorage/common/utils";
import { useLocalStorage } from "../../../../../hooks/useLocalStorage/useLocalStorage";
import { BaseComponentProps } from "../../../../../theme/common/types";
import { ButtonPrimary } from "../../../Button/components/ButtonPrimary/buttonPrimary";
import { DismissibleBanner } from "../DismissibleBanner/dismissibleBanner";
import { CookieBanner as Banner } from "./cookieBanner.styles";

export interface CookieBannerProps extends MAlertProps {
className?: string;
export interface CookieBannerProps extends BaseComponentProps, MAlertProps {
localStorageKey: string;
message?: ReactNode;
secondaryAction?: ReactNode;
Expand Down
16 changes: 6 additions & 10 deletions src/components/common/Breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import ChevronRightRoundedIcon from "@mui/icons-material/ChevronRightRounded";
import {
Link as BreadcrumbLink,
Breadcrumbs as MBreadcrumbs,
Typography,
} from "@mui/material";
import Link from "next/link";
import { Link, Breadcrumbs as MBreadcrumbs, Typography } from "@mui/material";
import NLink from "next/link";
import React, { ReactNode } from "react";
import { BaseComponentProps } from "../../../theme/common/types";

export interface Breadcrumb {
path: string;
text: ReactNode;
}

export interface BreadcrumbsProps {
export interface BreadcrumbsProps extends BaseComponentProps {
breadcrumbs: Breadcrumb[];
className?: string;
Separator?: ReactNode;
}

Expand All @@ -29,8 +25,8 @@ export const Breadcrumbs = ({
<MBreadcrumbs className={className} separator={Separator}>
{breadcrumbs.map(({ path, text }, b) =>
path ? (
<Link key={`${path}${b}`} href={path} legacyBehavior passHref>
<BreadcrumbLink>{text}</BreadcrumbLink>
<Link component={NLink} key={b} href={path}>
{text}
</Link>
) : (
<Typography key={`${path}${b}`} maxWidth={180} noWrap>
Expand Down
5 changes: 4 additions & 1 deletion src/theme/common/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,14 @@ export const MuiInputBase = (theme: Theme): Components["MuiInputBase"] => {
*/
export const MuiLink: Components["MuiLink"] = {
defaultProps: {
underline: "hover",
underline: "always",
},
styleOverrides: {
root: {
cursor: "pointer",
textDecorationColor: "currentColor",
textDecorationSkipInk: "none",
textUnderlinePosition: "from-font",
},
},
};
Expand Down
3 changes: 3 additions & 0 deletions src/theme/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface BaseComponentProps {
className?: string;
}

0 comments on commit 7f401b8

Please sign in to comment.