|
1 | | -import type React from 'react'; |
2 | 1 | import { cloneElement, forwardRef } from 'react'; |
3 | | -import type { IconSize } from '../icon-config.js'; |
| 2 | +import type { IconProps } from '../icon-config.js'; |
4 | 3 | import { ICON_SIZE_MAP, STROKE_WIDTH_MAP } from '../icon-config.js'; |
5 | | -export interface IconProps extends React.SVGProps<SVGSVGElement> { |
6 | | - size?: IconSize | number; |
7 | | - strokeWidth?: number; |
8 | | - className?: string; |
9 | | -} |
| 4 | +export type { IconProps }; |
| 5 | +const ICON_NAME = 'accessibility'; |
10 | 6 | const SvgAccessibility = forwardRef<SVGSVGElement, IconProps>( |
11 | 7 | ({ color = 'currentColor', size, strokeWidth, className, ...props }, ref) => { |
12 | 8 | const element = ( |
@@ -36,10 +32,22 @@ const SvgAccessibility = forwardRef<SVGSVGElement, IconProps>( |
36 | 32 | const w = element.props.width != null ? Number(element.props.width) : 24; |
37 | 33 | const h = element.props.height != null ? Number(element.props.height) : 24; |
38 | 34 | const viewBoxWhenMissing = `0 0 ${w} ${h}`; |
| 35 | + const isHidden = props['aria-hidden'] === true || props['aria-hidden'] === 'true'; |
| 36 | + const a11yDefaults = isHidden |
| 37 | + ? { |
| 38 | + focusable: 'false', |
| 39 | + } |
| 40 | + : { |
| 41 | + role: 'img', |
| 42 | + 'aria-label': ICON_NAME, |
| 43 | + focusable: 'false', |
| 44 | + }; |
| 45 | + const baseClassName = `signoz-icon signoz-icon-${ICON_NAME}`; |
39 | 46 | const elementProps = { |
| 47 | + ...a11yDefaults, |
40 | 48 | ...props, |
41 | 49 | ref, |
42 | | - className: className ? `signoz-icon ${className}` : 'signoz-icon', |
| 50 | + className: className ? `${baseClassName} ${className}` : baseClassName, |
43 | 51 | ...(!isCustomIcon && { |
44 | 52 | stroke: color, |
45 | 53 | strokeWidth: resolvedStrokeWidth, |
|
0 commit comments