-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButton.tsx
More file actions
44 lines (39 loc) · 1.04 KB
/
Button.tsx
File metadata and controls
44 lines (39 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react';
import { createCssClassNames } from '@ids-internal/shared/css.class.names';
import { ButtonProps } from './Button.types';
const Button = ({
onClick,
children,
ariaLabel,
disabled = false,
extraAria = {},
extraClasses = '',
size = 'medium',
title = '',
type = 'primary',
}: ButtonProps) => {
const classes = createCssClassNames({
'ids-btn': true,
[`ids-btn--${type}`]: true,
[`ids-btn--${size}`]: true,
'ids-btn--disabled': disabled,
[extraClasses]: !!extraClasses,
});
const btnAriaLabel = ariaLabel ?? (typeof children === 'string' ? children : undefined);
return (
<button
aria-disabled={disabled}
aria-label={btnAriaLabel}
className={classes}
disabled={disabled}
onClick={onClick}
role="button"
title={title}
type="button"
{...extraAria}
>
{children}
</button>
);
};
export default Button;