@eeacms/volto-eea-design-system 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,81 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [0.5.0](https://github.com/eea/volto-eea-design-system/compare/0.4.5...0.5.0)
8
+
9
+ - fix(header-dropdown): mobile text is now visible [`#111`](https://github.com/eea/volto-eea-design-system/pull/111)
10
+ - fix(header): Internal links in mega menu [`d8ca135`](https://github.com/eea/volto-eea-design-system/commit/d8ca13558c3e8c336800791f2fea8a8d33a2b602)
11
+ - Update package.json [`9dc3816`](https://github.com/eea/volto-eea-design-system/commit/9dc38165a95deca1faf2dfccdc03fd6cab3d8c54)
12
+ - refactor(header): and mega menu to latest spec #114 [`44fcf68`](https://github.com/eea/volto-eea-design-system/commit/44fcf68be242f97ced852b28ac3ab820dc0e1045)
13
+ - fix(header): show active menu when clicking on children [`a54fa67`](https://github.com/eea/volto-eea-design-system/commit/a54fa67a1a92e2ab4216e6d149f66e1ee53aab89)
14
+ - change(header): use Link instead of a tag for menu items [`9812b3f`](https://github.com/eea/volto-eea-design-system/commit/9812b3fba7b8305399d6972daf135b8a2d88e876)
15
+ - change(header): hide first link(home) from header menu on site [`ae7f3b9`](https://github.com/eea/volto-eea-design-system/commit/ae7f3b9385620eb3d840dd90f512e37cd8556a6d)
16
+ - change(header): renamed mega menu items href attribute to url [`3ed8144`](https://github.com/eea/volto-eea-design-system/commit/3ed8144589f87a9ad219c97193863c999a72cb6d)
17
+ - change(header): disable sticky setting until feature is more stable [`1d7af95`](https://github.com/eea/volto-eea-design-system/commit/1d7af954c85cb6a8a657c1625e4ae863e562346a)
18
+ - refactor(header): add link for menu title inside desktop mega menu [`24355d0`](https://github.com/eea/volto-eea-design-system/commit/24355d000b2bd808b2031cd2b78e60cafb9ad5b1)
19
+ - change(megamenu): typo correction and key setting on list.items [`96d2c4f`](https://github.com/eea/volto-eea-design-system/commit/96d2c4fbfa722d22a215e8d27f1400e65fe9476e)
20
+ - Autobuild of docusaurus docs [`e75be30`](https://github.com/eea/volto-eea-design-system/commit/e75be303421cd7ea70b0a15998636c6416459869)
21
+ - feat(hero): added storybook implementation of hero component #172 [`17b9d16`](https://github.com/eea/volto-eea-design-system/commit/17b9d1693e31bf7b3b41ca84be7bd21f07065674)
22
+ - Autobuild of docusaurus docs [`fe9d209`](https://github.com/eea/volto-eea-design-system/commit/fe9d209da5e493a6ce5c7fee63a47ba3d9788530)
23
+ - feature(item): added themes to item icons #190 [`a6a2907`](https://github.com/eea/volto-eea-design-system/commit/a6a2907df09575a18fb6e81dc52e8d6651eff118)
24
+ - Override tile image in .block parrent [`005655d`](https://github.com/eea/volto-eea-design-system/commit/005655ddff6f45e211f1ff8156b0b7efa1e47a2e)
25
+ - Move item icon themes to item.overrides [`31e8921`](https://github.com/eea/volto-eea-design-system/commit/31e8921f4ee4d92ba3a9c58275b41dd3101cffd2)
26
+ - Override only the width [`8d49270`](https://github.com/eea/volto-eea-design-system/commit/8d4927084e5daedcb69e6f3a57cab73a9016a55f)
27
+ - Add end of line [`51639d8`](https://github.com/eea/volto-eea-design-system/commit/51639d804a2b84f66373fb77c569bcc43b22e303)
28
+ - Add item themes; override .block .ui.image width based on size [`06010db`](https://github.com/eea/volto-eea-design-system/commit/06010db21398638d46d2e007317d72a7aff7e7d9)
29
+ - refactor(hero): add full-heigh control to adjust height [`a45cb7c`](https://github.com/eea/volto-eea-design-system/commit/a45cb7c599cdc11426207001e67d8f7d727233fe)
30
+ - refactor(utilities): update hex with color token [`8dc65ef`](https://github.com/eea/volto-eea-design-system/commit/8dc65ef55a62dcb32b6eb8a684524a8dc1fa6ba6)
31
+ - refactor(headings): update heading sizes for mobile [`19f3cca`](https://github.com/eea/volto-eea-design-system/commit/19f3ccacaf2c744b5f5c2ec8635773de7ef0016b)
32
+ - refactor(header): minor updates on colors and widths [`a70129f`](https://github.com/eea/volto-eea-design-system/commit/a70129fd929fedb344a47e049cca94274e84a3b1)
33
+ - refactor(hero):make button variant and inverted different button controls [`7e182ca`](https://github.com/eea/volto-eea-design-system/commit/7e182ca9ecdb76507205d84f83cad6a79dd74a03)
34
+ - fix(header): fix accessibility issue by David [`783dcec`](https://github.com/eea/volto-eea-design-system/commit/783dcec0d140e6e6e568d0f82833dcbf8a5c7d3d)
35
+ - fix(header): accessibility and dropdown possition fixes [`505ac36`](https://github.com/eea/volto-eea-design-system/commit/505ac36a27d86e620fb5af515a0b8b5979610f0a)
36
+ - refactor(header):main bar sticky on scroll up [`9c9e7c6`](https://github.com/eea/volto-eea-design-system/commit/9c9e7c6f9651c0663a1eab1856d7324a73afb2de)
37
+ - refactor(megaMenu): update mega menu in header component [`2d1ce45`](https://github.com/eea/volto-eea-design-system/commit/2d1ce454553d116efa96288079b8b77649e10abb)
38
+ - refactor(header): add control for inverted logo [`023ca45`](https://github.com/eea/volto-eea-design-system/commit/023ca45e6f263166211cbea0d63b1938d11221da)
39
+ - refactor(hero): move quoted utility to h2 tag [`7376676`](https://github.com/eea/volto-eea-design-system/commit/7376676b4875494f16c49945f6b5dac19c6b8009)
40
+ - refactor(header): update main section and and add color variations [`f2f0fd1`](https://github.com/eea/volto-eea-design-system/commit/f2f0fd1de7c04eff4b2a9b62d03dd13a1b0d69bc)
41
+ - refactor(header): update structure and variables of top bar [`af70909`](https://github.com/eea/volto-eea-design-system/commit/af709094f94f0cc2e2309b1aedb376e45dc7f136)
42
+ - refactor(hero):prettier & style changes [`d846884`](https://github.com/eea/volto-eea-design-system/commit/d84688440417a430afd9fd24f4c8cfeef0121203)
43
+ - refactor(hero): align hero's text and meta seperately [`4fa958f`](https://github.com/eea/volto-eea-design-system/commit/4fa958f7c7cc6d331a8eb7aaf25dc44d6cd3632a)
44
+ - refactor(hero):add button variant controls [`f362a7b`](https://github.com/eea/volto-eea-design-system/commit/f362a7b2ec273131fa0876f23b74c740c7217b3a)
45
+ - refactor(hero): update variables with new design tokens [`1d97922`](https://github.com/eea/volto-eea-design-system/commit/1d9792231c50f12fd68364e201054f6ab0926665)
46
+ - feat(hero): add hero block component and stories [`6019fc8`](https://github.com/eea/volto-eea-design-system/commit/6019fc843ec14a8afc7558e92c2d4b4bb14ee199)
47
+ - refactor(header): add control for main section stickiness [`2f07572`](https://github.com/eea/volto-eea-design-system/commit/2f07572f78074137e7e6a49585273210ed5cedcb)
48
+ - change(header): disabled active menu when clicking on globalnav links [`3f7b5ee`](https://github.com/eea/volto-eea-design-system/commit/3f7b5eedb038b51fbae8a14a683dc6adc919549b)
49
+ - fix(header): transparency class should apply on the current bg color or image [`f9a0033`](https://github.com/eea/volto-eea-design-system/commit/f9a0033c5538cb19f08f26cf28d47954cc52607d)
50
+ - refactor(header) add position sticky & transparent for main section [`29df772`](https://github.com/eea/volto-eea-design-system/commit/29df772edfe23b1752aa3d184659eea90c3c9221)
51
+ - refactor(header): add control that toggles transparency class on main section [`b8d4bdb`](https://github.com/eea/volto-eea-design-system/commit/b8d4bdb9c527f102ffd3718f32bf1a43309a9bb4)
52
+ - refactor(Language List): add less variables [`7ccc1cc`](https://github.com/eea/volto-eea-design-system/commit/7ccc1ccf57419b6eecbf71d479db72b84428d43a)
53
+ - refactor(Language List): render language dropdown as ul and li elements [`3617442`](https://github.com/eea/volto-eea-design-system/commit/3617442da78af07d3f473d0c43c47dd48c9b2ac3)
54
+ - change(header): mark top level active menu item [`665c449`](https://github.com/eea/volto-eea-design-system/commit/665c449bc2667cc1471a4b97923c897ad3506792)
55
+ - change(header): target link instead of span directly [`9e865fb`](https://github.com/eea/volto-eea-design-system/commit/9e865fbb5b256196756c3d84de397296ac0b447a)
56
+ - change(header): introduced item class to the mega menu link content [`00ca376`](https://github.com/eea/volto-eea-design-system/commit/00ca376ea4cf1de4851e84567b97c374ee7f66e3)
57
+ - fix(header): dropdown disappears after window resize #116 [`fc7dd8b`](https://github.com/eea/volto-eea-design-system/commit/fc7dd8bd7911421fb734a696a2dd5d3ad3b652b0)
58
+ - change(header): use viewport width for changing mobile text in header dropdowns [`b50fa58`](https://github.com/eea/volto-eea-design-system/commit/b50fa585c0abeedc04a46395f08e50a9e112c430)
59
+ - update storybook header.topdropdown [`e58ac08`](https://github.com/eea/volto-eea-design-system/commit/e58ac0821af56c06272e3373383647cbbff20978)
60
+ - rename to viewportWidth [`32162e7`](https://github.com/eea/volto-eea-design-system/commit/32162e7c695774bbb68ac63a0008e8b148f1e9f5)
61
+ - don't connect component to store [`470b8ba`](https://github.com/eea/volto-eea-design-system/commit/470b8bade5e8f2eaabb20a7bb02c8e82ca42f8a0)
62
+ - use volto-screen-helper width [`ea156aa`](https://github.com/eea/volto-eea-design-system/commit/ea156aad1100166ba78635163cfacdcfb913c1d4)
63
+ - fix(header): dropdowns disappear on resize [`52338fd`](https://github.com/eea/volto-eea-design-system/commit/52338fd3e711f4918612e052dc2034a8d9bd40bd)
64
+ - fix(header-topdropdown): dedupe html dropdown elements for topdropdowns #115 [`f10a7a8`](https://github.com/eea/volto-eea-design-system/commit/f10a7a8743a5fb2cecd0c3374ec9d894e914143f)
65
+ - behave as mobile under 480 only [`11b99e1`](https://github.com/eea/volto-eea-design-system/commit/11b99e15cb83245a32bb04f3937f5b95a60b1e95)
66
+ - make it account for all mobile-s,m,l [`69e23ae`](https://github.com/eea/volto-eea-design-system/commit/69e23ae8d12042f241dc53c9e296c340d5b17089)
67
+ - fix(header-topdropdown): dedupe html elements for topdropdowns [`cd8a2a7`](https://github.com/eea/volto-eea-design-system/commit/cd8a2a7ea091e81b736438f7c2a87c254af1b092)
68
+ - refactor(header): restore union dropdown after implementation [`7e98bab`](https://github.com/eea/volto-eea-design-system/commit/7e98bab497ee10ad89d2dfed76c7117b633206fe)
69
+ - fix(header): mobile dropdown now visible [`34371b4`](https://github.com/eea/volto-eea-design-system/commit/34371b436f2ec100f3920f78de49983ba16679b0)
70
+ - Add divider content for metadata field in Banner [`327ad1c`](https://github.com/eea/volto-eea-design-system/commit/327ad1c5fdca0d376d04fd36084b940e5dd016ab)
71
+ - refactor(header): update search input [`368962e`](https://github.com/eea/volto-eea-design-system/commit/368962eabb668e2ec1bdcd18ae81658e7b1d911b)
72
+ - refactor(header): remove unused imports [`7e232db`](https://github.com/eea/volto-eea-design-system/commit/7e232db6ce0b2553be79d98d8497fa06f548b772)
73
+ - refactor(header): update search input and file endings [`afab36f`](https://github.com/eea/volto-eea-design-system/commit/afab36f96f245e197eff528cb1d9e6fea45bc7ba)
74
+ - refactor(header): add fluid font sizes [`5f2743e`](https://github.com/eea/volto-eea-design-system/commit/5f2743e39107fd1bd00a54e03bf92963eb9853f2)
75
+ - refactor(header): minor responsive fixes [`16a0006`](https://github.com/eea/volto-eea-design-system/commit/16a000634505c9e8f8b310860a30b62798a0fb87)
76
+
7
77
  #### [0.4.5](https://github.com/eea/volto-eea-design-system/compare/0.4.4...0.4.5)
8
78
 
79
+ > 8 June 2022
80
+
81
+ - change(tabs,footer): tabs styling and react warning fixes [`#188`](https://github.com/eea/volto-eea-design-system/pull/188)
9
82
  - Autobuild of docusaurus docs [`728c62b`](https://github.com/eea/volto-eea-design-system/commit/728c62b1ddc9ea5e7f551230b657897c6eafbc57)
10
83
  - change(tabs): Add style for tabs accordion template #187 [`fb8adbf`](https://github.com/eea/volto-eea-design-system/commit/fb8adbf84ac564a14d45bb6e8f4e1661811672d5)
11
84
  - Autobuild of docusaurus docs [`06fbae7`](https://github.com/eea/volto-eea-design-system/commit/06fbae751c4f14ace793d4aa51f1ba0b52fec735)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-design-system",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "@eeacms/volto-eea-design-system: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
package/src/semantic.less CHANGED
@@ -272,3 +272,7 @@
272
272
  & {
273
273
  @import '@eeacms/volto-eea-design-system/../theme/themes/eea/extras/languageLabeledIcon';
274
274
  }
275
+
276
+ & {
277
+ @import '@eeacms/volto-eea-design-system/../theme/themes/eea/extras/hero';
278
+ }
@@ -13,6 +13,12 @@ import burgerIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/asse
13
13
 
14
14
  import HeaderSearchPopUp from './HeaderSearchPopUp';
15
15
  import HeaderMenuPopUp from './HeaderMenuPopUp';
16
+ import PropTypes from 'prop-types';
17
+
18
+ Header.propTypes = {
19
+ transparency: PropTypes.bool,
20
+ inverted: PropTypes.bool,
21
+ };
16
22
 
17
23
  function Header({ children }) {
18
24
  return <div className="eea header">{children}</div>;
@@ -39,7 +45,7 @@ const TopDropdownMenu = ({
39
45
  text,
40
46
  viewportWidth,
41
47
  }) => {
42
- const isMobile = viewportWidth < 480;
48
+ const isMobile = viewportWidth < 767;
43
49
 
44
50
  const Component = ({ mobileText }) => (
45
51
  <Dropdown
@@ -57,14 +63,39 @@ const TopDropdownMenu = ({
57
63
  );
58
64
  };
59
65
 
66
+ // disable sticky until it's more stable
67
+ // const useScrollingUp = () => {
68
+ // let prevScroll;
69
+ //
70
+ // if (process.browser) {
71
+ // prevScroll = window.pageYOffset;
72
+ // }
73
+ // const [scrollingUp, setScrollingUp] = React.useState(false);
74
+ // const handleScroll = () => {
75
+ // const currScroll = window.pageYOffset;
76
+ // const isScrolled = prevScroll > currScroll;
77
+ // setScrollingUp(isScrolled);
78
+ // prevScroll = currScroll;
79
+ // };
80
+ // React.useEffect(() => {
81
+ // window.addEventListener('scroll', handleScroll, { passive: true });
82
+ // return () => {
83
+ // window.removeEventListener('scroll', handleScroll, { passive: true });
84
+ // };
85
+ // });
86
+ // return scrollingUp;
87
+ // };
88
+
60
89
  const Main = ({
61
90
  logo,
62
91
  menuItems,
63
92
  renderMenuItem,
64
93
  renderGlobalMenuItem,
65
94
  pathname,
95
+ transparency,
96
+ inverted,
66
97
  }) => {
67
- const [activeItem, setActiveItem] = React.useState('');
98
+ const [activeItem, setActiveItem] = React.useState(pathname);
68
99
  const [menuIsActive, setMenuIsActive] = React.useState(false);
69
100
  const [searchIsActive, setSearchIsActive] = React.useState(false);
70
101
  const [burger, setBurger] = React.useState('');
@@ -73,15 +104,19 @@ const Main = ({
73
104
  setMenuIsActive(false);
74
105
  setSearchIsActive(false);
75
106
  setBurger('');
107
+ // remove active menu when we have no pathname which means we hit logo to go home
108
+ if (!pathname) {
109
+ setActiveItem('');
110
+ }
76
111
  }, [pathname]);
77
112
 
78
113
  const searchOnClick = (e, x) => {
79
114
  if (menuIsActive === true) {
80
115
  setBurger('');
81
116
  setMenuIsActive(false);
117
+ setActiveItem('');
82
118
  }
83
119
  setSearchIsActive(!searchIsActive);
84
- setActiveItem('');
85
120
  };
86
121
 
87
122
  const mobileBurgerOnClick = () => {
@@ -95,49 +130,57 @@ const Main = ({
95
130
  } else {
96
131
  setBurger('');
97
132
  setMenuIsActive(false);
133
+ setActiveItem('');
98
134
  }
99
135
  };
100
136
 
101
- const desktopBurgerOnClick = () => {
102
- setMenuIsActive(false);
103
- setActiveItem('');
104
- };
105
-
106
137
  const menuOnClick = (e, item) => {
107
138
  if (searchIsActive) setSearchIsActive(false);
108
139
  setActiveItem(item['@id'] || item.url);
109
140
  setMenuIsActive(true);
110
141
  };
111
142
 
112
- React.useEffect(() => {
113
- if (searchIsActive || burger === 'open' || menuIsActive) {
114
- document.body.style.overflow = 'hidden';
115
- } else {
116
- document.body.style.overflow = 'unset';
117
- }
118
- }, [searchIsActive, burger, menuIsActive]);
143
+ // React.useEffect(() => {
144
+ // if (searchIsActive || burger === 'open' || menuIsActive) {
145
+ // document.body.style.overflow = 'hidden';
146
+ // } else {
147
+ // document.body.style.overflow = 'unset';
148
+ // }
149
+ // }, [searchIsActive, burger, menuIsActive]);
119
150
 
120
151
  const node = React.useRef();
121
152
  const searchButtonRef = React.useRef();
122
- const desktopMenuBurgerRef = React.useRef();
123
153
  const mobileMenuBurgerRef = React.useRef();
124
154
 
155
+ // disable sticky setting until feature is more stable
156
+ // const isScrollingUp = useScrollingUp();
157
+ // <div
158
+ // className={`main bar ${transparency ? 'transparency' : ''} ${
159
+ // isScrollingUp ? 'sticky' : ''
160
+ // }`}
161
+ // >
125
162
  return (
126
- <div className="main bar" ref={node}>
163
+ <div
164
+ className={`main bar ${transparency ? 'transparency' : ''}`}
165
+ ref={node}
166
+ >
127
167
  <Container>
128
168
  <Grid>
129
169
  <Grid.Column mobile={8} tablet={8} computer={4}>
130
170
  {logo}
131
171
  </Grid.Column>
132
172
  <Grid.Column mobile={4} tablet={4} computer={8}>
133
- <div className="main-menu">
134
- {!menuIsActive && menuItems && (
173
+ <div className={inverted ? 'main-menu inverted' : 'main-menu'}>
174
+ {menuItems && (
135
175
  <Menu className="eea-main-menu tablet or lower hidden" text>
136
176
  {menuItems.map((item) => (
137
177
  <Menu.Item
138
178
  name={item['@id'] || item.url}
139
- active={activeItem === item.key}
140
179
  key={item['@id'] || item.url}
180
+ active={
181
+ activeItem.indexOf(item['@id']) !== -1 ||
182
+ activeItem.indexOf(item.url) !== -1
183
+ }
141
184
  >
142
185
  {renderGlobalMenuItem(item, {
143
186
  onClick: menuOnClick,
@@ -146,16 +189,6 @@ const Main = ({
146
189
  ))}
147
190
  </Menu>
148
191
  )}
149
- {menuIsActive && (
150
- <Header.BurgerAction
151
- className="desktop"
152
- onClick={desktopBurgerOnClick}
153
- ref={desktopMenuBurgerRef}
154
- >
155
- {/* <Icon name="close" /> */}
156
- <Image src={closeIcon} alt="menu close icon" />
157
- </Header.BurgerAction>
158
- )}
159
192
  <div
160
193
  className="search-action"
161
194
  onClick={searchOnClick}
@@ -173,9 +206,6 @@ const Main = ({
173
206
  onClick={mobileBurgerOnClick}
174
207
  ref={mobileMenuBurgerRef}
175
208
  >
176
- {/* <Icon
177
- name={this.state.burger === 'open' ? 'close' : 'bars'}
178
- ></Icon> */}
179
209
  <Image
180
210
  src={burger === 'open' ? `${closeIcon}` : `${burgerIcon}`}
181
211
  alt="menu icon open/close"
@@ -197,7 +227,7 @@ const Main = ({
197
227
  activeItem={activeItem}
198
228
  menuItems={menuItems}
199
229
  onClose={mobileBurgerOnClick}
200
- triggerRefs={[mobileMenuBurgerRef, desktopMenuBurgerRef]}
230
+ triggerRefs={[mobileMenuBurgerRef]}
201
231
  />
202
232
  )}
203
233
  </div>
@@ -1,76 +1,237 @@
1
1
  import React from 'react';
2
- import { Container } from 'semantic-ui-react';
3
- import cx from 'classnames';
2
+ import {
3
+ Container,
4
+ Divider,
5
+ Grid,
6
+ List,
7
+ Icon,
8
+ Accordion,
9
+ } from 'semantic-ui-react';
4
10
 
11
+ import { Link } from 'react-router-dom';
5
12
  import { useClickOutside } from '@eeacms/volto-eea-design-system/helpers';
6
13
 
7
- const levels = ['first', 'second', 'third'];
14
+ const createColumns = (item, length) => {
15
+ let subArrays = [];
16
+ let size = length;
17
+ for (let i = 0; i < item.items.length; i += size) {
18
+ subArrays.push(item.items.slice(i, i + size));
19
+ }
8
20
 
9
- const Item = ({ item, renderMenuItem }) => (
21
+ const column = subArrays.map((subArray, index) => (
22
+ <Grid.Column key={index}>
23
+ <List>
24
+ {subArray.map((arrayItem, idx) => (
25
+ <Link role="listitem" className="item" to={arrayItem.url} key={idx}>
26
+ {arrayItem.title}
27
+ </Link>
28
+ ))}
29
+ </List>
30
+ </Grid.Column>
31
+ ));
32
+
33
+ return column;
34
+ };
35
+
36
+ const ItemGrid = ({ item, columns, length }) => (
37
+ <>
38
+ <Link className="sub-title" to={item.url}>
39
+ {item.title}
40
+ </Link>
41
+ <Grid columns={columns}>{createColumns(item, length)}</Grid>
42
+ </>
43
+ );
44
+
45
+ const Item = ({ item, icon = false, iconName }) => (
10
46
  <>
11
- {item.items.length > 0 && (
12
- <label htmlFor={`drop-${item['@id'] || item.url}`} className="toggle">
13
- {item.title}
14
- </label>
15
- )}
16
- {renderMenuItem(item)}
17
- {item.items.length > 0 && (
18
- <input type="checkbox" id={`drop-${item['@id'] || item.url}`} />
19
- )}
47
+ <Link className="sub-title" to={item.url}>
48
+ {item.title}
49
+ </Link>
50
+ <List className="menu-list">
51
+ {item.items.map((listItem, index) => (
52
+ <Link role="listitem" className="item" to={listItem.url} key={index}>
53
+ {icon && <Icon className={iconName} />}
54
+ {listItem.title}
55
+ </Link>
56
+ ))}
57
+ </List>
20
58
  </>
21
59
  );
22
60
 
23
- const ItemsList = ({ items, renderMenuItem, level = 0, activeItem }) => (
24
- <ul
25
- className={cx(
26
- level === 0 ? 'menu' : 'sub',
27
- levels[level],
28
- `level-${level}`,
29
- )}
30
- >
31
- {items.map((item) => (
32
- <li
33
- key={item['@id'] || item.url}
34
- className={cx({
35
- hasSubMenu: item.items?.length > 0,
36
- active: (item['@id'] || item.url) === activeItem,
37
- })}
38
- >
39
- <Item item={item} renderMenuItem={renderMenuItem} />
40
-
41
- {item.items.length > 0 && (
42
- <ItemsList
43
- items={item.items}
44
- level={level + 1}
45
- renderMenuItem={renderMenuItem}
46
- activeItem={activeItem}
47
- />
61
+ const Topics = ({ menuItem }) => (
62
+ <Grid>
63
+ {menuItem.items.map((section, index) => (
64
+ <React.Fragment key={index}>
65
+ {section.title === 'At a glance' ? (
66
+ <Grid.Column width={3} id="at-a-glance">
67
+ <Item item={section} icon={true} iconName="ri-leaf-line" />
68
+ </Grid.Column>
69
+ ) : (
70
+ <Grid.Column width={9} key={index}>
71
+ <ItemGrid item={section} columns={4} length={10} />
72
+ </Grid.Column>
48
73
  )}
49
- </li>
74
+ </React.Fragment>
75
+ ))}
76
+ </Grid>
77
+ );
78
+
79
+ const Countries = ({ menuItem }) => (
80
+ <Grid>
81
+ <Grid.Column width={8}>
82
+ {menuItem.items.map((section, index) => (
83
+ <React.Fragment key={index}>
84
+ {section.title === 'EEA member countries' && (
85
+ <ItemGrid item={section} columns={5} length={7} />
86
+ )}
87
+ </React.Fragment>
88
+ ))}
89
+ </Grid.Column>
90
+ <Grid.Column width={4}>
91
+ <Grid columns={1} className="nested-grid">
92
+ {menuItem.items.map((section, index) => (
93
+ <React.Fragment key={index}>
94
+ {section.title !== 'EEA member countries' && (
95
+ <Grid.Column>
96
+ <ItemGrid item={section} columns={2} length={3} />
97
+ </Grid.Column>
98
+ )}
99
+ </React.Fragment>
100
+ ))}
101
+ </Grid>
102
+ </Grid.Column>
103
+ </Grid>
104
+ );
105
+
106
+ const StandardMegaMenuGrid = ({ menuItem }) => (
107
+ <Grid columns={4}>
108
+ {menuItem.items.map((section, index) => (
109
+ <Grid.Column key={index}>
110
+ <Item item={section} />
111
+ </Grid.Column>
50
112
  ))}
51
- </ul>
113
+ </Grid>
52
114
  );
53
115
 
54
- function HeaderMenuPopUp({
55
- menuItems,
56
- onClose,
57
- triggerRefs,
58
- renderMenuItem,
59
- activeItem,
60
- }) {
116
+ const FirstLevelContent = ({ element }) => {
117
+ const topics = element.title === 'Topics' ? true : false;
118
+
119
+ const firstLevelPanels = [];
120
+ let content;
121
+ if (!topics) {
122
+ element.items.forEach((item, index) => {
123
+ let x = {};
124
+ x.key = item['@id'];
125
+ x.title = (
126
+ <Accordion.Title key={`title=${index}`}>
127
+ {item.title}
128
+ <Icon className="ri-arrow-down-s-line" size="small" />
129
+ </Accordion.Title>
130
+ );
131
+ x.content = (
132
+ <Accordion.Content key={index}>
133
+ <SecondLevelContent element={item} />
134
+ </Accordion.Content>
135
+ );
136
+ firstLevelPanels.push(x);
137
+ });
138
+ content = <Accordion.Accordion panels={firstLevelPanels} />;
139
+ } else {
140
+ content = <SecondLevelContent element={element} topics={true} />;
141
+ }
142
+ return <>{content}</>;
143
+ };
144
+
145
+ const SecondLevelContent = ({ element, topics = false }) => {
146
+ let content;
147
+ if (topics) {
148
+ const atAGlance = element.items.find(
149
+ (element) => element.title === 'At a glance',
150
+ );
151
+ content = (
152
+ <List>
153
+ {atAGlance.items.map((item, index) => (
154
+ <Link role="listitem" className="item" to={item.url} key={index}>
155
+ {item.title}
156
+ </Link>
157
+ ))}
158
+ <Link
159
+ role="listitem"
160
+ className="item"
161
+ to={element.url}
162
+ key={element['@id']}
163
+ >
164
+ A-Z Topics
165
+ </Link>
166
+ </List>
167
+ );
168
+ } else {
169
+ content = (
170
+ <List>
171
+ {element.items.map((item, index) => (
172
+ <Link role="listitem" className="item" to={item.url} key={index}>
173
+ {item.title}
174
+ </Link>
175
+ ))}
176
+ </List>
177
+ );
178
+ }
179
+
180
+ return <>{content}</>;
181
+ };
182
+
183
+ const NestedAccordion = ({ menuItems }) => {
184
+ const rootPanels = [];
185
+ menuItems.forEach((element, index) => {
186
+ let x = {};
187
+ x.key = index;
188
+ x.title = (
189
+ <Accordion.Title key={`title-${index}`}>
190
+ {element.title}
191
+ <Icon className="ri-arrow-down-s-line" size="small" />
192
+ </Accordion.Title>
193
+ );
194
+ x.content = (
195
+ <Accordion.Content key={index}>
196
+ <FirstLevelContent element={element} />
197
+ </Accordion.Content>
198
+ );
199
+ rootPanels.push(x);
200
+ });
201
+
202
+ return <Accordion panels={rootPanels} />;
203
+ };
204
+
205
+ function HeaderMenuPopUp({ menuItems, onClose, triggerRefs, activeItem }) {
61
206
  const nodeRef = React.useRef();
62
207
  useClickOutside({ targetRefs: [nodeRef, ...triggerRefs], callback: onClose });
63
208
 
209
+ const menuItem = menuItems.find(
210
+ (current) => current.url === activeItem || current['@id'] === activeItem,
211
+ );
212
+
64
213
  return (
65
214
  <div id="mega-menu" ref={nodeRef}>
66
215
  <Container>
67
- <nav>
68
- <ItemsList
69
- items={menuItems}
70
- renderMenuItem={renderMenuItem}
71
- activeItem={activeItem}
72
- />
73
- </nav>
216
+ {menuItem && (
217
+ <div className="menu-content tablet hidden mobile hidden">
218
+ <h3 className="title">
219
+ <Link to={menuItem.url}>{menuItem.title}</Link>
220
+ </h3>
221
+ <Divider fitted />
222
+ {menuItem.title === 'Topics' ? (
223
+ <Topics menuItem={menuItem} />
224
+ ) : menuItem.title === 'Countries' ? (
225
+ <Countries menuItem={menuItem} />
226
+ ) : (
227
+ <StandardMegaMenuGrid menuItem={menuItem} />
228
+ )}
229
+ </div>
230
+ )}
231
+
232
+ <div className="tablet only mobile only">
233
+ <NestedAccordion menuItems={menuItems} />
234
+ </div>
74
235
  </Container>
75
236
  </div>
76
237
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Container, Input, Button, Icon } from 'semantic-ui-react';
2
+ import { Container, Input } from 'semantic-ui-react';
3
3
 
4
4
  import { useClickOutside } from '@eeacms/volto-eea-design-system/helpers';
5
5
 
@@ -14,16 +14,16 @@ function HeaderSearchPopUp({ onClose, triggerRefs = [] }) {
14
14
  <div className="wrapper">
15
15
  <Input
16
16
  className="search"
17
- icon="search"
17
+ icon={{ className: 'ri-search-line', link: true }}
18
18
  placeholder="Search..."
19
19
  fluid
20
20
  />
21
- <div className="action">
21
+ {/* <div className="action">
22
22
  <Button icon labelPosition="left" className="search">
23
23
  <Icon name="search" />
24
24
  Advanced Search
25
25
  </Button>
26
- </div>
26
+ </div> */}
27
27
  </div>
28
28
  </Container>
29
29
  </div>