@eeacms/volto-n2k 0.1.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.
Files changed (233) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.release-it.json +17 -0
  3. package/CHANGELOG.md +155 -0
  4. package/DEVELOP.md +53 -0
  5. package/Jenkinsfile +209 -0
  6. package/LICENSE.md +9 -0
  7. package/README.md +62 -0
  8. package/bootstrap +41 -0
  9. package/cypress/fixtures/example.json +5 -0
  10. package/cypress/integration/block-basics.js +32 -0
  11. package/cypress/plugins/index.js +26 -0
  12. package/cypress/support/commands.js +315 -0
  13. package/cypress/support/index.js +53 -0
  14. package/cypress.json +12 -0
  15. package/jest-addon.config.js +36 -0
  16. package/package.json +57 -0
  17. package/src/actions.js +20 -0
  18. package/src/components/index.js +3 -0
  19. package/src/components/manage/Blocks/BodyClass/Edit.jsx +29 -0
  20. package/src/components/manage/Blocks/BodyClass/View.jsx +13 -0
  21. package/src/components/manage/Blocks/BodyClass/index.js +24 -0
  22. package/src/components/manage/Blocks/BodyClass/schema.js +19 -0
  23. package/src/components/manage/Blocks/BubbleChart/BubbleChart.jsx +101 -0
  24. package/src/components/manage/Blocks/BubbleChart/Chart.jsx +67 -0
  25. package/src/components/manage/Blocks/BubbleChart/ChartContext.jsx +3 -0
  26. package/src/components/manage/Blocks/BubbleChart/View.jsx +63 -0
  27. package/src/components/manage/Blocks/BubbleChart/index.js +17 -0
  28. package/src/components/manage/Blocks/BubbleChart/schema.js +124 -0
  29. package/src/components/manage/Blocks/BubbleChart/style.less +12 -0
  30. package/src/components/manage/Blocks/CarouselHorizontal/HorizontalView.jsx +221 -0
  31. package/src/components/manage/Blocks/CarouselHorizontal/index.js +19 -0
  32. package/src/components/manage/Blocks/CarouselHorizontal/schema.js +32 -0
  33. package/src/components/manage/Blocks/CddaShape/View.jsx +109 -0
  34. package/src/components/manage/Blocks/CddaShape/index.js +23 -0
  35. package/src/components/manage/Blocks/CddaShape/schema.js +19 -0
  36. package/src/components/manage/Blocks/CddaShape/style.less +14 -0
  37. package/src/components/manage/Blocks/ContactBlock/View.jsx +56 -0
  38. package/src/components/manage/Blocks/ContactBlock/icons/domain.svg +1 -0
  39. package/src/components/manage/Blocks/ContactBlock/icons/email.svg +1 -0
  40. package/src/components/manage/Blocks/ContactBlock/icons/location.svg +1 -0
  41. package/src/components/manage/Blocks/ContactBlock/index.js +17 -0
  42. package/src/components/manage/Blocks/ContactBlock/schema.js +57 -0
  43. package/src/components/manage/Blocks/ContactBlock/styles.less +31 -0
  44. package/src/components/manage/Blocks/ExplodedPiesChart/Pie.jsx +125 -0
  45. package/src/components/manage/Blocks/ExplodedPiesChart/View.jsx +80 -0
  46. package/src/components/manage/Blocks/ExplodedPiesChart/index.js +17 -0
  47. package/src/components/manage/Blocks/ExplodedPiesChart/schema.js +75 -0
  48. package/src/components/manage/Blocks/ExplodedPiesChart/style.less +80 -0
  49. package/src/components/manage/Blocks/ExploreHabitats/Edit.jsx +29 -0
  50. package/src/components/manage/Blocks/ExploreHabitats/View.jsx +177 -0
  51. package/src/components/manage/Blocks/ExploreHabitats/index.js +24 -0
  52. package/src/components/manage/Blocks/ExploreHabitats/schema.js +15 -0
  53. package/src/components/manage/Blocks/ExploreHabitats/style.less +15 -0
  54. package/src/components/manage/Blocks/ExploreSites/Edit.jsx +29 -0
  55. package/src/components/manage/Blocks/ExploreSites/View.jsx +175 -0
  56. package/src/components/manage/Blocks/ExploreSites/index.js +24 -0
  57. package/src/components/manage/Blocks/ExploreSites/schema.js +15 -0
  58. package/src/components/manage/Blocks/ExploreSites/style.less +15 -0
  59. package/src/components/manage/Blocks/ExploreSpecies/Edit.jsx +29 -0
  60. package/src/components/manage/Blocks/ExploreSpecies/View.jsx +177 -0
  61. package/src/components/manage/Blocks/ExploreSpecies/index.js +24 -0
  62. package/src/components/manage/Blocks/ExploreSpecies/schema.js +15 -0
  63. package/src/components/manage/Blocks/ExploreSpecies/style.less +15 -0
  64. package/src/components/manage/Blocks/HabitatClassification/View.jsx +30 -0
  65. package/src/components/manage/Blocks/HabitatClassification/index.js +17 -0
  66. package/src/components/manage/Blocks/HabitatClassification/schema.js +19 -0
  67. package/src/components/manage/Blocks/HabitatClassification/style.less +3 -0
  68. package/src/components/manage/Blocks/HabitatDistribution/View.jsx +97 -0
  69. package/src/components/manage/Blocks/HabitatDistribution/index.js +23 -0
  70. package/src/components/manage/Blocks/HabitatDistribution/schema.js +19 -0
  71. package/src/components/manage/Blocks/HabitatDistribution/style.less +5 -0
  72. package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +97 -0
  73. package/src/components/manage/Blocks/HabitatProtectedSites/index.js +23 -0
  74. package/src/components/manage/Blocks/HabitatProtectedSites/schema.js +19 -0
  75. package/src/components/manage/Blocks/HabitatProtectedSites/style.less +5 -0
  76. package/src/components/manage/Blocks/HabitatsBanner/View.jsx +39 -0
  77. package/src/components/manage/Blocks/HabitatsBanner/index.js +17 -0
  78. package/src/components/manage/Blocks/HabitatsBanner/schema.js +19 -0
  79. package/src/components/manage/Blocks/HabitatsBanner/style.less +49 -0
  80. package/src/components/manage/Blocks/ImageText/Edit.jsx +98 -0
  81. package/src/components/manage/Blocks/ImageText/View.jsx +66 -0
  82. package/src/components/manage/Blocks/ImageText/index.js +24 -0
  83. package/src/components/manage/Blocks/ImageText/schema.js +69 -0
  84. package/src/components/manage/Blocks/ImageText/styles.less +87 -0
  85. package/src/components/manage/Blocks/Landing/DefalutView.jsx +83 -0
  86. package/src/components/manage/Blocks/Landing/Edit.jsx +219 -0
  87. package/src/components/manage/Blocks/Landing/EditBlockWrapper.jsx +161 -0
  88. package/src/components/manage/Blocks/Landing/View.jsx +65 -0
  89. package/src/components/manage/Blocks/Landing/images/background.webp +0 -0
  90. package/src/components/manage/Blocks/Landing/images/coasts_and_seas.webp +0 -0
  91. package/src/components/manage/Blocks/Landing/images/forests.webp +0 -0
  92. package/src/components/manage/Blocks/Landing/images/grasslands.webp +0 -0
  93. package/src/components/manage/Blocks/Landing/images/hiker.webp +0 -0
  94. package/src/components/manage/Blocks/Landing/images/islands.webp +0 -0
  95. package/src/components/manage/Blocks/Landing/images/mountains.webp +0 -0
  96. package/src/components/manage/Blocks/Landing/images/natura2000.webp +0 -0
  97. package/src/components/manage/Blocks/Landing/images/natura2000_square.webp +0 -0
  98. package/src/components/manage/Blocks/Landing/images/peatlands.webp +0 -0
  99. package/src/components/manage/Blocks/Landing/images/people_and_nature.webp +0 -0
  100. package/src/components/manage/Blocks/Landing/images/rivers.webp +0 -0
  101. package/src/components/manage/Blocks/Landing/index.js +104 -0
  102. package/src/components/manage/Blocks/Landing/schema.js +62 -0
  103. package/src/components/manage/Blocks/Landing/style.less +174 -0
  104. package/src/components/manage/Blocks/List/View.jsx +37 -0
  105. package/src/components/manage/Blocks/List/index.js +17 -0
  106. package/src/components/manage/Blocks/List/schema.js +49 -0
  107. package/src/components/manage/Blocks/List/style.less +12 -0
  108. package/src/components/manage/Blocks/NavigationAnchors/Edit.jsx +33 -0
  109. package/src/components/manage/Blocks/NavigationAnchors/View.jsx +132 -0
  110. package/src/components/manage/Blocks/NavigationAnchors/assets/external.png +0 -0
  111. package/src/components/manage/Blocks/NavigationAnchors/index.js +23 -0
  112. package/src/components/manage/Blocks/NavigationAnchors/schema.js +76 -0
  113. package/src/components/manage/Blocks/NavigationAnchors/styles.less +104 -0
  114. package/src/components/manage/Blocks/SimpleDataTable/index.js +16 -0
  115. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/View.jsx +178 -0
  116. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/index.js +4 -0
  117. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/schema.js +56 -0
  118. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/style.less +54 -0
  119. package/src/components/manage/Blocks/SiteBanner/View.jsx +148 -0
  120. package/src/components/manage/Blocks/SiteBanner/index.js +17 -0
  121. package/src/components/manage/Blocks/SiteBanner/schema.js +19 -0
  122. package/src/components/manage/Blocks/SiteBanner/style.less +106 -0
  123. package/src/components/manage/Blocks/SiteHabitatsList/View.jsx +89 -0
  124. package/src/components/manage/Blocks/SiteHabitatsList/index.js +17 -0
  125. package/src/components/manage/Blocks/SiteHabitatsList/schema.js +19 -0
  126. package/src/components/manage/Blocks/SiteHabitatsList/style.less +70 -0
  127. package/src/components/manage/Blocks/SiteProtectedHabitats/View.jsx +47 -0
  128. package/src/components/manage/Blocks/SiteProtectedHabitats/images/background.webp +0 -0
  129. package/src/components/manage/Blocks/SiteProtectedHabitats/index.js +17 -0
  130. package/src/components/manage/Blocks/SiteProtectedHabitats/schema.js +19 -0
  131. package/src/components/manage/Blocks/SiteProtectedHabitats/style.less +90 -0
  132. package/src/components/manage/Blocks/SiteProtectedSpecies/View.jsx +55 -0
  133. package/src/components/manage/Blocks/SiteProtectedSpecies/images/background.webp +0 -0
  134. package/src/components/manage/Blocks/SiteProtectedSpecies/index.js +17 -0
  135. package/src/components/manage/Blocks/SiteProtectedSpecies/schema.js +19 -0
  136. package/src/components/manage/Blocks/SiteProtectedSpecies/style.less +90 -0
  137. package/src/components/manage/Blocks/SiteShape/View.jsx +107 -0
  138. package/src/components/manage/Blocks/SiteShape/index.js +23 -0
  139. package/src/components/manage/Blocks/SiteShape/schema.js +19 -0
  140. package/src/components/manage/Blocks/SiteShape/style.less +15 -0
  141. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SortBy.jsx +52 -0
  142. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SpeciesGroups.jsx +43 -0
  143. package/src/components/manage/Blocks/SiteSpeciesList/Filters/View.jsx +200 -0
  144. package/src/components/manage/Blocks/SiteSpeciesList/Filters/index.js +4 -0
  145. package/src/components/manage/Blocks/SiteSpeciesList/View.jsx +253 -0
  146. package/src/components/manage/Blocks/SiteSpeciesList/index.js +17 -0
  147. package/src/components/manage/Blocks/SiteSpeciesList/schema.js +19 -0
  148. package/src/components/manage/Blocks/SiteSpeciesList/style.less +264 -0
  149. package/src/components/manage/Blocks/SiteSpeciesList/utils.js +33 -0
  150. package/src/components/manage/Blocks/SlateLink/render.jsx +77 -0
  151. package/src/components/manage/Blocks/SlateLink/styles.less +22 -0
  152. package/src/components/manage/Blocks/SlateSVG/constants.js +1 -0
  153. package/src/components/manage/Blocks/SlateSVG/extensions.js +11 -0
  154. package/src/components/manage/Blocks/SlateSVG/index.js +47 -0
  155. package/src/components/manage/Blocks/SlateSVG/render.jsx +42 -0
  156. package/src/components/manage/Blocks/SlateSVG/schema.js +12 -0
  157. package/src/components/manage/Blocks/SlateSVG/styles.less +6 -0
  158. package/src/components/manage/Blocks/SpeciesBanner/View.jsx +109 -0
  159. package/src/components/manage/Blocks/SpeciesBanner/index.js +17 -0
  160. package/src/components/manage/Blocks/SpeciesBanner/schema.js +19 -0
  161. package/src/components/manage/Blocks/SpeciesBanner/style.less +115 -0
  162. package/src/components/manage/Blocks/SpeciesClassification/View.jsx +19 -0
  163. package/src/components/manage/Blocks/SpeciesClassification/index.js +17 -0
  164. package/src/components/manage/Blocks/SpeciesClassification/schema.js +19 -0
  165. package/src/components/manage/Blocks/SpeciesClassification/style.less +3 -0
  166. package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +97 -0
  167. package/src/components/manage/Blocks/SpeciesDistribution/index.js +23 -0
  168. package/src/components/manage/Blocks/SpeciesDistribution/schema.js +19 -0
  169. package/src/components/manage/Blocks/SpeciesDistribution/style.less +5 -0
  170. package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +97 -0
  171. package/src/components/manage/Blocks/SpeciesProtectedSites/index.js +23 -0
  172. package/src/components/manage/Blocks/SpeciesProtectedSites/schema.js +19 -0
  173. package/src/components/manage/Blocks/SpeciesProtectedSites/style.less +5 -0
  174. package/src/components/manage/Blocks/StackedBarChart/Chart.jsx +127 -0
  175. package/src/components/manage/Blocks/StackedBarChart/ChartContext.jsx +3 -0
  176. package/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +116 -0
  177. package/src/components/manage/Blocks/StackedBarChart/View.jsx +64 -0
  178. package/src/components/manage/Blocks/StackedBarChart/index.js +17 -0
  179. package/src/components/manage/Blocks/StackedBarChart/schema.js +25 -0
  180. package/src/components/manage/Blocks/StackedBarChart/style.less +37 -0
  181. package/src/components/manage/Blocks/TilesImages/Edit.jsx +32 -0
  182. package/src/components/manage/Blocks/TilesImages/View.jsx +37 -0
  183. package/src/components/manage/Blocks/TilesImages/index.js +23 -0
  184. package/src/components/manage/Blocks/TilesImages/schema.js +72 -0
  185. package/src/components/manage/Blocks/TilesImages/styles.less +57 -0
  186. package/src/components/theme/AppExtras/CopyPaste/CopyPaste.jsx +176 -0
  187. package/src/components/theme/AppExtras/CopyPaste/index.js +3 -0
  188. package/src/components/theme/AppExtras/CopyPaste/style.less +18 -0
  189. package/src/components/theme/AppExtras/MultilingualRedirector/MultilingualRedirector.jsx +35 -0
  190. package/src/components/theme/AppExtras/index.js +13 -0
  191. package/src/components/theme/Footer/Footer.jsx +209 -0
  192. package/src/components/theme/Header/Header.jsx +81 -0
  193. package/src/components/theme/LanguageSelector/LanguageSelector.jsx +79 -0
  194. package/src/components/theme/LanguageSelector/styles.less +44 -0
  195. package/src/components/theme/Navigation/Navigation.jsx +453 -0
  196. package/src/components/theme/Sitemap/Sitemap.jsx +152 -0
  197. package/src/fonts/OpenSans-Bold.ttf +0 -0
  198. package/src/fonts/OpenSans-Regular.ttf +0 -0
  199. package/src/fonts/OpenSans-Semibold.ttf +0 -0
  200. package/src/fonts/Rajdhani-Bold.ttf +0 -0
  201. package/src/fonts/Rajdhani-Regular.ttf +0 -0
  202. package/src/grid.js +78 -0
  203. package/src/helpers.js +148 -0
  204. package/src/hocs/index.js +6 -0
  205. package/src/hocs/useResizeObserver.jsx +26 -0
  206. package/src/hocs/withLocalStorage.jsx +37 -0
  207. package/src/hocs/withScreenSize.jsx +43 -0
  208. package/src/icons/home.svg +12 -0
  209. package/src/icons/info.svg +5 -0
  210. package/src/icons/n2k-logo-transparent.png +0 -0
  211. package/src/icons/n2k-logo.png +0 -0
  212. package/src/icons/natura2000.svg +142 -0
  213. package/src/icons/placeholders/Algae.png +0 -0
  214. package/src/icons/placeholders/Amphibians.png +0 -0
  215. package/src/icons/placeholders/Birds.png +0 -0
  216. package/src/icons/placeholders/Conifers.png +0 -0
  217. package/src/icons/placeholders/Fishes.png +0 -0
  218. package/src/icons/placeholders/Fungi.png +0 -0
  219. package/src/icons/placeholders/Mammals.png +0 -0
  220. package/src/icons/placeholders/Plants.png +0 -0
  221. package/src/icons/placeholders/Reptiles.png +0 -0
  222. package/src/icons/placeholders/default.png +0 -0
  223. package/src/index.js +163 -0
  224. package/src/less/globals.less +3 -0
  225. package/src/less/styles.less +691 -0
  226. package/src/less/variables.less +2 -0
  227. package/src/static/cca.svg +61 -0
  228. package/src/static/ec.png +0 -0
  229. package/src/static/eea.png +0 -0
  230. package/src/static/eu.jpg +0 -0
  231. package/src/static/forest.svg +100 -0
  232. package/src/static/wise.png +0 -0
  233. package/src/store.js +24 -0
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import _uniqueId from 'lodash/uniqueId';
3
+ import { pack, hierarchy } from 'd3';
4
+ import * as d3 from 'd3';
5
+ import { adjustBrightness, getContrastColor } from '@eeacms/volto-n2k/helpers';
6
+ import { FormattedValue } from '@eeacms/volto-datablocks/Utils';
7
+ import ChartContext from './ChartContext';
8
+
9
+ function BubbleChart(props) {
10
+ const { chartData, interpolation } = props;
11
+ const { element, height, width, popup, setPopup } = React.useContext(
12
+ ChartContext,
13
+ );
14
+ const root = pack().size([width, height]).padding(10)(
15
+ hierarchy({ children: chartData })
16
+ .sum((d) => d.value)
17
+ .sort((a, b) => b.value - a.value),
18
+ );
19
+ const backgroundColor = React.useCallback(
20
+ (value) => {
21
+ if (chartData?.[0]?.maxValue && chartData?.[0]?.minValue) {
22
+ return d3
23
+ .scaleSequential()
24
+ .domain([chartData[0].minValue, chartData[0].maxValue])
25
+ .interpolator(d3[interpolation])(value);
26
+ }
27
+ return '#000';
28
+ },
29
+ /* eslint-disable-next-line */
30
+ [chartData, interpolation],
31
+ );
32
+
33
+ return (
34
+ <React.Fragment>
35
+ {root.leaves().map((leaf, index) => {
36
+ const data = leaf.data;
37
+ if (!leaf.r) return '';
38
+ const id = _uniqueId('leaf-');
39
+
40
+ return (
41
+ <g
42
+ key={`leaf-${data.name}`}
43
+ style={{
44
+ transform: `translate(${leaf.x}px, ${leaf.y}px)`,
45
+ }}
46
+ >
47
+ <circle
48
+ id={id}
49
+ r={leaf.r}
50
+ fill={
51
+ popup?.id === `${index}_leaf_${data.name}`
52
+ ? adjustBrightness(backgroundColor(leaf.value), -20)
53
+ : backgroundColor(leaf.value)
54
+ }
55
+ onFocus={() => {}}
56
+ onBlur={() => {}}
57
+ onMouseMoveCapture={(event) => {
58
+ const elementPosition = element.parentNode.getBoundingClientRect();
59
+ setPopup({
60
+ id: `${index}_leaf_${data.name}`,
61
+ clientX: event.clientX - elementPosition.x,
62
+ clientY: event.clientY - elementPosition.y - 16,
63
+ content: (
64
+ <>
65
+ <p>{data.name}</p>
66
+ </>
67
+ ),
68
+ });
69
+ }}
70
+ onMouseOut={() => {
71
+ setPopup(null);
72
+ }}
73
+ />
74
+ <text
75
+ className="bubble-text"
76
+ fill={getContrastColor(backgroundColor(leaf.value))}
77
+ >
78
+ <tspan x={0} y={0}>
79
+ <FormattedValue
80
+ value={data.name}
81
+ textTemplate={props.data.yTextTemplate}
82
+ specifier={props.data.ySpecifier}
83
+ wrapped={false}
84
+ />
85
+ </tspan>
86
+ <tspan x={0} y={'28px'}>
87
+ <FormattedValue
88
+ value={data.value}
89
+ textTemplate={props.data.xTextTemplate}
90
+ specifier={props.data.xSpecifier}
91
+ wrapped={false}
92
+ />
93
+ </tspan>
94
+ </text>
95
+ </g>
96
+ );
97
+ })}
98
+ </React.Fragment>
99
+ );
100
+ }
101
+ export default BubbleChart;
@@ -0,0 +1,67 @@
1
+ import React, { useState, useRef } from 'react';
2
+ import cx from 'classnames';
3
+ import ChartContext from './ChartContext';
4
+
5
+ /**
6
+ * example:
7
+ * <Chart width="100%" height="400px">
8
+ * <Bars />
9
+ * <Legend />
10
+ * </Chart>
11
+ */
12
+
13
+ function Chart(props) {
14
+ const [popup, setPopup] = useState();
15
+ const chartWrapper = useRef();
16
+ const svgRef = useRef();
17
+ const popupRef = useRef();
18
+ const { margin = { top: 20, right: 30, bottom: 70, left: 40 } } = props;
19
+
20
+ // const dispose = () => {
21
+ // const svg = select(svgRef.current);
22
+ // svg.selectAll('*').remove();
23
+ // };
24
+
25
+ return (
26
+ <ChartContext.Provider
27
+ value={{
28
+ element: svgRef.current,
29
+ popupElement: popupRef.current,
30
+ height: props.height,
31
+ width: props.width,
32
+ margin,
33
+ popup,
34
+ setPopup,
35
+ }}
36
+ >
37
+ <div ref={chartWrapper} className="chart-wrapper">
38
+ <svg
39
+ viewBox={`0 0 ${props.width} ${props.height}`}
40
+ preserveAspectRatio="xMinYMin meet"
41
+ ref={svgRef}
42
+ >
43
+ {props.children}
44
+ </svg>
45
+ <div
46
+ style={
47
+ popup
48
+ ? {
49
+ top: popup.clientY - 20,
50
+ left: popup.clientX,
51
+ }
52
+ : {}
53
+ }
54
+ className={cx(
55
+ 'chart-popup ui top center popup',
56
+ popup?.content ? 'visible' : {},
57
+ )}
58
+ ref={popupRef}
59
+ >
60
+ <div className="content">{popup ? popup.content : ''}</div>
61
+ </div>
62
+ </div>
63
+ </ChartContext.Provider>
64
+ );
65
+ }
66
+
67
+ export default Chart;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ const ChartContext = new React.createContext();
3
+ export default ChartContext;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import Chart from './Chart';
3
+ import BubbleChart from './BubbleChart';
4
+
5
+ import './style.less';
6
+
7
+ const View = (props) => {
8
+ const [chartData, setChartData] = React.useState([]);
9
+ const { x, y, interpolation = 'interpolateBlues' } = props.data;
10
+ const data = props.provider_data || {};
11
+
12
+ React.useEffect(() => {
13
+ if (!x || !y || !data[x]?.length || !data[y]?.length) return;
14
+ let total = 0;
15
+ let maxValue = -Infinity;
16
+ let minValue = Infinity;
17
+ data[x].forEach((value) => {
18
+ total += value;
19
+ if (value > maxValue) {
20
+ maxValue = value;
21
+ }
22
+ if (value < minValue) {
23
+ minValue = value;
24
+ }
25
+ });
26
+ setChartData([
27
+ ...data[x].map((_, index) => ({
28
+ name: data[y][index],
29
+ value: data[x][index],
30
+ percentage: data[x][index] / total,
31
+ maxValue,
32
+ minValue,
33
+ })),
34
+ ]);
35
+ /* eslint-disable-next-line */
36
+ }, [x, y, data]);
37
+
38
+ if (__SERVER__) return '';
39
+ return (
40
+ <React.Fragment>
41
+ <div className="bubble-chart">
42
+ {data?.[x]?.length ? (
43
+ <p style={{ textAlign: 'center' }}>
44
+ The <span className="highlight">{data[x].length}</span> Member
45
+ States with the highest number of sites
46
+ </p>
47
+ ) : (
48
+ ''
49
+ )}
50
+ <Chart width={800} height={800}>
51
+ <BubbleChart
52
+ data={props.data}
53
+ x={x}
54
+ y={y}
55
+ chartData={chartData}
56
+ interpolation={interpolation}
57
+ />
58
+ </Chart>
59
+ </div>
60
+ </React.Fragment>
61
+ );
62
+ };
63
+ export default View;
@@ -0,0 +1,17 @@
1
+ import BubbleChart from './View';
2
+ import getSchema from './schema';
3
+
4
+ export default (config) => {
5
+ config.blocks.blocksConfig.custom_connected_block = {
6
+ ...config.blocks.blocksConfig.custom_connected_block,
7
+ blocks: {
8
+ ...config.blocks.blocksConfig.custom_connected_block.blocks,
9
+ bubble_chart: {
10
+ view: BubbleChart,
11
+ getSchema: getSchema,
12
+ title: 'Bubble chart',
13
+ },
14
+ },
15
+ };
16
+ return config;
17
+ };
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+
3
+ const getSchema = (props) => {
4
+ const data = props.provider_data || {};
5
+ const choices = Object.keys(data).map((key) => [key, key]);
6
+
7
+ return {
8
+ title: 'Bubble chart',
9
+
10
+ fieldsets: [
11
+ {
12
+ id: 'default',
13
+ title: 'Default',
14
+ fields: ['x', 'y', 'interpolation'],
15
+ },
16
+ {
17
+ id: 'size_column',
18
+ title: 'Size column',
19
+ fields: ['xSpecifier', 'xTextTemplate'],
20
+ },
21
+ {
22
+ id: 'label_column',
23
+ title: 'Label column',
24
+ fields: ['ySpecifier', 'yTextTemplate'],
25
+ },
26
+ ],
27
+
28
+ properties: {
29
+ x: {
30
+ title: 'Size column',
31
+ choices,
32
+ },
33
+ y: {
34
+ title: 'Label column',
35
+ choices,
36
+ },
37
+ interpolation: {
38
+ title: 'Color schema',
39
+ choices: [
40
+ 'interpolateBlues',
41
+ 'interpolateBrBG',
42
+ 'interpolateBuGn',
43
+ 'interpolateBuPu',
44
+ 'interpolateCividis',
45
+ 'interpolateCool',
46
+ 'interpolateCubehelixDefault',
47
+ 'interpolateGnBu',
48
+ 'interpolateGreens',
49
+ 'interpolateGreys',
50
+ 'interpolateInferno',
51
+ 'interpolateMagma',
52
+ 'interpolateOrRd',
53
+ 'interpolateOranges',
54
+ 'interpolatePRGn',
55
+ 'interpolatePiYG',
56
+ 'interpolatePlasma',
57
+ 'interpolatePuBu',
58
+ 'interpolatePuBuGn',
59
+ 'interpolatePuOr',
60
+ 'interpolatePuRd',
61
+ 'interpolatePurples',
62
+ 'interpolateRainbow',
63
+ 'interpolateRdBu',
64
+ 'interpolateRdGy',
65
+ 'interpolateRdPu',
66
+ 'interpolateRdYlBu',
67
+ 'interpolateRdYlGn',
68
+ 'interpolateReds',
69
+ 'interpolateSinebow',
70
+ 'interpolateSpectral',
71
+ 'interpolateTurbo',
72
+ 'interpolateViridis',
73
+ 'interpolateWarm',
74
+ 'interpolateYlGn',
75
+ 'interpolateYlGnBu',
76
+ 'interpolateYlOrBr',
77
+ 'interpolateYlOrRd',
78
+ ].map((item) => [item, item]),
79
+ },
80
+ xSpecifier: {
81
+ title: 'Format specifier',
82
+ description: (
83
+ <>
84
+ See{' '}
85
+ <a
86
+ target="_blank"
87
+ rel="noopener noreferrer"
88
+ href="https://github.com/d3/d3-format"
89
+ >
90
+ D3 format documentation
91
+ </a>
92
+ </>
93
+ ),
94
+ },
95
+ xTextTemplate: {
96
+ title: 'Text template',
97
+ description: 'Add suffix/prefix to text. Use {} for value placeholder',
98
+ },
99
+ ySpecifier: {
100
+ title: 'Format specifier',
101
+ description: (
102
+ <>
103
+ See{' '}
104
+ <a
105
+ target="_blank"
106
+ rel="noopener noreferrer"
107
+ href="https://github.com/d3/d3-format"
108
+ >
109
+ D3 format documentation
110
+ </a>
111
+ </>
112
+ ),
113
+ },
114
+ yTextTemplate: {
115
+ title: 'Text template',
116
+ description: 'Add suffix/prefix to text. Use {} for value placeholder',
117
+ },
118
+ },
119
+
120
+ required: [],
121
+ };
122
+ };
123
+
124
+ export default getSchema;
@@ -0,0 +1,12 @@
1
+ .bubble-chart {
2
+ .bubble-text {
3
+ font-size: 22px;
4
+ font-weight: 600;
5
+ text-anchor: middle;
6
+ }
7
+
8
+ .highlight {
9
+ color: #ed1834;
10
+ font-weight: bold;
11
+ }
12
+ }
@@ -0,0 +1,221 @@
1
+ import React from 'react';
2
+ import { connect } from 'react-redux';
3
+ import { compose } from 'redux';
4
+ import { withRouter } from 'react-router';
5
+ import loadable from '@loadable/component';
6
+ import { Icon, RenderBlocks } from '@plone/volto/components';
7
+ import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
8
+ import rightArrowSVG from '@eeacms/volto-tabs-block/icons/right-arrow.svg';
9
+ import leftArrowSVG from '@eeacms/volto-tabs-block/icons/left-arrow.svg';
10
+ import cx from 'classnames';
11
+ import 'slick-carousel/slick/slick.css';
12
+ import 'slick-carousel/slick/slick-theme.css';
13
+ import '@eeacms/volto-tabs-block/less/carousel.less';
14
+
15
+ const Slider = loadable(() => import('react-slick'));
16
+
17
+ const Dots = (props) => {
18
+ const { activeTab = null, tabsList = [], slider = {} } = props;
19
+ return slider.current && tabsList.length > 1 ? (
20
+ <div className="slick-dots-wrapper">
21
+ <div className="slick-line" />
22
+ <ul className={cx('slick-dots ui container', props.uiContainer)}>
23
+ {tabsList.map((tab, index) => (
24
+ <li
25
+ key={`dot-${tab}`}
26
+ className={cx({ 'slick-active': activeTab === tab })}
27
+ >
28
+ <button
29
+ aria-label={`Select slide ${index + 1}`}
30
+ onClick={() => {
31
+ slider.current.slickGoTo(index);
32
+ }}
33
+ />
34
+ </li>
35
+ ))}
36
+ </ul>
37
+ </div>
38
+ ) : (
39
+ ''
40
+ );
41
+ };
42
+
43
+ const ArrowsGroup = (props) => {
44
+ const { activeTab = null, tabsList = [], slider = {} } = props;
45
+ const currentSlide = tabsList.indexOf(activeTab);
46
+ const slideCount = tabsList.length;
47
+
48
+ return slider.current ? (
49
+ <div
50
+ className={cx({
51
+ 'slick-arrows': true,
52
+ 'one-arrow': currentSlide === 0 || currentSlide === slideCount - 1,
53
+ })}
54
+ >
55
+ {currentSlide > 0 ? (
56
+ <button
57
+ aria-label="Previous slide"
58
+ className="slick-arrow slick-prev"
59
+ onClick={slider.current.slickPrev}
60
+ >
61
+ <Icon name={leftArrowSVG} size="50px" />
62
+ </button>
63
+ ) : (
64
+ ''
65
+ )}
66
+ {currentSlide < slideCount - 1 ? (
67
+ <button
68
+ aria-label="Next slide"
69
+ className="slick-arrow slick-next"
70
+ onClick={slider.current.slickNext}
71
+ >
72
+ {currentSlide === 0 && props.learnMore ? (
73
+ <p className="learn-more">{props.learnMore}</p>
74
+ ) : (
75
+ ''
76
+ )}
77
+ <Icon name={rightArrowSVG} size="50px" />
78
+ </button>
79
+ ) : (
80
+ ''
81
+ )}
82
+ </div>
83
+ ) : (
84
+ ''
85
+ );
86
+ };
87
+
88
+ const View = (props) => {
89
+ const slider = React.useRef(null);
90
+ const img = React.useRef(null);
91
+ const [imgHeight, setImgHeight] = React.useState(0);
92
+ const [hashlinkOnMount, setHashlinkOnMount] = React.useState(false);
93
+ const {
94
+ activeTab = null,
95
+ data = {},
96
+ hashlink = {},
97
+ metadata = {},
98
+ tabsList = [],
99
+ tabs = {},
100
+ setActiveTab = () => {},
101
+ } = props;
102
+ const activeTabIndex = tabsList.indexOf(activeTab);
103
+ // const tabData = tabs[activeTab] || {};
104
+ const uiContainer = data.align === 'full' ? 'ui container' : false;
105
+ const image = data.image || null;
106
+
107
+ const settings = {
108
+ autoplay: false,
109
+ arrows: false,
110
+ dots: false,
111
+ speed: 500,
112
+ initialSlide: 0,
113
+ lazyLoad: 'ondemand',
114
+ swipe: true,
115
+ slidesToShow: 1,
116
+ slidesToScroll: 1,
117
+ touchMove: true,
118
+ beforeChange: (oldIndex, index) => {
119
+ setActiveTab(tabsList[index]);
120
+ },
121
+ };
122
+
123
+ const panes = tabsList.map((tab, index) => {
124
+ return {
125
+ id: tab,
126
+ renderItem: (
127
+ <React.Fragment key={`slide-${tab}`}>
128
+ <RenderBlocks {...props} metadata={metadata} content={tabs[tab]} />
129
+ {index === 0 ? (
130
+ <div
131
+ className="divider"
132
+ style={{ height: `${imgHeight - 80}px` }}
133
+ />
134
+ ) : (
135
+ ''
136
+ )}
137
+ </React.Fragment>
138
+ ),
139
+ };
140
+ });
141
+
142
+ const updateImageHeight = () => {
143
+ setImgHeight(img.current?.height || 0);
144
+ };
145
+
146
+ React.useEffect(() => {
147
+ const urlHash = props.location.hash.substring(1) || '';
148
+ if (
149
+ hashlink.counter > 0 ||
150
+ (hashlink.counter === 0 && urlHash && !hashlinkOnMount)
151
+ ) {
152
+ const id = hashlink.hash || urlHash || '';
153
+ const index = tabsList.indexOf(id);
154
+ const parentId = data.id || props.id;
155
+ const parent = document.getElementById(parentId);
156
+ // TODO: Find the best way to add offset relative to header
157
+ // The header can be static on mobile and relative on > mobile
158
+ const headerWrapper = document.querySelector('.header-wrapper');
159
+ const offsetHeight = headerWrapper?.offsetHeight || 0;
160
+ if (
161
+ id !== parentId &&
162
+ parentId === hashlink.data.parentId &&
163
+ index > -1 &&
164
+ parent
165
+ ) {
166
+ if (activeTabIndex !== index) {
167
+ slider.current.slickGoTo(index);
168
+ }
169
+ props.scrollToTarget(parent, offsetHeight);
170
+ } else if (id === parentId && parent) {
171
+ props.scrollToTarget(parent, offsetHeight);
172
+ }
173
+ }
174
+ if (!hashlinkOnMount) {
175
+ setHashlinkOnMount(true);
176
+ }
177
+ /* eslint-disable-next-line */
178
+ }, [hashlink.counter]);
179
+
180
+ React.useEffect(() => {
181
+ updateImageHeight();
182
+ img.current.onload = () => {
183
+ updateImageHeight();
184
+ };
185
+ window.addEventListener('resize', updateImageHeight);
186
+ return () => {
187
+ window.removeEventListener('resize', updateImageHeight);
188
+ };
189
+ /* eslint-disable-next-line */
190
+ }, []);
191
+
192
+ return (
193
+ <>
194
+ <Slider {...settings} ref={slider} className={cx(uiContainer)}>
195
+ {panes.length ? panes.map((pane) => pane.renderItem) : ''}
196
+ </Slider>
197
+ <img
198
+ ref={img}
199
+ className={cx('slick-image', { hidden: activeTabIndex !== 0 })}
200
+ src={`${image}/@@images/image/preview`}
201
+ alt="Logo"
202
+ />
203
+ <ArrowsGroup
204
+ activeTab={activeTab}
205
+ tabsList={tabsList}
206
+ slider={slider}
207
+ learnMore={data.learnMore}
208
+ />
209
+ <Dots activeTab={activeTab} tabsList={tabsList} slider={slider} />
210
+ </>
211
+ );
212
+ };
213
+
214
+ export default compose(
215
+ connect((state) => {
216
+ return {
217
+ hashlink: state.hashlink,
218
+ };
219
+ }),
220
+ withScrollToTarget,
221
+ )(withRouter(View));
@@ -0,0 +1,19 @@
1
+ import HorizontalCarouselView from './HorizontalView';
2
+ import carouselSchema from './schema';
3
+
4
+ export { HorizontalCarouselView, carouselSchema };
5
+
6
+ export default (config) => {
7
+ config.blocks.blocksConfig.tabs_block = {
8
+ ...(config.blocks.blocksConfig.tabs_block || {}),
9
+ templates: {
10
+ ...(config.blocks.blocksConfig.tabs_block?.templates || {}),
11
+ carousel_n2k: {
12
+ title: 'Carousel Natura 2000',
13
+ view: HorizontalCarouselView,
14
+ schema: carouselSchema,
15
+ },
16
+ },
17
+ };
18
+ return config;
19
+ };
@@ -0,0 +1,32 @@
1
+ export default () => ({
2
+ title: 'Carousel block',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['theme', 'image', 'learnMore'],
8
+ },
9
+ ],
10
+ properties: {
11
+ theme: {
12
+ title: 'Theme',
13
+ type: 'array',
14
+ choices: [
15
+ ['light', 'Light'],
16
+ ['dark', 'Dark'],
17
+ ['grey', 'Grey'],
18
+ ],
19
+ default: 'light',
20
+ },
21
+ image: {
22
+ title: 'Image',
23
+ widget: 'object_by_path',
24
+ },
25
+ learnMore: {
26
+ title: 'Learn more',
27
+ widget: 'textarea',
28
+ description: 'Learn more placeholder apearing only on first slide',
29
+ },
30
+ },
31
+ required: [],
32
+ });