Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable Slim header from control panel #598

Merged
merged 7 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@

## Versione x.x.x (xx/xx/xxxx)

### Novità
- Nel template Slider del blocco elenco, ora è possibile scegliere l'aspetto degli elementi dello slider (default: slide semplice con immagine e titolo cliccabile, Card semplice, Card con immagine).
## Versione X.X.X (dd/mm/yyyy)

### Migliorie

- Nel blocco Argomenti in Evidenza, è stata rimossa l'obbligatorietà di aggiungere una card argomento, ora si possono inserire anche solo le etichette.
Expand All @@ -57,6 +53,8 @@

### Novità

- Ora i link in testata nell'header slim sono configurabili da pannello di controllo.
- Nel template Slider del blocco elenco, ora è possibile scegliere l'aspetto degli elementi dello slider (default: slide semplice con immagine e titolo cliccabile, Card semplice, Card con immagine).
- Nel blocco Argomenti in Evidenza sono state aggiunte due nuove proprietà, una permette di allineare gli "Altri argomenti" al centro e la seconda serve a nascondere o meno il bottone "Vedi tutti" che punta alla pagina argomenti.

### Fix
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"volto-data-grid-widget",
"volto-querywidget-with-browser",
"@eeacms/volto-taxonomy",
"volto-feedback"
"volto-feedback",
"volto-slimheader"
],
"scripts": {
"prepare": "husky install",
Expand Down Expand Up @@ -153,6 +154,7 @@
"volto-querywidget-with-browser": "0.4.2",
"volto-rss-block": "3.0.0",
"volto-secondarymenu": "4.0.0",
"volto-slimheader": "0.1.0",
"volto-social-settings": "3.0.0",
"volto-subblocks": "2.0.0",
"volto-subfooter": "3.0.0",
Expand Down
31 changes: 27 additions & 4 deletions src/components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,39 @@
* @module components/ItaliaTheme/Header/HeaderSlim/TertiaryMenu
*/

import React from 'react';
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { Nav, NavItem, NavLink } from 'design-react-kit';
import { UniversalLink } from '@plone/volto/components';
import { flattenToAppURL } from '@plone/volto/helpers';
import { useIntl } from 'react-intl';
import config from '@plone/volto/registry';
import { getSiteProperty } from 'design-comuni-plone-theme/helpers';
import { getSlimHeader, getItemsByPath } from 'volto-slimheader';

const TertiaryMenu = () => {
const intl = useIntl();
let menu = config.settings.siteProperties.headerslimTertiaryMenu;
const items = menu[intl.locale];
const pathname = useLocation().pathname;
const dispatch = useDispatch();

const slimHeader = useSelector((state) => state.slimHeader?.result);
const slimHeaderItems = getItemsByPath(slimHeader, pathname)
?.filter((item) => item.visible)
.map((item) => {
return {
url: item.href || flattenToAppURL(item.linkUrl?.[0]?.['@id']) || '/',
title: item.title,
};
});

const staticMenu =
getSiteProperty('headerslimTertiaryMenu', intl.locale) ?? [];

useEffect(() => {
dispatch(getSlimHeader());
}, [dispatch]);

const items = slimHeaderItems?.length > 0 ? slimHeaderItems : staticMenu;

return items?.length > 0 ? (
<Nav vertical={false} className="tertiary-menu">
Expand Down
4 changes: 4 additions & 0 deletions src/config/italiaConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ export default function applyConfig(voltoConfig) {
// arLogoutUrl: '/logout?e=1',
// spidLogin: true, //se true, nella pagina di errore Unauthorized, mostra il pulsante per il login a Spid.
headerslimTertiaryMenu: {
default: [
//{ title: 'Contatti', url: '/it/contatti' },
//{ title: 'Novità', url: '/it/novita' },
],
it: [
//{ title: 'Contatti', url: '/it/contatti' },
//{ title: 'Novità', url: '/it/novita' },
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getSiteProperty = (property, locale) => {
value
);
} else {
return value.default ?? value;
return value.default ?? value[locale] ?? value;
}
default:
break;
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6583,6 +6583,7 @@ __metadata:
volto-querywidget-with-browser: 0.4.2
volto-rss-block: 3.0.0
volto-secondarymenu: 4.0.0
volto-slimheader: 0.1.0
volto-social-settings: 3.0.0
volto-subblocks: 2.0.0
volto-subfooter: 3.0.0
Expand Down Expand Up @@ -14432,6 +14433,15 @@ __metadata:
languageName: node
linkType: hard

"volto-slimheader@npm:0.1.0":
version: 0.1.0
resolution: "volto-slimheader@npm:0.1.0"
peerDependencies:
"@plone/volto": ">=16.0.0-alpha.38"
checksum: 2cdd3f53cb6ce20571fa1f58a2658f2b0d6694dab37d06be8784338500bca2227f45471be1b7980583d666719eb7a9c80c9a8013a93ef354cd8f697608161d25
languageName: node
linkType: hard

"volto-social-settings@npm:3.0.0":
version: 3.0.0
resolution: "volto-social-settings@npm:3.0.0"
Expand Down
Loading