11import React from 'react' ;
22import { ExclamationCircleIcon , ExclamationTriangleIcon } from '@patternfly/react-icons' ;
3- import { Button , Tooltip , TooltipProps } from '@patternfly/react-core' ;
3+ import { Button , Icon , Tooltip , TooltipProps } from '@patternfly/react-core' ;
44import clsx from 'clsx' ;
55import { createUseStyles } from 'react-jss' ;
66
@@ -53,6 +53,8 @@ export interface CullingInformation extends Omit<TooltipProps, 'content'> {
5353 render ?: Render ;
5454 /** Optional custom warning message */
5555 message ?: string ;
56+ /** Accessible label for the icon */
57+ "aria-label" ?: string ;
5658}
5759
5860const CullingInformation : React . FunctionComponent < CullingInformation > = ( {
@@ -64,6 +66,7 @@ const CullingInformation: React.FunctionComponent<CullingInformation> = ({
6466 children,
6567 render,
6668 message,
69+ "aria-label" : ariaLabel ,
6770 ...props
6871} ) => {
6972 const classes = useStyles ( ) ;
@@ -102,23 +105,22 @@ const CullingInformation: React.FunctionComponent<CullingInformation> = ({
102105 className = { clsx ( { [ classes . inventoryCullingWarning ] : isWarn , [ classes . inventoryCullingDanger ] : isError } , className ) }
103106 >
104107 { isWarn &&
105- < Button variant = "plain" aria-label = "Action" role = "tooltip" icon = { < ExclamationTriangleIcon className = { clsx ( classes . iconMargin , classes . inventoryCullingWarning ) } /> } / >
108+ < Icon status = "warning" > < ExclamationTriangleIcon className = { clsx ( classes . iconMargin ) } aria-label = { ariaLabel || "Warning" } /> </ Icon >
106109 }
107110 { isError &&
108- < Button variant = "plain" aria-label = "Action" role = "tooltip" icon = { < ExclamationCircleIcon className = { clsx ( classes . iconMargin , classes . inventoryCullingDanger ) } /> } / >
111+ < Icon status = "danger" > < ExclamationCircleIcon className = { clsx ( classes . iconMargin ) } aria-label = { ariaLabel || "Danger" } /> </ Icon >
109112 }
110113 < span className = { clsx ( classes . messageFont ) } >
111114 { render ( { msg } ) }
112115 </ span >
113-
114116 </ span >
115117 ) ;
116118 }
117119
118120 return (
119121 < >
120- { isError && < Tooltip { ...props } content = { < div > { msg } </ div > } > < Button variant = "plain" role = "tooltip" icon = { < ExclamationTriangleIcon className = { clsx ( classes . inventoryCullingWarning ) } /> } alt = "warning icon" /> </ Tooltip > }
121- { isWarn && < Tooltip { ...props } content = { < div > { msg } </ div > } > < Button variant = "plain" role = "tooltip" icon = { < ExclamationCircleIcon className = { clsx ( classes . inventoryCullingDanger ) } /> } alt = "danger icon" /> </ Tooltip > }
122+ { isError && < Tooltip { ...props } content = { < div > { msg } </ div > } > < Button variant = "plain" icon = { < Icon status = "warning" > < ExclamationTriangleIcon /> </ Icon > } aria-label = { ariaLabel || "Warning" } /> </ Tooltip > }
123+ { isWarn && < Tooltip { ...props } content = { < div > { msg } </ div > } > < Button variant = "plain" icon = { < Icon status = "danger" > < ExclamationCircleIcon /> </ Icon > } aria-label = { ariaLabel || "Danger" } /> </ Tooltip > }
122124 { children }
123125 </ >
124126 ) ;
0 commit comments