@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,12 @@
1
+ .connected-list {
2
+ .column {
3
+ .label {
4
+ margin-bottom: 0;
5
+ font-weight: bold;
6
+ }
7
+
8
+ .value {
9
+ margin-bottom: 1rem;
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { SidebarPortal } from '@plone/volto/components';
3
+ import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
4
+ import getSchema from './schema';
5
+ import './styles.less';
6
+
7
+ import View from './View';
8
+
9
+ const Edit = (props) => {
10
+ const { selected = false } = props;
11
+ const schema = getSchema();
12
+
13
+ return (
14
+ <React.Fragment>
15
+ <View {...props} mode="edit" />
16
+ <SidebarPortal selected={selected}>
17
+ <InlineForm
18
+ schema={schema}
19
+ title={schema.title}
20
+ onChangeField={(id, value) => {
21
+ props.onChangeBlock(props.block, {
22
+ ...props.data,
23
+ [id]: value,
24
+ });
25
+ }}
26
+ formData={props.data}
27
+ />
28
+ </SidebarPortal>
29
+ </React.Fragment>
30
+ );
31
+ };
32
+
33
+ export default Edit;
@@ -0,0 +1,132 @@
1
+ import React, { useState, useEffect, useContext, useRef } from 'react';
2
+ import { connect } from 'react-redux';
3
+ import { withRouter } from 'react-router';
4
+ import { Menu, Container, Sticky } from 'semantic-ui-react';
5
+ import qs from 'querystring';
6
+ import cx from 'classnames';
7
+ import { UniversalLink } from '@plone/volto/components';
8
+ import { withHashLink } from 'volto-slate/hooks';
9
+ import { StickyContext } from '~/components';
10
+ import './styles.less';
11
+
12
+ const formatLink = (str, obj) => {
13
+ let newStr = str;
14
+ if (!str || typeof str !== 'string') return str;
15
+ Object.keys(obj || {}).forEach((key) => {
16
+ newStr = newStr.replace(new RegExp(`\\$${key}`, 'g'), obj[key]);
17
+ });
18
+ return newStr;
19
+ };
20
+
21
+ const View = (props) => {
22
+ const [activeHash, setActiveHash] = useState();
23
+ const [offsetHeight, setOffsetHeight] = useState(0);
24
+ const { stickyRef } = useContext(StickyContext);
25
+ const anchorsRef = useRef();
26
+ const { data = {}, screen = {} } = props;
27
+ const links = data.links || [];
28
+ const sticky = data.sticky ?? true;
29
+
30
+ const params = {
31
+ ...props.match.params,
32
+ ...(props.route_parameters || {}),
33
+ ...qs.parse(props.location.search.replace('?', '')),
34
+ };
35
+
36
+ const hashList = links
37
+ .map((link) => link.hash?.[0]?.['id'])
38
+ .filter((hash) => hash);
39
+
40
+ const onScroll = () => {
41
+ const top = document.documentElement.scrollTop;
42
+ const offsetHeight = anchorsRef.current?.offsetHeight + 10;
43
+ let activeHash,
44
+ maxTop = 0;
45
+ hashList.forEach((hash) => {
46
+ const hashTop = document.getElementById(hash)?.offsetTop;
47
+ if (top >= hashTop - offsetHeight && top >= maxTop) {
48
+ maxTop = top;
49
+ activeHash = hash;
50
+ }
51
+ });
52
+ setActiveHash(activeHash);
53
+ setOffsetHeight(offsetHeight - 11);
54
+ };
55
+
56
+ useEffect(() => {
57
+ onScroll();
58
+ document.addEventListener('scroll', onScroll);
59
+ return () => {
60
+ document.removeEventListener('scroll', onScroll);
61
+ };
62
+ /* eslint-disable-next-line */
63
+ }, []);
64
+
65
+ return (
66
+ <Sticky
67
+ active={sticky && screen.page?.width > 765}
68
+ context={stickyRef}
69
+ className={cx('sticky-navigation-anchors', {
70
+ 'full-width': sticky,
71
+ 'is-sticky': sticky,
72
+ })}
73
+ >
74
+ <div
75
+ className={cx('navigation-anchors', data.className)}
76
+ ref={anchorsRef}
77
+ >
78
+ <Container>
79
+ <Menu
80
+ stackable
81
+ style={{ justifyContent: data.align || 'flex-start' }}
82
+ >
83
+ {links?.map((link, index) => {
84
+ const href = formatLink(link.href, params);
85
+ const hash = link.hash?.[0] || {};
86
+
87
+ return (
88
+ <Menu.Item
89
+ key={`anchor-${link.title}-${index}`}
90
+ active={
91
+ (hash.id && activeHash && hash.id === activeHash) ||
92
+ (!hash.id &&
93
+ !link.isHash &&
94
+ props.location.pathname === href.replace(/\/$/, ''))
95
+ }
96
+ >
97
+ {link.isHash ? (
98
+ <a
99
+ href={`#${hash.id}`}
100
+ title={link.title}
101
+ onClick={(event) => {
102
+ event.preventDefault();
103
+ if (link.target === '_self') return;
104
+ props.setHashLink(hash.id, { ...hash, offsetHeight });
105
+ }}
106
+ target={link.target || '_self'}
107
+ >
108
+ {link.title}
109
+ </a>
110
+ ) : (
111
+ <UniversalLink
112
+ href={href || '#'}
113
+ openLinkInNewTab={link.target === '_blank'}
114
+ title={link.title}
115
+ >
116
+ {link.title}
117
+ </UniversalLink>
118
+ )}
119
+ </Menu.Item>
120
+ );
121
+ })}
122
+ </Menu>
123
+ </Container>
124
+ </div>
125
+ </Sticky>
126
+ );
127
+ };
128
+
129
+ export default connect((state) => ({
130
+ screen: state.screen,
131
+ route_parameters: state.route_parameters || {},
132
+ }))(withHashLink(withRouter(View)));
@@ -0,0 +1,23 @@
1
+ import NavigationAnchorsEdit from './Edit';
2
+ import NavigationAnchorsView from './View';
3
+ import worldSVG from '@plone/volto/icons/world.svg';
4
+
5
+ export default (config) => {
6
+ config.blocks.blocksConfig.navigation_anchors = {
7
+ id: 'navigation_anchors',
8
+ title: 'Navigation anchors',
9
+ icon: worldSVG,
10
+ group: 'natura_2000',
11
+ edit: NavigationAnchorsEdit,
12
+ view: NavigationAnchorsView,
13
+ restricted: false,
14
+ mostUsed: false,
15
+ sidebarTab: 1,
16
+ blocks: {},
17
+ security: {
18
+ addPermission: [],
19
+ view: [],
20
+ },
21
+ };
22
+ return config;
23
+ };
@@ -0,0 +1,76 @@
1
+ const linksSchema = () => ({
2
+ title: 'Link',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['title', 'href', 'hash', 'target', 'isHash'],
8
+ },
9
+ ],
10
+ properties: {
11
+ title: {
12
+ title: 'Title',
13
+ },
14
+ href: {
15
+ title: 'URL',
16
+ widget: 'textarea',
17
+ },
18
+ hash: {
19
+ title: 'Hash',
20
+ widget: 'blocks_browser',
21
+ multiple: false,
22
+ selectedItemAttrs: [],
23
+ },
24
+ target: {
25
+ title: 'Target',
26
+ choices: [
27
+ ['_blank', 'External'],
28
+ ['_self', 'internal'],
29
+ ],
30
+ defaultValue: '_self',
31
+ },
32
+ isHash: {
33
+ title: 'Hash link',
34
+ type: 'boolean',
35
+ default: true,
36
+ },
37
+ },
38
+ required: [],
39
+ });
40
+
41
+ export default () => ({
42
+ title: 'Navigation anchors',
43
+ fieldsets: [
44
+ {
45
+ id: 'default',
46
+ title: 'Default',
47
+ fields: ['sticky', 'className', 'align', 'links'],
48
+ },
49
+ ],
50
+ properties: {
51
+ sticky: {
52
+ title: 'Sticky',
53
+ type: 'boolean',
54
+ default: true,
55
+ },
56
+ className: {
57
+ title: 'Class',
58
+ widget: 'textarea',
59
+ },
60
+ align: {
61
+ title: 'Align',
62
+ choices: [
63
+ ['flex-start', 'Left'],
64
+ ['flex-end', 'Right'],
65
+ ['center', 'Center'],
66
+ ],
67
+ defaultValue: 'flex-start',
68
+ },
69
+ links: {
70
+ title: 'Links',
71
+ schema: linksSchema(),
72
+ widget: 'object_list',
73
+ },
74
+ },
75
+ required: [],
76
+ });
@@ -0,0 +1,104 @@
1
+ div#view .ui.container > .sticky-navigation-anchors {
2
+ &.is-sticky {
3
+ margin-bottom: 0;
4
+ }
5
+
6
+ &:not(.is-sticky):first-child {
7
+ margin-top: 1rem;
8
+ }
9
+
10
+ margin-bottom: 1rem;
11
+
12
+ .ui.menu {
13
+ margin-bottom: 0;
14
+ }
15
+ }
16
+
17
+ .sticky-navigation-anchors {
18
+ &.is-sticky {
19
+ .navigation-anchors {
20
+ background-color: #fff;
21
+ -webkit-box-shadow: 0px 0px 10px -5px #000000;
22
+ box-shadow: 0px 0px 10px -5px #000000;
23
+ }
24
+ }
25
+ }
26
+
27
+ .navigation-anchors {
28
+ padding: 1rem 0;
29
+
30
+ .ui.container > .ui.menu {
31
+ border: 0;
32
+ box-shadow: none;
33
+ overflow-x: auto;
34
+
35
+ .item {
36
+ padding: 1rem;
37
+ background: none;
38
+ color: #000;
39
+ font-family: 'Raleway', sans-serif;
40
+ font-weight: normal;
41
+
42
+ p,
43
+ a {
44
+ position: relative;
45
+ color: #000;
46
+ font-size: 16px;
47
+ font-weight: normal;
48
+
49
+ &:hover {
50
+ opacity: 0.9;
51
+ }
52
+
53
+ &[target='_blank']::after {
54
+ position: absolute;
55
+ right: -6px;
56
+ width: 16px;
57
+ height: 16px;
58
+ background-image: url('./assets/external.png');
59
+ background-repeat: no-repeat;
60
+ background-size: contain;
61
+ content: '';
62
+ line-height: 16px;
63
+ transform: translateX(16px);
64
+ }
65
+ }
66
+
67
+ &.active {
68
+ p,
69
+ a {
70
+ color: #04a87d;
71
+ }
72
+ }
73
+
74
+ &::before {
75
+ display: none;
76
+ }
77
+ }
78
+ }
79
+
80
+ &.natura-2000 {
81
+ .ui.container > .ui.menu {
82
+ .item {
83
+ &.active {
84
+ p,
85
+ a {
86
+ color: #3b7f02;
87
+ font-weight: bold;
88
+ }
89
+ }
90
+
91
+ &:hover {
92
+ p,
93
+ a {
94
+ color: #3b7f02;
95
+ }
96
+ }
97
+
98
+ &::before {
99
+ display: none;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,16 @@
1
+ import { ColoredTableView, coloredTableSchema } from './templates/colored';
2
+
3
+ export default (config) => {
4
+ config.blocks.blocksConfig.simpleDataConnectedTable = {
5
+ ...config.blocks.blocksConfig.simpleDataConnectedTable,
6
+ templates: {
7
+ ...config.blocks.blocksConfig.simpleDataConnectedTable.templates,
8
+ colored_table_v2: {
9
+ title: 'Colored table v2',
10
+ view: ColoredTableView,
11
+ schema: coloredTableSchema,
12
+ },
13
+ },
14
+ };
15
+ return config;
16
+ };
@@ -0,0 +1,178 @@
1
+ import React from 'react';
2
+ import { Icon } from '@plone/volto/components';
3
+ import { Table, Menu } from 'semantic-ui-react';
4
+ import RenderComponent from '@eeacms/volto-datablocks/components/manage/Blocks/SimpleDataTable/components';
5
+ import cx from 'classnames';
6
+
7
+ import leftSVG from '@plone/volto/icons/left-key.svg';
8
+ import rightSVG from '@plone/volto/icons/right-key.svg';
9
+
10
+ import './style.less';
11
+
12
+ const View = (props) => {
13
+ const {
14
+ data = {},
15
+ getAlignmentOfColumn,
16
+ getNameOfColumn,
17
+ getTitleOfColumn,
18
+ has_pagination,
19
+ pagination = {},
20
+ placeholder,
21
+ row_size,
22
+ selectedColumns,
23
+ show_header,
24
+ tableData,
25
+ updatePagination = () => {},
26
+ } = props;
27
+
28
+ const { td_color = [] } = data;
29
+
30
+ const getColorOfField = (field, index) => {
31
+ return td_color?.filter(
32
+ (td) => td.label === tableData[field.column][index],
33
+ )[0]?.color;
34
+ };
35
+
36
+ return (
37
+ <div className="colored-table-v2">
38
+ {row_size ? (
39
+ <Table
40
+ textAlign="left"
41
+ striped={data.striped}
42
+ className={`unstackable ${data.bordered ? 'no-borders' : ''}
43
+ ${data.compact_table ? 'compact-table' : ''}`}
44
+ >
45
+ {show_header ? (
46
+ <Table.Header>
47
+ <Table.Row>
48
+ {td_color && td_color.length > 0 && <Table.HeaderCell />}
49
+ {selectedColumns.map((colDef, j) => (
50
+ <Table.HeaderCell
51
+ key={getNameOfColumn(colDef)}
52
+ className={getAlignmentOfColumn(colDef, j)}
53
+ >
54
+ {getTitleOfColumn(colDef)}
55
+ </Table.HeaderCell>
56
+ ))}
57
+ </Table.Row>
58
+ </Table.Header>
59
+ ) : null}
60
+ <Table.Body>
61
+ {Array(Math.max(0, row_size))
62
+ .fill()
63
+ .map((_, i) => (
64
+ <Table.Row key={i}>
65
+ {selectedColumns.map((colDef, j) => {
66
+ const color = getColorOfField(colDef, i);
67
+ return (
68
+ <Table.Cell
69
+ className={cx({ colored: !!color })}
70
+ key={`${i}-${getNameOfColumn(colDef)}`}
71
+ textAlign={getAlignmentOfColumn(colDef, j)}
72
+ style={color ? { color } : {}}
73
+ >
74
+ {color ? (
75
+ <span
76
+ style={{ backgroundColor: color }}
77
+ className="bullet"
78
+ />
79
+ ) : (
80
+ ''
81
+ )}
82
+ <RenderComponent
83
+ tableData={tableData}
84
+ colDef={colDef}
85
+ row={i}
86
+ {...props}
87
+ />
88
+ </Table.Cell>
89
+ );
90
+ })}
91
+ </Table.Row>
92
+ ))}
93
+ </Table.Body>
94
+ {has_pagination ? (
95
+ <Table.Footer>
96
+ <Table.Row>
97
+ <Table.HeaderCell
98
+ colSpan={selectedColumns.length}
99
+ style={{ textAlign: 'center' }}
100
+ >
101
+ <Menu pagination>
102
+ <Menu.Item
103
+ as="a"
104
+ icon
105
+ disabled={props.isPending || pagination.activePage === 1}
106
+ onClick={() => {
107
+ if (pagination.activePage > 1) {
108
+ updatePagination({
109
+ activePage: pagination.activePage - 1,
110
+ });
111
+ }
112
+ }}
113
+ >
114
+ <Icon name={leftSVG} size="24px" />
115
+ </Menu.Item>
116
+ <Menu.Item
117
+ as="a"
118
+ icon
119
+ disabled={
120
+ props.isPending ||
121
+ pagination.activePage === pagination.lastPage
122
+ }
123
+ onClick={() => {
124
+ if (row_size === pagination.itemsPerPage) {
125
+ updatePagination({
126
+ activePage: pagination.activePage + 1,
127
+ });
128
+ }
129
+ }}
130
+ >
131
+ <Icon name={rightSVG} size="24px" />
132
+ </Menu.Item>
133
+ </Menu>
134
+ </Table.HeaderCell>
135
+ </Table.Row>
136
+ </Table.Footer>
137
+ ) : null}
138
+ </Table>
139
+ ) : (
140
+ // TODO: find a better solution to keep headers
141
+ <Table
142
+ textAlign="left"
143
+ striped={data.striped}
144
+ className={`unstackable ${data.bordered ? 'no-borders' : ''}
145
+ ${data.compact_table ? 'compact-table' : ''}`}
146
+ >
147
+ {show_header ? (
148
+ <Table.Header>
149
+ <Table.Row>
150
+ <Table.HeaderCell />
151
+ {data?.columns?.map((header) => (
152
+ <Table.HeaderCell
153
+ key={header.column}
154
+ className={header.textAlign || 'left'}
155
+ >
156
+ <p>{header.title}</p>
157
+ </Table.HeaderCell>
158
+ ))}
159
+ </Table.Row>
160
+ </Table.Header>
161
+ ) : null}
162
+ <Table.Body>
163
+ <Table.Row>
164
+ <Table.Cell className="colored-cell">
165
+ <span />
166
+ </Table.Cell>
167
+ <Table.Cell colSpan={data?.columns?.length || 1}>
168
+ <p>{placeholder}</p>
169
+ </Table.Cell>
170
+ </Table.Row>
171
+ </Table.Body>
172
+ </Table>
173
+ )}
174
+ </div>
175
+ );
176
+ };
177
+
178
+ export default View;
@@ -0,0 +1,4 @@
1
+ import ColoredTableView from './View';
2
+ import coloredTableSchema from './schema';
3
+
4
+ export { ColoredTableView, coloredTableSchema };
@@ -0,0 +1,56 @@
1
+ import config from '@plone/volto/registry';
2
+
3
+ const colorSchema = (props) => {
4
+ return {
5
+ title: 'Color',
6
+
7
+ fieldsets: [
8
+ {
9
+ id: 'default',
10
+ title: 'Default',
11
+ fields: ['label', 'color'],
12
+ },
13
+ ],
14
+
15
+ properties: {
16
+ label: {
17
+ title: 'Label',
18
+ type: 'string',
19
+ },
20
+ color: {
21
+ title: 'Color',
22
+ widget: 'simple_color',
23
+ available_colors:
24
+ config.blocks.blocksConfig.simpleDataConnectedTable.available_colors,
25
+ },
26
+ },
27
+
28
+ required: [],
29
+ };
30
+ };
31
+
32
+ const coloredTableSchema = (props) => {
33
+ return {
34
+ title: 'Colored datatable v2',
35
+
36
+ fieldsets: [
37
+ {
38
+ id: 'default',
39
+ title: 'Default',
40
+ fields: ['td_color'],
41
+ },
42
+ ],
43
+
44
+ properties: {
45
+ td_color: {
46
+ title: 'Table rows color',
47
+ widget: 'objectlist',
48
+ schema: colorSchema(props),
49
+ },
50
+ },
51
+
52
+ required: [],
53
+ };
54
+ };
55
+
56
+ export default coloredTableSchema;
@@ -0,0 +1,54 @@
1
+ .simple-data-table {
2
+ .colored-table-v2 {
3
+ table {
4
+ overflow: hidden;
5
+ width: auto;
6
+ background: #fff !important;
7
+ border-collapse: separate !important;
8
+ border-radius: 12px !important;
9
+
10
+ thead,
11
+ td {
12
+ background-color: #fff;
13
+ }
14
+
15
+ th {
16
+ font-weight: bold !important;
17
+
18
+ &:after {
19
+ padding: 0;
20
+ border: none;
21
+ }
22
+ }
23
+
24
+ th,
25
+ td {
26
+ border-bottom: 1px solid transparent !important;
27
+ }
28
+
29
+ td.colored {
30
+ display: flex;
31
+ align-items: center;
32
+ margin-left: 1rem;
33
+
34
+ .bullet {
35
+ display: block;
36
+ width: 16px;
37
+ height: 16px;
38
+ margin-right: 0.5rem;
39
+ border-radius: 50%;
40
+ }
41
+
42
+ > * {
43
+ line-height: 1;
44
+ }
45
+ }
46
+
47
+ tbody {
48
+ td {
49
+ height: 46px;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }