@eeacms/volto-eea-website-theme 1.9.3 → 1.11.0

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.
@@ -8,7 +8,6 @@ import PropTypes from 'prop-types';
8
8
  import { UniversalLink } from '@plone/volto/components';
9
9
  import cx from 'classnames';
10
10
  import { Copyright } from '@eeacms/volto-eea-design-system/ui';
11
- import './style.less';
12
11
  import { Icon } from 'semantic-ui-react';
13
12
  import { flattenToAppURL } from '@plone/volto/helpers';
14
13
 
@@ -17,59 +16,90 @@ import { flattenToAppURL } from '@plone/volto/helpers';
17
16
  * @class View
18
17
  * @extends Component
19
18
  */
20
- const View = ({ data, properties }) => {
19
+ const View = (props) => {
20
+ const { data, properties } = props;
21
21
  const { copyright, copyrightIcon, copyrightPosition } = data;
22
22
 
23
+ // const [hovering, setHovering] = React.useState(false);
24
+ const [viewLoaded, setViewLoaded] = React.useState(false);
25
+
26
+ React.useEffect(() => {
27
+ setViewLoaded(true);
28
+ }, []);
29
+
23
30
  return (
24
- <p
25
- className={cx(
26
- 'block image align',
27
- {
28
- center: !Boolean(data.align),
29
- },
30
- data.align,
31
- )}
32
- >
33
- {properties.image && (
34
- <>
35
- {(() => {
36
- const image = (
37
- <div className="image-block">
38
- <img
39
- className={cx({ 'full-width': data.align === 'full' })}
40
- src={flattenToAppURL(properties.image.download)}
41
- alt={properties.image_caption || ''}
42
- />
43
- <div className="copyright-image">
44
- {copyright ? (
45
- <Copyright copyrightPosition={copyrightPosition}>
46
- <Copyright.Icon>
47
- <Icon className={copyrightIcon} />
48
- </Copyright.Icon>
49
- <Copyright.Text>{copyright}</Copyright.Text>
50
- </Copyright>
51
- ) : (
52
- ''
53
- )}
54
- </div>
55
- </div>
56
- );
57
- if (data.href) {
58
- return (
59
- <UniversalLink
60
- href={data.href}
61
- openLinkInNewTab={data.openLinkInNewTab}
62
- >
63
- {image}
64
- </UniversalLink>
65
- );
66
- } else {
67
- return image;
68
- }
69
- })()}
70
- </>
31
+ <>
32
+ {viewLoaded && (
33
+ <p
34
+ className={cx(
35
+ 'block image align',
36
+ {
37
+ center: !Boolean(data.align),
38
+ },
39
+ data.align,
40
+ )}
41
+ >
42
+ <div
43
+ className={`image-block-container ${
44
+ data?.align ? data?.align : ''
45
+ }`}
46
+ >
47
+ {properties.image && (
48
+ <>
49
+ {(() => {
50
+ const image = (
51
+ <div className="image-block">
52
+ <img
53
+ className={cx({ 'full-width': data.align === 'full' })}
54
+ src={flattenToAppURL(properties.image.download)}
55
+ alt={properties.image_caption || ''}
56
+ />
57
+ <div
58
+ // onMouseEnter={() => setHovering(true)}
59
+ // onMouseLeave={() => setHovering(false)}
60
+ className={`copyright-wrapper ${
61
+ copyrightPosition ? copyrightPosition : 'left'
62
+ }`}
63
+ >
64
+ {copyright ? (
65
+ <Copyright copyrightPosition={copyrightPosition}>
66
+ <Copyright.Icon>
67
+ <Icon className={copyrightIcon} />
68
+ </Copyright.Icon>
69
+ {/*<div*/}
70
+ {/* className={cx(*/}
71
+ {/* 'copyright-hover-container',*/}
72
+ {/* !hovering ? 'hiddenStructure' : '',*/}
73
+ {/* )}*/}
74
+ {/*>*/}
75
+ <Copyright.Text>{copyright}</Copyright.Text>
76
+ {/*</div>*/}
77
+ </Copyright>
78
+ ) : (
79
+ ''
80
+ )}
81
+ </div>
82
+ </div>
83
+ );
84
+ if (data.href) {
85
+ return (
86
+ <UniversalLink
87
+ href={data.href}
88
+ openLinkInNewTab={data.openLinkInNewTab}
89
+ >
90
+ {image}
91
+ </UniversalLink>
92
+ );
93
+ } else {
94
+ return image;
95
+ }
96
+ })()}
97
+ </>
98
+ )}
99
+ </div>
100
+ </p>
71
101
  )}
72
- </p>
102
+ </>
73
103
  );
74
104
  };
75
105
 
@@ -83,4 +113,4 @@ View.propTypes = {
83
113
  properties: PropTypes.objectOf(PropTypes.any).isRequired,
84
114
  };
85
115
 
86
- export default View;
116
+ export default React.memo(View);
@@ -0,0 +1,105 @@
1
+ import { defineMessages } from 'react-intl';
2
+
3
+ const messages = defineMessages({
4
+ Image: {
5
+ id: 'Image',
6
+ defaultMessage: 'Image',
7
+ },
8
+ Origin: {
9
+ id: 'Origin',
10
+ defaultMessage: 'Origin',
11
+ },
12
+ AltText: {
13
+ id: 'Alt text',
14
+ defaultMessage: 'Alt text',
15
+ },
16
+ Copyright: {
17
+ id: 'Text',
18
+ defaultMessage: 'Text',
19
+ },
20
+ CopyrightIcon: {
21
+ id: 'Icon',
22
+ defaultMessage: 'Icon',
23
+ },
24
+ Align: {
25
+ id: 'Alignment',
26
+ defaultMessage: 'Alignment',
27
+ },
28
+ LinkTo: {
29
+ id: 'Link to',
30
+ defaultMessage: 'Link to',
31
+ },
32
+ openLinkInNewTab: {
33
+ id: 'Open in a new tab',
34
+ defaultMessage: 'Open in a new tab',
35
+ },
36
+ NoImageSelected: {
37
+ id: 'No image set in image content field',
38
+ defaultMessage: 'No image set in image content field',
39
+ },
40
+ externalURL: {
41
+ id: 'External URL',
42
+ defaultMessage: 'External URL',
43
+ },
44
+ });
45
+
46
+ export function LeadImageSchema({ formData, intl }) {
47
+ return {
48
+ fieldsets: [
49
+ {
50
+ id: 'default',
51
+ title: 'Default',
52
+ fields: [...(formData.image ? ['alt', 'align'] : [])],
53
+ },
54
+
55
+ ...(formData.image
56
+ ? [
57
+ {
58
+ id: 'link_settings',
59
+ title: 'Link settings',
60
+ fields: ['href', 'openLinkInNewTab'],
61
+ },
62
+ ]
63
+ : []),
64
+ {
65
+ id: 'copyright',
66
+ title: 'Copyright',
67
+ fields: ['copyright', 'copyrightIcon', 'copyrightPosition'],
68
+ },
69
+ ],
70
+ properties: {
71
+ alt: {
72
+ title: intl.formatMessage(messages.AltText),
73
+ },
74
+ align: {
75
+ title: intl.formatMessage(messages.Align),
76
+ widget: 'align',
77
+ },
78
+ href: {
79
+ title: intl.formatMessage(messages.LinkTo),
80
+ widget: 'object_browser',
81
+ mode: 'link',
82
+ selectedItemAttrs: ['Title', 'Description', 'hasPreviewImage'],
83
+ allowExternals: true,
84
+ },
85
+ openLinkInNewTab: {
86
+ title: intl.formatMessage(messages.openLinkInNewTab),
87
+ type: 'boolean',
88
+ },
89
+ copyright: {
90
+ title: 'Text',
91
+ },
92
+ copyrightIcon: {
93
+ title: 'Icon',
94
+ default: 'ri-copyright-line',
95
+ },
96
+ copyrightPosition: {
97
+ title: 'Align',
98
+ widget: 'align',
99
+ actions: ['left', 'right'],
100
+ defaultValue: 'left',
101
+ },
102
+ },
103
+ required: [],
104
+ };
105
+ }
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+
3
+ export default function withDeviceSize(WrappedComponent) {
4
+ return (props) => {
5
+ const [device, setDevice] = React.useState(null);
6
+
7
+ const updateScreenSize = () => {
8
+ if (__CLIENT__) {
9
+ const screenWidth =
10
+ document.documentElement.clientWidth ||
11
+ document.body.clientWidth ||
12
+ window.innerWidth ||
13
+ 0;
14
+
15
+ setDevice(getDeviceConfig(screenWidth));
16
+ }
17
+ };
18
+
19
+ const getDeviceConfig = (width) => {
20
+ // semantic ui breakpoints
21
+ if (width < 768) {
22
+ return 'mobile';
23
+ } else if (width >= 768 && width < 992) {
24
+ return 'tablet';
25
+ } else if (width >= 992 && width < 1200) {
26
+ return 'computer';
27
+ } else if (width >= 1200 && width < 1920) {
28
+ return 'large';
29
+ } else if (width >= 1920) {
30
+ return 'widescreen';
31
+ }
32
+ };
33
+
34
+ React.useEffect(() => {
35
+ updateScreenSize();
36
+ window.addEventListener('resize', updateScreenSize);
37
+ return () => {
38
+ window.removeEventListener('resize', updateScreenSize);
39
+ };
40
+ /* eslint-disable-next-line */
41
+ }, []);
42
+
43
+ return <WrappedComponent {...props} device={device} />;
44
+ };
45
+ }
@@ -1,12 +0,0 @@
1
- .image-block {
2
- position: relative;
3
- }
4
-
5
- .copyright-image {
6
- position: absolute;
7
- z-index: 1000;
8
- top: 90%;
9
- width: 100%;
10
- padding-right: 10px;
11
- padding-left: 10px;
12
- }
@@ -1,12 +0,0 @@
1
- .image-block {
2
- position: relative;
3
- }
4
-
5
- .copyright-image {
6
- position: absolute;
7
- z-index: 1000;
8
- top: 90%;
9
- width: 100%;
10
- padding-right: 10px;
11
- padding-left: 10px;
12
- }