Skip to content

Commit 26ee89a

Browse files
committed
fix(#126): set aria-hidden=false if aria-label is present
1 parent d6d4553 commit 26ee89a

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/converter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ export function convert(
7575
default: {
7676
if (key.indexOf('aria-') === 0 || key.indexOf('data-') === 0) {
7777
mixins.attrs[key.toLowerCase()] = val
78+
if (key === 'aria-label' && !!val) {
79+
mixins.attrs['aria-hidden'] = 'false'
80+
}
7881
} else {
7982
mixins.attrs[camelize(key)] = val
8083
}

src/types/icon-props.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CSSProperties, RefAttributes, SVGAttributes } from 'react'
22

3-
import type { IconProp } from '@fortawesome/fontawesome-svg-core'
3+
import type { IconProp, SizeProp } from '@fortawesome/fontawesome-svg-core'
44

55
import type { AnimationProps } from './animation-props'
66
import { CSSVariables } from './css-variables'
@@ -16,6 +16,8 @@ export interface FontAwesomeIconProps
1616
* @see {@link https://docs.fontawesome.com/web/use-with/react/add-icons}
1717
*/
1818
icon: IconProp
19+
/** The size of the icon from a predefined set of sizes. */
20+
size?: SizeProp | undefined
1921
/**
2022
* Grab the Mask utility when you want to layer two icons but have the inner icon cut out from the icon below so the parent element’s background shows through.
2123
* @see {@link https://docs.fontawesome.com/web/use-with/react/style#mask}

src/types/transform-props.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@ import type {
33
FlipProp,
44
PullProp,
55
RotateProp,
6-
SizeProp,
76
Transform,
87
} from '@fortawesome/fontawesome-svg-core'
98

109
export interface TransformProps {
1110
/**
12-
* Use this property to indicate that the icon is to be used as the decorative bullet
13-
* for a list item. Remember to mark-up the list with `<ul className="fa-ul">` and the list items with
14-
* `<li className="fa-li">`.
11+
* @deprecated Simply wrap the icon instead, no need to pass this property.
12+
*
13+
* @example
14+
* ```tsx
15+
* <ul className='fa-ul'>
16+
* <li>
17+
* <span className='fa-li'>
18+
* <FontAwesomeIcon icon={['fas', 'check']} />
19+
* </span>
20+
* List item with icon
21+
* </li>
22+
* </ul>
23+
* ```
1524
*
16-
* @see {@link https://docs.fontawesome.com/web/use-with/react/style#icons-in-a-list}
1725
* @see {@link https://docs.fontawesome.com/web/style/lists}
1826
*/
1927
listItem?: boolean | undefined
2028
/** Flip the icon horizontally, vertically or both. */
2129
flip?: FlipProp | boolean | undefined
22-
/** The size of the icon from a predefined set of sizes. */
23-
size?: SizeProp | undefined
2430
/** Wrap text around the icon by pulling it left or right. */
2531
pull?: PullProp | undefined
2632
/**

src/utils/get-class-list-from-props.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export function getClassListFromProps(props: FontAwesomeIconProps): string[] {
2929
fixedWidth,
3030
inverse,
3131
border,
32-
listItem,
3332
flip,
3433
size,
3534
rotation,
@@ -56,7 +55,6 @@ export function getClassListFromProps(props: FontAwesomeIconProps): string[] {
5655
if (fixedWidth) result.push(STYLE_CLASSES.fixedWidth)
5756
if (inverse) result.push(STYLE_CLASSES.inverse)
5857
if (border) result.push(STYLE_CLASSES.border)
59-
if (listItem) result.push(STYLE_CLASSES.listItem)
6058
if (flip === true) result.push(STYLE_CLASSES.flip)
6159
if (flip === 'horizontal' || flip === 'both') {
6260
result.push(STYLE_CLASSES.flipHorizontal)

0 commit comments

Comments
 (0)