diff --git a/CHANGELOG.md b/CHANGELOG.md index c41180d..e438b35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,47 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [0.1.9](https://github.com/eea/volto-forests-theme/compare/0.1.8...0.1.9) + +- update volto-slate [`7248c0f`](https://github.com/eea/volto-forests-theme/commit/7248c0f0db2916f3a98d2f360e0da462545c49a9) +- remove api_path [`99418ac`](https://github.com/eea/volto-forests-theme/commit/99418ac02dfb0adb6af39c5e4a1e64a928070748) +- api_path [`1542048`](https://github.com/eea/volto-forests-theme/commit/1542048c90ee77e9ffc92a87f64856adad981af0) + +#### [0.1.8](https://github.com/eea/volto-forests-theme/compare/0.1.7...0.1.8) + +> 10 November 2021 + +- remove duplicate helpers [`#11`](https://github.com/eea/volto-forests-theme/pull/11) + +#### [0.1.7](https://github.com/eea/volto-forests-theme/compare/0.1.6...0.1.7) + +> 10 November 2021 + +- LeadNav update [`#9`](https://github.com/eea/volto-forests-theme/pull/9) + +#### [0.1.6](https://github.com/eea/volto-forests-theme/compare/0.1.5...0.1.6) + +> 9 November 2021 + +- Develop: hotfix for homepage view wide [`#8`](https://github.com/eea/volto-forests-theme/pull/8) +- use wideview on homepage [`63129c8`](https://github.com/eea/volto-forests-theme/commit/63129c8f2d614507064fbd381fa5922f851769e9) +- update [`70f5181`](https://github.com/eea/volto-forests-theme/commit/70f5181f92b3397788ff0fbf839b71b3ed70e2a9) + +#### [0.1.5](https://github.com/eea/volto-forests-theme/compare/0.1.4...0.1.5) + +> 8 November 2021 + +- Develop [`#7`](https://github.com/eea/volto-forests-theme/pull/7) +- update to volto 14 [`32c2318`](https://github.com/eea/volto-forests-theme/commit/32c231806a553bc06e783d8a8cb8e3576e57babe) +- fix query params [`7764b3a`](https://github.com/eea/volto-forests-theme/commit/7764b3a46e3b5fafca833f6ec838ac02dc1bee81) + #### [0.1.4](https://github.com/eea/volto-forests-theme/compare/0.1.3...0.1.4) +> 5 November 2021 + +- Updates on HeaderNavigation & Lead Image [`#5`](https://github.com/eea/volto-forests-theme/pull/5) +- lint fix [`25997f2`](https://github.com/eea/volto-forests-theme/commit/25997f2b27dd12b0b946021aed58add10325fc7b) +- Use screen width from store rather than hook [`b15911d`](https://github.com/eea/volto-forests-theme/commit/b15911d6e188f5e436ddd8828743137361f4f17b) - Hover typo [`90b38c4`](https://github.com/eea/volto-forests-theme/commit/90b38c4b4552849581b193ebafa9e4664c17dded) - window dimension hook cleanup [`6f94af1`](https://github.com/eea/volto-forests-theme/commit/6f94af12cf46f19e06d19a255497a465efb34180) - window Dimension hook & mobile improvements to HeaderNavigation [`7b2f299`](https://github.com/eea/volto-forests-theme/commit/7b2f299806ed17a54f4f1c7568e9f1028e82c012) diff --git a/package.json b/package.json index 166e6b6..f89fc9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-forests-theme", - "version": "0.1.4", + "version": "0.1.9", "description": "@eeacms/volto-forests-theme: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -32,11 +32,11 @@ "raven-js": "3.27.2", "recharts": "2.1.6", "react-highlight-words": "^0.16.0", - "react-image-gallery": "1.0.8", + "react-image-gallery": "1.2.7", "react-lazy-load-image-component": "^1.5.0", "react-stickynode": "^2.1.1", "react-toastify": "^5.3.2", - "volto-slate": "2.9.1", + "volto-slate": "4.2.1", "webpack-bundle-analyzer": "^3.6.0" }, "devDependencies": { diff --git a/src/components/manage/Blocks/NavigationBlock/View.jsx b/src/components/manage/Blocks/NavigationBlock/View.jsx index 566418f..511f994 100644 --- a/src/components/manage/Blocks/NavigationBlock/View.jsx +++ b/src/components/manage/Blocks/NavigationBlock/View.jsx @@ -8,10 +8,6 @@ import { Menu } from 'semantic-ui-react'; /* HELPERS */ import cx from 'classnames'; import { isActive, getNavigationByParent, getBasePath } from './helpers'; -import { - deleteQueryParam, - setQueryParam, -} from '@eeacms/volto-datablocks/actions'; import { useEffect } from 'react'; import './styles.css'; import cookie from 'react-cookie'; @@ -249,6 +245,6 @@ export default compose( ) : {}, }), - { deleteQueryParam, setQueryParam }, + {}, ), )(View); diff --git a/src/components/theme/Header/HeaderNavigation.jsx b/src/components/theme/Header/HeaderNavigation.jsx index 4c052f8..0cf8bf1 100644 --- a/src/components/theme/Header/HeaderNavigation.jsx +++ b/src/components/theme/Header/HeaderNavigation.jsx @@ -3,10 +3,10 @@ import React from 'react'; import { useHistory } from 'react-router-dom'; import { Link } from 'react-router-dom'; -import useWindowSize from '../../../helpers/useWindowSize'; import downIcon from '@plone/volto/icons/down-key.svg'; import closeIcon from '@plone/volto/icons/clear.svg'; import { Icon } from '@plone/volto/components'; +import { connect } from 'react-redux'; const MobileNav = ({ items, activeItem }) => { const [expanded, setExpanded] = React.useState(false); @@ -61,28 +61,26 @@ const MobileNav = ({ items, activeItem }) => { ); }; -const HeaderNavigation = ({ items }) => { +const HeaderNavigation = ({ items, pageWidth }) => { const [activeItem, setActiveItem] = React.useState(''); const [isMobile, setIsMobile] = React.useState(false); const history = useHistory(); - const size = useWindowSize(); React.useEffect(() => { - const { width } = size; const activeRouteDetected = items.filter( (item) => item.url === history.location.pathname, ); if (activeRouteDetected && activeRouteDetected.length > 0) { setActiveItem(activeRouteDetected[0]); } - if (width && width <= 768) { + if (pageWidth && pageWidth <= 768) { setIsMobile(true); } - if (width && width > 768) { + if (pageWidth && pageWidth > 768) { setIsMobile(false); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [items, size]); + }, [items, pageWidth]); return ( @@ -108,4 +106,6 @@ const HeaderNavigation = ({ items }) => { ); }; -export default HeaderNavigation; +export default connect((state) => ({ + pageWidth: state.screen.page.width, +}))(HeaderNavigation); diff --git a/src/customizations/helpers/index.js b/src/customizations/helpers/index.js deleted file mode 100644 index db2302d..0000000 --- a/src/customizations/helpers/index.js +++ /dev/null @@ -1,104 +0,0 @@ -import { getBaseUrl, flattenToAppURL } from '@plone/volto/helpers'; -import { setConnectedDataParameters } from '@eeacms/volto-datablocks/actions'; - -export function getBasePath(url) { - return flattenToAppURL(getBaseUrl(url)); -} - -export const objectHasData = (obj) => { - return typeof obj === 'object' && obj !== null && Object.keys(obj).length > 0; -}; - -export const getSchemaWithDataQuery = (props) => { - if (!props.schema) return {}; - let schemaWithDataQuery = {}; - Object.keys(props.schema).forEach((element) => { - if (props.schema[element].type === 'data-provider') { - if ( - !objectHasData( - props?.connected_data_parameters?.byProviderPath?.[props.path], - ) && - !objectHasData( - props?.connected_data_parameters?.byContextPath?.[props.path], - ) - ) { - const dataQuery = {}; - dataQuery[element + '_data_query'] = { - defaultformat: 'compactnumber', - type: 'data-query', - }; - schemaWithDataQuery[element] = props.schema[element]; - schemaWithDataQuery = { ...schemaWithDataQuery, ...dataQuery }; - } - } - schemaWithDataQuery[element] = props.schema[element]; - }); - return schemaWithDataQuery; -}; - -export function getLocation(href) { - var match = href.match( - /^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/, - ); - return ( - match && { - href: href, - protocol: match[1], - host: match[2], - hostname: match[3], - port: match[4], - pathname: match[5], - search: match[6], - hash: match[7], - } - ); -} - -export function samePath(url, path) { - // returns true if the router path is equal to the given url path - const parsed = getLocation(url); - const clean = getBasePath(url) - .replace(parsed.hash, '') - .replace(parsed.search, '') - .replace(/\/$/, ''); - - const cleanPath = path.replace(/\/$/, ''); - return clean === cleanPath; -} - -export const updateConnectedDataParameters = (props) => { - props.schema && - Object.keys(props.schema).forEach((element) => { - if (props.schema[element].type === 'data-query') { - if ( - props?.newData?.columns?.[element] && - (props?.newData?.columns?.[element]?.value?.i !== - props?.data?.columns?.[element]?.value?.i || - props?.newData?.columns?.[element]?.value?.v !== - props?.data?.columns?.[element]?.value?.v) - ) { - const path = getBasePath(props.pathname); - const byPath = props?.connected_data_parameters?.byPath; - const connected_data_parameters = - (byPath?.[path]?.override?.length > 0 && - byPath?.[path]?.override?.[`${props.id}_${element}`]) || - null; - if ( - connected_data_parameters === null || - connected_data_parameters?.i !== - props?.newData?.columns?.[element]?.value?.i || - connected_data_parameters?.v?.join(',') !== - props?.newData?.columns?.[element]?.value?.v - ) { - props.dispatch( - setConnectedDataParameters( - path.replace('/edit', ''), - props?.newData?.columns?.[element]?.value, - `${props.id}_${element}`, - ), - ); - } - } - } - }); -}; diff --git a/src/customizations/volto/components/theme/View/View.jsx b/src/customizations/volto/components/theme/View/View.jsx index 7ed0ecc..d9a523c 100644 --- a/src/customizations/volto/components/theme/View/View.jsx +++ b/src/customizations/volto/components/theme/View/View.jsx @@ -172,10 +172,17 @@ class View extends Component { * @method getViewByLayout * @returns {string} Markup for component. */ - getViewByLayout = () => - config.views.layoutViews[ - this.props.content[getLayoutFieldname(this.props.content)] - ] || null; + getViewByLayout = () => { + if (this.props.pathname === '/') { + return config.views.layoutViews['document_view_wide']; + } + + return ( + config.views.layoutViews[ + this.props.content[getLayoutFieldname(this.props.content)] + ] || null + ); + }; /** * Cleans the component displayName (specially for connected components) @@ -359,6 +366,7 @@ export default compose( injectIntl, connect( (state, props) => ({ + state, actions: state.actions.actions, token: state.userSession.token, content: state.content.data, diff --git a/src/helpers/useWindowSize.jsx b/src/helpers/useWindowSize.jsx deleted file mode 100644 index a908882..0000000 --- a/src/helpers/useWindowSize.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import { useState, useEffect } from 'react'; - -export default function useWindowSize() { - const [windowSize, setWindowSize] = useState({ - width: undefined, - height: undefined, - }); - useEffect(() => { - function handleResize() { - if (typeof window !== 'undefined') { - setWindowSize({ - width: window.innerWidth, - height: window.innerHeight, - }); - } - } - if (typeof window !== 'undefined') { - window.addEventListener('resize', handleResize); - handleResize(); - } - return () => { - if (typeof window !== 'undefined') { - window.removeEventListener('resize', handleResize); - } - }; - }, []); - return windowSize; -} diff --git a/theme/site/globals/site.overrides b/theme/site/globals/site.overrides index 095434c..ba311f1 100644 --- a/theme/site/globals/site.overrides +++ b/theme/site/globals/site.overrides @@ -207,8 +207,14 @@ body.has-toolbar { font-size: 16px; font-weight: bold; text-decoration: none; + + @media (max-width: @computerBreakpoint) { + padding: 8px 10px; + font-size: 14px; + } } + .lead-navigation-item:hover { background: white;