Skip to content

Commit

Permalink
Suporte a mapa do site no rodapé (Fixes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Jul 23, 2024
1 parent 1f2d318 commit 6f9d6b0
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/packages/portalbrasil-intranet/news/2.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Suporte a exibição do mapa do site no rodapé [@ericof]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSelector, shallowEqual } from 'react-redux';
import { UniversalLink } from '@plone/volto/components';
import { Container } from '@plone/components';
import { flattenToAppURL, addAppURL } from '@plone/volto/helpers';
import Sitemap from './Sitemap';
import ToolLogo from '../ToolLogo/ToolLogo';
import config from '@plone/volto/registry';

Expand All @@ -15,8 +16,9 @@ import config from '@plone/volto/registry';
* @param {Object} intl Intl object
* @returns {string} Markup of the component
*/
const Footer = ({ intl }) => {
const Footer = ({ pathname, intl }) => {
const { settings } = config;
const { display_sitemap, display_toollogo } = settings.intranet?.footer;
const { lang, siteActions = [] } = useSelector(
(state) => ({
lang: state.intl.locale,
Expand Down Expand Up @@ -52,9 +54,16 @@ const Footer = ({ intl }) => {
))
: null}
</ul>
<div className="logo">
<ToolLogo />
</div>
{display_sitemap && (
<Container narrow>
<Sitemap pathname={pathname} />
</Container>
)}
{display_toollogo && (
<Container className="logo">
<ToolLogo />
</Container>
)}
<a className="item powered-by" href="https://plone.org">
<FormattedMessage
id="Powered by Portal Brasil: Intranet, Plone & Python"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useEffect } from 'react';
import { useDispatch, useSelector, shallowEqual } from 'react-redux';
import { NavLink } from 'react-router-dom';
import { getNavigation } from '@plone/volto/actions';
import { GridList, GridListItem } from '@plone/components';
import { getBaseUrl, hasApiExpander } from '@plone/volto/helpers';
import config from '@plone/volto/registry';

const Sitemap = ({ pathname }) => {
const dispatch = useDispatch();
const token = useSelector((state) => state.userSession.token, shallowEqual);
const items = useSelector((state) => state.navigation.items, shallowEqual);

useEffect(() => {
if (!hasApiExpander('navigation', getBaseUrl(pathname))) {
dispatch(getNavigation(getBaseUrl(pathname), config.settings.navDepth));
}
}, [pathname, token, dispatch]);

return (
<nav id="footer-navigation" aria-label="navigation" className="navigation">
<GridList className={'navigation-grid'}>
{items.map((item, index) => (
<GridListItem key={item.url} className={'navigation-item'}>
<h3 className={'section'}>
<NavLink to={item.url}>{item.title}</NavLink>
</h3>
{item.items && item.items.length > 0 && (
<ul className={'item-wrapper'}>
{item.items.map((subitem) => (
<li key={subitem.url} className={'nav-subitem'}>
<NavLink to={subitem.url}>{subitem.title}</NavLink>
</li>
))}
</ul>
)}
</GridListItem>
))}
</GridList>
</nav>
);
};

export default Sitemap;
4 changes: 4 additions & 0 deletions frontend/packages/portalbrasil-intranet/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const applyConfig = (config) => {
enable_fonte: true,
enable_link: false,
},
footer: {
display_sitemap: false,
display_toollogo: true,
},
},
image_crop_aspect_ratios: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,46 @@
width: 300px;
}
}
.navigation {
height: unset;
.navigation-grid {
display: flex;
flex-direction: row;
justify-content: space-evenly;
text-align: left;
h3.section {
> a {
@include add(weight, bold);
color: var(--color-primary);
text-transform: uppercase;
&:hover {
text-decoration: underline;
}
}
}
.navigation-item {
-webkit-flex: 1; /* Safari */
flex: 1;
padding-left: $spacing-xsmall;
border-left: 2px solid var(--color-primary);
}
.item-wrapper {
display: block;
text-align: left;
> li {
padding: 0px 7px 0px 0px;
border: unset;
> a {
@include add(weight, light);
color: var(--color-primary);
&:hover {
@include add(weight, light);
text-decoration: underline;
}
}
}
}
}
}
}
}

0 comments on commit 6f9d6b0

Please sign in to comment.