gravity-ui / uikit

https://gravity-ui.com
MIT License
516 stars 84 forks source link

feat(Button): allow to pass any valid `<button>` or `<a>` HTML attributes #1594

Open amje opened 1 month ago

amje commented 1 month ago

This PR introduces an easier way to pass any extra properties to the component and deprecates extraProps prop:

// Before
<Button extraProps={{onKeyDown: () => {}}} />

// After
<Button onKeyDown={() => {}} />

By default, extra properties extend React.ButtonHTMLAttributes and when href property is passed they extend React.AnchorHTMLAttributes.

PR potentially will break types because ButtonProps can no longer be extended in interface declaration:

// Can't extend in interface
interface MyButton extends ButtonProps {
    myProp: string;
}

// This works fine
type MyButton = ButtonProps & {
    myProp: string;
}
gravity-ui-bot commented 1 month ago

Playwright Test Component is ready.

gravity-ui-bot commented 1 month ago

Preview is ready.

goshander commented 1 month ago

@amje aria-label props pass to React component as is, without camelCase converting?

amje commented 1 month ago

@amje aria-label props pass to React component as is, without camelCase converting?

Yes, it's valid