Skip to content

Commit

Permalink
fix: added aria label to icons across ioComune
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrina-bongiovanni committed Feb 28, 2024
1 parent 01ed12b commit cc7bd97
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HeaderSearch = () => {
}}
href="#search"
>
<Icon icon="it-search" />
<Icon icon="it-search" title={intl.formatMessage(messages.search)} />
</a>
</div>
<SearchModal
Expand Down
8 changes: 7 additions & 1 deletion src/components/ItaliaTheme/Header/SocialHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const SocialHeader = () => {
target="_blank"
rel="noopener noreferrer"
>
<Icon color="" icon={social.icon} padding={false} size="" />
<Icon
color=""
icon={social.icon}
padding={false}
size=""
title={social.title}
/>
</a>
</li>
))}
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Icons/DesignIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const Icon = ({ icon, title, className, size }) => {
? `<title>${title}</title>${name.content}`
: name.content,
}}
alt={title}
/>
);
}
Expand Down
7 changes: 4 additions & 3 deletions 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, socialTitle } = props;
const [loadedIcon, setLoadedIcon] = React.useState({
module: null,
iconName: '',
Expand Down Expand Up @@ -35,8 +35,8 @@ const FontAwesomeIcon = (props) => {
prefixKey === 'fab'
? 'brands'
: prefixKey === 'far'
? 'regular'
: 'solid',
? 'regular'
: 'solid',
iconName,
];
};
Expand Down Expand Up @@ -74,6 +74,7 @@ const FontAwesomeIcon = (props) => {
? `<title>${title}</title>${loadedIcon.module.content}`
: loadedIcon.module.content,
}}
alt={socialTitle || title}
/>
) : icon ? (
<span className={`icon fa-icon placeholder ${className ?? ''}`}></span>
Expand Down
16 changes: 13 additions & 3 deletions src/components/ItaliaTheme/Icons/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, title, ...rest } = props;
if (icon) {
const classes = classNames(
'icon',
Expand All @@ -35,11 +35,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}`}
socialTitle={title}
{...rest}
/>
);
} else {
return (
<FontAwesomeIcon icon={icon} className={`fal ${classes}`} {...rest} />
<FontAwesomeIcon
icon={icon}
className={`fal ${classes}`}
socialTitle={title}
{...rest}
/>
);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Icons/svg/TelegramSVG.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const TelegramSVG = (props) => (
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 496 512"
alt="Telegram"
>
<path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm121.8 169.9l-40.7 191.8c-3 13.6-11.1 16.9-22.4 10.5l-62-45.7-29.9 28.8c-3.3 3.3-6.1 6.1-12.5 6.1l4.4-63.1 114.9-103.8c5-4.4-1.1-6.9-7.7-2.5l-142 89.4-61.2-19.1c-13.3-4.2-13.6-13.3 2.8-19.7l239.1-92.2c11.1-4 20.8 2.7 17.2 19.5z"></path>
</svg>
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Icons/svg/XTwitterSVG.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const XTwitterSVG = (props) => (
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 496 512"
alt="Twitter"
>
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
</svg>
Expand Down
19 changes: 17 additions & 2 deletions src/components/ItaliaTheme/View/Commons/Argument/ArgumentIcon.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useIntl, defineMessages } from 'react-intl';
import PropTypes from 'prop-types';
import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';

Expand All @@ -8,10 +9,17 @@ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
* @params {object} Dates: object.
* @returns {string} Markup of the component.
*/
const ArgumentIcon = ({ icon }) => {
const ArgumentIcon = ({ icon, title }) => {
const intl = useIntl();

return icon ? (
<div className="icon-argument-container mb-2">
<Icon icon={icon} />
<Icon
icon={icon}
title={intl.formatMessage(messages.iconTitle, {
argument_title: title,
})}
/>
</div>
) : null;
};
Expand All @@ -21,3 +29,10 @@ export default ArgumentIcon;
ArgumentIcon.propTypes = {
icon: PropTypes.string,
};

const messages = defineMessages({
iconTitle: {
id: 'icon_title',
defaultMessage: "Icona per l'argomento {argument_title}",
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const PaginaArgomentoView = ({ content }) => {
>
<Breadcrumbs pathname={location.pathname} />

<ArgumentIcon icon={content.icona} />
<ArgumentIcon icon={content.icona} title={content.title} />
<h1 className="mb-3" data-element="page-name">
{content?.title}
</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';

import config from '@plone/volto/registry';

const messages = {
externalLink: {
id: 'external_link',
defaultMessage: 'Link esterno',
},
};

const UniversalLink = ({
href,
item = null,
Expand Down Expand Up @@ -121,7 +128,7 @@ const UniversalLink = ({
config.settings.siteProperties.markSpecialLinks && (
<Icon
icon="it-external-link"
title={title}
title={title || intl.formatMessage(messages.externalLink)}
size="xs"
className="ms-1 align-sub external-link"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ const Navigation = ({ pathname }) => {
<HeaderToggler
aria-controls="#it-navigation-collapse"
aria-expanded={collapseOpen}
aria-label="Toggle navigation"
aria-label={intl.formatMessage(messages.toggleNavigation)}
onClick={() => {
setCollapseOpen(!collapseOpen);
setFocusTrapActive(!focusTrapActive);
}}
>
<Icon icon="it-burger" />
<Icon
icon="it-burger"
title={intl.formatMessage(messages.toggleNavigation)}
/>
</HeaderToggler>
<Collapse
header
Expand Down Expand Up @@ -161,7 +164,12 @@ const Navigation = ({ pathname }) => {
title={intl.formatMessage(messages.CloseMenu)}
onClick={() => setCollapseOpen(!collapseOpen)}
>
<Icon color="white" icon="it-close-big" padding={false} />
<Icon
color="white"
icon="it-close-big"
padding={false}
title={intl.formatMessage(messages.CloseMenu)}
/>
</button>
</div>
</FocusLock>
Expand All @@ -177,6 +185,10 @@ const messages = defineMessages({
id: 'close-menu',
defaultMessage: 'Chiudi menu',
},
toggleNavigation: {
id: 'toggle-navigation',
defaultMessage: 'Apri il menu',
},
});

Navigation.propTypes = {
Expand Down

0 comments on commit cc7bd97

Please sign in to comment.