@eeacms/volto-n2k 1.0.15 → 1.0.17

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.
@@ -4,49 +4,88 @@
4
4
  */
5
5
 
6
6
  import React, { useEffect, useContext, useMemo } from 'react';
7
+ import cx from 'classnames';
7
8
  import { matchPath, withRouter } from 'react-router';
8
- import { Container, Sticky } from 'semantic-ui-react';
9
+ import { Link } from 'react-router-dom';
10
+ import { compose } from 'redux';
9
11
  import { connect } from 'react-redux';
10
12
  import { Portal } from 'react-portal';
13
+ import { Container, Segment, Sticky, Image } from 'semantic-ui-react';
11
14
  import config from '@plone/volto/registry';
12
15
  import { Anontools } from '@plone/volto/components';
13
16
  import { withLocalStorage } from '@eeacms/volto-n2k/hocs';
14
- import Navigation from '../Navigation/Navigation';
15
17
  import { StickyContext } from '@eeacms/volto-bise/components';
18
+ import Navigation from '../Navigation/Navigation';
19
+ import LanguageSelector from '../LanguageSelector/LanguageSelector';
20
+
21
+ import BISELogo from '@eeacms/volto-bise/customizations/volto/components/theme/Logo/Logo.svg';
16
22
 
17
23
  function removeTrailingSlash(str) {
18
24
  return str.replace(/\/+$/, '');
19
25
  }
20
26
 
27
+ function matchPaths(paths, pathname) {
28
+ if (
29
+ matchPath(pathname, {
30
+ path: paths,
31
+ exact: true,
32
+ strict: false,
33
+ })
34
+ ) {
35
+ return true;
36
+ }
37
+ return false;
38
+ }
39
+
21
40
  const Navbar = (props) => {
22
41
  const currentLang = props.localStorage.get('N2K_LANGUAGE');
23
42
 
24
43
  return (
25
- <Container>
26
- <div className="header-wrapper">
27
- <div className="header">
28
- <div className="logo-nav-wrapper">
29
- <div className="tools-search-wrapper">
30
- {currentLang ? (
31
- <Navigation
32
- isSticky={props.isSticky}
33
- isRoot={props.isRoot}
34
- isExplorer={props.isExplorer}
35
- pathname={props.pathname}
36
- />
37
- ) : (
38
- ''
44
+ <div>
45
+ <Segment basic role="banner" className={cx('header-wrapper')}>
46
+ <Container>
47
+ <div className="header">
48
+ <div className="logo-nav-wrapper">
49
+ <div className="logo">
50
+ <Link title="Natura 2000" to="/">
51
+ <Image
52
+ src={BISELogo}
53
+ alt="Biodiversity logo"
54
+ title="Biodiversity logo"
55
+ height={64}
56
+ width={192}
57
+ />
58
+ </Link>
59
+ </div>
60
+ <div className="tools-search-wrapper">
61
+ {currentLang ? (
62
+ <Navigation
63
+ pathname={props.pathname}
64
+ isSticky={props.isSticky}
65
+ isRoot={props.isRoot}
66
+ isExplorer={props.isExplorer}
67
+ />
68
+ ) : (
69
+ ''
70
+ )}
71
+ </div>
72
+ {!props.isSdf && !props.isExplorer && (
73
+ <div className="mobile hidden tablet hidden computer hidden language-selector-wrapper">
74
+ <LanguageSelector navigation={props.navigation} />
75
+ </div>
39
76
  )}
40
77
  </div>
41
78
  </div>
42
- </div>
43
- </div>
44
- {!props.token && (
45
- <Portal node={__CLIENT__ && document.querySelector('#footer_links')}>
46
- <Anontools />
47
- </Portal>
48
- )}
49
- </Container>
79
+ {!props.token && (
80
+ <Portal
81
+ node={__CLIENT__ && document.querySelector('#footer_links')}
82
+ >
83
+ <Anontools />
84
+ </Portal>
85
+ )}
86
+ </Container>
87
+ </Segment>
88
+ </div>
50
89
  );
51
90
  };
52
91
 
@@ -64,16 +103,13 @@ const Header = (props) => {
64
103
  [props.pathname],
65
104
  );
66
105
 
106
+ const isSdf = useMemo(() => matchPaths(config.settings.sdf, props.pathname), [
107
+ props.pathname,
108
+ ]);
109
+
67
110
  const isExplorer = useMemo(
68
- () =>
69
- (isRoot &&
70
- !config.settings.n2k.supportedLanguages.includes(isRoot.params.lang)) ||
71
- matchPath(props.pathname, {
72
- path: '/natura2000/explore-natura2000/*',
73
- exact: true,
74
- strict: false,
75
- }),
76
- [props.pathname, isRoot],
111
+ () => matchPaths(config.settings.explorer, props.pathname),
112
+ [props.pathname],
77
113
  );
78
114
 
79
115
  useEffect(() => {
@@ -86,13 +122,14 @@ const Header = (props) => {
86
122
  /* eslint-disable-next-line */
87
123
  }, []);
88
124
 
89
- return isRoot || isExplorer ? (
125
+ return isRoot ? (
90
126
  <div className="ui basic segment sticky-header-wrapper">
91
127
  <div className="ui sticky">
92
128
  <Navbar
93
129
  {...props}
94
130
  isSticky={false}
95
131
  isRoot={isRoot}
132
+ isSdf={isSdf}
96
133
  isExplorer={isExplorer}
97
134
  />
98
135
  </div>
@@ -113,12 +150,20 @@ const Header = (props) => {
113
150
  {...props}
114
151
  isSticky={isSticky}
115
152
  isRoot={isRoot}
153
+ isSdf={isSdf}
116
154
  isExplorer={isExplorer}
117
155
  />
118
156
  </Sticky>
119
157
  );
120
158
  };
121
159
 
122
- export default connect((state) => ({
123
- token: state.userSession.token,
124
- }))(withRouter(withLocalStorage(Header)));
160
+ export default compose(
161
+ withRouter,
162
+ withLocalStorage,
163
+ connect((state) => {
164
+ return {
165
+ token: state.userSession.token,
166
+ navigation: state.navigation,
167
+ };
168
+ }),
169
+ )(Header);
@@ -1,19 +1,37 @@
1
+ .computer.hidden.language-selector-wrapper {
2
+ .language-selector > .ui.dropdown {
3
+ display: flex;
4
+ flex-flow: row-reverse;
5
+ align-items: center;
6
+ }
7
+ }
8
+
1
9
  .language-selector {
10
+ margin-right: 0;
11
+
2
12
  .ui.dropdown {
3
- &:not(.button) .text,
4
- &:not(.button) .default.text {
5
- color: #005248;
13
+ .divider.text {
14
+ display: inline-block;
15
+ color: #005248 !important;
6
16
  font-family: OpenSans, 'Raleway', sans-serif;
17
+ font-weight: 700;
7
18
  text-transform: uppercase;
19
+ }
8
20
 
9
- &:hover {
10
- color: #00a390;
21
+ .ui.image {
22
+ display: inline-block;
23
+ margin-right: 0.25rem;
24
+ }
25
+
26
+ &:hover {
27
+ .divider.text {
28
+ color: #00a390 !important;
11
29
  }
12
30
  }
13
31
 
14
- .menu {
15
- margin-top: 0.5rem;
16
- margin-left: -0.6rem;
32
+ > .menu {
33
+ position: absolute;
34
+ top: 30px !important;
17
35
 
18
36
  .item {
19
37
  background: #fff !important;
@@ -22,20 +40,13 @@
22
40
  color: #005248;
23
41
  font-family: OpenSans, 'Raleway', sans-serif;
24
42
  font-size: 1rem;
25
- font-weight: bold;
43
+ font-weight: 700;
26
44
  text-transform: uppercase;
27
45
  }
28
46
 
29
- &.active.selected {
30
- background: #fff !important;
31
-
47
+ &:hover {
32
48
  .text {
33
- color: #005248;
34
- }
35
-
36
- &::before {
37
- display: none !important;
38
- opacity: 0;
49
+ color: #00a390;
39
50
  }
40
51
  }
41
52
  }