@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 CHANGED
@@ -4,7 +4,28 @@ 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
- ### [1.20.0](https://github.com/eea/volto-eea-design-system/compare/1.19.0...1.20.0) - 1 November 2023
7
+ ### [1.21.0](https://github.com/eea/volto-eea-design-system/compare/1.20.0...1.21.0) - 20 November 2023
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(item): styling difference so that column group or section group flex template match design [David Ichim - [`f57e074`](https://github.com/eea/volto-eea-design-system/commit/f57e0744808df8b467e179b83266e8b2c2398956)]
12
+
13
+ #### :nail_care: Enhancements
14
+
15
+ - change(message): Renamed Error to ErrorMessage to avoid special identifier Sonarqube warning [David Ichim - [`09e49ac`](https://github.com/eea/volto-eea-design-system/commit/09e49ac4e71c02b439459eec29266d3f5b884d50)]
16
+ - change(header): dropdowns now auto open and close on focus and blur when using keyboard navigation [David Ichim - [`d558e9b`](https://github.com/eea/volto-eea-design-system/commit/d558e9bf7abba19221744be871759d025ce0f05a)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ - Release 1.21.0 [Alin Voinea - [`fe39edd`](https://github.com/eea/volto-eea-design-system/commit/fe39edde81fd4f01f7958aee706887a5dedce521)]
21
+ - Modified test to reference ErrorMessage [David Ichim - [`36fefd0`](https://github.com/eea/volto-eea-design-system/commit/36fefd05a6b30d92494a7974c9fb86d35cae5acc)]
22
+ - Lint fix [David Ichim - [`c1fc104`](https://github.com/eea/volto-eea-design-system/commit/c1fc104f1e7be0611de4aa17c55ad9c402c70ff8)]
23
+ - Test Header onBlur [David Ichim - [`42f9c97`](https://github.com/eea/volto-eea-design-system/commit/42f9c97d01f7b59a1c63e42e1825dfa0697f0ef2)]
24
+ - Add dropdown test case to Header component [David Ichim - [`9ea3234`](https://github.com/eea/volto-eea-design-system/commit/9ea3234c2c0f1c819c7c2b54a75c56cda7812c56)]
25
+ - Remove unused import in Header.test.jsx [David Ichim - [`082069e`](https://github.com/eea/volto-eea-design-system/commit/082069e1f057786e0f1fb00c98d54b8e03b5d9c5)]
26
+ - Added some tests for TopDropdownMenu mobile and dropdown interaction [David Ichim - [`9d24488`](https://github.com/eea/volto-eea-design-system/commit/9d24488c1e97b2b1b14bd9bd8cb6f5b68414794b)]
27
+ - Lint fix [David Ichim - [`e29fd50`](https://github.com/eea/volto-eea-design-system/commit/e29fd50ee73477007dcf94a268596e6c11176d7b)]
28
+ ### [1.20.0](https://github.com/eea/volto-eea-design-system/compare/1.19.0...1.20.0) - 2 November 2023
8
29
 
9
30
  #### :rocket: New Features
10
31
 
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 5000,
5
+ defaultCommandTimeout: 8888,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
- video: true,
8
+ video: false,
9
9
  retries: {
10
- runMode: 1,
10
+ runMode: 2,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-design-system",
3
- "version": "1.20.0",
3
+ "version": "1.21.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",
@@ -3,6 +3,7 @@ import { Container, Icon, Button, Grid } from 'semantic-ui-react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
5
5
  import { formatDate } from '@plone/volto/helpers/Utils/Date';
6
+ import cx from 'classnames';
6
7
  import config from '@plone/volto/registry';
7
8
 
8
9
  Banner.propTypes = {
@@ -44,7 +45,7 @@ export const sharePage = (url, platform) => {
44
45
  link.click();
45
46
  };
46
47
 
47
- function Banner({ image, metadata, properties, children, ...rest }) {
48
+ function Banner({ image, metadata, properties, children, styles, ...rest }) {
48
49
  if (image) {
49
50
  //extract Lead image from page content.
50
51
  const content = metadata || properties;
@@ -52,7 +53,7 @@ function Banner({ image, metadata, properties, children, ...rest }) {
52
53
  return (
53
54
  <div className="eea banner">
54
55
  <div
55
- className={imageUrl ? 'image' : ''}
56
+ className={cx(imageUrl ? 'image' : '', styles?.bg)}
56
57
  style={imageUrl ? { backgroundImage: `url(${imageUrl})` } : {}}
57
58
  >
58
59
  <div className="gradient">
@@ -72,21 +73,14 @@ function Banner({ image, metadata, properties, children, ...rest }) {
72
73
  }
73
74
 
74
75
  Banner.Action = React.forwardRef(function (
75
- { id, title, titleClass, icon, onClick, className, color, ...rest },
76
+ { title, titleClass, icon, onClick, className, color, ...rest },
76
77
  ref,
77
78
  ) {
78
79
  return (
79
80
  <div className="action" ref={ref}>
80
- <Button
81
- className={className}
82
- basic
83
- icon
84
- inverted
85
- onClick={onClick}
86
- {...rest}
87
- >
88
- <Icon className={icon} color={color}></Icon>
89
- <span className={titleClass || 'mobile hidden'}>{title}</span>
81
+ <Button className={className} basic icon inverted onClick={onClick}>
82
+ <Icon className={icon} color={color} title={title}></Icon>
83
+ <span className={titleClass || 'mobile-sr-only'}>{title}</span>
90
84
  </Button>
91
85
  </div>
92
86
  );
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Card, Image, Grid, Container, Icon, Button } from 'semantic-ui-react';
3
3
  import Slider from 'react-slick';
4
+ import TagList from '../TagList/TagList';
5
+ import Tag from '../Tag/Tag';
4
6
 
5
7
  import 'slick-carousel/slick/slick.css';
6
8
  import 'slick-carousel/slick/slick-theme.css';
@@ -8,89 +10,89 @@ import 'slick-carousel/slick/slick-theme.css';
8
10
  const tabletBreakpoint = 835;
9
11
  const mobileBreakpoint = 480;
10
12
 
11
- const createCardModel = (
12
- title,
13
- imgUrl,
14
- description,
15
- meta,
16
- metaRight,
17
- eventDate,
18
- href,
19
- ) => {
20
- return {
21
- title: title,
22
- imgUrl: imgUrl,
23
- description: description,
24
- meta: meta,
25
- metaRight: metaRight,
26
- eventDate: eventDate,
27
- href: href,
28
- };
13
+ // Content for all cards
14
+ let cardData = {
15
+ cardContent: {
16
+ title: [
17
+ 'Economy and resources',
18
+ 'Health',
19
+ 'Nature',
20
+ 'Climate',
21
+ "State of Europe's environment",
22
+ ],
23
+ imgUrl: [
24
+ 'https://www.eea.europa.eu/publications/eea-eionet-strategy-2021-2030/image_mini',
25
+ 'https://www.eea.europa.eu/en/topics/at-a-glance/health/@@images/image/preview',
26
+ 'https://www.eea.europa.eu/en/topics/at-a-glance/nature/@@images/image/preview',
27
+ 'https://www.eea.europa.eu/en/topics/at-a-glance/climate/@@images/image/preview',
28
+ 'https://www.eea.europa.eu/en/topics/at-a-glance/state-of-europes-environment/@@images/image/preview',
29
+ ],
30
+ description: [
31
+ 'The economy plays a vital role in our lives by providing access to employment, ' +
32
+ 'products and services that help us thrive. Unfortunately, with its key sectors like agriculture,' +
33
+ ' energy and transport, our economy also harms the environment and causes climate change. ' +
34
+ 'Europe needs a circular, carbon-neutral and zero-pollution economy. ',
35
+ 'By improving air, water, and soil quality and limiting pollution released to nature, ' +
36
+ 'the EU has significantly contributed to enhancing human health in the last five ' +
37
+ 'decades. Yet, many vulnerable groups continue to be impacted by environmental ' +
38
+ 'degradation and climate change. Further improvements can help keep Europeans ' +
39
+ 'healthier and better equipped to cope with climate change impacts.',
40
+ 'Europe’s nature is filled with forests, mountains, vast plains, long rivers, deep blue seas and ' +
41
+ 'refreshing lakes. But it also is under threat. Unsustainable farming and forestry practices, ' +
42
+ 'pollution, climate change and invasive species are stressing and destabilising all natural ' +
43
+ 'systems in Europe. The result is a biodiversity crisis. The EU is taking steps to protect and restore nature.',
44
+ 'Climate change affects us all and is accelerating. Its impacts will become even more severe if ' +
45
+ 'the increase in global temperature is not kept below 1.5°C. The EU and its Member States are ' +
46
+ 'taking important steps to rapidly reduce greenhouse gas emissions and adapt to climate change.',
47
+ 'EU environment and climate policies have delivered substantial benefits over recent ' +
48
+ 'decades, such as cleaner air and water. Nevertheless, Europe, as well as the rest ' +
49
+ 'of the globe, is facing environmental challenges of unprecedented scale and urgency.',
50
+ ],
51
+ metaRight: [
52
+ '20/05/2023',
53
+ '30/04/2023',
54
+ '10/04/2023',
55
+ '02/04/2023',
56
+ '16/03/2023',
57
+ ],
58
+ eventDate: [
59
+ '20/05/2023',
60
+ '30/04/2023',
61
+ '10/04/2023',
62
+ '02/04/2023',
63
+ '16/03/2023',
64
+ ],
65
+ tags: [
66
+ { category: 'tag 1', href: '#' },
67
+ { category: 'tag 2', href: '#' },
68
+ { category: 'bigger tag', href: '#' },
69
+ { category: 'tag 3', href: '#' },
70
+ { category: 'tag 4', href: '#' },
71
+ ],
72
+ },
29
73
  };
30
74
 
31
- const cardData = [
32
- [
33
- 'Economy and resources',
34
- 'https://www.eea.europa.eu/publications/eea-eionet-strategy-2021-2030/image_mini',
35
- 'The economy plays a vital role in our lives by providing access to employment, ' +
36
- 'products and services that help us thrive. Unfortunately, with its key sectors like agriculture,' +
37
- ' energy and transport, our economy also harms the environment and causes climate change. ' +
38
- 'Europe needs a circular, carbon-neutral and zero-pollution economy. ',
39
- 'Article',
40
- '20/05/2022',
41
- '15/10/2023',
42
- '/#',
43
- ],
44
- [
45
- 'Health',
46
- 'https://www.eea.europa.eu/en/topics/at-a-glance/health/@@images/image/preview',
47
- 'By improving air, water, and soil quality and limiting pollution released to nature, ' +
48
- 'the EU has significantly contributed to enhancing human health in the last five ' +
49
- 'decades. Yet, many vulnerable groups continue to be impacted by environmental ' +
50
- 'degradation and climate change. Further improvements can help keep Europeans ' +
51
- 'healthier and better equipped to cope with climate change impacts.',
52
- 'Article',
53
- '30/06/2023',
54
- '03/08/2023',
55
- '/#',
56
- ],
57
- [
58
- 'Nature',
59
- 'https://www.eea.europa.eu/en/topics/at-a-glance/nature/@@images/image/preview',
60
- "Europe's nature is filled with forests, mountains, vast plains, long rivers, deep blue seas and " +
61
- 'refreshing lakes. But it also is under threat. Unsustainable farming and forestry practices, ' +
62
- 'pollution, climate change and invasive species are stressing and destabilising all natural ' +
63
- 'systems in Europe. The result is a biodiversity crisis. The EU is taking steps to protect and restore nature.',
64
- 'Article',
65
- '10/04/2022',
66
- '18/05/2023',
67
- '/#',
68
- ],
69
- [
70
- 'Climate',
71
- 'https://www.eea.europa.eu/en/topics/at-a-glance/climate/@@images/image/preview',
72
- 'Climate change affects us all and is accelerating. Its impacts will become even more severe if ' +
73
- 'the increase in global temperature is not kept below 1.5°C. The EU and its Member States are ' +
74
- 'taking important steps to rapidly reduce greenhouse gas emissions and adapt to climate change.',
75
- 'Article',
76
- '20/06/2022',
77
- '15/03/2024',
78
- '/#',
79
- ],
80
- [
81
- "State of Europe's environment",
82
- 'https://www.eea.europa.eu/en/topics/at-a-glance/state-of-europes-environment/@@images/image/preview',
83
- 'EU environment and climate policies have delivered substantial benefits over recent ' +
84
- 'decades, such as cleaner air and water. Nevertheless, Europe, as well as the rest ' +
85
- 'of the globe, is facing environmental challenges of unprecedented scale and urgency.',
86
- 'Article',
87
- '16/03/2022',
88
- '13/01/2024',
89
- '/#',
90
- ],
91
- ];
92
-
93
- const cardModels = cardData.map((card) => createCardModel(...card));
75
+ // Fill the cardModel array that stories use
76
+ let cardModels = [];
77
+ let tempCardContent = {};
78
+ for (var i = 0; i <= cardData.cardContent.title.length; i++) {
79
+ tempCardContent = {
80
+ title: cardData.cardContent.title[i],
81
+ imgUrl: cardData.cardContent.imgUrl[i],
82
+ description: cardData.cardContent.description[i],
83
+ meta: 'Article',
84
+ metaRight: cardData.cardContent.metaRight[i],
85
+ eventDate: cardData.cardContent.eventDate[i],
86
+ href: '/#',
87
+ tags: [],
88
+ };
89
+
90
+ // Fill cards with random amount of tags
91
+ for (var j = 0; j < Math.floor(Math.random() * 4 + 1); j++) {
92
+ tempCardContent.tags.push(cardData.cardContent.tags[j]);
93
+ }
94
+ cardModels.push(tempCardContent);
95
+ }
94
96
 
95
97
  export default {
96
98
  title: 'Components/Card/Default',
@@ -203,6 +205,28 @@ export default {
203
205
  defaultValue: { summary: ' "" ' },
204
206
  },
205
207
  },
208
+ hasTags: {
209
+ name: 'Tags',
210
+ table: {
211
+ defaultValue: { summary: 'false' },
212
+ type: { summary: 'boolean' },
213
+ category: 'Tags',
214
+ },
215
+ },
216
+ direction: {
217
+ name: 'Tags direction',
218
+ control: { type: 'select' },
219
+ options: ['right', 'left'],
220
+ table: {
221
+ type: {
222
+ summary: 'string',
223
+ },
224
+ defaultValue: {
225
+ summary: 'left',
226
+ },
227
+ category: 'Tags',
228
+ },
229
+ },
206
230
  },
207
231
  };
208
232
 
@@ -242,6 +266,8 @@ const CardTemplate = ({
242
266
  eventDate,
243
267
  fluid,
244
268
  card,
269
+ hasTags,
270
+ direction,
245
271
  }) => (
246
272
  <Card
247
273
  fluid={fluid}
@@ -288,6 +314,19 @@ const CardTemplate = ({
288
314
 
289
315
  {/* Description */}
290
316
  <Card.Description>{card.description}</Card.Description>
317
+ {hasTags && (
318
+ <div className="card-tags">
319
+ <TagList className={direction}>
320
+ <TagList.Content>
321
+ {card.tags.map((tag, index) => [
322
+ <Tag href={tag.href} key={index}>
323
+ {tag.category}
324
+ </Tag>,
325
+ ])}
326
+ </TagList.Content>
327
+ </TagList>
328
+ </div>
329
+ )}
291
330
  </Card.Content>
292
331
 
293
332
  {/* Additional links */}
@@ -322,6 +361,8 @@ Default.args = {
322
361
  numberOfCards: 1,
323
362
  fluid: false,
324
363
  cards: [...cardModels],
364
+ hasTags: false,
365
+ direction: 'left',
325
366
  };
326
367
  const GridTemplate = (args) => (
327
368
  <Container>
@@ -349,6 +390,8 @@ CardGrid.args = {
349
390
  fluid: true,
350
391
  numberOfCards: 5,
351
392
  cards: [...cardModels],
393
+ hasTags: false,
394
+ direction: 'left',
352
395
  };
353
396
 
354
397
  const ImageCard = ({
@@ -394,6 +437,8 @@ ImageGrid.args = {
394
437
  fluid: true,
395
438
  cards: [...cardModels],
396
439
  numberOfCards: 5,
440
+ hasTags: false,
441
+ direction: 'left',
397
442
  };
398
443
 
399
444
  ImageGrid.argTypes = {
@@ -443,6 +488,8 @@ FluidGrid.args = {
443
488
  eventDate: false,
444
489
  fluid: true,
445
490
  cards: [...cardModels],
491
+ hasTags: false,
492
+ direction: 'left',
446
493
  };
447
494
  const PrevArrow = (props) => {
448
495
  const { onClick } = props;
@@ -562,6 +609,8 @@ CarouselCards.args = {
562
609
  },
563
610
  numberOfCards: 5,
564
611
  cards: [...cardModels],
612
+ hasTags: false,
613
+ direction: 'left',
565
614
  };
566
615
  CarouselCards.argTypes = {
567
616
  settings: {
@@ -587,6 +636,8 @@ const TeaserCard = ({
587
636
  maxLines,
588
637
  eventDate,
589
638
  card,
639
+ hasTags,
640
+ direction,
590
641
  }) => (
591
642
  <div className="column grid-block-teaser">
592
643
  <div
@@ -625,6 +676,19 @@ const TeaserCard = ({
625
676
  </div>
626
677
  {eventDate && <EventDate {...card} />}
627
678
  <Card.Description>{card.description}</Card.Description>
679
+ {hasTags && (
680
+ <div className="card-tags">
681
+ <TagList className={direction}>
682
+ <TagList.Content>
683
+ {card.tags.map((tag, index) => [
684
+ <Tag href={tag.href} key={index}>
685
+ {tag.category}
686
+ </Tag>,
687
+ ])}
688
+ </TagList.Content>
689
+ </TagList>
690
+ </div>
691
+ )}
628
692
  </div>
629
693
  )}
630
694
  </div>
@@ -669,4 +733,6 @@ TeaserCardGrid.args = {
669
733
  fluid: true,
670
734
  numberOfCards: 3,
671
735
  cards: [...cardModels],
736
+ hasTags: false,
737
+ direction: 'left',
672
738
  };
@@ -5,8 +5,8 @@ import {
5
5
  TeaserCardGrid,
6
6
  CarouselCards,
7
7
  FluidGrid,
8
- CardGrid,
9
8
  ImageGrid,
9
+ CardGrid,
10
10
  Default,
11
11
  } from './Card.stories';
12
12
 
@@ -113,6 +113,16 @@ describe('CarouselCards component', () => {
113
113
  });
114
114
  });
115
115
 
116
+ describe('ImageGrid component', () => {
117
+ it('renders the image grid with correct number of cards', () => {
118
+ const { container } = render(<ImageGrid {...ImageGrid.args} />);
119
+ const imageGridCards = container.querySelectorAll(
120
+ '.imageCard-items .ui.card a.image',
121
+ );
122
+ expect(imageGridCards.length).toBe(5);
123
+ });
124
+ });
125
+
116
126
  describe('FluidGrid component', () => {
117
127
  it('renders correctly', () => {
118
128
  const { container } = render(<FluidGrid {...FluidGrid.args} />);
@@ -18,7 +18,7 @@ import Description from '@eeacms/volto-eea-design-system/ui/Footer/Description';
18
18
  /**
19
19
  * Component to display the footer.
20
20
  * @function Footer
21
- * @param {Object} intl Intl object
21
+ * @param {Object} props object
22
22
  * @returns {string} Markup of the component
23
23
  */
24
24
 
@@ -28,7 +28,7 @@ const Footer = (props) => {
28
28
  const bgImgRef = React.useRef();
29
29
  const onScreen = useFirstVisited(bgImgRef);
30
30
  return (
31
- <footer id={'footer'}>
31
+ <footer id={'footer'} aria-label={'Footer'}>
32
32
  <div
33
33
  ref={bgImgRef}
34
34
  className={onScreen ? 'footer-wrapper' : 'footer-wrapper-nobg'}