Files
web/packages/design-system/lib/components/Button/Button.tsx
Rasmus Langvad d0546926a9 Merged in fix/3697-prettier-configs (pull request #3396)
fix(SW-3691): Setup one prettier config for whole repo

* Setup prettierrc in root and remove other configs


Approved-by: Joakim Jäderberg
Approved-by: Linus Flood
2026-01-07 12:45:50 +00:00

67 lines
1.6 KiB
TypeScript

import { Button as ButtonRAC } from "react-aria-components"
import { Loading } from "../Loading/Loading"
import { MaterialIcon } from "../Icons/MaterialIcon"
import { Typography } from "../Typography"
import type { ButtonProps } from "./types"
import { variants } from "./variants"
export function Button({
variant,
color,
size,
wrapping,
fullWidth,
leadingIconName,
trailingIconName,
className,
children,
...props
}: ButtonProps) {
const classNames = variants({
variant,
color,
size,
wrapping,
fullWidth,
className,
})
return (
<Typography
variant={
size === "sm"
? "Body/Supporting text (caption)/smBold"
: "Body/Paragraph/mdBold"
}
>
<ButtonRAC {...props} className={classNames}>
{({ isPending }) => {
return (
<>
{leadingIconName && !isPending ? (
<MaterialIcon
icon={leadingIconName}
color="CurrentColor"
size={size === "sm" ? 20 : 24}
/>
) : null}
{children}
{trailingIconName && !isPending ? (
<MaterialIcon
icon={trailingIconName}
color="CurrentColor"
size={size === "sm" ? 20 : 24}
/>
) : null}
{isPending ? (
<Loading size={size === "sm" ? 18 : 20} type="CurrentColor" />
) : null}
</>
)
}}
</ButtonRAC>
</Typography>
)
}