Revert "fix(SW-2101): do not apply underline to Material icons inside Link and Button"
This reverts commit 35f9c3aab5.
This commit is contained in:
@@ -1,29 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { Children, type ReactNode } from "react"
|
||||
import { Button as ButtonRAC } from "react-aria-components"
|
||||
|
||||
import { buttonVariants } from "./variants"
|
||||
|
||||
import type { ButtonProps } from "./button"
|
||||
|
||||
// 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 buttons as Material Symbols
|
||||
// are implemented as a font and therefore gets underline. Icons inside buttons
|
||||
// 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 Button(props: ButtonProps) {
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
clean,
|
||||
intent,
|
||||
@@ -46,17 +31,9 @@ export default function Button(props: ButtonProps) {
|
||||
variant,
|
||||
})
|
||||
|
||||
const wrappedChildren =
|
||||
typeof children === "function" ? children : wrapTextNodes(children)
|
||||
|
||||
if (restProps.asChild) {
|
||||
const { asChild, ...slotProps } = restProps
|
||||
return (
|
||||
<Slot className={classNames} {...slotProps}>
|
||||
{/* @ts-expect-error: Incorrect types for Slot */}
|
||||
{wrappedChildren}
|
||||
</Slot>
|
||||
)
|
||||
return <Slot className={classNames} {...slotProps} />
|
||||
}
|
||||
|
||||
const { asChild, onClick, disabled, ...racProps } = restProps
|
||||
@@ -66,8 +43,6 @@ export default function Button(props: ButtonProps) {
|
||||
isDisabled={disabled}
|
||||
onPress={onClick}
|
||||
{...racProps}
|
||||
>
|
||||
{wrappedChildren}
|
||||
</ButtonRAC>
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user