@@ -14,47 +14,36 @@ const IconBasicComponent = (
14
14
ref : React . ForwardedRef < HTMLSpanElement >
15
15
) : JSX . Element | null => {
16
16
const device = useMediaDevice ( ) ;
17
+ const ariaProps = pickAriaProps ( props ) ;
18
+ const { disabled, altText, onClick, screenReaderText, ...iconProps } = props ;
17
19
18
20
const isLinearIcon =
19
21
! ! props . color || ! ! props . customIconStyles ?. color || ! ! props . customIconStyles ?. [ device ] ?. color ;
20
22
21
- const iconWithTitle = (
22
- < IconStandAlone { ...props } ref = { ref } altText = "" icon = { props . icon } linearIcon = { isLinearIcon } />
23
- ) ;
24
-
25
- const buildButton = ( ) : JSX . Element => {
26
- const ariaProps = pickAriaProps ( props ) ;
27
- let iconElement = < > </ > ;
28
- if ( props . icon ) {
29
- if ( props . onClick ) {
30
- iconElement = (
31
- < IconButtonStyled
32
- { ...ariaProps }
33
- $customIconStyles = { props . customIconStyles }
34
- $height = { props . height }
35
- $width = { props . width }
36
- aria-disabled = { props . disabled }
37
- aria-label = { props [ 'aria-label' ] || props . altText }
38
- disabled = { props . disabled }
39
- tabIndex = { tabIndex }
40
- type = { ButtonType . BUTTON }
41
- onClick = { props . onClick }
42
- >
43
- < ScreenReaderOnly > { props . screenReaderText } </ ScreenReaderOnly >
44
- { iconWithTitle }
45
- </ IconButtonStyled >
46
- ) ;
47
- } else {
48
- iconElement = (
49
- < IconStandAlone { ...props } ref = { ref } icon = { props . icon } linearIcon = { isLinearIcon } />
50
- ) ;
51
- }
52
- return iconElement ;
53
- }
54
- return iconElement ;
55
- } ;
56
-
57
- return buildButton ( ) ;
23
+ if ( ! props . icon ) {
24
+ return < > </ > ;
25
+ }
26
+
27
+ if ( props . onClick ) {
28
+ return (
29
+ < IconButtonStyled
30
+ { ...ariaProps }
31
+ $customIconStyles = { props . customIconStyles }
32
+ $height = { props . height }
33
+ $width = { props . width }
34
+ aria-disabled = { disabled }
35
+ aria-label = { props [ 'aria-label' ] || altText }
36
+ disabled = { disabled }
37
+ type = { ButtonType . BUTTON }
38
+ onClick = { onClick }
39
+ >
40
+ < ScreenReaderOnly > { screenReaderText } </ ScreenReaderOnly >
41
+ < IconStandAlone { ...iconProps } ref = { ref } linearIcon = { isLinearIcon } />
42
+ </ IconButtonStyled >
43
+ ) ;
44
+ }
45
+
46
+ return < IconStandAlone { ...iconProps } ref = { ref } altText = { altText } linearIcon = { isLinearIcon } /> ;
58
47
} ;
59
48
60
49
export const IconBasic = React . forwardRef ( IconBasicComponent ) ;
0 commit comments