import {
forwardRef,
type ButtonHTMLAttributes,
type ElementType,
type ForwardedRef,
type PropsWithChildren,
} from 'react'
import {
getButtonProps,
getButtonIconOptions,
getIconProps,
splitClassNameProp,
} from '@pluralsight/headless-styles'
import type { ButtonOptions } from '@pluralsight/headless-styles/types'
export interface ButtonProps
extends ButtonOptions,
ButtonHTMLAttributes {
endIcon?: ElementType
startIcon?: ElementType
}
function ButtonEl(
props: PropsWithChildren,
ref: ForwardedRef
) {
const {
children,
disabled,
size,
sentiment,
usage,
startIcon,
endIcon,
...nativeProps
} = props
const btnProps = getButtonProps({
classNames: splitClassNameProp(nativeProps.className),
disabled,
size,
sentiment,
usage,
})
const iconProps = getIconProps(getButtonIconOptions(size))
const StartIcon = startIcon
const EndIcon = endIcon
return (
)
}
export const Button = forwardRef(ButtonEl)