Skip to content

Commit 75ccda4

Browse files
committed
Add pending / icon to Button props
1 parent 5f8e161 commit 75ccda4

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/components/Button.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ import {
33
Button as ButtonPrimitive,
44
type ButtonProps as ButtonPrimitiveProps
55
} from 'react-aria-components'
6-
76
import './Button.css'
7+
import type {ComponentType, ReactNode} from 'react'
8+
import {Icon} from './Icon.tsx'
9+
import {ProgressCircle} from './ProgressCircle.tsx'
810

911
export interface ButtonProps extends ButtonPrimitiveProps {
1012
appearance?: 'solid' | 'outline' | 'plain' | 'active'
1113
intent?: 'primary' | 'secondary' | 'danger' | 'warning'
1214
size?: 'small' | 'medium' | 'large' | 'square-petite' | 'icon'
15+
icon?: ComponentType
16+
children?: ReactNode
1317
}
1418

1519
export function Button({
1620
intent = 'primary',
1721
size = 'medium',
1822
appearance = 'solid',
23+
children,
24+
icon,
1925
...props
2026
}: ButtonProps) {
2127
return (
@@ -25,6 +31,13 @@ export function Button({
2531
data-appearance={appearance}
2632
{...props}
2733
className={clsx('alinea-rac-Button', props.className)}
28-
/>
34+
>
35+
{props.isPending ? (
36+
<ProgressCircle isIndeterminate aria-label="Pending..." />
37+
) : (
38+
icon && <Icon icon={icon} data-slot="icon" />
39+
)}
40+
{children}
41+
</ButtonPrimitive>
2942
)
3043
}

0 commit comments

Comments
 (0)