@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.
- package/.coverage.babel.config.js +9 -0
- package/.release-it.json +17 -0
- package/CHANGELOG.md +155 -0
- package/DEVELOP.md +53 -0
- package/Jenkinsfile +209 -0
- package/LICENSE.md +9 -0
- package/README.md +62 -0
- package/bootstrap +41 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/integration/block-basics.js +32 -0
- package/cypress/plugins/index.js +26 -0
- package/cypress/support/commands.js +315 -0
- package/cypress/support/index.js +53 -0
- package/cypress.json +12 -0
- package/jest-addon.config.js +36 -0
- package/package.json +57 -0
- package/src/actions.js +20 -0
- package/src/components/index.js +3 -0
- package/src/components/manage/Blocks/BodyClass/Edit.jsx +29 -0
- package/src/components/manage/Blocks/BodyClass/View.jsx +13 -0
- package/src/components/manage/Blocks/BodyClass/index.js +24 -0
- package/src/components/manage/Blocks/BodyClass/schema.js +19 -0
- package/src/components/manage/Blocks/BubbleChart/BubbleChart.jsx +101 -0
- package/src/components/manage/Blocks/BubbleChart/Chart.jsx +67 -0
- package/src/components/manage/Blocks/BubbleChart/ChartContext.jsx +3 -0
- package/src/components/manage/Blocks/BubbleChart/View.jsx +63 -0
- package/src/components/manage/Blocks/BubbleChart/index.js +17 -0
- package/src/components/manage/Blocks/BubbleChart/schema.js +124 -0
- package/src/components/manage/Blocks/BubbleChart/style.less +12 -0
- package/src/components/manage/Blocks/CarouselHorizontal/HorizontalView.jsx +221 -0
- package/src/components/manage/Blocks/CarouselHorizontal/index.js +19 -0
- package/src/components/manage/Blocks/CarouselHorizontal/schema.js +32 -0
- package/src/components/manage/Blocks/CddaShape/View.jsx +109 -0
- package/src/components/manage/Blocks/CddaShape/index.js +23 -0
- package/src/components/manage/Blocks/CddaShape/schema.js +19 -0
- package/src/components/manage/Blocks/CddaShape/style.less +14 -0
- package/src/components/manage/Blocks/ContactBlock/View.jsx +56 -0
- package/src/components/manage/Blocks/ContactBlock/icons/domain.svg +1 -0
- package/src/components/manage/Blocks/ContactBlock/icons/email.svg +1 -0
- package/src/components/manage/Blocks/ContactBlock/icons/location.svg +1 -0
- package/src/components/manage/Blocks/ContactBlock/index.js +17 -0
- package/src/components/manage/Blocks/ContactBlock/schema.js +57 -0
- package/src/components/manage/Blocks/ContactBlock/styles.less +31 -0
- package/src/components/manage/Blocks/ExplodedPiesChart/Pie.jsx +125 -0
- package/src/components/manage/Blocks/ExplodedPiesChart/View.jsx +80 -0
- package/src/components/manage/Blocks/ExplodedPiesChart/index.js +17 -0
- package/src/components/manage/Blocks/ExplodedPiesChart/schema.js +75 -0
- package/src/components/manage/Blocks/ExplodedPiesChart/style.less +80 -0
- package/src/components/manage/Blocks/ExploreHabitats/Edit.jsx +29 -0
- package/src/components/manage/Blocks/ExploreHabitats/View.jsx +177 -0
- package/src/components/manage/Blocks/ExploreHabitats/index.js +24 -0
- package/src/components/manage/Blocks/ExploreHabitats/schema.js +15 -0
- package/src/components/manage/Blocks/ExploreHabitats/style.less +15 -0
- package/src/components/manage/Blocks/ExploreSites/Edit.jsx +29 -0
- package/src/components/manage/Blocks/ExploreSites/View.jsx +175 -0
- package/src/components/manage/Blocks/ExploreSites/index.js +24 -0
- package/src/components/manage/Blocks/ExploreSites/schema.js +15 -0
- package/src/components/manage/Blocks/ExploreSites/style.less +15 -0
- package/src/components/manage/Blocks/ExploreSpecies/Edit.jsx +29 -0
- package/src/components/manage/Blocks/ExploreSpecies/View.jsx +177 -0
- package/src/components/manage/Blocks/ExploreSpecies/index.js +24 -0
- package/src/components/manage/Blocks/ExploreSpecies/schema.js +15 -0
- package/src/components/manage/Blocks/ExploreSpecies/style.less +15 -0
- package/src/components/manage/Blocks/HabitatClassification/View.jsx +30 -0
- package/src/components/manage/Blocks/HabitatClassification/index.js +17 -0
- package/src/components/manage/Blocks/HabitatClassification/schema.js +19 -0
- package/src/components/manage/Blocks/HabitatClassification/style.less +3 -0
- package/src/components/manage/Blocks/HabitatDistribution/View.jsx +97 -0
- package/src/components/manage/Blocks/HabitatDistribution/index.js +23 -0
- package/src/components/manage/Blocks/HabitatDistribution/schema.js +19 -0
- package/src/components/manage/Blocks/HabitatDistribution/style.less +5 -0
- package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +97 -0
- package/src/components/manage/Blocks/HabitatProtectedSites/index.js +23 -0
- package/src/components/manage/Blocks/HabitatProtectedSites/schema.js +19 -0
- package/src/components/manage/Blocks/HabitatProtectedSites/style.less +5 -0
- package/src/components/manage/Blocks/HabitatsBanner/View.jsx +39 -0
- package/src/components/manage/Blocks/HabitatsBanner/index.js +17 -0
- package/src/components/manage/Blocks/HabitatsBanner/schema.js +19 -0
- package/src/components/manage/Blocks/HabitatsBanner/style.less +49 -0
- package/src/components/manage/Blocks/ImageText/Edit.jsx +98 -0
- package/src/components/manage/Blocks/ImageText/View.jsx +66 -0
- package/src/components/manage/Blocks/ImageText/index.js +24 -0
- package/src/components/manage/Blocks/ImageText/schema.js +69 -0
- package/src/components/manage/Blocks/ImageText/styles.less +87 -0
- package/src/components/manage/Blocks/Landing/DefalutView.jsx +83 -0
- package/src/components/manage/Blocks/Landing/Edit.jsx +219 -0
- package/src/components/manage/Blocks/Landing/EditBlockWrapper.jsx +161 -0
- package/src/components/manage/Blocks/Landing/View.jsx +65 -0
- package/src/components/manage/Blocks/Landing/images/background.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/coasts_and_seas.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/forests.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/grasslands.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/hiker.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/islands.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/mountains.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/natura2000.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/natura2000_square.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/peatlands.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/people_and_nature.webp +0 -0
- package/src/components/manage/Blocks/Landing/images/rivers.webp +0 -0
- package/src/components/manage/Blocks/Landing/index.js +104 -0
- package/src/components/manage/Blocks/Landing/schema.js +62 -0
- package/src/components/manage/Blocks/Landing/style.less +174 -0
- package/src/components/manage/Blocks/List/View.jsx +37 -0
- package/src/components/manage/Blocks/List/index.js +17 -0
- package/src/components/manage/Blocks/List/schema.js +49 -0
- package/src/components/manage/Blocks/List/style.less +12 -0
- package/src/components/manage/Blocks/NavigationAnchors/Edit.jsx +33 -0
- package/src/components/manage/Blocks/NavigationAnchors/View.jsx +132 -0
- package/src/components/manage/Blocks/NavigationAnchors/assets/external.png +0 -0
- package/src/components/manage/Blocks/NavigationAnchors/index.js +23 -0
- package/src/components/manage/Blocks/NavigationAnchors/schema.js +76 -0
- package/src/components/manage/Blocks/NavigationAnchors/styles.less +104 -0
- package/src/components/manage/Blocks/SimpleDataTable/index.js +16 -0
- package/src/components/manage/Blocks/SimpleDataTable/templates/colored/View.jsx +178 -0
- package/src/components/manage/Blocks/SimpleDataTable/templates/colored/index.js +4 -0
- package/src/components/manage/Blocks/SimpleDataTable/templates/colored/schema.js +56 -0
- package/src/components/manage/Blocks/SimpleDataTable/templates/colored/style.less +54 -0
- package/src/components/manage/Blocks/SiteBanner/View.jsx +148 -0
- package/src/components/manage/Blocks/SiteBanner/index.js +17 -0
- package/src/components/manage/Blocks/SiteBanner/schema.js +19 -0
- package/src/components/manage/Blocks/SiteBanner/style.less +106 -0
- package/src/components/manage/Blocks/SiteHabitatsList/View.jsx +89 -0
- package/src/components/manage/Blocks/SiteHabitatsList/index.js +17 -0
- package/src/components/manage/Blocks/SiteHabitatsList/schema.js +19 -0
- package/src/components/manage/Blocks/SiteHabitatsList/style.less +70 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/View.jsx +47 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/images/background.webp +0 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/index.js +17 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/schema.js +19 -0
- package/src/components/manage/Blocks/SiteProtectedHabitats/style.less +90 -0
- package/src/components/manage/Blocks/SiteProtectedSpecies/View.jsx +55 -0
- package/src/components/manage/Blocks/SiteProtectedSpecies/images/background.webp +0 -0
- package/src/components/manage/Blocks/SiteProtectedSpecies/index.js +17 -0
- package/src/components/manage/Blocks/SiteProtectedSpecies/schema.js +19 -0
- package/src/components/manage/Blocks/SiteProtectedSpecies/style.less +90 -0
- package/src/components/manage/Blocks/SiteShape/View.jsx +107 -0
- package/src/components/manage/Blocks/SiteShape/index.js +23 -0
- package/src/components/manage/Blocks/SiteShape/schema.js +19 -0
- package/src/components/manage/Blocks/SiteShape/style.less +15 -0
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/SortBy.jsx +52 -0
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/SpeciesGroups.jsx +43 -0
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/View.jsx +200 -0
- package/src/components/manage/Blocks/SiteSpeciesList/Filters/index.js +4 -0
- package/src/components/manage/Blocks/SiteSpeciesList/View.jsx +253 -0
- package/src/components/manage/Blocks/SiteSpeciesList/index.js +17 -0
- package/src/components/manage/Blocks/SiteSpeciesList/schema.js +19 -0
- package/src/components/manage/Blocks/SiteSpeciesList/style.less +264 -0
- package/src/components/manage/Blocks/SiteSpeciesList/utils.js +33 -0
- package/src/components/manage/Blocks/SlateLink/render.jsx +77 -0
- package/src/components/manage/Blocks/SlateLink/styles.less +22 -0
- package/src/components/manage/Blocks/SlateSVG/constants.js +1 -0
- package/src/components/manage/Blocks/SlateSVG/extensions.js +11 -0
- package/src/components/manage/Blocks/SlateSVG/index.js +47 -0
- package/src/components/manage/Blocks/SlateSVG/render.jsx +42 -0
- package/src/components/manage/Blocks/SlateSVG/schema.js +12 -0
- package/src/components/manage/Blocks/SlateSVG/styles.less +6 -0
- package/src/components/manage/Blocks/SpeciesBanner/View.jsx +109 -0
- package/src/components/manage/Blocks/SpeciesBanner/index.js +17 -0
- package/src/components/manage/Blocks/SpeciesBanner/schema.js +19 -0
- package/src/components/manage/Blocks/SpeciesBanner/style.less +115 -0
- package/src/components/manage/Blocks/SpeciesClassification/View.jsx +19 -0
- package/src/components/manage/Blocks/SpeciesClassification/index.js +17 -0
- package/src/components/manage/Blocks/SpeciesClassification/schema.js +19 -0
- package/src/components/manage/Blocks/SpeciesClassification/style.less +3 -0
- package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +97 -0
- package/src/components/manage/Blocks/SpeciesDistribution/index.js +23 -0
- package/src/components/manage/Blocks/SpeciesDistribution/schema.js +19 -0
- package/src/components/manage/Blocks/SpeciesDistribution/style.less +5 -0
- package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +97 -0
- package/src/components/manage/Blocks/SpeciesProtectedSites/index.js +23 -0
- package/src/components/manage/Blocks/SpeciesProtectedSites/schema.js +19 -0
- package/src/components/manage/Blocks/SpeciesProtectedSites/style.less +5 -0
- package/src/components/manage/Blocks/StackedBarChart/Chart.jsx +127 -0
- package/src/components/manage/Blocks/StackedBarChart/ChartContext.jsx +3 -0
- package/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +116 -0
- package/src/components/manage/Blocks/StackedBarChart/View.jsx +64 -0
- package/src/components/manage/Blocks/StackedBarChart/index.js +17 -0
- package/src/components/manage/Blocks/StackedBarChart/schema.js +25 -0
- package/src/components/manage/Blocks/StackedBarChart/style.less +37 -0
- package/src/components/manage/Blocks/TilesImages/Edit.jsx +32 -0
- package/src/components/manage/Blocks/TilesImages/View.jsx +37 -0
- package/src/components/manage/Blocks/TilesImages/index.js +23 -0
- package/src/components/manage/Blocks/TilesImages/schema.js +72 -0
- package/src/components/manage/Blocks/TilesImages/styles.less +57 -0
- package/src/components/theme/AppExtras/CopyPaste/CopyPaste.jsx +176 -0
- package/src/components/theme/AppExtras/CopyPaste/index.js +3 -0
- package/src/components/theme/AppExtras/CopyPaste/style.less +18 -0
- package/src/components/theme/AppExtras/MultilingualRedirector/MultilingualRedirector.jsx +35 -0
- package/src/components/theme/AppExtras/index.js +13 -0
- package/src/components/theme/Footer/Footer.jsx +209 -0
- package/src/components/theme/Header/Header.jsx +81 -0
- package/src/components/theme/LanguageSelector/LanguageSelector.jsx +79 -0
- package/src/components/theme/LanguageSelector/styles.less +44 -0
- package/src/components/theme/Navigation/Navigation.jsx +453 -0
- package/src/components/theme/Sitemap/Sitemap.jsx +152 -0
- package/src/fonts/OpenSans-Bold.ttf +0 -0
- package/src/fonts/OpenSans-Regular.ttf +0 -0
- package/src/fonts/OpenSans-Semibold.ttf +0 -0
- package/src/fonts/Rajdhani-Bold.ttf +0 -0
- package/src/fonts/Rajdhani-Regular.ttf +0 -0
- package/src/grid.js +78 -0
- package/src/helpers.js +148 -0
- package/src/hocs/index.js +6 -0
- package/src/hocs/useResizeObserver.jsx +26 -0
- package/src/hocs/withLocalStorage.jsx +37 -0
- package/src/hocs/withScreenSize.jsx +43 -0
- package/src/icons/home.svg +12 -0
- package/src/icons/info.svg +5 -0
- package/src/icons/n2k-logo-transparent.png +0 -0
- package/src/icons/n2k-logo.png +0 -0
- package/src/icons/natura2000.svg +142 -0
- package/src/icons/placeholders/Algae.png +0 -0
- package/src/icons/placeholders/Amphibians.png +0 -0
- package/src/icons/placeholders/Birds.png +0 -0
- package/src/icons/placeholders/Conifers.png +0 -0
- package/src/icons/placeholders/Fishes.png +0 -0
- package/src/icons/placeholders/Fungi.png +0 -0
- package/src/icons/placeholders/Mammals.png +0 -0
- package/src/icons/placeholders/Plants.png +0 -0
- package/src/icons/placeholders/Reptiles.png +0 -0
- package/src/icons/placeholders/default.png +0 -0
- package/src/index.js +163 -0
- package/src/less/globals.less +3 -0
- package/src/less/styles.less +691 -0
- package/src/less/variables.less +2 -0
- package/src/static/cca.svg +61 -0
- package/src/static/ec.png +0 -0
- package/src/static/eea.png +0 -0
- package/src/static/eu.jpg +0 -0
- package/src/static/forest.svg +100 -0
- package/src/static/wise.png +0 -0
- package/src/store.js +24 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Message, Container } from 'semantic-ui-react';
|
|
3
|
+
import Map from '@eeacms/volto-openlayers-map/Map';
|
|
4
|
+
import { Interactions } from '@eeacms/volto-openlayers-map/Interactions';
|
|
5
|
+
import { Controls } from '@eeacms/volto-openlayers-map/Controls';
|
|
6
|
+
import { Layers, Layer } from '@eeacms/volto-openlayers-map/Layers';
|
|
7
|
+
import { openlayers } from '@eeacms/volto-openlayers-map';
|
|
8
|
+
import { getCddaShapeURL } from './index';
|
|
9
|
+
import './style.less';
|
|
10
|
+
|
|
11
|
+
const View = (props) => {
|
|
12
|
+
const [options, setOptions] = React.useState({});
|
|
13
|
+
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const { extent, format, proj, style, source } = openlayers;
|
|
15
|
+
const provider_data = props.provider_data || {};
|
|
16
|
+
const { site_code = [] } = provider_data;
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (__SERVER__) return;
|
|
20
|
+
setVectorSource(new source.Vector());
|
|
21
|
+
/* eslint-disable-next-line */
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (__SERVER__ || !vectorSource || !site_code[0]) return;
|
|
26
|
+
const esrijsonFormat = new format.EsriJSON();
|
|
27
|
+
// Get site shape
|
|
28
|
+
fetch(getCddaShapeURL(site_code[0])).then(function (response) {
|
|
29
|
+
if (response.status !== 200) return;
|
|
30
|
+
response.json().then(function (data) {
|
|
31
|
+
if (data.features && data.features.length > 0) {
|
|
32
|
+
const features = esrijsonFormat.readFeatures(data);
|
|
33
|
+
if (features.length > 0) {
|
|
34
|
+
vectorSource.addFeatures(features);
|
|
35
|
+
const vectorExtent = vectorSource.getExtent();
|
|
36
|
+
let size = extent.getSize(vectorExtent);
|
|
37
|
+
setOptions({
|
|
38
|
+
...options,
|
|
39
|
+
extent: new extent.buffer(vectorExtent, size[0] * 0.1),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
/* eslint-disable-next-line */
|
|
46
|
+
}, [site_code?.[0]]);
|
|
47
|
+
|
|
48
|
+
if (__SERVER__ || !vectorSource) return '';
|
|
49
|
+
return (
|
|
50
|
+
<div className="site-shape-wrapper full-width">
|
|
51
|
+
<div className="site-shape">
|
|
52
|
+
<Map
|
|
53
|
+
view={{
|
|
54
|
+
center: proj.fromLonLat([20, 50]),
|
|
55
|
+
showFullExtent: true,
|
|
56
|
+
maxZoom: 10,
|
|
57
|
+
minZoom: 10,
|
|
58
|
+
zoom: 10,
|
|
59
|
+
}}
|
|
60
|
+
{...options}
|
|
61
|
+
>
|
|
62
|
+
<Layers>
|
|
63
|
+
<Layer.Tile zIndex={0} />
|
|
64
|
+
<Layer.Vector
|
|
65
|
+
source={vectorSource}
|
|
66
|
+
style={
|
|
67
|
+
new style.Style({
|
|
68
|
+
fill: new style.Fill({
|
|
69
|
+
color: 'rgba(255,255,255,0.4)',
|
|
70
|
+
}),
|
|
71
|
+
stroke: new style.Stroke({
|
|
72
|
+
color: '#04A77D',
|
|
73
|
+
width: 3,
|
|
74
|
+
lineDash: [5, 7],
|
|
75
|
+
}),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
zIndex={1}
|
|
79
|
+
/>
|
|
80
|
+
</Layers>
|
|
81
|
+
<Controls attribution={true} zoom={false} />
|
|
82
|
+
<Interactions
|
|
83
|
+
doubleClickZoom={false}
|
|
84
|
+
dragAndDrop={false}
|
|
85
|
+
dragPan={false}
|
|
86
|
+
keyboardPan={false}
|
|
87
|
+
keyboardZoom={false}
|
|
88
|
+
mouseWheelZoom={false}
|
|
89
|
+
pointer={false}
|
|
90
|
+
select={false}
|
|
91
|
+
/>
|
|
92
|
+
</Map>
|
|
93
|
+
</div>
|
|
94
|
+
<Container className="map-info-notice">
|
|
95
|
+
<Message>
|
|
96
|
+
<p>
|
|
97
|
+
The designations employed and the presentation of material on this
|
|
98
|
+
map do not imply the expression of any opinion whatsoever on the
|
|
99
|
+
part of the European Union concerning the legal status of any
|
|
100
|
+
country, territory, city or area or of its authorities, or
|
|
101
|
+
concerning the delimitation of its frontiers or boundaries.
|
|
102
|
+
</p>
|
|
103
|
+
</Message>
|
|
104
|
+
</Container>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default View;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import CddaShapeView from './View';
|
|
2
|
+
import getSchema from './schema';
|
|
3
|
+
|
|
4
|
+
export function getCddaShapeURL(site_code) {
|
|
5
|
+
return encodeURI(
|
|
6
|
+
`https://bio.discomap.eea.europa.eu/arcgis/rest/services/ProtectedSites/CDDA_Dyna_WM/MapServer/4/query?f=json&where=cddaId = ${site_code}&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*&outSR=102100`,
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default (config) => {
|
|
11
|
+
config.blocks.blocksConfig.custom_connected_block = {
|
|
12
|
+
...config.blocks.blocksConfig.custom_connected_block,
|
|
13
|
+
blocks: {
|
|
14
|
+
...config.blocks.blocksConfig.custom_connected_block.blocks,
|
|
15
|
+
cdda_shape: {
|
|
16
|
+
view: CddaShapeView,
|
|
17
|
+
getSchema: getSchema,
|
|
18
|
+
title: 'CDDA shape',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return config;
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
div#view .ui.container > .site-shape-wrapper,
|
|
2
|
+
div#view .ui.container > .site-shape {
|
|
3
|
+
margin-bottom: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.site-shape {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
margin-bottom: 0;
|
|
10
|
+
|
|
11
|
+
&.visible.transition {
|
|
12
|
+
display: flex !important;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '@plone/volto/components';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import domainSVG from './icons/domain.svg';
|
|
5
|
+
import locationSVG from './icons/location.svg';
|
|
6
|
+
import emailSVG from './icons/email.svg';
|
|
7
|
+
|
|
8
|
+
import './styles.less';
|
|
9
|
+
|
|
10
|
+
const icons = {
|
|
11
|
+
domain: domainSVG,
|
|
12
|
+
location: locationSVG,
|
|
13
|
+
email: emailSVG,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const View = (props) => {
|
|
17
|
+
const {
|
|
18
|
+
mode = 'view',
|
|
19
|
+
data = {},
|
|
20
|
+
placeholder = 'No contact information',
|
|
21
|
+
} = props;
|
|
22
|
+
const { contactFields = [] } = data;
|
|
23
|
+
const provider_data = props.provider_data || {};
|
|
24
|
+
|
|
25
|
+
const contacts = contactFields.length
|
|
26
|
+
? [
|
|
27
|
+
...Array(
|
|
28
|
+
provider_data[Object.keys(provider_data)[0]]?.length || 0,
|
|
29
|
+
).keys(),
|
|
30
|
+
]
|
|
31
|
+
: [];
|
|
32
|
+
|
|
33
|
+
return contacts.length ? (
|
|
34
|
+
<div className="contact-block">
|
|
35
|
+
{contacts.map((index) => (
|
|
36
|
+
<div key={`contact-${index}`} className="contact">
|
|
37
|
+
{contactFields.map((field) => (
|
|
38
|
+
<div
|
|
39
|
+
key={`contact-field-${index}-${field.dataEntity}`}
|
|
40
|
+
className="contact-field"
|
|
41
|
+
>
|
|
42
|
+
<Icon name={icons[field.icon]} size="24px" />
|
|
43
|
+
<p>{provider_data[field.dataEntity]?.[index] || '-'}</p>
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
))}
|
|
48
|
+
</div>
|
|
49
|
+
) : (
|
|
50
|
+
<div className={cx('contact-block no-data', mode)}>
|
|
51
|
+
<p>{placeholder}</p>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default View;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:none;}.b{fill:#04a87d;}</style></defs><path class="a" d="M0,0H24V24H0Z"/><path class="b" d="M12,7V3H2V21H22V7ZM6,19H4V17H6Zm0-4H4V13H6Zm0-4H4V9H6ZM6,7H4V5H6Zm4,12H8V17h2Zm0-4H8V13h2Zm0-4H8V9h2Zm0-4H8V5h2ZM20,19H12V17h2V15H12V13h2V11H12V9h8Zm-2-8H16v2h2Zm0,4H16v2h2Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:#04a87d;}.b{fill:none;}</style></defs><path class="a" d="M20,4H4A2,2,0,0,0,2.01,6L2,18a2.006,2.006,0,0,0,2,2H20a2.006,2.006,0,0,0,2-2V6A2.006,2.006,0,0,0,20,4Zm0,4-8,5L4,8V6l8,5,8-5Z"/><path class="b" d="M0,0H24V24H0Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:#04a87d;}.b{fill:none;}</style></defs><path class="a" d="M12,2A7,7,0,0,0,5,9c0,5.25,7,13,7,13s7-7.75,7-13A7,7,0,0,0,12,2Zm0,9.5A2.5,2.5,0,1,1,14.5,9,2.5,2.5,0,0,1,12,11.5Z"/><path class="b" d="M0,0H24V24H0Z"/></svg>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ContactBlockView 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
|
+
contact_block: {
|
|
10
|
+
view: ContactBlockView,
|
|
11
|
+
getSchema: getSchema,
|
|
12
|
+
title: 'Contact block',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const getContactFields = (props) => {
|
|
2
|
+
const data = props.provider_data || {};
|
|
3
|
+
const choices = Object.keys(data).map((key) => [key, key]) || [];
|
|
4
|
+
|
|
5
|
+
return {
|
|
6
|
+
title: 'Contact field',
|
|
7
|
+
fieldsets: [
|
|
8
|
+
{
|
|
9
|
+
id: 'default',
|
|
10
|
+
title: 'Default',
|
|
11
|
+
fields: ['icon', 'dataEntity'],
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
properties: {
|
|
15
|
+
icon: {
|
|
16
|
+
title: 'Icon',
|
|
17
|
+
type: 'array',
|
|
18
|
+
choices: [
|
|
19
|
+
['domain', 'Domain'],
|
|
20
|
+
['location', 'Location'],
|
|
21
|
+
['email', 'Email'],
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
dataEntity: {
|
|
25
|
+
title: 'Data entity',
|
|
26
|
+
type: 'array',
|
|
27
|
+
choices,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ['icon', 'dataEntity'],
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const getSchema = (props) => {
|
|
34
|
+
return {
|
|
35
|
+
title: 'Contact block',
|
|
36
|
+
|
|
37
|
+
fieldsets: [
|
|
38
|
+
{
|
|
39
|
+
id: 'default',
|
|
40
|
+
title: 'Default',
|
|
41
|
+
fields: ['contactFields'],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
properties: {
|
|
46
|
+
contactFields: {
|
|
47
|
+
title: 'Contact fields',
|
|
48
|
+
widget: 'objectlist',
|
|
49
|
+
schema: getContactFields(props),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
required: [],
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default getSchema;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.contact-block {
|
|
2
|
+
margin-left: 1rem;
|
|
3
|
+
|
|
4
|
+
&.no-data:not(.edit) {
|
|
5
|
+
margin-top: -1.5rem;
|
|
6
|
+
margin-left: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.contact {
|
|
10
|
+
&:not(:last-child) {
|
|
11
|
+
border-bottom: 1px solid #dadada;
|
|
12
|
+
margin-bottom: 1rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.contact-field {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-flow: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
margin-bottom: 1rem;
|
|
20
|
+
|
|
21
|
+
.icon {
|
|
22
|
+
margin-right: 0.5rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
p {
|
|
26
|
+
color: #636363;
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as d3 from 'd3';
|
|
3
|
+
import { Popup } from 'semantic-ui-react';
|
|
4
|
+
import { adjustBrightness } from '@eeacms/volto-n2k/helpers';
|
|
5
|
+
|
|
6
|
+
const Arc = ({ data, index, createArc, format, size }) => {
|
|
7
|
+
const [mouseOver, setMouseOver] = React.useState(false);
|
|
8
|
+
const arcData = data.data;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<g key={index} className="arc">
|
|
12
|
+
{arcData.showValue && arcData.label ? (
|
|
13
|
+
<g>
|
|
14
|
+
<foreignObject
|
|
15
|
+
transform={`translate(-${size.realOuterRadius}, -${size.realOuterRadius})`}
|
|
16
|
+
width="100%"
|
|
17
|
+
height={size.height}
|
|
18
|
+
position="relative"
|
|
19
|
+
x={size.realOuterRadius + size.outerRadius}
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
className="text"
|
|
23
|
+
xmlns="http://www.w3.org/1999/xhtml"
|
|
24
|
+
style={{
|
|
25
|
+
width: `calc(100% - ${
|
|
26
|
+
size.realOuterRadius + size.outerRadius
|
|
27
|
+
}px)`,
|
|
28
|
+
height: 2 * size.outerRadius,
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<p className="value">{format(arcData.value * 100)}%</p>
|
|
32
|
+
<span className="line" />
|
|
33
|
+
<p className="label">{arcData.label}</p>
|
|
34
|
+
</div>
|
|
35
|
+
</foreignObject>
|
|
36
|
+
</g>
|
|
37
|
+
) : (
|
|
38
|
+
''
|
|
39
|
+
)}
|
|
40
|
+
<Popup
|
|
41
|
+
content={
|
|
42
|
+
<>
|
|
43
|
+
<p style={{ marginBottom: 0 }}>{format(arcData.value * 100)}%</p>
|
|
44
|
+
<p>{arcData.label}</p>
|
|
45
|
+
</>
|
|
46
|
+
}
|
|
47
|
+
disabled={!arcData.showMouseOver}
|
|
48
|
+
trigger={
|
|
49
|
+
<path
|
|
50
|
+
className="arc"
|
|
51
|
+
d={createArc(data)}
|
|
52
|
+
fill={
|
|
53
|
+
mouseOver ? adjustBrightness(arcData.color, -10) : arcData.color
|
|
54
|
+
}
|
|
55
|
+
filter={arcData.filter ? `url(${arcData.filter})` : ''}
|
|
56
|
+
onFocus={() => {}}
|
|
57
|
+
onBlur={() => {}}
|
|
58
|
+
onMouseOver={(event) => {
|
|
59
|
+
if (arcData.showMouseOver) {
|
|
60
|
+
setMouseOver(true);
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
onMouseOut={() => {
|
|
64
|
+
if (mouseOver) {
|
|
65
|
+
setMouseOver(false);
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
</g>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const Pie = (props) => {
|
|
76
|
+
const createPie = d3
|
|
77
|
+
.pie()
|
|
78
|
+
.value((d) => d.value)
|
|
79
|
+
.sort(null);
|
|
80
|
+
const createArc = d3
|
|
81
|
+
.arc()
|
|
82
|
+
.innerRadius((d) => d.data.innerRadius || props.innerRadius)
|
|
83
|
+
.outerRadius((d) => d.data.outerRadius || props.outerRadius)
|
|
84
|
+
.startAngle(0)
|
|
85
|
+
.endAngle((d) => d.value * 2 * Math.PI);
|
|
86
|
+
const data = createPie(props.data);
|
|
87
|
+
const format = d3.format(`.${props.precision || 2}f`);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<svg width={'100%'} height={props.height}>
|
|
91
|
+
<defs>
|
|
92
|
+
<filter id="drop-shadow" x="0" y="0" width="200%" height="200%">
|
|
93
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="2" />
|
|
94
|
+
<feOffset dx="1" dy="4" result="offsetblur" />
|
|
95
|
+
<feFlood floodColor="rgba(0, 0, 0, 0.2)" />
|
|
96
|
+
<feComposite in2="offsetblur" operator="in" />
|
|
97
|
+
<feMerge>
|
|
98
|
+
<feMergeNode />
|
|
99
|
+
<feMergeNode in="SourceGraphic" />
|
|
100
|
+
</feMerge>
|
|
101
|
+
</filter>
|
|
102
|
+
</defs>
|
|
103
|
+
<g transform={`translate(${props.center[0]} ${props.center[1]})`}>
|
|
104
|
+
{data.map((d, i) => (
|
|
105
|
+
<Arc
|
|
106
|
+
key={i}
|
|
107
|
+
data={d}
|
|
108
|
+
index={i}
|
|
109
|
+
createArc={createArc}
|
|
110
|
+
format={format}
|
|
111
|
+
size={{
|
|
112
|
+
width: props.width,
|
|
113
|
+
height: props.height,
|
|
114
|
+
innerRadius: props.innerRadius,
|
|
115
|
+
outerRadius: props.outerRadius,
|
|
116
|
+
realOuterRadius: props.center[0],
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
</g>
|
|
121
|
+
</svg>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default Pie;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Grid } from 'semantic-ui-react';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import './style.less';
|
|
5
|
+
|
|
6
|
+
import Pie from './Pie';
|
|
7
|
+
|
|
8
|
+
const View = (props) => {
|
|
9
|
+
const { placeholder = 'No results' } = props;
|
|
10
|
+
const { x = null, y = null, x_colors = [], precision = 2 } = props.data;
|
|
11
|
+
const data = props.provider_data || {};
|
|
12
|
+
const x_values = data?.[x] || [];
|
|
13
|
+
const y_values = data?.[y] || [];
|
|
14
|
+
const format = d3.format('.2f');
|
|
15
|
+
|
|
16
|
+
const xColorsObj = {};
|
|
17
|
+
|
|
18
|
+
x_colors.forEach((item) => {
|
|
19
|
+
xColorsObj[item.label] = item.color;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const dataReady =
|
|
23
|
+
data && Object.keys(data).length && x_values.length && y_values.length;
|
|
24
|
+
|
|
25
|
+
const total = dataReady
|
|
26
|
+
? format(y_values.reduce((a1, a2) => a1 + a2, 0))
|
|
27
|
+
: null;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
{dataReady ? (
|
|
32
|
+
<Grid className="exploded-pies-chart">
|
|
33
|
+
{y_values?.length > 0
|
|
34
|
+
? y_values.map((value, index) => (
|
|
35
|
+
<Grid.Column
|
|
36
|
+
key={`x_${index}`}
|
|
37
|
+
mobile="12"
|
|
38
|
+
tablet="6"
|
|
39
|
+
computer="4"
|
|
40
|
+
largeScreen="4"
|
|
41
|
+
widescreen="4"
|
|
42
|
+
className="pie-column"
|
|
43
|
+
>
|
|
44
|
+
<Grid>
|
|
45
|
+
<Grid.Column>
|
|
46
|
+
<Pie
|
|
47
|
+
width={320}
|
|
48
|
+
height={120}
|
|
49
|
+
innerRadius={0}
|
|
50
|
+
outerRadius={44}
|
|
51
|
+
center={[60, 60]}
|
|
52
|
+
data={[
|
|
53
|
+
{ value: 1, color: '#EAEAEA' },
|
|
54
|
+
{
|
|
55
|
+
value: value / total,
|
|
56
|
+
label: x_values[index],
|
|
57
|
+
outerRadius: 55,
|
|
58
|
+
shadow: 5,
|
|
59
|
+
showValue: true,
|
|
60
|
+
showMouseOver: true,
|
|
61
|
+
color: xColorsObj[x_values[index]] || '#7BB7F4',
|
|
62
|
+
filter: '#drop-shadow',
|
|
63
|
+
},
|
|
64
|
+
]}
|
|
65
|
+
precision={precision}
|
|
66
|
+
/>
|
|
67
|
+
</Grid.Column>
|
|
68
|
+
</Grid>
|
|
69
|
+
</Grid.Column>
|
|
70
|
+
))
|
|
71
|
+
: ''}
|
|
72
|
+
</Grid>
|
|
73
|
+
) : (
|
|
74
|
+
<p>{placeholder}</p>
|
|
75
|
+
)}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default View;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ExplodedPiesChart 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
|
+
exploded_pies_chart: {
|
|
10
|
+
view: ExplodedPiesChart,
|
|
11
|
+
getSchema: getSchema,
|
|
12
|
+
title: 'Exploded pies chart',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
return config;
|
|
17
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const xColorSchema = (props) => {
|
|
2
|
+
const data = props.provider_data || {};
|
|
3
|
+
const x = props.data.x || '';
|
|
4
|
+
const choices = data[x]?.map((key) => [key, key]) || [];
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
title: 'Color',
|
|
8
|
+
|
|
9
|
+
fieldsets: [
|
|
10
|
+
{
|
|
11
|
+
id: 'default',
|
|
12
|
+
title: 'Default',
|
|
13
|
+
fields: ['label', 'color'],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
|
|
17
|
+
properties: {
|
|
18
|
+
label: {
|
|
19
|
+
title: 'Label',
|
|
20
|
+
type: 'array',
|
|
21
|
+
choices,
|
|
22
|
+
},
|
|
23
|
+
color: {
|
|
24
|
+
title: 'Color',
|
|
25
|
+
type: 'string',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
required: ['label', 'color'],
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getSchema = (props) => {
|
|
34
|
+
const data = props.provider_data || {};
|
|
35
|
+
const choices = Object.keys(data).map((key) => [key, key]);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
title: 'Exploded pies chart',
|
|
39
|
+
|
|
40
|
+
fieldsets: [
|
|
41
|
+
{
|
|
42
|
+
id: 'default',
|
|
43
|
+
title: 'Default',
|
|
44
|
+
fields: ['x', 'y', 'x_colors', 'precision'],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
properties: {
|
|
49
|
+
x: {
|
|
50
|
+
title: 'Value',
|
|
51
|
+
type: 'array',
|
|
52
|
+
choices,
|
|
53
|
+
},
|
|
54
|
+
y: {
|
|
55
|
+
title: 'Label',
|
|
56
|
+
type: 'array',
|
|
57
|
+
choices,
|
|
58
|
+
},
|
|
59
|
+
x_colors: {
|
|
60
|
+
title: 'Labels color',
|
|
61
|
+
widget: 'objectlist',
|
|
62
|
+
schema: xColorSchema(props),
|
|
63
|
+
},
|
|
64
|
+
precision: {
|
|
65
|
+
title: 'Precision',
|
|
66
|
+
type: 'number',
|
|
67
|
+
minimum: -1,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
required: [],
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default getSchema;
|