Skip to content

Commit e30fed2

Browse files
committed
feat: extend button html attributes
1 parent 52b16e0 commit e30fed2

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/Shared/Components/Button/Button.component.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { getButtonDerivedClass } from './utils'
77
import './button.scss'
88

99
const Button = ({
10-
buttonProps = {},
1110
variant = ButtonVariantType.primary,
1211
size = ComponentSizeType.large,
1312
style = ButtonStyleType.default,
@@ -18,6 +17,8 @@ const Button = ({
1817
isLoading,
1918
showTippy,
2019
tippyContent,
20+
type = 'button',
21+
...props
2122
}: ButtonProps) => {
2223
const isDisabled = disabled || isLoading
2324
const iconClass = `dc__no-shrink flex dc__fill-available-space ${BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP[size]}`
@@ -26,11 +27,11 @@ const Button = ({
2627
<Tooltip content={tippyContent} alwaysShowTippyOnHover={showTippy && !!tippyContent}>
2728
<div>
2829
<button
29-
{...buttonProps}
30+
{...props}
3031
disabled={isDisabled}
3132
// eslint-disable-next-line react/button-has-type
32-
type={buttonProps.type || 'button'}
33-
className={`br-4 flex cursor dc__mnw-100 dc__tab-focus dc__position-rel dc__capitalize ${getButtonDerivedClass({ size, variant, style, isLoading })} ${isDisabled ? 'dc__disabled' : ''} ${buttonProps.className || ''}`}
33+
type={type}
34+
className={`br-4 flex cursor dc__mnw-100 dc__tab-focus dc__position-rel dc__capitalize ${getButtonDerivedClass({ size, variant, style, isLoading })} ${isDisabled ? 'dc__disabled' : ''}`}
3435
>
3536
{startIcon && <span className={iconClass}>{startIcon}</span>}
3637
<span className="dc__mxw-150 dc__align-left dc__truncate">{text}</span>

src/Shared/Components/Button/types.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ export enum ButtonStyleType {
1717
neutral = 'neutral',
1818
}
1919

20-
export type ButtonProps = {
21-
buttonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'>
20+
export type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'styles' | 'className'> & {
2221
variant?: ButtonVariantType
2322
size?: ComponentSizeType
2423
style?: ButtonStyleType
2524
text: string
2625
startIcon?: ReactElement
2726
endIcon?: ReactElement
28-
disabled?: boolean
2927
isLoading?: boolean
3028
} & (
31-
| {
32-
showTippy: boolean
33-
tippyContent: TooltipProps['content']
34-
}
35-
| {
36-
showTippy?: never
37-
tippyContent?: never
38-
}
39-
)
29+
| {
30+
showTippy: boolean
31+
tippyContent: TooltipProps['content']
32+
}
33+
| {
34+
showTippy?: never
35+
tippyContent?: never
36+
}
37+
)

src/Shared/Components/ButtonWithLoader/ButtonWithLoader.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export interface ButtonWithLoaderProps {
2929
type?: 'submit' | 'reset' | 'button'
3030
}
3131

32+
/**
33+
* @deprecated use Button instead
34+
*/
3235
export class ButtonWithLoader extends Component<ButtonWithLoaderProps> {
3336
constructor(props) {
3437
super(props)

0 commit comments

Comments
 (0)