@eeacms/volto-eea-design-system 1.20.0 → 1.21.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 +22 -1
- package/cypress.config.js +3 -3
- package/package.json +1 -1
- package/src/ui/Banner/Banner.jsx +7 -13
- package/src/ui/Card/Card.stories.jsx +147 -81
- package/src/ui/Card/Card.stories.test.jsx +11 -1
- package/src/ui/Footer/Footer.jsx +2 -2
- package/src/ui/Header/Header.jsx +71 -71
- package/src/ui/Header/Header.stories.js +44 -41
- package/src/ui/Header/Header.test.jsx +102 -4
- package/src/ui/Header/HeaderMenuPopUp.js +2 -3
- package/src/ui/InpageNavigation/InpageNavigation.jsx +5 -1
- package/src/ui/Item/Item.stories.test.js +2 -2
- package/src/ui/Item/ItemGroupWithIcons.stories.js +28 -18
- package/src/ui/Message/Message.stories.js +6 -6
- package/src/ui/Message/Message.stories.test.js +11 -5
- package/src/ui/TagList/TagList.stories.jsx +1 -1
- package/theme/themes/eea/extras/header.less +2 -15
- package/theme/themes/eea/extras/header.variables +1 -3
- package/theme/themes/eea/extras/tag.less +5 -0
- package/theme/themes/eea/extras/tag.variables +1 -1
- package/theme/themes/eea/globals/utilities.less +21 -1
- package/theme/themes/eea/modules/search.overrides +2 -2
- package/theme/themes/eea/views/card.overrides +2 -1
- package/theme/themes/eea/views/card.variables +2 -2
- package/theme/themes/eea/views/item.overrides +14 -20
- package/theme/themes/eea/views/item.variables +3 -5
package/src/ui/Header/Header.jsx
CHANGED
|
@@ -15,7 +15,7 @@ import burgerIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/asse
|
|
|
15
15
|
import HeaderSearchPopUp from './HeaderSearchPopUp';
|
|
16
16
|
import HeaderMenuPopUp from './HeaderMenuPopUp';
|
|
17
17
|
import PropTypes from 'prop-types';
|
|
18
|
-
|
|
18
|
+
import _ from 'lodash';
|
|
19
19
|
import { isInternalURL } from '@plone/volto/helpers';
|
|
20
20
|
import config from '@plone/volto/registry';
|
|
21
21
|
|
|
@@ -25,7 +25,11 @@ Header.propTypes = {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
function Header({ children }) {
|
|
28
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
<header className="eea header" aria-label={'Site'}>
|
|
30
|
+
{children}
|
|
31
|
+
</header>
|
|
32
|
+
);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
const TopHeader = ({ children }) => (
|
|
@@ -44,15 +48,15 @@ const onKeyDownHandler = (event) => {
|
|
|
44
48
|
if (event.key === 'Enter') {
|
|
45
49
|
event.preventDefault();
|
|
46
50
|
event.target.click();
|
|
47
|
-
//event.target.focus();
|
|
48
51
|
}
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
const TopDropdownMenu = ({
|
|
52
55
|
children,
|
|
56
|
+
ariaLabel,
|
|
53
57
|
className,
|
|
58
|
+
classNameHeader,
|
|
54
59
|
icon,
|
|
55
|
-
hasLanguageDropdown = false,
|
|
56
60
|
id,
|
|
57
61
|
tabletText,
|
|
58
62
|
mobileText,
|
|
@@ -63,45 +67,38 @@ const TopDropdownMenu = ({
|
|
|
63
67
|
const isMobile = viewportWidth < 767;
|
|
64
68
|
|
|
65
69
|
const Component = ({ mobileText }) => {
|
|
70
|
+
const headerText = mobileText || text;
|
|
71
|
+
const label = ariaLabel || headerText;
|
|
72
|
+
const dropdownRef = React.useRef(null);
|
|
73
|
+
|
|
66
74
|
return (
|
|
67
75
|
<>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
aria-label="dropdown"
|
|
95
|
-
lazyLoad
|
|
96
|
-
closeOnChange={true}
|
|
97
|
-
closeOnBlur={false}
|
|
98
|
-
closeOnEscape={true}
|
|
99
|
-
openOnFocus={false}
|
|
100
|
-
onKeyDown={onKeyDownHandler}
|
|
101
|
-
>
|
|
102
|
-
<Dropdown.Menu role="option">{children}</Dropdown.Menu>
|
|
103
|
-
</Dropdown>
|
|
104
|
-
)}
|
|
76
|
+
<Dropdown
|
|
77
|
+
id={id}
|
|
78
|
+
className={className}
|
|
79
|
+
text={() => (
|
|
80
|
+
<div className={`divider text ${classNameHeader}`}>
|
|
81
|
+
{headerText}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
ref={dropdownRef}
|
|
85
|
+
icon={icon || 'chevron down'}
|
|
86
|
+
aria-label={label}
|
|
87
|
+
closeOnChange={true}
|
|
88
|
+
closeOnBlur={false}
|
|
89
|
+
closeOnEscape={true}
|
|
90
|
+
openOnFocus={true}
|
|
91
|
+
onBlur={(e) => {
|
|
92
|
+
const dropdown = dropdownRef.current;
|
|
93
|
+
const ref = dropdown.ref.current;
|
|
94
|
+
if (e.target !== ref && !ref.contains(e.relatedTarget)) {
|
|
95
|
+
dropdown.close();
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
onKeyDown={onKeyDownHandler}
|
|
99
|
+
>
|
|
100
|
+
<Dropdown.Menu role="option">{children}</Dropdown.Menu>
|
|
101
|
+
</Dropdown>
|
|
105
102
|
</>
|
|
106
103
|
);
|
|
107
104
|
};
|
|
@@ -288,7 +285,7 @@ const Main = ({
|
|
|
288
285
|
className={`main bar ${transparency ? 'transparency' : ''}`}
|
|
289
286
|
ref={node}
|
|
290
287
|
>
|
|
291
|
-
<Container>
|
|
288
|
+
<Container className={'main-bar-container'}>
|
|
292
289
|
<Grid>
|
|
293
290
|
<Grid.Column mobile={8} tablet={8} computer={4}>
|
|
294
291
|
{logo}
|
|
@@ -296,52 +293,57 @@ const Main = ({
|
|
|
296
293
|
<Grid.Column mobile={4} tablet={4} computer={8}>
|
|
297
294
|
<div className={inverted ? 'main-menu inverted' : 'main-menu'}>
|
|
298
295
|
{menuItems && (
|
|
299
|
-
<
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
296
|
+
<nav aria-label={'Main'}>
|
|
297
|
+
<ul
|
|
298
|
+
className="ui text eea-main-menu tablet or lower hidden menu"
|
|
299
|
+
ref={desktopMenuRef}
|
|
300
|
+
id={'navigation'}
|
|
301
|
+
>
|
|
302
|
+
{menuItems.map((item) => (
|
|
303
|
+
<Menu.Item
|
|
304
|
+
name={item['@id'] || item.url}
|
|
305
|
+
key={item['@id'] || item.url}
|
|
306
|
+
as={'li'}
|
|
307
|
+
active={
|
|
308
|
+
activeItem.indexOf(item['@id']) !== -1 ||
|
|
309
|
+
activeItem.indexOf(item.url) !== -1
|
|
310
|
+
}
|
|
311
|
+
aria-expanded={
|
|
312
|
+
activeItem.indexOf(item['@id']) !== -1 ||
|
|
313
|
+
activeItem.indexOf(item.url) !== -1
|
|
314
|
+
}
|
|
315
|
+
>
|
|
316
|
+
{renderGlobalMenuItem(item, {
|
|
317
|
+
onClick: menuOnClick,
|
|
318
|
+
})}
|
|
319
|
+
</Menu.Item>
|
|
320
|
+
))}
|
|
321
|
+
</ul>
|
|
322
|
+
</nav>
|
|
320
323
|
)}
|
|
321
324
|
{!hideSearch && (
|
|
322
325
|
<button
|
|
323
326
|
className="search-action"
|
|
324
327
|
onClick={searchOnClick}
|
|
325
|
-
|
|
326
|
-
aria-pressed="false"
|
|
327
|
-
aria-haspopup="true"
|
|
328
|
+
aria-expanded={searchIsActive}
|
|
328
329
|
ref={searchButtonRef}
|
|
329
330
|
>
|
|
330
331
|
{/* <Icon name={!state.activeSearch ? 'search' : 'close'} /> */}
|
|
331
332
|
<Image
|
|
332
333
|
src={!searchIsActive ? `${searchIcon}` : `${closeIcon}`}
|
|
333
|
-
alt="search
|
|
334
|
+
alt="Global search"
|
|
334
335
|
/>
|
|
335
336
|
</button>
|
|
336
337
|
)}
|
|
337
338
|
<Header.BurgerAction
|
|
338
339
|
className={`mobile ${burger}`}
|
|
339
340
|
onClick={mobileBurgerOnClick}
|
|
341
|
+
aria-expanded={menuIsActive}
|
|
340
342
|
ref={mobileMenuBurgerRef}
|
|
341
343
|
>
|
|
342
344
|
<Image
|
|
343
345
|
src={burger === 'open' ? `${closeIcon}` : `${burgerIcon}`}
|
|
344
|
-
alt="
|
|
346
|
+
alt="Menu navigation"
|
|
345
347
|
/>
|
|
346
348
|
</Header.BurgerAction>
|
|
347
349
|
</div>
|
|
@@ -374,9 +376,7 @@ const BurgerAction = React.forwardRef((props, ref) => (
|
|
|
374
376
|
<button
|
|
375
377
|
ref={ref}
|
|
376
378
|
className={`burger-action ${props.className}`}
|
|
377
|
-
|
|
378
|
-
aria-pressed="false"
|
|
379
|
-
aria-haspopup="true"
|
|
379
|
+
{..._.omit(props, ['onClick', 'children', 'className', 'ref'])}
|
|
380
380
|
onClick={props.onClick}
|
|
381
381
|
>
|
|
382
382
|
{props.children}
|
|
@@ -1246,6 +1246,7 @@ const Template = (args) => {
|
|
|
1246
1246
|
icon="chevron down"
|
|
1247
1247
|
aria-label="dropdown"
|
|
1248
1248
|
className=""
|
|
1249
|
+
classNameHeader="mobile-sr-only"
|
|
1249
1250
|
viewportWidth={viewportWidth}
|
|
1250
1251
|
>
|
|
1251
1252
|
<div
|
|
@@ -1280,7 +1281,7 @@ const Template = (args) => {
|
|
|
1280
1281
|
mobileText={mobileLinksMenuTitle}
|
|
1281
1282
|
viewportWidth={viewportWidth}
|
|
1282
1283
|
>
|
|
1283
|
-
<div className="wrapper">
|
|
1284
|
+
<div className="wrapper" tabIndex={0} role={'presentation'}>
|
|
1284
1285
|
{links.map((item, index) => (
|
|
1285
1286
|
<Dropdown.Item key={index}>
|
|
1286
1287
|
<a
|
|
@@ -1297,47 +1298,49 @@ const Template = (args) => {
|
|
|
1297
1298
|
</Header.TopDropdownMenu>
|
|
1298
1299
|
</Header.TopItem>
|
|
1299
1300
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
<ul
|
|
1316
|
-
className="wrapper language-list"
|
|
1317
|
-
role="listbox"
|
|
1318
|
-
aria-label="language switcher"
|
|
1301
|
+
{hasLanguageDropdown && (
|
|
1302
|
+
<Header.TopDropdownMenu
|
|
1303
|
+
id="language-switcher"
|
|
1304
|
+
className="item"
|
|
1305
|
+
ariaLabel={'language switcher'}
|
|
1306
|
+
text={`${language.toUpperCase()}`}
|
|
1307
|
+
mobileText={`${language.toUpperCase()}`}
|
|
1308
|
+
icon={
|
|
1309
|
+
<Image
|
|
1310
|
+
role="option"
|
|
1311
|
+
src={globeIcon}
|
|
1312
|
+
alt="language dropdown globe icon"
|
|
1313
|
+
></Image>
|
|
1314
|
+
}
|
|
1315
|
+
viewportWidth={viewportWidth}
|
|
1319
1316
|
>
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
{
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1317
|
+
<ul
|
|
1318
|
+
className="wrapper language-list"
|
|
1319
|
+
role="listbox"
|
|
1320
|
+
aria-label="language switcher"
|
|
1321
|
+
>
|
|
1322
|
+
{languages.map((item, index) => (
|
|
1323
|
+
<Dropdown.Item
|
|
1324
|
+
as="li"
|
|
1325
|
+
key={index}
|
|
1326
|
+
text={
|
|
1327
|
+
<a
|
|
1328
|
+
href={'/' + item.code}
|
|
1329
|
+
onClick={() => setLanguage(item.code)}
|
|
1330
|
+
tabIndex={0}
|
|
1331
|
+
className={'language-link'}
|
|
1332
|
+
>
|
|
1333
|
+
{item.name}
|
|
1334
|
+
<span className="country-code">
|
|
1335
|
+
{item.code.toUpperCase()}
|
|
1336
|
+
</span>
|
|
1337
|
+
</a>
|
|
1338
|
+
}
|
|
1339
|
+
></Dropdown.Item>
|
|
1340
|
+
))}
|
|
1341
|
+
</ul>
|
|
1342
|
+
</Header.TopDropdownMenu>
|
|
1343
|
+
)}
|
|
1341
1344
|
</Header.TopHeader>
|
|
1342
1345
|
<Header.Main
|
|
1343
1346
|
transparency={args.transparency}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
|
|
3
5
|
import { createMemoryHistory } from 'history';
|
|
4
6
|
import { Router } from 'react-router-dom';
|
|
5
7
|
import Header from './Header';
|
|
@@ -29,10 +31,7 @@ describe('Header component', () => {
|
|
|
29
31
|
<p>Test</p>
|
|
30
32
|
</Header.TopItem>
|
|
31
33
|
<Header.TopItem>
|
|
32
|
-
<Header.TopDropdownMenu
|
|
33
|
-
hasLanguageDropdown={true}
|
|
34
|
-
viewportWidth={1000}
|
|
35
|
-
>
|
|
34
|
+
<Header.TopDropdownMenu viewportWidth={1000}>
|
|
36
35
|
<div aria-label="language switcher">Language Switcher</div>
|
|
37
36
|
</Header.TopDropdownMenu>
|
|
38
37
|
</Header.TopItem>
|
|
@@ -290,4 +289,103 @@ describe('Header component', () => {
|
|
|
290
289
|
code: 'Enter',
|
|
291
290
|
});
|
|
292
291
|
});
|
|
292
|
+
|
|
293
|
+
test('TopDropdownMenu renders without crashing', () => {
|
|
294
|
+
render(<Header.TopDropdownMenu text="Desktop" />);
|
|
295
|
+
const dropdownMenu = screen.getByText('Desktop');
|
|
296
|
+
expect(dropdownMenu).toBeInTheDocument();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test('TopDropdownMenu renders the correct text based on viewportWidth', () => {
|
|
300
|
+
render(
|
|
301
|
+
<Header.TopDropdownMenu
|
|
302
|
+
text="Desktop"
|
|
303
|
+
mobileText="Mobile"
|
|
304
|
+
viewportWidth={500}
|
|
305
|
+
/>,
|
|
306
|
+
);
|
|
307
|
+
expect(screen.getByText('Mobile')).toBeInTheDocument();
|
|
308
|
+
|
|
309
|
+
render(
|
|
310
|
+
<Header.TopDropdownMenu
|
|
311
|
+
text="Desktop"
|
|
312
|
+
mobileText="Mobile"
|
|
313
|
+
viewportWidth={1200}
|
|
314
|
+
/>,
|
|
315
|
+
);
|
|
316
|
+
expect(screen.getByText('Desktop')).toBeInTheDocument();
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test('TopDropdownMenu opens dropdown menu when clicked, closed on escape', () => {
|
|
320
|
+
render(<Header.TopDropdownMenu text={'Desktop'} />);
|
|
321
|
+
const dropdownMenu = screen.getByText('Desktop');
|
|
322
|
+
fireEvent.click(dropdownMenu);
|
|
323
|
+
const dropdownItems = screen.getByRole('option');
|
|
324
|
+
expect(dropdownItems).toBeVisible();
|
|
325
|
+
|
|
326
|
+
fireEvent.keyDown(screen.getByText('Desktop'), {
|
|
327
|
+
key: 'Escape',
|
|
328
|
+
code: 'Escape',
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
test('renders dropdown text and checks for visibility of options on click', () => {
|
|
332
|
+
// Render the component
|
|
333
|
+
render(
|
|
334
|
+
<div className="wrapper">
|
|
335
|
+
<Header.TopDropdownMenu
|
|
336
|
+
text="Dropdown"
|
|
337
|
+
tabletText="Tablet Dropdown"
|
|
338
|
+
mobileText="Mobile Dropdown"
|
|
339
|
+
>
|
|
340
|
+
<a href="/" data-testid="option1">
|
|
341
|
+
Option 1
|
|
342
|
+
</a>
|
|
343
|
+
</Header.TopDropdownMenu>
|
|
344
|
+
<a href="/" data-testid="option2">
|
|
345
|
+
Option 2
|
|
346
|
+
</a>
|
|
347
|
+
</div>,
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const dropdown = screen.getByRole('listbox');
|
|
351
|
+
|
|
352
|
+
// Find the dropdown text and options
|
|
353
|
+
const dropdownText = screen.getByText('Dropdown');
|
|
354
|
+
|
|
355
|
+
// Initially, options should not be visible
|
|
356
|
+
expect(dropdown).toHaveAttribute('aria-expanded', 'false');
|
|
357
|
+
|
|
358
|
+
// Simulate click on the dropdown text
|
|
359
|
+
fireEvent.click(dropdownText);
|
|
360
|
+
|
|
361
|
+
// After clicking, options should be visible
|
|
362
|
+
expect(dropdown).toHaveAttribute('aria-expanded', 'true');
|
|
363
|
+
|
|
364
|
+
// Simulate Escape key press to trigger onBlur
|
|
365
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
366
|
+
|
|
367
|
+
// After Escape key press, options should not be visible
|
|
368
|
+
expect(dropdown).toHaveAttribute('aria-expanded', 'false');
|
|
369
|
+
|
|
370
|
+
// Simulate click on the dropdown text
|
|
371
|
+
// fireEvent.click(dropdownText);
|
|
372
|
+
|
|
373
|
+
// Click on document to trigger onBlur
|
|
374
|
+
// fireEvent.click(document);
|
|
375
|
+
|
|
376
|
+
// Hit Enter key on the dropdown text
|
|
377
|
+
// fireEvent.keyDown(dropdownText, { key: 'Enter', code: 'Enter' });
|
|
378
|
+
|
|
379
|
+
// Tab outside of the dropdown
|
|
380
|
+
fireEvent.keyDown(dropdownText, { key: 'Tab', code: 'Tab' });
|
|
381
|
+
fireEvent.keyDown(dropdownText, { key: 'Enter', code: 'Enter' });
|
|
382
|
+
|
|
383
|
+
expect(dropdown).toHaveAttribute('aria-expanded', 'true');
|
|
384
|
+
|
|
385
|
+
// Simulate Escape key press to trigger onBlur
|
|
386
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
387
|
+
|
|
388
|
+
// Call onBlur on the dropdown text
|
|
389
|
+
fireEvent.blur(dropdownText);
|
|
390
|
+
});
|
|
293
391
|
});
|
|
@@ -202,6 +202,7 @@ const FirstLevelContent = ({ element, renderMenuItem, pathName }) => {
|
|
|
202
202
|
panels={firstLevelPanels}
|
|
203
203
|
key={index}
|
|
204
204
|
defaultActiveIndex={defaultIndex === index ? 0 : -1}
|
|
205
|
+
className={'ui'}
|
|
205
206
|
/>
|
|
206
207
|
);
|
|
207
208
|
})}
|
|
@@ -287,9 +288,7 @@ const NestedAccordion = ({ menuItems, renderMenuItem, pathName }) => {
|
|
|
287
288
|
aria-expanded={activeIndex === index}
|
|
288
289
|
as="button"
|
|
289
290
|
onClick={() => {
|
|
290
|
-
|
|
291
|
-
setActiveIndex(-1);
|
|
292
|
-
} else setActiveIndex(index);
|
|
291
|
+
setActiveIndex(activeIndex === index ? -1 : index);
|
|
293
292
|
}}
|
|
294
293
|
>
|
|
295
294
|
{element.title}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Container, Button, Icon } from 'semantic-ui-react';
|
|
3
|
+
import { debounce } from 'lodash';
|
|
3
4
|
|
|
4
5
|
class InpageNavigation extends Component {
|
|
5
6
|
constructor(props) {
|
|
@@ -22,7 +23,10 @@ class InpageNavigation extends Component {
|
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
componentDidMount() {
|
|
25
|
-
window.addEventListener(
|
|
26
|
+
window.addEventListener(
|
|
27
|
+
'scroll',
|
|
28
|
+
debounce(this.handleInpageNavigationVisibility, 250),
|
|
29
|
+
);
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
componentWillUnmount() {
|
|
@@ -19,7 +19,7 @@ describe('DefaultGroup Component', () => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
describe('DefaultItem Component', () => {
|
|
22
|
-
it('renders
|
|
22
|
+
it('renders correctly', () => {
|
|
23
23
|
const { container } = render(<DefaultItem {...DefaultItem.args} />);
|
|
24
24
|
expect(container.querySelector('.header')).toBeInTheDocument();
|
|
25
25
|
expect(container.querySelector('.meta')).toBeInTheDocument();
|
|
@@ -29,7 +29,7 @@ describe('DefaultItem Component', () => {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
describe('Default Component', () => {
|
|
32
|
-
it('renders
|
|
32
|
+
it('renders correctly', () => {
|
|
33
33
|
const { container } = render(<Default {...Default.args} />);
|
|
34
34
|
expect(container.querySelector('.header')).toBeInTheDocument();
|
|
35
35
|
expect(container.querySelector('.meta')).toBeInTheDocument();
|
|
@@ -133,7 +133,12 @@ function ItemGroup({
|
|
|
133
133
|
<Container>
|
|
134
134
|
<Grid>
|
|
135
135
|
<Grid.Row>
|
|
136
|
-
<Grid.Column
|
|
136
|
+
<Grid.Column
|
|
137
|
+
mobile={12}
|
|
138
|
+
tablet={6}
|
|
139
|
+
computer={6}
|
|
140
|
+
className={'column-blocks-wrapper'}
|
|
141
|
+
>
|
|
137
142
|
<Item.Group unstackable className="row">
|
|
138
143
|
{ColumnLeft.map((item) => (
|
|
139
144
|
<SingleItem
|
|
@@ -148,7 +153,12 @@ function ItemGroup({
|
|
|
148
153
|
))}
|
|
149
154
|
</Item.Group>
|
|
150
155
|
</Grid.Column>
|
|
151
|
-
<Grid.Column
|
|
156
|
+
<Grid.Column
|
|
157
|
+
mobile={12}
|
|
158
|
+
tablet={6}
|
|
159
|
+
computer={6}
|
|
160
|
+
className={'column-blocks-wrapper'}
|
|
161
|
+
>
|
|
152
162
|
<Item.Group unstackable className="row">
|
|
153
163
|
{ColumnRight.map((item) => (
|
|
154
164
|
<SingleItem
|
|
@@ -265,42 +275,42 @@ FlexGroup.args = {
|
|
|
265
275
|
imageUrl: GlobeEco,
|
|
266
276
|
icon: 'ri-earth-line',
|
|
267
277
|
description:
|
|
268
|
-
'Support Europe’s transition to a sustainable future with evidence-based knowledge and data.',
|
|
278
|
+
'Support Europe’s transition to a sustainable future with evidence-based knowledge and data. ',
|
|
269
279
|
},
|
|
270
280
|
{
|
|
271
281
|
childKey: 1,
|
|
272
|
-
imageUrl:
|
|
273
|
-
icon: 'ri-
|
|
282
|
+
imageUrl: Network,
|
|
283
|
+
icon: 'ri-pin-distance-line',
|
|
274
284
|
description:
|
|
275
|
-
'
|
|
285
|
+
'Build stronger networks and partnerships with state and regional governments and organisations. This is an example of an item having bigger description text. ',
|
|
276
286
|
},
|
|
277
287
|
{
|
|
278
288
|
childKey: 2,
|
|
279
|
-
imageUrl:
|
|
280
|
-
icon: 'ri-
|
|
289
|
+
imageUrl: Sustainable,
|
|
290
|
+
icon: 'ri-leaf-line',
|
|
281
291
|
description:
|
|
282
|
-
'
|
|
292
|
+
'Supply input on solutions to the sustainability challenges of today – and tomorrow. This is an example of an item having bigger description text. ',
|
|
283
293
|
},
|
|
284
294
|
{
|
|
285
295
|
childKey: 3,
|
|
286
|
-
imageUrl:
|
|
287
|
-
icon: 'ri-
|
|
296
|
+
imageUrl: Knowledge,
|
|
297
|
+
icon: 'ri-line-chart-line',
|
|
288
298
|
description:
|
|
289
|
-
'
|
|
299
|
+
'Strengthen the EU’s knowledge capacity and help secure the resources needed to create a sustainable Europe.',
|
|
290
300
|
},
|
|
291
301
|
{
|
|
292
302
|
childKey: 4,
|
|
293
|
-
imageUrl:
|
|
294
|
-
icon: 'ri-
|
|
303
|
+
imageUrl: DataAnalytics,
|
|
304
|
+
icon: 'ri-pie-chart-line',
|
|
295
305
|
description:
|
|
296
|
-
'
|
|
306
|
+
'Leverage the data and technology to support the EU’s decision-making processes concerning the environment and climate',
|
|
297
307
|
},
|
|
298
308
|
{
|
|
299
309
|
childKey: 5,
|
|
300
|
-
imageUrl:
|
|
301
|
-
icon: 'ri-
|
|
310
|
+
imageUrl: GlobeEco,
|
|
311
|
+
icon: 'ri-earth-line',
|
|
302
312
|
description:
|
|
303
|
-
'
|
|
313
|
+
'Support Europe’s transition to a sustainable future with evidence-based knowledge and data.',
|
|
304
314
|
},
|
|
305
315
|
],
|
|
306
316
|
};
|
|
@@ -114,15 +114,15 @@ Warning.parameters = {
|
|
|
114
114
|
},
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
export const
|
|
118
|
-
|
|
119
|
-
header: '
|
|
120
|
-
content: 'This is an
|
|
117
|
+
export const ErrorMessage = Template.bind({});
|
|
118
|
+
ErrorMessage.args = {
|
|
119
|
+
header: 'ErrorMessage header',
|
|
120
|
+
content: 'This is an ErrorMessage Message',
|
|
121
121
|
icon: 'exclamation circle',
|
|
122
122
|
error: true,
|
|
123
123
|
size: 'small',
|
|
124
124
|
};
|
|
125
|
-
|
|
125
|
+
ErrorMessage.argTypes = {
|
|
126
126
|
error: {
|
|
127
127
|
description: 'message may be formatted to display an error message',
|
|
128
128
|
table: {
|
|
@@ -135,7 +135,7 @@ Error.argTypes = {
|
|
|
135
135
|
},
|
|
136
136
|
},
|
|
137
137
|
};
|
|
138
|
-
|
|
138
|
+
ErrorMessage.parameters = {
|
|
139
139
|
controls: {
|
|
140
140
|
exclude: ['icon', 'error'],
|
|
141
141
|
hideNoControlsWarning: true,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Info,
|
|
5
|
+
ErrorMessage,
|
|
6
|
+
Warning,
|
|
7
|
+
Success,
|
|
8
|
+
Default,
|
|
9
|
+
} from './Message.stories';
|
|
4
10
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
11
|
|
|
6
12
|
describe('Info component', () => {
|
|
@@ -11,11 +17,11 @@ describe('Info component', () => {
|
|
|
11
17
|
});
|
|
12
18
|
});
|
|
13
19
|
|
|
14
|
-
describe('
|
|
20
|
+
describe('ErrorMessage component', () => {
|
|
15
21
|
it('renders a Message component', () => {
|
|
16
|
-
const { getByText } = render(<
|
|
17
|
-
expect(getByText(
|
|
18
|
-
expect(getByText(
|
|
22
|
+
const { getByText } = render(<ErrorMessage {...ErrorMessage.args} />);
|
|
23
|
+
expect(getByText(ErrorMessage.args.header)).toBeInTheDocument();
|
|
24
|
+
expect(getByText(ErrorMessage.args.content)).toBeInTheDocument();
|
|
19
25
|
});
|
|
20
26
|
});
|
|
21
27
|
|
|
@@ -45,7 +45,7 @@ export const List = (args) => (
|
|
|
45
45
|
<TagList.Title>{args.title}</TagList.Title>
|
|
46
46
|
<TagList.Content>
|
|
47
47
|
{args.tags.map((tag, index) => [
|
|
48
|
-
<Tag
|
|
48
|
+
<Tag href={tag.href} key={index}>
|
|
49
49
|
{tag.category}
|
|
50
50
|
</Tag>,
|
|
51
51
|
])}
|