From f36c5c103df04b8c5cca05885f1cf90a322129c7 Mon Sep 17 00:00:00 2001 From: NicolaZ <116741115+NicolaZivago@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:49:40 +0100 Subject: [PATCH 001/270] docs: aggiunto campegine a publiccode.yml (#160) add campegine --- publiccode.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/publiccode.yml b/publiccode.yml index a57a7c5f6..e81c3d183 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -245,6 +245,7 @@ usedBy: - Camera di Commercio di Reggio Emilia - Comune della Spezia - Comune di Bibbiano + - Comune di Campegine - Comune di Camposanto - Comune di Cantagallo - Comune di Cavezzo From 5172337fce80452311249c81b16397bd826aa7c0 Mon Sep 17 00:00:00 2001 From: NicolaZ <116741115+NicolaZivago@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:50:05 +0100 Subject: [PATCH 002/270] docs: aggiunto canossa a publiccode.yml (#161) add canossa --- publiccode.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/publiccode.yml b/publiccode.yml index e81c3d183..0b616cd3a 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -247,6 +247,7 @@ usedBy: - Comune di Bibbiano - Comune di Campegine - Comune di Camposanto + - Comune di Canossa - Comune di Cantagallo - Comune di Cavezzo - Comune di Cavriago From 23f9c501634795f0263e0c7bb66eb26768853e65 Mon Sep 17 00:00:00 2001 From: NicolaZ <116741115+NicolaZivago@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:50:36 +0100 Subject: [PATCH 003/270] docs: aggiornata lista dei comuni nel README.md (#162) * Update README.md aggiornamento esempio siti * Update README.md aggiornata lista --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index be76131e2..3b8dda3a5 100644 --- a/README.md +++ b/README.md @@ -68,26 +68,47 @@ Si veda ad esempio: - [Biblioteche Pianura Est](https://bibest.it) - [Camera di Commercio dell'Umbria](https://www.umbria.camcom.it/) - [Camera di Commercio di Reggio Emilia](https://www.re.camcom.gov.it/) +- [Comune della Spezia](https://www.comune.laspezia.it/) - [Comune di Bibbiano](https://www.comune.bibbiano.re.it/) +- [Comune di Borgo Tossignano](https://www.comune.borgotossignano.bo.it/) - [Comune di Campegine](https://www.comune.campegine.re.it/) - [Comune di Camposanto](https://www.comune.camposanto.mo.it/) - [Comune di Canossa](https://www.comune.canossa.re.it/) - [Comune di Cantagallo](https://www.comune.cantagallo.po.it/) +- [Comune di Casalfiumanese](https://www.comune.casalfiumanese.bo.it/) +- [Comune di Castel del Rio](https://www.comune.casteldelrio.bo.it/) +- [Comune di Cavezzo](https://www.comune.cavezzo.mo.it/) - [Comune di Cavriago](https://www.comune.cavriago.re.it/) +- [Comune di Concordia sul Secchia](https://www.comune.concordia.mo.it/) +- [Comune di Dozza](https://www.comune.dozza.bo.it/) +- [Comune di Finale Emilia](https://www.comune.finale.mo.it/) +- [Comune di Fiorano Modenese](https://www.comune.fiorano-modenese.mo.it/) +- [Comune di Fontanelice](https://www.comune.fontanelice.bo.it/) +- [Comune di Formigine](https://www.comune.formigine.mo.it/) +- [Comune di Frassinoro](https://www.comune.frassinoro.mo.it/) - [Comune di Gattatico](https://www.comune.gattatico.re.it/) - [Comune di Imola](https://www.comune.imola.bo.it) +- [Comune di Maranello](https://www.comune.maranello.mo.it/) - [Comune di Medolla](https://www.comune.medolla.mo.it/) - [Comune di Mirandola](https://www.comune.mirandola.mo.it/) - [Comune di Modena](https://www.comune.modena.it/) - [Comune di Montecchio Emilia](https://www.comune.montecchio-emilia.re.it/) +- [Comune di Montefiorino](https://www.comune.montefiorino.mo.it/) +- [Comune di Mordano](https://www.comune.mordano.bo.it/) - [Comune di Novellara](https://www.comune.novellara.re.it/) +- [Comune di Palagano](https://www.comune.palagano.mo.it/) - [Comune di Parma](https://www.comune.parma.it/) - [Comune di Piacenza](https://www.comune.piacenza.it/) +- [Comune di Prignano sulla Secchia](https://www.comune.prignano.mo.it/) - [Comune di Reggio Emilia](https://www.comune.re.it/) +- [Comune di San Felice sul Panaro](https://www.comune.sanfelice.mo.it/) - [Comune di San Lazzaro di Savena](https://www.comune.sanlazzaro.bo.it) - [Comune di San Polo d'Enza](https://www.comune.sanpolodenza.re.it/) - [Comune di San Possidonio](https://www.comune.sanpossidonio.mo.it/) +- [Comune di San Prospero](https://www.comune.sanprospero.mo.it/) - [Comune di Santilario d'Enza](https://www.comune.santilariodenza.re.it/) +- [Comune di Sassuolo](https://www.comune.sassuolo.mo.it/) +- [Comune di Toscolano Maderno](https://www.comune.toscolanomaderno.bs.it/) - [Comune di Vaiano](https://www.comune.vaiano.po.it/) - [Comune di Vernio](https://www.comune.vernio.po.it/) - [Comando Generale della Guardia di Finanza](https://www.gdf.gov.it/it) @@ -95,6 +116,7 @@ Si veda ad esempio: - [Nuovo Circondario Imolese](https://www.nuovocircondarioimolese.it) - [Ospedali Galliera - Bilancio Sociale](https://bilanciosociale.galliera.it) - [Provincia di Pisa](https://www.provincia.pisa.it/) +- [Unione Comuni Distretto Ceramico](https://www.distrettoceramico.mo.it/) - [UCMAN (Unione dei Comuni Modenesi Area Nord)](https://www.unioneareanord.mo.it/) - [Unione Val d'Enza](https://www.unionevaldenza.it/) - [Unione Val di Bisenzio](https://www.bisenzio.it/) From 3748bcddd93d86137f74bd4311ebe50600a04549 Mon Sep 17 00:00:00 2001 From: NicolaZ <116741115+NicolaZivago@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:51:28 +0100 Subject: [PATCH 004/270] docs: aggiunti i comuni di nci a publiccode.yml (#163) add NCI Co-authored-by: Piero Nicolli --- publiccode.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/publiccode.yml b/publiccode.yml index 0b616cd3a..406d8c165 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -245,16 +245,21 @@ usedBy: - Camera di Commercio di Reggio Emilia - Comune della Spezia - Comune di Bibbiano + - Comune di Borgo Tossignano - Comune di Campegine - Comune di Camposanto - Comune di Canossa - Comune di Cantagallo + - Comune di Casalfiumanese + - Comune di Castel del Rio - Comune di Cavezzo - Comune di Cavriago - Comune di Concordia sul Secchia + - Comune di Dozza - Comune di Gattatico - Comune di Finale Emilia - Comune di Fiorano Modenese + - Comune di Fontanelice - Comune di Formigine - Comune di Frassinoro - Comune di Imola @@ -264,6 +269,7 @@ usedBy: - Comune di Modena - Comune di Montecchio Emilia - Comune di Montefiorino + - Comune di Mordano - Comune di Novellara - Comune di Palagano - Comune di Parma From 27ba53db1fb14b318f0d792545481903cd1dea4c Mon Sep 17 00:00:00 2001 From: Piero Nicolli Date: Mon, 18 Dec 2023 14:03:15 +0100 Subject: [PATCH 005/270] fix: external-link icon colors --- RELEASE.md | 6 ++++++ .../Blocks/_completeBlockLinkstemplate.scss | 4 ---- src/theme/ItaliaTheme/Blocks/_ctaBlock.scss | 5 ----- src/theme/ItaliaTheme/Blocks/_imageBlock.scss | 4 ++++ src/theme/ItaliaTheme/_common.scss | 21 ++----------------- 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index db03b1c6d..1a68ead0c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -41,6 +41,12 @@ - ... --> +## Versione 10.6.4 (18/12/2023) + +### Fix + +- Colori delle icone che specificano che un link è esterno che in alcuni casi erano errati. + ## Versione 10.6.3 (15/12/2023) ### Fix diff --git a/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss b/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss index 6cc796cce..b5d6419f1 100644 --- a/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss +++ b/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss @@ -45,10 +45,6 @@ font-size: 1rem !important; font-weight: 700 !important; line-height: 1.44444rem; - - .external-link { - fill: $external-link-fill-buttons !important; - } } .card:after { diff --git a/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss b/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss index 8177735a5..d1b759154 100644 --- a/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +++ b/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss @@ -42,17 +42,12 @@ &:focus { background: $secondary-text; color: $secondary; - - .external-link { - fill: #004080 !important; - } } .external-link { position: absolute; top: 3px; right: 3px; - fill: $external-link-fill-buttons !important; } } diff --git a/src/theme/ItaliaTheme/Blocks/_imageBlock.scss b/src/theme/ItaliaTheme/Blocks/_imageBlock.scss index f4c6b3ad8..1f79d377c 100644 --- a/src/theme/ItaliaTheme/Blocks/_imageBlock.scss +++ b/src/theme/ItaliaTheme/Blocks/_imageBlock.scss @@ -17,4 +17,8 @@ &.right { margin-bottom: 0; } + + .external-link { + display: none; + } } diff --git a/src/theme/ItaliaTheme/_common.scss b/src/theme/ItaliaTheme/_common.scss index da45026c7..10e698873 100644 --- a/src/theme/ItaliaTheme/_common.scss +++ b/src/theme/ItaliaTheme/_common.scss @@ -65,34 +65,17 @@ } } - .btn-primary, - .btn-secondary, - .btn-tertiary, - .draftjs-buttons { - .external-link { - fill: $external-link-fill-buttons !important; - } - } - .external-link { - fill: $link-color !important; + fill: currentColor; &.align-sub { vertical-align: sub; } - - &:hover { - fill: #004080 !important; - } - } - - .it-footer-small-prints-list .external-link { - fill: $external-link-fill-subfooter !important; } } .icon.external-link.icon-xs { - height: 1rem; + height: 1rem !important; } section.it-page-section, From c962dc699f850ff9f5206afb01abe38d2577a3cf Mon Sep 17 00:00:00 2001 From: Piero Nicolli Date: Mon, 18 Dec 2023 14:04:23 +0100 Subject: [PATCH 006/270] docs: updated publiccode --- publiccode.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/publiccode.yml b/publiccode.yml index 406d8c165..3fd040c66 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -227,9 +227,9 @@ maintenance: name: io-Comune - Il sito AgID per Comuni ed Enti Pubblici platforms: - web -releaseDate: '2023-12-15' +releaseDate: '2023-12-18' softwareType: standalone/web -softwareVersion: 10.6.3 +softwareVersion: 10.6.4 url: 'https://github.com/italia/design-comuni-plone-theme' usedBy: - ASP Comuni Modenesi Area Nord From 22cce64d7ed5083d71dbd334760dc0e509dc13b0 Mon Sep 17 00:00:00 2001 From: Piero Nicolli Date: Mon, 18 Dec 2023 14:06:02 +0100 Subject: [PATCH 007/270] chore: release v10.6.4 --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6a01d4f..ec47e63ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ +## [10.6.4](https://github.com/redturtle/design-comuni-plone-theme/compare/v10.6.3...v10.6.4) (2023-12-18) + + +### Bug Fixes + +* external-link icon colors ([27ba53d](https://github.com/redturtle/design-comuni-plone-theme/commit/27ba53db1fb14b318f0d792545481903cd1dea4c)) + + +### Documentation + +* aggiornata lista dei comuni nel README.md ([#162](https://github.com/redturtle/design-comuni-plone-theme/issues/162)) ([23f9c50](https://github.com/redturtle/design-comuni-plone-theme/commit/23f9c501634795f0263e0c7bb66eb26768853e65)) +* aggiunti i comuni di nci a publiccode.yml ([#163](https://github.com/redturtle/design-comuni-plone-theme/issues/163)) ([3748bcd](https://github.com/redturtle/design-comuni-plone-theme/commit/3748bcddd93d86137f74bd4311ebe50600a04549)) +* aggiunto campegine a publiccode.yml ([#160](https://github.com/redturtle/design-comuni-plone-theme/issues/160)) ([f36c5c1](https://github.com/redturtle/design-comuni-plone-theme/commit/f36c5c103df04b8c5cca05885f1cf90a322129c7)) +* aggiunto canossa a publiccode.yml ([#161](https://github.com/redturtle/design-comuni-plone-theme/issues/161)) ([5172337](https://github.com/redturtle/design-comuni-plone-theme/commit/5172337fce80452311249c81b16397bd826aa7c0)) +* updated publiccode ([c962dc6](https://github.com/redturtle/design-comuni-plone-theme/commit/c962dc699f850ff9f5206afb01abe38d2577a3cf)) + ## [10.6.3](https://github.com/redturtle/design-comuni-plone-theme/compare/v10.6.2...v10.6.3) (2023-12-15) diff --git a/package.json b/package.json index c6c099b83..10d2d3175 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "design-comuni-plone-theme", "description": "Volto Theme for Italia design guidelines", "license": "GPL-v3", - "version": "10.6.3", + "version": "10.6.4", "main": "src/index.js", "keywords": [ "volto-addon", From 4f399dcdeb841fdd91d19d55dc87d0ad5e15dd2d Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Tue, 21 Nov 2023 17:30:43 +0100 Subject: [PATCH 008/270] feat!: upgrade to volto 17.5.0 (#382) * fix: change image component in ctablock * ci: upgrade volto * fix: change image component in hlcontent * fix: change image component listingimage * fix: change image component subevents * fix: change image component gallery * fix: change image component GenericCard * fix: change image component * fix: change image component (sponsor + venuesmall) * fix: change image component * fix: minutes with 00 format * docs: rimosso commento obsoleto * fix: review giulia * fix: review giulia * fix: scroll position on h2 .visually-hidden * feat: upgrade to volto 17.5.0 * docs: fix order Co-authored-by: Piero Nicolli * fix: review piero * fix: sponsor evento without image * fix: gallery preview --------- Co-authored-by: Giulia Ghisini Co-authored-by: Piero Nicolli --- .github/workflows/main.yml | 2 +- .github/workflows/prs.yml | 2 +- .github/workflows/release.yml | 2 +- Makefile | 2 +- jest-addon.config.js | 4 - package.json | 2 +- razzle.extend.js | 17 - src/components/Image/Image.jsx | 165 ----- src/components/Image/__tests__/Image.test.jsx | 636 ------------------ src/components/Image/helpers.js | 147 ---- .../ItaliaTheme/Blocks/CTABlock/Block.jsx | 31 +- .../ItaliaTheme/Blocks/Calendar/Item.jsx | 28 +- .../Blocks/Calendar/ListingSidebar.jsx | 7 +- .../Blocks/HighlightedContent/Body.jsx | 8 +- .../Blocks/Listing/CardWithImageTemplate.jsx | 3 + .../Listing/CardWithSlideUpTextTemplate.jsx | 2 +- .../Blocks/Listing/Commons/ListingImage.jsx | 47 +- .../Listing/CompleteBlockLinksTemplate.jsx | 7 +- .../Listing/ContentInEvidenceTemplate.jsx | 3 + .../Blocks/Listing/GridGalleryTemplate.jsx | 4 +- .../Blocks/Listing/InEvidenceTemplate.jsx | 8 +- .../Blocks/Listing/PhotogalleryTemplate.jsx | 6 +- .../Blocks/Listing/SliderTemplate.jsx | 5 +- .../Listing/SmallBlockLinksTemplate.jsx | 5 +- .../CardWithImageTemplateSkeleton.jsx | 2 - .../GalleryPreview/GalleryPreview.jsx | 7 +- .../View/BandoView/BandoAreaResponsabile.jsx | 3 + .../View/BandoView/BandoServizi.jsx | 3 + .../ItaliaTheme/View/Commons/ContentImage.jsx | 13 +- .../ItaliaTheme/View/Commons/CuredBy.jsx | 14 +- .../ItaliaTheme/View/Commons/Events.jsx | 45 +- .../ItaliaTheme/View/Commons/Gallery.jsx | 19 +- .../ItaliaTheme/View/Commons/GenericCard.jsx | 55 +- .../ItaliaTheme/View/Commons/LocationItem.jsx | 69 +- .../ItaliaTheme/View/Commons/OfficeCard.jsx | 55 +- .../View/Commons/PageHeader/PageHeader.jsx | 108 +-- .../View/Commons/RelatedArticles.jsx | 9 +- .../ItaliaTheme/View/Commons/RelatedItems.jsx | 47 +- .../ItaliaTheme/View/Commons/Sponsors.jsx | 53 +- .../ItaliaTheme/View/Commons/VenuesSmall.jsx | 91 +-- .../ItaliaTheme/View/Commons/WideImage.jsx | 18 +- .../DocumentoAccedereServizio.jsx | 7 +- .../View/IncaricoView/IncaricoView.jsx | 16 +- .../View/NewsItemView/NewsItemACuraDi.jsx | 3 + .../ItaliaTheme/View/PageView/PageView.jsx | 26 +- .../PaginaArgomentoView.jsx | 12 +- .../View/ServizioView/ServizioAccedi.jsx | 7 +- .../View/ServizioView/ServizioContatti.jsx | 2 - .../ItaliaTheme/View/UOView/UOStructure.jsx | 8 +- .../View/VenueView/VenueContacts.jsx | 2 +- .../View/VenueView/VenueDescription.jsx | 1 - .../ItaliaTheme/View/VenueView/VenueView.jsx | 2 +- .../Blocks/_cardWithImageAndInEvidence.scss | 1 + .../Blocks/_photogallerytemplate.scss | 1 + .../Components/_galleryPreview.scss | 2 + yarn.lock | 2 +- 56 files changed, 392 insertions(+), 1454 deletions(-) delete mode 100644 src/components/Image/Image.jsx delete mode 100644 src/components/Image/__tests__/Image.test.jsx delete mode 100644 src/components/Image/helpers.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5da70561d..5c2bc44b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: build-args: | ADDON_NAME=design-comuni-plone-theme ADDON_PATH=design-comuni-plone-theme - VOLTO_VERSION=17.0.0-alpha.19 + VOLTO_VERSION=17.5.0 - name: Deploy to rancher uses: redturtle/rancher-deploy-action@v0.2.0 diff --git a/.github/workflows/prs.yml b/.github/workflows/prs.yml index 53b515258..fa2c24e3a 100644 --- a/.github/workflows/prs.yml +++ b/.github/workflows/prs.yml @@ -34,4 +34,4 @@ jobs: build-args: | ADDON_NAME=design-comuni-plone-theme ADDON_PATH=design-comuni-plone-theme - VOLTO_VERSION=17.0.0-alpha.19 + VOLTO_VERSION=17.5.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 123e90e5c..a77c15c57 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,4 +35,4 @@ jobs: build-args: | ADDON_NAME=design-comuni-plone-theme ADDON_PATH=design-comuni-plone-theme - VOLTO_VERSION=17.0.0-alpha.19 + VOLTO_VERSION=17.5.0 diff --git a/Makefile b/Makefile index 77bc4d89f..0f5b0d344 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) # ADDON ?= "design-comuni-plone-theme" PLONE_VERSION=6 -VOLTO_VERSION=17.0.0-alpha.19 +VOLTO_VERSION=17.5.0 ADDON_NAME='design-comuni-plone-theme' ADDON_PATH='design-comuni-plone-theme' diff --git a/jest-addon.config.js b/jest-addon.config.js index debdbbcd4..59ad11305 100644 --- a/jest-addon.config.js +++ b/jest-addon.config.js @@ -17,10 +17,6 @@ module.exports = { ], moduleNameMapper: { '\\.(css|less|scss|sass|svg)$': 'identity-obj-proxy', - '@plone/volto/components/theme/Image/Image': - '/src/addons/design-comuni-plone-theme/src/components/Image/Image.jsx', - '@plone/volto/helpers/Image/Image': - '/src/addons/design-comuni-plone-theme/src/components/Image/helpers.js', '@plone/volto/cypress': '/node_modules/@plone/volto/cypress', '@plone/volto/babel': '/node_modules/@plone/volto/babel', '@plone/volto/(.*)$': '/node_modules/@plone/volto/src/$1', diff --git a/package.json b/package.json index 10d2d3175..a1e0a0438 100644 --- a/package.json +++ b/package.json @@ -191,7 +191,7 @@ "stylelint-prettier": "4.0.2" }, "peerDependencies": { - "@plone/volto": "17.0.0-alpha.19" + "@plone/volto": "17.5.0" }, "packageManager": "yarn@3.2.3" } diff --git a/razzle.extend.js b/razzle.extend.js index a964ce978..7081de0df 100644 --- a/razzle.extend.js +++ b/razzle.extend.js @@ -108,23 +108,6 @@ const modify = (webpackConfig, { target, dev }, webpackObject) => { const babelLoader = webpackConfig.module.rules.find(babelLoaderFinder); babelLoader.include.push(/node_modules\/design-react-kit/); - webpackConfig.resolve.alias = { - // TODO remove the next two when implemented in core - '@plone/volto/components/theme/Image/Image': `${__dirname}/src/components/Image/Image.jsx`, - '@plone/volto/helpers/Image/Image': `${__dirname}/src/components/Image/helpers.js`, - ...webpackConfig.resolve.alias, - // 'design-comuni-plone-theme': `${__dirname}/src`, - }; - - // remove unused languages. (TODO: move to ENV at build time) - // webpackConfig.plugins.push( - // new webpackObject.ContextReplacementPlugin( - // /moment[/\\]locale$/, - // /(it|it-it|en-us|en-gb)$/, - // ), - // // Ignore all locale files of moment.js - new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), - // ); - return webpackConfig; }; diff --git a/src/components/Image/Image.jsx b/src/components/Image/Image.jsx deleted file mode 100644 index 4e62c5f65..000000000 --- a/src/components/Image/Image.jsx +++ /dev/null @@ -1,165 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react'; - -import PropTypes from 'prop-types'; -// eslint-disable-next-line import/no-unresolved -import { getImageAttributes } from '@plone/volto/helpers/Image/Image'; - -/** - * Image component - * @param {string} itemUrl - url (`@id`) of the item. **ONLY** use this if rendering an image from a brain object, leave undefined otherwise - * @param {object | string} image - Plone image as object or url - * @param {string} imageField - (default: image) image field for scales URL - * @param {string} alt - Alternative text for image - * @param {string} className - CSS class attribute - * @param {string} containerClassName - CSS class attribute for picture element - * @param {string} floated - float left or right - * @param {string} responsive - if the image is responsive - * @param {string} size - (css class) actual width: thumb, small, medium or large - * @param {string} role - img role attribute - * @param {boolean} critical - if critical, do not lazy load the image - * @param {number} maxSize - maximum size to render - * @param {boolean} useOriginal - whether to render original size - */ -const Image = ({ - itemUrl, - image, - imageField = 'image', - alt = '', - className, - containerClassName, - floated, - size, - responsive = true, - role = 'img', - critical = false, - maxSize, - minSize = 0, - useOriginal = false, - sizes = '100vw', - ...imageProps -}) => { - const { src, srcSet, width, height, aspectRatio } = getImageAttributes( - image, - { - itemUrl, - imageField, - maxSize, - useOriginal, - minSize, - }, - ); - const imageRef = useRef(); - const [actualSrcSet, setActualSrcSet] = useState( - critical && srcSet ? srcSet.join(', ') : null, - ); - // TODO: serve a qualcuno questo? - const imageHasLoaded = imageRef?.current?.complete; - - //picture classname - let pictureClassName = `volto-image${ - containerClassName ? ` ${containerClassName}` : '' - }`; - if (floated) { - pictureClassName = `${pictureClassName} floated ${floated}`; - } - if (size) { - pictureClassName = `${pictureClassName} ${size}`; - } - - if (responsive) { - pictureClassName = `${pictureClassName} responsive`; - } - - //intersection observer - useEffect(() => { - const applySrcSet = () => { - setActualSrcSet(srcSet.join(', ')); - }; - - if (srcSet && !critical) { - if ('IntersectionObserver' in window) { - const observer = new IntersectionObserver( - (entries) => { - entries.forEach((entry) => { - if (entry.isIntersecting && !actualSrcSet) { - applySrcSet(); - if (imageRef.current instanceof Element) { - observer.unobserve(imageRef.current); - } - } - }); - }, - { threshold: [0], rootMargin: '100px' }, - ); - observer.observe(imageRef.current); - } else { - applySrcSet(); - } - } - }, [imageHasLoaded, srcSet, actualSrcSet, critical]); - - return ( - <> - - {actualSrcSet?.length > 0 && ( - - )} - {alt} - - {!critical && ( -