@ilo-org/react 0.6.0 → 0.7.1
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 +29 -0
- package/lib/cjs/components/Accordion/AccordionPanel.js +3 -3
- package/lib/cjs/components/Hero/Hero.js +21 -11
- package/lib/cjs/components/Hero/HeroCard.js +20 -10
- package/lib/cjs/components/Hero/index.js +6 -2
- package/lib/cjs/components/LogoGrid/LogoGrid.js +30 -0
- package/lib/cjs/components/LogoGrid/index.js +13 -0
- package/lib/cjs/components/index.js +2 -2
- package/lib/cjs/index.js +2 -2
- package/lib/esm/components/Accordion/AccordionPanel.js +3 -3
- package/lib/esm/components/Hero/Hero.js +22 -12
- package/lib/esm/components/Hero/HeroCard.js +20 -10
- package/lib/esm/components/Hero/index.js +6 -2
- package/lib/esm/components/LogoGrid/LogoGrid.js +28 -0
- package/lib/esm/components/LogoGrid/index.js +7 -0
- package/lib/esm/components/index.js +2 -2
- package/lib/esm/index.js +2 -2
- package/lib/types/react/src/components/Accordion/AccordionPanel.props.d.ts +4 -0
- package/lib/types/react/src/components/Card/Card.props.d.ts +2 -2
- package/lib/types/react/src/components/Hero/Hero.props.d.ts +28 -6
- package/lib/types/react/src/components/Hero/HeroCard.props.d.ts +13 -23
- package/lib/types/react/src/components/Image/Image.props.d.ts +7 -3
- package/lib/types/react/src/components/LogoGrid/LogoGrid.d.ts +4 -0
- package/lib/types/react/src/components/LogoGrid/LogoGrid.props.d.ts +24 -0
- package/lib/types/react/src/components/LogoGrid/index.d.ts +1 -0
- package/lib/types/react/src/types/index.d.ts +1 -3
- package/package.json +2 -2
- package/public/fao-logo.svg +195 -0
- package/public/unhcr-logo.svg +1 -0
- package/public/unicef-logo.png +0 -0
- package/public/wfp-logo.svg +1 -0
- package/public/who-logo.svg +1 -0
- package/src/components/Accordion/AccordionPanel.props.ts +5 -0
- package/src/components/Accordion/AccordionPanel.tsx +3 -3
- package/src/components/Card/Card.props.ts +2 -2
- package/src/components/Hero/Hero.args.ts +84 -270
- package/src/components/Hero/Hero.props.ts +33 -6
- package/src/components/Hero/Hero.tsx +66 -18
- package/src/components/Hero/HeroCard.props.ts +14 -25
- package/src/components/Hero/HeroCard.tsx +45 -33
- package/src/components/Image/Image.props.ts +8 -3
- package/src/components/LogoGrid/LogoGrid.args.ts +50 -0
- package/src/components/LogoGrid/LogoGrid.props.ts +28 -0
- package/src/components/LogoGrid/LogoGrid.tsx +53 -0
- package/src/components/LogoGrid/index.ts +1 -0
- package/src/types/index.ts +1 -9
|
@@ -1,51 +1,63 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
|
-
import
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
29
|
+
theme = "dark",
|
|
30
|
+
background = "solid",
|
|
31
|
+
cornercut = "true",
|
|
10
32
|
eyebrow,
|
|
11
|
-
intro,
|
|
12
|
-
socials,
|
|
13
33
|
title,
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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={
|
|
30
|
-
|
|
31
|
-
{datecopy && <p className={
|
|
32
|
-
{intro && <p className={
|
|
33
|
-
<
|
|
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
|
|
5
|
+
breakpoint: number;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Specify the url of this breakpoint's image src
|
|
9
9
|
*/
|
|
10
|
-
src
|
|
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
|
|
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";
|
package/src/types/index.ts
CHANGED
|
@@ -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"
|