Skip to content

Commit

Permalink
fix: added aria-hidden attribute to icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrina-bongiovanni committed Mar 15, 2024
1 parent 80a6586 commit 99e91a3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
- ...
-->

## Versione X.X.X (dd/mm/yyyy)

### Migliorie

- Migliorata l'accessibilità del blocco Icone.

## Versione 11.7.0 (15/03/2024)

### Novità
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
<CardBody tag="div">
{data.icon?.length > 0 && (
<div className="iconblock-icon">
<Icon icon={data.icon} />
<Icon icon={data.icon} ariaHidden={true} />
</div>
)}

Expand Down
3 changes: 2 additions & 1 deletion src/components/ItaliaTheme/Icons/FontAwesomeIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';
import { fontAwesomeAliases } from 'design-comuni-plone-theme/helpers/index';

const FontAwesomeIcon = (props) => {
const { className, icon, prefix, title } = props;
const { className, icon, prefix, title, ariaHidden } = props;
const [loadedIcon, setLoadedIcon] = React.useState({
module: null,
iconName: '',
Expand Down Expand Up @@ -74,6 +74,7 @@ const FontAwesomeIcon = (props) => {
? `<title>${title}</title>${loadedIcon.module.content}`
: loadedIcon.module.content,
}}
aria-hidden={ariaHidden || null}
/>
) : icon ? (
<span className={`icon fa-icon placeholder ${className ?? ''}`}></span>
Expand Down
17 changes: 14 additions & 3 deletions src/components/ItaliaTheme/Icons/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import XTwitterSVG from './svg/XTwitterSVG';
import { FontAwesomeIcon } from 'design-comuni-plone-theme/components/ItaliaTheme';

const Icon = (props) => {
const { icon, className, color, size, padding, ...rest } = props;
const { icon, className, color, size, padding, ariaHidden, ...rest } = props;

if (icon) {
const classes = classNames(
'icon',
Expand All @@ -35,11 +36,21 @@ const Icon = (props) => {
return <XTwitterSVG className={classes} {...rest} />;
} else if (parts.length > 1) {
return (
<FontAwesomeIcon icon={parts} className={`fal ${classes}`} {...rest} />
<FontAwesomeIcon
icon={parts}
className={`fal ${classes}`}
ariaHidden={ariaHidden}
{...rest}
/>
);
} else {
return (
<FontAwesomeIcon icon={icon} className={`fal ${classes}`} {...rest} />
<FontAwesomeIcon
icon={icon}
className={`fal ${classes}`}
ariaHidden={ariaHidden}
{...rest}
/>
);
}
}
Expand Down

0 comments on commit 99e91a3

Please sign in to comment.