@eeacms/volto-eea-website-theme 2.3.0 → 2.4.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/package.json +3 -1
  3. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx +45 -0
  4. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +88 -0
  5. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.jsx +14 -0
  6. package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.test.jsx +71 -0
  7. package/src/components/manage/Blocks/ContextNavigation/index.js +30 -0
  8. package/src/components/manage/Blocks/ContextNavigation/schema.js +88 -0
  9. package/src/components/manage/Blocks/ContextNavigation/variations/Accordion.jsx +179 -0
  10. package/src/components/manage/Blocks/ContextNavigation/variations/Default.jsx +9 -0
  11. package/src/components/manage/Blocks/ContextNavigation/variations/index.js +18 -0
  12. package/src/components/manage/Blocks/Title/Edit.jsx +7 -4
  13. package/src/components/manage/Blocks/Title/View.jsx +14 -24
  14. package/src/components/manage/Blocks/Title/index.js +52 -0
  15. package/src/components/manage/Blocks/Title/variations/Default.jsx +43 -0
  16. package/src/components/manage/Blocks/Title/variations/WebReport.jsx +69 -0
  17. package/src/components/manage/Blocks/Title/variations/WebReportPage.jsx +59 -0
  18. package/src/components/manage/Blocks/Title/variations/styles.less +28 -0
  19. package/src/components/theme/Banner/View.jsx +5 -1
  20. package/src/components/theme/SubsiteClass.jsx +3 -1
  21. package/src/components/theme/WebReport/WebReportSectionView.jsx +49 -0
  22. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +20 -2
  23. package/src/customizations/volto/components/theme/Header/Header.jsx +3 -3
  24. package/src/customizations/volto/components/theme/View/DefaultView.jsx +190 -0
  25. package/src/hocs/withDeviceSize.test.jsx +79 -0
  26. package/src/index.js +20 -7
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { render, act } from '@testing-library/react';
3
+ import withDeviceSize from './withDeviceSize.jsx';
4
+
5
+ describe('withDeviceSize HOC', () => {
6
+ // Mock the WrappedComponent
7
+ const WrappedComponent = ({ device }) => (
8
+ <div data-testid="device">{device}</div>
9
+ );
10
+
11
+ const mockResize = (width) => {
12
+ Object.defineProperty(document.documentElement, 'clientWidth', {
13
+ writable: true,
14
+ configurable: true,
15
+ value: width,
16
+ });
17
+ window.dispatchEvent(new Event('resize'));
18
+ };
19
+
20
+ it('should return mobile for screen width less than 768px', () => {
21
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
22
+
23
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
24
+
25
+ act(() => {
26
+ mockResize(500); // Simulating a mobile screen
27
+ });
28
+
29
+ expect(getByTestId('device').textContent).toBe('mobile');
30
+ });
31
+
32
+ it('should return tablet for screen width between 768px and 992px', () => {
33
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
34
+
35
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
36
+
37
+ act(() => {
38
+ mockResize(800); // Simulating a tablet screen
39
+ });
40
+
41
+ expect(getByTestId('device').textContent).toBe('tablet');
42
+ });
43
+
44
+ it('should return computer for screen width between 992px and 1200px', () => {
45
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
46
+
47
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
48
+
49
+ act(() => {
50
+ mockResize(1000); // Simulating a computer screen
51
+ });
52
+
53
+ expect(getByTestId('device').textContent).toBe('computer');
54
+ });
55
+
56
+ it('should return large for screen width between 1200px and 1920px', () => {
57
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
58
+
59
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
60
+
61
+ act(() => {
62
+ mockResize(1500); // Simulating a large screen
63
+ });
64
+
65
+ expect(getByTestId('device').textContent).toBe('large');
66
+ });
67
+
68
+ it('should return widescreen for screen width above 1920px', () => {
69
+ const ComponentWithDeviceSize = withDeviceSize(WrappedComponent);
70
+
71
+ const { getByTestId } = render(<ComponentWithDeviceSize />);
72
+
73
+ act(() => {
74
+ mockResize(2000); // Simulating a widescreen display
75
+ });
76
+
77
+ expect(getByTestId('device').textContent).toBe('widescreen');
78
+ });
79
+ });
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ import CustomCSS from '@eeacms/volto-eea-website-theme/components/theme/CustomCS
11
11
  import DraftBackground from '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground';
12
12
  import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView';
13
13
  import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView';
14
+ import WebReportSectionView from '@eeacms/volto-eea-website-theme/components/theme/WebReport/WebReportSectionView';
14
15
  import NotFound from '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound';
15
16
  import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget';
16
17
  import { TopicsWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TopicsWidget';
@@ -26,6 +27,7 @@ import {
26
27
  } from '@eeacms/volto-eea-website-theme/helpers/schema-utils';
27
28
 
28
29
  import installLayoutSettingsBlock from '@eeacms/volto-eea-website-theme/components/manage/Blocks/LayoutSettings';
30
+ import installContextNavigationBlock from '@eeacms/volto-eea-website-theme/components/manage/Blocks/ContextNavigation';
29
31
  import installCustomTitle from '@eeacms/volto-eea-website-theme/components/manage/Blocks/Title';
30
32
 
31
33
  import FlexGroup from '@eeacms/volto-eea-website-theme/components/manage/Blocks/GroupBlockTemplate/FlexGroup/FlexGroup';
@@ -241,7 +243,14 @@ const applyConfig = (config) => {
241
243
  ...(config.views.layoutViewsNamesMapping || {}),
242
244
  homepage_view: 'Homepage view',
243
245
  homepage_inverse_view: 'Homepage white view',
246
+ web_report_section: 'Web report section',
244
247
  };
248
+
249
+ config.views.contentTypesViews = {
250
+ ...(config.views.contentTypesViews || {}),
251
+ web_report_section: WebReportSectionView,
252
+ };
253
+
245
254
  config.views.errorViews = {
246
255
  ...config.views.errorViews,
247
256
  404: NotFound,
@@ -486,11 +495,11 @@ const applyConfig = (config) => {
486
495
  // },
487
496
  };
488
497
 
489
- // layout settings
490
- config = [installLayoutSettingsBlock].reduce(
491
- (acc, apply) => apply(acc),
492
- config,
493
- );
498
+ //If you don't want to show the content type as a link in the breadcrumbs, you can set it to a number
499
+ // where 1 is the last item in the breadcrumbs, 2 is the second last, etc.
500
+ config.settings.contentTypeToAvoidAsLinks = {
501
+ web_report_section: 2,
502
+ };
494
503
 
495
504
  // Group
496
505
  if (config.blocks.blocksConfig.group) {
@@ -559,8 +568,12 @@ const applyConfig = (config) => {
559
568
  GET_CONTENT: ['breadcrumbs'], // 'navigation', 'actions', 'types'],
560
569
  });
561
570
 
562
- // Custom blocks: Title
563
- return [installCustomTitle].reduce((acc, apply) => apply(acc), config);
571
+ // Custom blocks: Title,Layout settings, Context navigation
572
+ return [
573
+ installCustomTitle,
574
+ installLayoutSettingsBlock,
575
+ installContextNavigationBlock,
576
+ ].reduce((acc, apply) => apply(acc), config);
564
577
  };
565
578
 
566
579
  export default applyConfig;