Revert "fix(SW-2101): do not apply underline to Material icons inside Link and Button"

This reverts commit 35f9c3aab5.
This commit is contained in:
Michael Zetterberg
2025-04-02 10:29:43 +02:00
parent b6db9757d8
commit be04600863
7 changed files with 8 additions and 78 deletions

View File

@@ -1,7 +1,7 @@
"use client"
import NextLink from "next/link"
import { usePathname, useSearchParams } from "next/navigation"
import { Children, type ReactNode, useCallback, useMemo } from "react"
import { useCallback, useMemo } from "react"
import { useCheckIfExternalLink } from "@/hooks/useCheckIfExternalLink"
import { trackClick } from "@/utils/tracking"
@@ -10,21 +10,7 @@ import { linkVariants } from "./variants"
import type { LinkProps } from "./link"
// We wrap all text nodes to avoid having consumers manually wrap text nodes in spans.
// This is so that we can better support underline on links as Material Symbols
// are implemented as a font and therefore gets underline. Icons inside links
// should not get an underline.
function wrapTextNodes(children: ReactNode): ReactNode {
return Children.map(children, (child) => {
if (typeof child === "string") {
return <span>{child}</span>
}
return child
})
}
export default function Link({
children,
active,
className,
color,
@@ -110,9 +96,6 @@ export default function Link({
className: classNames,
}
const wrappedChildren =
typeof children === "function" ? children : wrapTextNodes(children)
return isExternal ? (
<a
{...linkProps}
@@ -122,9 +105,7 @@ export default function Link({
onClick(e)
}
}}
>
{wrappedChildren}
</a>
/>
) : (
<NextLink
scroll={scroll}
@@ -140,8 +121,6 @@ export default function Link({
id={trackingId}
{...props}
{...linkProps}
>
{wrappedChildren}
</NextLink>
/>
)
}

View File

@@ -43,10 +43,7 @@
font-weight: var(--typography-Body-Underline-fontWeight);
letter-spacing: var(--typography-Body-Underline-letterSpacing);
line-height: var(--typography-Body-Underline-lineHeight);
& span:not(:global(.material-symbols)) {
text-decoration: underline;
}
text-decoration: underline;
}
.myPageMobileDropdown {