@ilo-org/react 0.5.1 → 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 (66) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/cjs/components/Accordion/AccordionPanel.js +3 -3
  3. package/lib/cjs/components/Footer/Footer.js +4 -3
  4. package/lib/cjs/components/Footer/index.js +2 -0
  5. package/lib/cjs/components/Hero/Hero.js +21 -11
  6. package/lib/cjs/components/Hero/HeroCard.js +20 -10
  7. package/lib/cjs/components/Hero/index.js +6 -2
  8. package/lib/cjs/components/LogoGrid/LogoGrid.js +30 -0
  9. package/lib/cjs/components/LogoGrid/index.js +13 -0
  10. package/lib/cjs/components/SocialMedia/SocialMedia.js +25 -0
  11. package/lib/cjs/components/SocialMedia/index.js +57 -0
  12. package/lib/cjs/components/index.js +2 -0
  13. package/lib/cjs/index.js +2 -0
  14. package/lib/esm/components/Accordion/AccordionPanel.js +3 -3
  15. package/lib/esm/components/Footer/Footer.js +5 -4
  16. package/lib/esm/components/Footer/index.js +2 -0
  17. package/lib/esm/components/Hero/Hero.js +22 -12
  18. package/lib/esm/components/Hero/HeroCard.js +20 -10
  19. package/lib/esm/components/Hero/index.js +6 -2
  20. package/lib/esm/components/LogoGrid/LogoGrid.js +28 -0
  21. package/lib/esm/components/LogoGrid/index.js +7 -0
  22. package/lib/esm/components/SocialMedia/SocialMedia.js +23 -0
  23. package/lib/esm/components/SocialMedia/index.js +54 -0
  24. package/lib/esm/components/index.js +2 -0
  25. package/lib/esm/index.js +2 -0
  26. package/lib/types/react/src/components/Accordion/AccordionPanel.props.d.ts +4 -0
  27. package/lib/types/react/src/components/Card/Card.props.d.ts +2 -2
  28. package/lib/types/react/src/components/Footer/Footer.props.d.ts +2 -23
  29. package/lib/types/react/src/components/Hero/Hero.props.d.ts +28 -6
  30. package/lib/types/react/src/components/Hero/HeroCard.props.d.ts +13 -23
  31. package/lib/types/react/src/components/Image/Image.props.d.ts +7 -3
  32. package/lib/types/react/src/components/LogoGrid/LogoGrid.d.ts +4 -0
  33. package/lib/types/react/src/components/LogoGrid/LogoGrid.props.d.ts +24 -0
  34. package/lib/types/react/src/components/LogoGrid/index.d.ts +1 -0
  35. package/lib/types/react/src/components/SocialMedia/SocialMedia.args.d.ts +4 -0
  36. package/lib/types/react/src/components/SocialMedia/SocialMedia.d.ts +3 -0
  37. package/lib/types/react/src/components/SocialMedia/SocialMedia.props.d.ts +37 -0
  38. package/lib/types/react/src/components/SocialMedia/index.d.ts +3 -0
  39. package/lib/types/react/src/types/index.d.ts +2 -4
  40. package/package.json +4 -4
  41. package/public/fao-logo.svg +195 -0
  42. package/public/unhcr-logo.svg +1 -0
  43. package/public/unicef-logo.png +0 -0
  44. package/public/wfp-logo.svg +1 -0
  45. package/public/who-logo.svg +1 -0
  46. package/src/components/Accordion/AccordionPanel.props.ts +5 -0
  47. package/src/components/Accordion/AccordionPanel.tsx +3 -3
  48. package/src/components/Card/Card.props.ts +2 -2
  49. package/src/components/Footer/Footer.args.ts +2 -21
  50. package/src/components/Footer/Footer.props.ts +2 -26
  51. package/src/components/Footer/Footer.tsx +7 -19
  52. package/src/components/Hero/Hero.args.ts +84 -270
  53. package/src/components/Hero/Hero.props.ts +33 -6
  54. package/src/components/Hero/Hero.tsx +66 -18
  55. package/src/components/Hero/HeroCard.props.ts +14 -25
  56. package/src/components/Hero/HeroCard.tsx +45 -33
  57. package/src/components/Image/Image.props.ts +8 -3
  58. package/src/components/LogoGrid/LogoGrid.args.ts +50 -0
  59. package/src/components/LogoGrid/LogoGrid.props.ts +28 -0
  60. package/src/components/LogoGrid/LogoGrid.tsx +53 -0
  61. package/src/components/LogoGrid/index.ts +1 -0
  62. package/src/components/SocialMedia/SocialMedia.args.ts +54 -0
  63. package/src/components/SocialMedia/SocialMedia.props.ts +45 -0
  64. package/src/components/SocialMedia/SocialMedia.tsx +46 -0
  65. package/src/components/SocialMedia/index.ts +3 -0
  66. package/src/types/index.ts +9 -10
@@ -1,51 +1,63 @@
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 { HeroCardProps } from "./HeroCard.props";
5
+ import { SocialMedia } from "../SocialMedia";
6
+
7
+ interface HeroCardTitleProps {
8
+ baseclass: string;
9
+ title: string;
10
+ url?: string;
11
+ }
12
+
13
+ const HeroCardTitle: FC<HeroCardTitleProps> = ({ baseclass, title, url }) => {
14
+ const titleClass = `${baseclass}--title`;
15
+ const linkClass = `${baseclass}--title-link`;
16
+
17
+ if (!url) {
18
+ return <h1 className={titleClass}>{title}</h1>;
19
+ }
20
+
21
+ return (
22
+ <a className={linkClass} href={url}>
23
+ <h1 className={titleClass}>{title}</h1>
24
+ </a>
25
+ );
26
+ };
5
27
 
6
28
  const HeroCard: FC<HeroCardProps> = ({
7
- className,
8
- alignment,
9
- datecopy,
29
+ theme = "dark",
30
+ background = "solid",
31
+ cornercut = "true",
10
32
  eyebrow,
11
- intro,
12
- socials,
13
33
  title,
14
- theme = "light",
15
- types = "article",
34
+ url,
35
+ datecopy,
36
+ intro,
37
+ socialmedia,
16
38
  }) => {
17
39
  const { prefix } = useGlobalSettings();
18
40
 
19
41
  const baseClass = `${prefix}--hero-card`;
20
- const heroCardClasses = classNames(className, {
21
- [baseClass]: true,
22
- [`${baseClass}--${alignment}`]: alignment,
23
- [`${baseClass}--${theme}`]: theme,
24
- [`${baseClass}--${types}`]: types,
42
+ const themeClass = `${baseClass}__theme__${theme}`;
43
+ const backgroundClass = `${baseClass}__background__${background}`;
44
+ const cornercutClass = `${baseClass}__cornercut`;
45
+
46
+ const heroCardClasses = classnames(baseClass, themeClass, backgroundClass, {
47
+ [cornercutClass]: cornercut,
25
48
  });
26
49
 
50
+ const eyebrowClass = `${baseClass}--eyebrow`;
51
+ const datecopyClass = `${baseClass}--datecopy`;
52
+ const introClass = `${baseClass}--intro`;
53
+
27
54
  return (
28
55
  <div className={heroCardClasses}>
29
- {eyebrow && <p className={`${baseClass}--eyebrow`}>{eyebrow}</p>}
30
- {title && <h2 className={`${baseClass}--title`}>{title}</h2>}
31
- {datecopy && <p className={`${baseClass}--datecopy`}>{datecopy}</p>}
32
- {intro && <p className={`${baseClass}--intro`}>{intro}</p>}
33
- <ul className={`${baseClass}--list`}>
34
- {socials &&
35
- socials.map((item: any, index: any) => {
36
- return (
37
- <li className={`${baseClass}--list--item`} key={index}>
38
- <a
39
- className={`${baseClass}--link icon icon--${item.icon}`}
40
- href={item.url}
41
- title={item.label}
42
- >
43
- {item.label}
44
- </a>
45
- </li>
46
- );
47
- })}
48
- </ul>
56
+ {eyebrow && <p className={eyebrowClass}>{eyebrow}</p>}
57
+ <HeroCardTitle baseclass={baseClass} title={title} url={url} />
58
+ {datecopy && <p className={datecopyClass}>{datecopy}</p>}
59
+ {intro && <p className={introClass}>{intro}</p>}
60
+ {socialmedia && <SocialMedia {...socialmedia} theme={theme} />}
49
61
  </div>
50
62
  );
51
63
  };
@@ -2,12 +2,12 @@ interface ImageUrl {
2
2
  /**
3
3
  * Specify the breakpoint at which this image src should be used
4
4
  */
5
- breakpoint?: number;
5
+ breakpoint: number;
6
6
 
7
7
  /**
8
8
  * Specify the url of this breakpoint's image src
9
9
  */
10
- src?: string;
10
+ src: string;
11
11
  }
12
12
 
13
13
  export interface ImageProps {
@@ -34,5 +34,10 @@ export interface ImageProps {
34
34
  /**
35
35
  * Specify the image src for the image
36
36
  */
37
- url?: Required<Array<ImageUrl>>;
37
+ url: ImageUrl[];
38
+
39
+ /**
40
+ * Value to pass to lading attribute
41
+ */
42
+ loading?: "lazy" | "eager";
38
43
  }
@@ -0,0 +1,50 @@
1
+ import { LogoGridProps } from "./LogoGrid.props";
2
+ import { logo_en_horizontal_blue_svg } from "@ilo-org/brand-assets";
3
+
4
+ export const defaultLogoGrid: LogoGridProps = {
5
+ logos: [
6
+ {
7
+ label: "International Labour Organization",
8
+ src: logo_en_horizontal_blue_svg,
9
+ url: "https://www.ilo.org/",
10
+ },
11
+ {
12
+ label: "Food and Agriculture Organization",
13
+ src: "/fao-logo.svg",
14
+ url: "https://www.fao.org",
15
+ },
16
+ {
17
+ label: "World Health Organization",
18
+ src: "/who-logo.svg",
19
+ url: "https://www.who.int/",
20
+ },
21
+ {
22
+ label: "World Food Programme",
23
+ src: "/wfp-logo.svg",
24
+ url: "https://www.wfp.org/",
25
+ },
26
+
27
+ {
28
+ label: "UNICEF",
29
+ src: "/unicef-logo.png",
30
+ url: "https://www.unicef.org/",
31
+ },
32
+ {
33
+ label: "UN Refugees",
34
+ src: "/unhcr-logo.svg",
35
+ url: "https://www.unhcr.org/",
36
+ },
37
+ ],
38
+ };
39
+
40
+ export const darkLogoGrid: LogoGridProps = {
41
+ ...defaultLogoGrid,
42
+ theme: "dark",
43
+ };
44
+
45
+ export const noLinksGrid: LogoGridProps = {
46
+ logos: defaultLogoGrid.logos.map(({ label, src }) => ({
47
+ label,
48
+ src,
49
+ })),
50
+ };
@@ -0,0 +1,28 @@
1
+ export interface LogoGridItemProps {
2
+ /**
3
+ * The label of the logo
4
+ */
5
+ label: string;
6
+
7
+ /**
8
+ * The image src of the logo
9
+ */
10
+ src: string | URL;
11
+
12
+ /**
13
+ * The link of the logo
14
+ */
15
+ url?: string;
16
+ }
17
+
18
+ export interface LogoGridProps {
19
+ /**
20
+ * The logos to display
21
+ */
22
+ logos: LogoGridItemProps[];
23
+
24
+ /**
25
+ * The theme of the logo grid
26
+ */
27
+ theme?: "dark" | "light";
28
+ }
@@ -0,0 +1,53 @@
1
+ import React from "react";
2
+ import classnames from "classnames";
3
+ import { useGlobalSettings } from "../../hooks";
4
+ import { LogoGridProps, LogoGridItemProps } from "./LogoGrid.props";
5
+
6
+ const LogoGridItem: React.FC<LogoGridItemProps> = ({ url, label, src }) => {
7
+ const { prefix } = useGlobalSettings();
8
+
9
+ const itemClass = `${prefix}--logo-grid--item`;
10
+ const itemLinkClass = `${prefix}--logo-grid--link`;
11
+
12
+ const gridItemClass = classnames(itemClass, {
13
+ [itemLinkClass]: !!url,
14
+ });
15
+
16
+ if (!url) {
17
+ return (
18
+ <div className={gridItemClass}>
19
+ <img alt={label} src={src as string} />
20
+ </div>
21
+ );
22
+ }
23
+ return (
24
+ <a
25
+ className={gridItemClass}
26
+ href={url}
27
+ target="_blank"
28
+ rel="noopener noreferrer"
29
+ >
30
+ <img alt={label} src={src as string} />
31
+ </a>
32
+ );
33
+ };
34
+
35
+ const LogoGrid: React.FC<LogoGridProps> = ({ logos, theme = "light" }) => {
36
+ const { prefix } = useGlobalSettings();
37
+
38
+ const baseClass = `${prefix}--logo-grid`;
39
+ const themeClass = `${baseClass}__theme__${theme}`;
40
+ const logoGridClass = classnames(baseClass, themeClass);
41
+
42
+ return (
43
+ <div className={logoGridClass}>
44
+ <div className={`${baseClass}--logos`}>
45
+ {logos.map((logo) => (
46
+ <LogoGridItem {...logo} />
47
+ ))}
48
+ </div>
49
+ </div>
50
+ );
51
+ };
52
+
53
+ export default LogoGrid;
@@ -0,0 +1 @@
1
+ export { default as LogoGrid } from "./LogoGrid";
@@ -0,0 +1,54 @@
1
+ import { SocialMediaProps } from "./SocialMedia.props";
2
+
3
+ export const defaultArgs: SocialMediaProps = {
4
+ headline: "Follow us on social media",
5
+ theme: "light",
6
+ justify: "start",
7
+ icons: [
8
+ {
9
+ icon: "facebook",
10
+ url: "https://www.facebook.com/ilo.org",
11
+ label: "Facebook",
12
+ },
13
+ {
14
+ icon: "twitter",
15
+ url: "https://twitter.com/#!/ilo",
16
+ label: "Twitter",
17
+ },
18
+ {
19
+ icon: "instagram",
20
+ url: "https://www.instagram.com/ilo.org/",
21
+ label: "Instagram",
22
+ },
23
+ {
24
+ icon: "linkedin",
25
+ url: "https://www.linkedin.com/company/international-labour-organization-ilo",
26
+ label: "LinkedIn",
27
+ },
28
+ {
29
+ icon: "youtube",
30
+ url: "https://www.youtube.com/channel/UCQsVmhSa4X-G3lHlUtejzLA",
31
+ label: "YouTube",
32
+ },
33
+ {
34
+ icon: "tiktok",
35
+ url: "https://www.tiktok.com/@ilo",
36
+ label: "TikTok",
37
+ },
38
+ {
39
+ icon: "flickr",
40
+ url: "https://www.flickr.com/photos/ilopictures/albums",
41
+ label: "TikTok",
42
+ },
43
+ ],
44
+ };
45
+
46
+ export const darkArgs: SocialMediaProps = {
47
+ ...defaultArgs,
48
+ theme: "dark",
49
+ };
50
+
51
+ export const centredArgs: SocialMediaProps = {
52
+ ...defaultArgs,
53
+ justify: "center",
54
+ };
@@ -0,0 +1,45 @@
1
+ import { SocialTypes } from "../../types";
2
+
3
+ export interface SocialMediaIcons {
4
+ /**
5
+ * The name of the icon to display
6
+ */
7
+ icon: SocialTypes;
8
+
9
+ /**
10
+ * The url to link to
11
+ */
12
+ url: string;
13
+
14
+ /**
15
+ * The alt text of the link
16
+ */
17
+ label: string;
18
+ }
19
+
20
+ export interface SocialMediaProps {
21
+ /**
22
+ * An optional headline to display above the icons
23
+ */
24
+ headline?: string;
25
+
26
+ /**
27
+ * Specify an optional className to be added to your SocialMedia.
28
+ */
29
+ className?: string;
30
+
31
+ /**
32
+ * Specify the theme of the SocialMedia.
33
+ */
34
+ theme?: "light" | "dark";
35
+
36
+ /**
37
+ * The justification of the icons
38
+ */
39
+ justify?: "start" | "center";
40
+
41
+ /**
42
+ * Specify the icons to display.
43
+ */
44
+ icons: SocialMediaIcons[];
45
+ }
@@ -0,0 +1,46 @@
1
+ import classnames from "classnames";
2
+ import { useGlobalSettings } from "../../hooks";
3
+ import { SocialMediaProps } from "./SocialMedia.props";
4
+
5
+ const SocialMedia: React.FC<SocialMediaProps> = ({
6
+ className,
7
+ theme = "light",
8
+ justify = "start",
9
+ headline,
10
+ icons,
11
+ }) => {
12
+ const { prefix } = useGlobalSettings();
13
+
14
+ // Classes to be applied to the outer element
15
+ const baseClass = `${prefix}--social-media`;
16
+ const themeClass = `${baseClass}__theme__${theme}`;
17
+ const justifyClass = `${baseClass}__justify__${justify}`;
18
+ const classes = classnames(baseClass, themeClass, justifyClass, className);
19
+
20
+ // Classes to be applied to inner elements
21
+ const headlineClass = `${baseClass}--headline`;
22
+ const listClass = `${baseClass}--list`;
23
+ const listItemClass = `${listClass}--item`;
24
+ const iconClass = `${listItemClass}--icon`;
25
+
26
+ return (
27
+ <div className={classes}>
28
+ {headline && <h5 className={headlineClass}>{headline}</h5>}
29
+ <ul className={listClass}>
30
+ {icons.map((item) => (
31
+ <li className={listItemClass}>
32
+ <a
33
+ title={item.label}
34
+ className={classnames(iconClass, `${iconClass}__${item.icon}`)}
35
+ href={item.url}
36
+ >
37
+ {item.label}
38
+ </a>
39
+ </li>
40
+ ))}
41
+ </ul>
42
+ </div>
43
+ );
44
+ };
45
+
46
+ export default SocialMedia;
@@ -0,0 +1,3 @@
1
+ export { default as SocialMedia } from "./SocialMedia";
2
+ export type { SocialMediaProps } from "./SocialMedia.props";
3
+ export { defaultArgs } from "./SocialMedia.args";
@@ -1,4 +1,5 @@
1
1
  // export type AccordionSize = "small" | "large";
2
+ export type ThemeTypes = "light" | "dark";
2
3
  export type ButtonFunctions = "button" | "submit" | "reset";
3
4
  export type ButtonTypes = "primary" | "secondary" | "tertiary" | "alert";
4
5
  export type CalloutTypes = "info" | "error" | "success" | "warning";
@@ -16,15 +17,6 @@ export type FieldTypes =
16
17
  | "file";
17
18
  export type FormGroupTypes = "default" | "filter";
18
19
  export type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
19
- export type HeroCardAlignment = "left" | "center" | "right";
20
- export type HeroCardTypes =
21
- | "home"
22
- | "publication"
23
- | "graphic"
24
- | "project"
25
- | "article"
26
- | "portal";
27
- export type HeroCardTheme = "dark" | "light";
28
20
  export type InputTypes =
29
21
  | "email"
30
22
  | "hidden"
@@ -49,7 +41,14 @@ export type NotificationTypes = "error" | "info" | "success" | "warning";
49
41
  export type PositionTypes = "top" | "bottom" | "left" | "right";
50
42
  export type SizeTypes = "small" | "medium" | "large";
51
43
  export type TagTypes = "anchor" | "display" | "button";
52
- export type SocialTypes = "instagram" | "facebook" | "twitter" | "youtube";
44
+ export type SocialTypes =
45
+ | "facebook"
46
+ | "twitter"
47
+ | "instagram"
48
+ | "linkedin"
49
+ | "youtube"
50
+ | "tiktok"
51
+ | "flickr";
53
52
  export type CardColor = "turquoise" | "green" | "yellow" | "blue";
54
53
  export type CardSize = "wide" | "standard" | "narrow";
55
54
  export type CardCornerType = "cornercut" | "corner";