Skip to content

Commit

Permalink
fix: remove title attr from some cards through prop in ListingImage t…
Browse files Browse the repository at this point in the history
…o remove title attr where needed (#558)

* fix: remove title attr from CardPersona, add prop in ListingImage to remove title attr where needed through props

* fix: remove title attr from some cards through prop in ListingImage to remove title attr where needed

---------

Co-authored-by: Piero Nicolli <[email protected]>
  • Loading branch information
deodorhunter and pnicolli authored Mar 4, 2024
1 parent 900e4da commit 8459177
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- L'icona per aprire il menu in mobile è ora visibile anche quando l'header del sito è bianca.
- La descrizione nelle card per i punti di contatto non mostrano più tutte le iniziali in maiuscolo.
- Il colore dei link nel menu mobile è ora accessibile per tutti i temi.
- Rimosso attributo title dall'immagine delle card: card con immagine, persona, blocco link completo, contenuto in evidenza, gallery a griglia, in evidenza
- Migliorata l'accessibilità del menu in versione mobile.
- Il layout dei campi di input "in errore" del blocco Form è stato uniformato.
- La tendina delle select nel blocco Form non si sovrappone più ai campi sottostanti.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const CardWithImageTemplate = (props) => {
<ListingText item={item} />
) : null;

const image = ListingImage({ item });
const image = ListingImage({ item, showTitleAttr: false });

const showImage =
(index < imagesToShow || always_show_image) && image != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ const ListingImage = ({
showDefault = false,
className = 'listing-image',
responsive = true,
showTitleAttr = true,
sizes = '(max-width:320px) 200px, (max-width:425px) 300px, (max-width:767px) 500px, 410px',
...imageProps
}) => {
const Image = config.getComponent({ name: 'Image' }).component;
// photogallery needs to check for null image
// https://stackoverflow.com/questions/33136399/is-there-a-way-to-tell-if-reactelement-renders-null
const image = Image({
let commonImageProps = {
item,
'aria-hidden': true,
alt: '',
role: 'presentation',
className,
loading,
title: item.title,
responsive,
sizes,
...imageProps,
});
};
if (showTitleAttr)
commonImageProps = { ...commonImageProps, title: item.title };
// photogallery needs to check for null image
// https://stackoverflow.com/questions/33136399/is-there-a-way-to-tell-if-reactelement-renders-null
const image = Image(commonImageProps);

if (image === null)
return showDefault ? <img src={DefaultImageSVG} alt="" /> : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const CompleteBlockLinksTemplate = (props) => {
)}
<Row className="items">
{items.map((item, index) => {
const image = ListingImage({ item, className: '', sizes: '60px' });
const image = ListingImage({
item,
className: '',
sizes: '60px',
showTitleAttr: false,
});

const BlockExtraTags = getComponentWithFallback({
name: 'BlockExtraTags',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const ContentInEvidenceTemplate = (props) => {
className: 'item-image',
loading: 'eager',
sizes: '(max-width:425px) 400px, (max-width:767px) 520px, 650px',
showTitleAttr: false,
});
const icon = getItemIcon(item);
const BlockExtraTags = getComponentWithFallback({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const GridGalleryTemplate = ({
let image = ListingImage({
item,
className: '',
showTitleAttr: false,
});
let scale = null;
if (index % 7 === 0 || index % 7 === 6 || index % 7 === 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const InEvidenceTemplate = (props) => {
const image = ListingImage({
item,
sizes: '(max-width:320px) 200px, 300px',
showTitleAttr: false,
});
const category = getCategory(item, show_type, show_section, props);
const topics = show_topics ? item.tassonomia_argomenti : null;
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/Cards/CardPersona.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const CardPersona = ({
const image = ListingImage({
item,
sizes: '130px',
showTitleAttr: false,
});

const hasImage = image !== null && showImage;
Expand Down

0 comments on commit 8459177

Please sign in to comment.