@ilo-org/react 0.6.0 → 0.7.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/cjs/components/Accordion/AccordionPanel.js +3 -3
  3. package/lib/cjs/components/Hero/Hero.js +21 -11
  4. package/lib/cjs/components/Hero/HeroCard.js +20 -10
  5. package/lib/cjs/components/Hero/index.js +6 -2
  6. package/lib/cjs/components/LogoGrid/LogoGrid.js +30 -0
  7. package/lib/cjs/components/LogoGrid/index.js +13 -0
  8. package/lib/cjs/components/index.js +2 -2
  9. package/lib/cjs/index.js +2 -2
  10. package/lib/esm/components/Accordion/AccordionPanel.js +3 -3
  11. package/lib/esm/components/Hero/Hero.js +22 -12
  12. package/lib/esm/components/Hero/HeroCard.js +20 -10
  13. package/lib/esm/components/Hero/index.js +6 -2
  14. package/lib/esm/components/LogoGrid/LogoGrid.js +28 -0
  15. package/lib/esm/components/LogoGrid/index.js +7 -0
  16. package/lib/esm/components/index.js +2 -2
  17. package/lib/esm/index.js +2 -2
  18. package/lib/types/react/src/components/Accordion/AccordionPanel.props.d.ts +4 -0
  19. package/lib/types/react/src/components/Card/Card.props.d.ts +2 -2
  20. package/lib/types/react/src/components/Hero/Hero.props.d.ts +28 -6
  21. package/lib/types/react/src/components/Hero/HeroCard.props.d.ts +13 -23
  22. package/lib/types/react/src/components/Image/Image.props.d.ts +7 -3
  23. package/lib/types/react/src/components/LogoGrid/LogoGrid.d.ts +4 -0
  24. package/lib/types/react/src/components/LogoGrid/LogoGrid.props.d.ts +24 -0
  25. package/lib/types/react/src/components/LogoGrid/index.d.ts +1 -0
  26. package/lib/types/react/src/types/index.d.ts +1 -3
  27. package/package.json +2 -2
  28. package/public/fao-logo.svg +195 -0
  29. package/public/unhcr-logo.svg +1 -0
  30. package/public/unicef-logo.png +0 -0
  31. package/public/wfp-logo.svg +1 -0
  32. package/public/who-logo.svg +1 -0
  33. package/src/components/Accordion/AccordionPanel.props.ts +5 -0
  34. package/src/components/Accordion/AccordionPanel.tsx +3 -3
  35. package/src/components/Card/Card.props.ts +2 -2
  36. package/src/components/Hero/Hero.args.ts +84 -270
  37. package/src/components/Hero/Hero.props.ts +33 -6
  38. package/src/components/Hero/Hero.tsx +66 -18
  39. package/src/components/Hero/HeroCard.props.ts +14 -25
  40. package/src/components/Hero/HeroCard.tsx +45 -33
  41. package/src/components/Image/Image.props.ts +8 -3
  42. package/src/components/LogoGrid/LogoGrid.args.ts +50 -0
  43. package/src/components/LogoGrid/LogoGrid.props.ts +28 -0
  44. package/src/components/LogoGrid/LogoGrid.tsx +53 -0
  45. package/src/components/LogoGrid/index.ts +1 -0
  46. package/src/types/index.ts +1 -9
@@ -1,294 +1,108 @@
1
1
  import { HeroProps } from "./Hero.props";
2
+ import { defaultArgs } from "../SocialMedia";
3
+ import { HeroCardProps } from "./HeroCard.props";
4
+ import { ImageProps } from "../Image/Image.props";
2
5
 
3
- const articleCenteredHero: HeroProps = {
4
- className: "storybook",
5
- image: {
6
- alt: "Alt tag",
7
- className: "storybook",
8
- url: [
9
- {
10
- breakpoint: 0,
11
- src: "/hero.jpg",
12
- },
13
- {
14
- breakpoint: 768,
15
- src: "/hero.jpg",
16
- },
17
- ],
18
- },
19
- heroCard: {
20
- alignment: "center",
21
- datecopy: "11 February 2021",
22
- eyebrow: "Eyebrow Title",
23
- intro:
24
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
25
- socials: [
26
- {
27
- label: "Facebook",
28
- url: "https://www.facebook.com/",
29
- icon: "facebook",
30
- },
31
- ],
32
- title:
33
- "This is an centered aligned article headline that is more than two lines long",
34
- theme: "light",
35
- types: "article",
6
+ const lightArticleCard: HeroCardProps = {
7
+ title: "Does Artificial Intelligence threaten decent work?",
8
+ datecopy: "17 July 2023",
9
+ eyebrow: "Future of Work Podcast",
10
+ intro:
11
+ "The world of work has always been shaped by technology, but the new generation of Artificial Intelligence (AI) has raised fears that it could destroy tens of millions of jobs, and undermine progress towards decent work and greater social justice.",
12
+ socialmedia: {
13
+ icons: defaultArgs.icons.slice(0, 3),
36
14
  },
37
15
  theme: "light",
38
- types: "article",
39
16
  };
40
17
 
41
- const articleHero: HeroProps = {
42
- className: "storybook",
43
- image: {
44
- alt: "Alt tag",
45
- className: "storybook",
46
- url: [
47
- {
48
- breakpoint: 0,
49
- src: "/hero.jpg",
50
- },
51
- {
52
- breakpoint: 768,
53
- src: "/hero.jpg",
54
- },
55
- ],
18
+ const darkPortalCard: HeroCardProps = {
19
+ title: "Child labour",
20
+ eyebrow: "ILO Topics",
21
+ socialmedia: {
22
+ icons: defaultArgs.icons.slice(0, 3),
56
23
  },
57
- heroCard: {
58
- alignment: "left",
59
- datecopy: "11 February 2021",
60
- eyebrow: "Eyebrow Title",
61
- intro:
62
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
63
- socials: [
64
- {
65
- label: "Facebook",
66
- url: "https://www.facebook.com/",
67
- icon: "facebook",
68
- },
69
- ],
70
- title:
71
- "This is an left aligned article headline that is more than two lines long",
72
- theme: "light",
73
- types: "article",
74
- },
75
- theme: "light",
76
- types: "article",
77
24
  };
78
25
 
79
- const articleNoImageHero: HeroProps = {
80
- className: "storybook",
81
- heroCard: {
82
- alignment: "center",
83
- datecopy: "11 February 2021",
84
- eyebrow: "Eyebrow Title",
85
- intro:
86
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
87
- socials: [
88
- {
89
- label: "Facebook",
90
- url: "https://www.facebook.com/",
91
- icon: "facebook",
92
- },
93
- ],
94
- title:
95
- "This is an center aligned article headline that is more than two lines long",
96
- theme: "light",
97
- types: "article",
98
- },
26
+ const lightPortalCard: HeroCardProps = {
27
+ ...darkPortalCard,
99
28
  theme: "light",
100
- types: "article",
101
29
  };
102
30
 
103
- const homeHero: HeroProps = {
104
- className: "storybook",
105
- image: {
106
- alt: "Alt tag",
107
- className: "storybook",
108
- url: [
109
- {
110
- breakpoint: 0,
111
- src: "/hero.jpg",
112
- },
113
- {
114
- breakpoint: 768,
115
- src: "/hero.jpg",
116
- },
117
- ],
118
- },
119
- heroCard: {
120
- alignment: "left",
121
- eyebrow: "Eyebrow Title",
122
- title:
123
- "ILO welcomes G7 call to make a just transition to a green economy happen",
124
- theme: "dark",
125
- types: "home",
126
- },
127
- theme: "dark",
128
- types: "home",
31
+ const homepageCard: HeroCardProps = {
32
+ eyebrow: lightArticleCard.eyebrow,
33
+ title: lightArticleCard.title,
34
+ url: "https://www.ilo.org",
35
+ background: "semi-transparent",
129
36
  };
130
37
 
131
- const portalHero: HeroProps = {
132
- className: "storybook",
133
- image: {
134
- alt: "Alt tag",
135
- className: "storybook",
136
- url: [
137
- {
138
- breakpoint: 0,
139
- src: "/hero.jpg",
140
- },
141
- {
142
- breakpoint: 768,
143
- src: "/hero.jpg",
144
- },
145
- ],
146
- },
147
- heroCard: {
148
- alignment: "left",
149
- eyebrow: "Eyebrow Title",
150
- socials: [
151
- {
152
- label: "Facebook",
153
- url: "https://www.facebook.com/",
154
- icon: "facebook",
155
- },
156
- {
157
- label: "Linkedin",
158
- url: "https://www.linkedin.com/",
159
- icon: "linkedin",
160
- },
161
- ],
162
- title: "This is a page title",
163
- theme: "dark",
164
- types: "portal",
165
- },
166
- theme: "dark",
167
- types: "portal",
38
+ const transparentHomepageCard: HeroCardProps = {
39
+ ...homepageCard,
40
+ background: "transparent",
168
41
  };
169
42
 
170
- const projectHero: HeroProps = {
43
+ const heroImage: ImageProps = {
44
+ alt: "Alt tag",
171
45
  className: "storybook",
172
- image: {
173
- alt: "Alt tag",
174
- className: "storybook",
175
- url: [
176
- {
177
- breakpoint: 0,
178
- src: "/hero.jpg",
179
- },
180
- {
181
- breakpoint: 768,
182
- src: "/hero.jpg",
183
- },
184
- ],
185
- },
186
- heroCard: {
187
- alignment: "center",
188
- eyebrow: "Eyebrow Title",
189
- datecopy: "Date | Duration",
190
- intro:
191
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
192
- socials: [
193
- {
194
- label: "Facebook",
195
- url: "https://www.facebook.com/",
196
- icon: "facebook",
197
- },
198
- ],
199
- title: "This is a page title",
200
- theme: "dark",
201
- types: "project",
202
- },
203
- theme: "dark",
204
- types: "project",
46
+ url: [
47
+ {
48
+ breakpoint: 0,
49
+ src: "/hero.jpg",
50
+ },
51
+ {
52
+ breakpoint: 768,
53
+ src: "/hero.jpg",
54
+ },
55
+ ],
205
56
  };
206
57
 
207
- const graphicHero: HeroProps = {
208
- className: "storybook",
209
- image: {
210
- alt: "Alt tag",
211
- className: "storybook",
212
- url: [
213
- {
214
- breakpoint: 0,
215
- src: "/hero.jpg",
216
- },
217
- {
218
- breakpoint: 768,
219
- src: "/hero.jpg",
220
- },
221
- ],
222
- },
223
- heroCard: {
224
- alignment: "center",
225
- eyebrow: "Eyebrow Title",
226
- datecopy: "Date | Duration",
227
- intro:
228
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
229
- socials: [
230
- {
231
- label: "Facebook",
232
- url: "https://www.facebook.com/",
233
- icon: "facebook",
234
- },
235
- ],
236
- title: "This is a centered graphic article headline that is two lines long",
237
- theme: "light",
238
- types: "graphic",
239
- },
240
- theme: "light",
241
- types: "graphic",
58
+ const standard = {
59
+ image: heroImage,
60
+ heroCard: darkPortalCard,
242
61
  };
243
62
 
244
- const publicationHero: HeroProps = {
245
- className: "storybook",
246
- image: {
247
- alt: "Alt tag",
248
- className: "storybook",
249
- url: [
250
- {
251
- breakpoint: 0,
252
- src: "/hero.jpg",
253
- },
254
- {
255
- breakpoint: 768,
256
- src: "/hero.jpg",
257
- },
258
- ],
259
- },
260
- heroCard: {
261
- alignment: "left",
262
- eyebrow: "Eyebrow Title",
263
- datecopy: "Date | Duration",
264
- intro:
265
- "Brief intro text - ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
266
- socials: [
267
- {
268
- label: "Facebook",
269
- url: "https://www.facebook.com/",
270
- icon: "facebook",
271
- },
272
- ],
273
- title: "This is a page title",
274
- theme: "light",
275
- types: "publication",
276
- },
277
- theme: "light",
278
- types: "publication",
63
+ export const darkPortal: HeroProps = standard;
64
+
65
+ export const lightPortal: HeroProps = {
66
+ ...standard,
67
+ heroCard: lightPortalCard,
279
68
  };
280
- /**
281
- * Sample prop definitions for Hero's enumerable properties (imported in stories and test)
282
- */
283
- const HeroArgs = {
284
- articleHero,
285
- articleCenteredHero,
286
- articleNoImageHero,
287
- homeHero,
288
- graphicHero,
289
- projectHero,
290
- portalHero,
291
- publicationHero,
69
+
70
+ export const semiTransparent: HeroProps = {
71
+ ...standard,
72
+ align: "center",
73
+ heroCard: homepageCard,
292
74
  };
293
75
 
294
- export default HeroArgs;
76
+ export const transparent: HeroProps = {
77
+ ...standard,
78
+ align: "center",
79
+ heroCard: transparentHomepageCard,
80
+ };
81
+
82
+ export const offset: HeroProps = {
83
+ ...standard,
84
+ align: "baseline",
85
+ justify: "offset",
86
+ };
87
+
88
+ export const center: HeroProps = {
89
+ ...standard,
90
+ align: "baseline",
91
+ justify: "center",
92
+ };
93
+
94
+ export const centerBottom: HeroProps = {
95
+ ...standard,
96
+ cardSize: "xlarge",
97
+ align: "bottom",
98
+ justify: "center",
99
+ heroCard: lightArticleCard,
100
+ };
101
+
102
+ export const noPoster: HeroProps = {
103
+ cardSize: "xlarge",
104
+ align: "bottom",
105
+ justify: "center",
106
+ posterSize: "small",
107
+ heroCard: lightArticleCard,
108
+ };
@@ -1,8 +1,30 @@
1
- import { HeroCardTheme, HeroCardTypes } from "../../types";
1
+ import { ThemeTypes } from "../../types";
2
+ import { BreadcrumbProps } from "../Breadcrumb/Breadcrumb.props";
2
3
  import { ImageProps } from "../Image/Image.props";
4
+ import { TooltipProps } from "../Tooltip/Tooltip.props";
3
5
  import { HeroCardProps } from "./HeroCard.props";
4
6
 
5
7
  export interface HeroProps {
8
+ /**
9
+ * Vertical alignment of the hero card
10
+ */
11
+ align?: "center" | "bottom" | "baseline";
12
+
13
+ /**
14
+ * Props to pass to the breadcrumb if there is one
15
+ */
16
+ breadcrumb?: BreadcrumbProps;
17
+
18
+ /**
19
+ * Caption to render in the hero card
20
+ */
21
+ caption?: TooltipProps;
22
+
23
+ /**
24
+ * Size the of hero card
25
+ */
26
+ cardSize?: "small" | "medium" | "large" | "xlarge" | "xxlarge";
27
+
6
28
  /**
7
29
  * Specify an optional className to be added to your Hero component.
8
30
  */
@@ -13,18 +35,23 @@ export interface HeroProps {
13
35
  */
14
36
  image?: ImageProps;
15
37
 
38
+ /**
39
+ * How to justify the hero card
40
+ */
41
+ justify?: "start" | "center" | "offset";
42
+
16
43
  /**
17
44
  * Props for the card for the hero
18
45
  */
19
- heroCard?: HeroCardProps;
46
+ heroCard: HeroCardProps;
20
47
 
21
48
  /**
22
- * Theme for the card
49
+ * The size of the poster image
23
50
  */
24
- theme?: HeroCardTheme;
51
+ posterSize?: "small" | "medium" | "large" | "xlarge";
25
52
 
26
53
  /**
27
- * Type of hero for the card
54
+ * Theme for the card
28
55
  */
29
- types?: HeroCardTypes;
56
+ theme?: ThemeTypes;
30
57
  }
@@ -1,34 +1,82 @@
1
1
  import { FC } from "react";
2
- import classNames from "classnames";
2
+ import classnames from "classnames";
3
3
  import useGlobalSettings from "../../hooks/useGlobalSettings";
4
4
  import { HeroProps } from "./Hero.props";
5
5
  import HeroCard from "./HeroCard";
6
- import { Image } from "../Image";
6
+ import { ImageProps } from "../Image/Image.props";
7
+ import { Breadcrumb } from "../Breadcrumb";
8
+ import { Tooltip } from "../Tooltip";
9
+
10
+ const HeroImage: FC<ImageProps> = ({ url, alt }) => {
11
+ const { prefix } = useGlobalSettings();
12
+
13
+ const imageClass = `${prefix}--card--image`;
14
+
15
+ // Sort the urls by breakpoint
16
+ const sortedUrls = url.sort((a, b) => a.breakpoint - b.breakpoint);
17
+
18
+ const defaultSrc = sortedUrls[sortedUrls.length - 1].src;
19
+
20
+ return (
21
+ <figure className="hero--figure">
22
+ <picture>
23
+ {sortedUrls.map((img) => (
24
+ <source
25
+ srcSet={img.src}
26
+ media={`(min-width: ${img.breakpoint}px)`}
27
+ key={img.breakpoint}
28
+ />
29
+ ))}
30
+ <img className={imageClass} src={defaultSrc} alt={alt} />
31
+ </picture>
32
+ </figure>
33
+ );
34
+ };
7
35
 
8
36
  const Hero: FC<HeroProps> = ({
9
- className,
37
+ justify = "start",
38
+ align = "baseline",
39
+ cardSize = "small",
40
+ posterSize = "large",
10
41
  image,
42
+ breadcrumb,
11
43
  heroCard,
12
- theme = "light",
13
- types,
44
+ caption,
14
45
  }) => {
15
- const { prefix } = useGlobalSettings();
16
-
17
- const baseClass = `${prefix}--hero`;
18
- const heroClasses = classNames(className, {
19
- [baseClass]: true,
20
- [`${baseClass}--${theme}`]: theme,
21
- [`${baseClass}--${types}`]: types,
22
- [`${baseClass}--image`]: image,
23
- });
46
+ const baseClass = "hero";
47
+ const justifyClass = `${baseClass}__card-justify__${justify}`;
48
+ const alignClass = `${baseClass}__card-align__${align}`;
49
+ const cardSizeClass = `${baseClass}__card-size__${cardSize}`;
50
+ const posterSizeClass = `${baseClass}__poster-size__${posterSize}`;
51
+ const heroClasses = classnames(
52
+ baseClass,
53
+ justifyClass,
54
+ alignClass,
55
+ cardSizeClass,
56
+ posterSizeClass
57
+ );
24
58
 
25
59
  return (
26
- <>
27
- <div className={heroClasses}>
28
- {image && <Image {...image} />}
60
+ <div className={heroClasses}>
61
+ {image ? <HeroImage {...image} /> : <div className="hero--figure" />}
62
+ {breadcrumb && (
63
+ <div className="hero--breadcrumbs">
64
+ <div className="hero--breadcrumbs--wrapper">
65
+ <Breadcrumb {...breadcrumb} />
66
+ </div>
67
+ </div>
68
+ )}
69
+ <div className="hero--card">
29
70
  <HeroCard {...heroCard} />
30
71
  </div>
31
- </>
72
+ {caption && (
73
+ <div className="hero--caption">
74
+ <div className="hero--caption--wrapper">
75
+ <Tooltip {...caption} />
76
+ </div>
77
+ </div>
78
+ )}
79
+ </div>
32
80
  );
33
81
  };
34
82
 
@@ -1,16 +1,22 @@
1
- import { HeroCardAlignment, HeroCardTypes, HeroCardTheme } from "../../types";
1
+ import { ThemeTypes } from "../../types";
2
+ import { SocialMediaProps } from "../SocialMedia";
2
3
 
3
4
  export interface HeroCardProps {
4
5
  /**
5
- * Theme for the card
6
+ * Specify whether the background should be solid, transparent or semi-transparent
6
7
  */
7
- alignment?: HeroCardAlignment;
8
+ background?: "solid" | "transparent" | "semi-transparent";
8
9
 
9
10
  /**
10
11
  * Specify an optional className to be added to your Hero component.
11
12
  */
12
13
  className?: string;
13
14
 
15
+ /**
16
+ * Whether the card should have a cornercut or not
17
+ */
18
+ cornercut?: boolean;
19
+
14
20
  /**
15
21
  * date copy for the hero card
16
22
  */
@@ -29,37 +35,20 @@ export interface HeroCardProps {
29
35
  /**
30
36
  * Specify the links to be displayed in this link group
31
37
  */
32
- socials?: SocialProps[];
38
+ socialmedia?: SocialMediaProps;
33
39
 
34
40
  /**
35
41
  * Title for the page
36
42
  */
37
- title?: string;
43
+ title: string;
38
44
 
39
45
  /**
40
46
  * Theme for the card
41
47
  */
42
- theme?: HeroCardTheme;
43
-
44
- /**
45
- * Type of hero for the card
46
- */
47
- types?: HeroCardTypes;
48
- }
49
-
50
- interface SocialProps {
51
- /**
52
- * Specify the label for this link
53
- */
54
- label?: Required<string>;
55
-
56
- /**
57
- * Specify the url for this link
58
- */
59
- url?: Required<string>;
48
+ theme?: ThemeTypes;
60
49
 
61
50
  /**
62
- * Specify the icon for this link
51
+ * The link of the card's title if it has one
63
52
  */
64
- icon?: Required<string>;
53
+ url?: string;
65
54
  }