design-comuni-plone-theme 11.22.0 → 11.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
 
2
2
 
3
+ ## [11.22.1](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v11.22.0...v11.22.1) (2024-09-09)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * removed RemoveBodyClass component in favor of a customized BodyClass component ([61062d8](https://github.com/RedTurtle/design-comuni-plone-theme/commit/61062d84041f52182c2d04716b0411673a98e1f9))
9
+
3
10
  ## [11.22.0](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v11.21.1...v11.22.0) (2024-09-05)
4
11
 
5
12
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "design-comuni-plone-theme",
3
3
  "description": "Volto Theme for Italia design guidelines",
4
4
  "license": "GPL-v3",
5
- "version": "11.22.0",
5
+ "version": "11.22.1",
6
6
  "main": "src/index.js",
7
7
  "repository": {
8
8
  "type": "git",
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { useSelector } from 'react-redux';
3
3
  import { useLocation } from 'react-router-dom';
4
4
  import { BodyClass } from '@plone/volto/helpers';
5
- import { RemoveBodyClass } from 'design-comuni-plone-theme/components/ItaliaTheme';
6
5
  import ScrollToTop from 'design-comuni-plone-theme/components/ItaliaTheme/ScrollToTop/ScrollToTop';
7
6
  import { SubsiteLoader } from 'volto-subsites';
8
7
  import config from '@plone/volto/registry';
@@ -28,7 +27,7 @@ const GenericAppExtras = (props) => {
28
27
  {isPublicUI && (
29
28
  <>
30
29
  <BodyClass className="public-ui" />
31
- <RemoveBodyClass className="cms-ui" />
30
+ <BodyClass className="cms-ui" remove={true} />
32
31
  </>
33
32
  )}
34
33
  <ScrollToTop />
@@ -11,10 +11,7 @@ import { defineMessages, useIntl } from 'react-intl';
11
11
  import { withRouter } from 'react-router-dom';
12
12
  import { Login } from '@plone/volto/components';
13
13
  import { Row, Col, Container } from 'design-react-kit';
14
- import {
15
- RemoveBodyClass,
16
- LoginAgidButtons,
17
- } from 'design-comuni-plone-theme/components/ItaliaTheme';
14
+ import { LoginAgidButtons } from 'design-comuni-plone-theme/components/ItaliaTheme';
18
15
  import { Button } from 'design-react-kit';
19
16
  import { useLocation } from 'react-router-dom';
20
17
  import { getBaseUrl } from '@plone/volto/helpers';
@@ -72,7 +69,7 @@ const LoginAgid = (props) => {
72
69
  <div id="page-login">
73
70
  <Helmet title={intl.formatMessage(messages.login)} />
74
71
  <BodyClass className="public-ui" />
75
- <RemoveBodyClass className="cms-ui" />
72
+ <BodyClass className="cms-ui" remove={true} />
76
73
  <Container className="view-wrapper py-5">
77
74
  <Row className="view-container">
78
75
  <Col xs={12} lg={{ size: 10, offset: 1 }}>
@@ -24,7 +24,7 @@ import {
24
24
  import { Skiplink, SkiplinkItem } from 'design-react-kit';
25
25
  import { useLocation, useHistory } from 'react-router-dom';
26
26
 
27
- import { Helmet, flattenToAppURL } from '@plone/volto/helpers';
27
+ import { Helmet, flattenToAppURL, BodyClass } from '@plone/volto/helpers';
28
28
  import { resetSubsite } from 'volto-subsites';
29
29
 
30
30
  import {
@@ -33,7 +33,6 @@ import {
33
33
  SearchTopics,
34
34
  SearchCTs,
35
35
  Icon,
36
- RemoveBodyClass,
37
36
  SearchResultItem,
38
37
  } from 'design-comuni-plone-theme/components/ItaliaTheme';
39
38
  import {
@@ -727,7 +726,7 @@ const Search = () => {
727
726
  </Container>
728
727
  </div>
729
728
  {/*force remove body class for subsite search pages*/}
730
- <RemoveBodyClass className="cms-ui" />
729
+ <BodyClass className="cms-ui" remove={true} />
731
730
  </>
732
731
  );
733
732
  };
@@ -13,10 +13,7 @@ import { BodyClass } from '@plone/volto/helpers';
13
13
  import { useLocation } from 'react-router-dom';
14
14
  import { getBaseUrl } from '@plone/volto/helpers';
15
15
  import config from '@plone/volto/registry';
16
- import {
17
- LoginAgidButtons,
18
- RemoveBodyClass,
19
- } from 'design-comuni-plone-theme/components/ItaliaTheme';
16
+ import { LoginAgidButtons } from 'design-comuni-plone-theme/components/ItaliaTheme';
20
17
 
21
18
  /**
22
19
  * unauthorized function.
@@ -58,7 +55,7 @@ const Unauthorized = (props) => {
58
55
  return (
59
56
  <div id="unauthorized-agid" className="view-wrapper">
60
57
  <BodyClass className="public-ui" />
61
- <RemoveBodyClass className="cms-ui" />
58
+ <BodyClass className="cms-ui" remove={true} />
62
59
 
63
60
  <Container className="view-wrapper py-5">
64
61
  {spidLoginUrl || spidLogin ? (
@@ -0,0 +1,78 @@
1
+ /**
2
+ * CUSTOMIZATIONS:
3
+ * - handle bodyclass removal
4
+ */
5
+ import { Component, Children } from 'react';
6
+ import PropTypes from 'prop-types';
7
+ import withSideEffect from 'react-side-effect';
8
+
9
+ /**
10
+ * @export
11
+ * @class BodyClass
12
+ * @extends {Component}
13
+ */
14
+ class BodyClass extends Component {
15
+ /**
16
+ * Render method.
17
+ * @method render
18
+ * @returns {string} Markup for the component.
19
+ */
20
+ render() {
21
+ if (this.props.children) {
22
+ return Children.only(this.props.children);
23
+ }
24
+ return null;
25
+ }
26
+ }
27
+
28
+ BodyClass.propTypes = {
29
+ children: PropTypes.element,
30
+ className: PropTypes.string,
31
+ remove: PropTypes.bool,
32
+ };
33
+
34
+ BodyClass.defaultProps = {
35
+ children: null,
36
+ className: null,
37
+ remove: false,
38
+ };
39
+
40
+ /**
41
+ * reducePropsToState
42
+ * @function reducePropsToState
43
+ * @param {*} propsList propsList
44
+ * @returns {List} classList
45
+ */
46
+ function reducePropsToState(propsList) {
47
+ let classList = [];
48
+ propsList.forEach((props) => {
49
+ if (props.className) {
50
+ if (props.remove) {
51
+ classList = classList.filter((c) => c !== props.className);
52
+ } else {
53
+ classList = classList.concat(props.className.split(' '));
54
+ }
55
+ }
56
+ });
57
+ return classList;
58
+ }
59
+
60
+ /**
61
+ * handleStateChangeOnClient
62
+ * @function handleStateChangeOnClient
63
+ * @param {*} classList classList
64
+ * @returns {null} null
65
+ */
66
+ function handleStateChangeOnClient(classList) {
67
+ document.body.className = '';
68
+ classList.forEach((className) => {
69
+ if (!document.body.classList.contains(className)) {
70
+ document.body.classList.add(className);
71
+ }
72
+ });
73
+ }
74
+
75
+ export default withSideEffect(
76
+ reducePropsToState,
77
+ handleStateChangeOnClient,
78
+ )(BodyClass);