@ilo-org/react 0.2.1 → 0.4.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 (95) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/lib/cjs/{DailyMotion-2aa7f048.js → DailyMotion-5654fa6e.js} +1 -1
  4. package/lib/cjs/{Facebook-87e24af8.js → Facebook-1924e510.js} +1 -1
  5. package/lib/cjs/{FilePlayer-e1216cc8.js → FilePlayer-9c697e42.js} +1 -1
  6. package/lib/cjs/{Kaltura-a673a8e9.js → Kaltura-177bb003.js} +1 -1
  7. package/lib/cjs/{Mixcloud-f9575c31.js → Mixcloud-91a772a6.js} +1 -1
  8. package/lib/cjs/{Preview-468c3a7f.js → Preview-8e2afb6a.js} +1 -1
  9. package/lib/cjs/{SoundCloud-7c59f293.js → SoundCloud-089e0f30.js} +1 -1
  10. package/lib/cjs/{Streamable-83e516e5.js → Streamable-4ca5b9c7.js} +1 -1
  11. package/lib/cjs/{Twitch-fdfa1c77.js → Twitch-dbc5c387.js} +1 -1
  12. package/lib/cjs/{VideoPlayer-9ce35136.js → VideoPlayer-874a52b0.js} +21 -16
  13. package/lib/cjs/{Vidyard-096bba3c.js → Vidyard-371acdcb.js} +1 -1
  14. package/lib/cjs/{Vimeo-2cb7476f.js → Vimeo-4d2029a8.js} +1 -1
  15. package/lib/cjs/{Wistia-5e830ac8.js → Wistia-cd0799ad.js} +1 -1
  16. package/lib/cjs/{YouTube-25a1d9a0.js → YouTube-23b7ec9e.js} +1 -1
  17. package/lib/cjs/components/Card/Card.js +43 -0
  18. package/lib/cjs/components/Card/CardGroup.js +25 -0
  19. package/lib/cjs/components/Card/index.js +21 -0
  20. package/lib/cjs/components/LocalNav/LocalNav.js +5 -3
  21. package/lib/cjs/components/LocalNav/index.js +1 -0
  22. package/lib/cjs/components/Logo/Logo.js +153 -0
  23. package/lib/cjs/components/Logo/index.js +13 -0
  24. package/lib/cjs/components/Navigation/Navigation.js +48 -0
  25. package/lib/cjs/components/Navigation/index.js +20 -0
  26. package/lib/cjs/components/Video/Video.js +1 -1
  27. package/lib/cjs/components/Video/VideoPlayer.js +1 -1
  28. package/lib/cjs/components/Video/index.js +1 -1
  29. package/lib/cjs/components/index.js +9 -1
  30. package/lib/cjs/index.js +9 -1
  31. package/lib/esm/{DailyMotion-66b6eff2.js → DailyMotion-88f6c379.js} +1 -1
  32. package/lib/esm/{Facebook-dbd1003d.js → Facebook-3a284039.js} +1 -1
  33. package/lib/esm/{FilePlayer-617ed2ce.js → FilePlayer-dee1f94b.js} +1 -1
  34. package/lib/esm/{Kaltura-bbcec33d.js → Kaltura-c5d42c88.js} +1 -1
  35. package/lib/esm/{Mixcloud-a681ec69.js → Mixcloud-430ab42a.js} +1 -1
  36. package/lib/esm/{Preview-407cc648.js → Preview-7f57e055.js} +1 -1
  37. package/lib/esm/{SoundCloud-16e78ee5.js → SoundCloud-d1ab591e.js} +1 -1
  38. package/lib/esm/{Streamable-ecb225c1.js → Streamable-042d61d5.js} +1 -1
  39. package/lib/esm/{Twitch-8d1b6769.js → Twitch-2f45534f.js} +1 -1
  40. package/lib/esm/{VideoPlayer-62e0ce79.js → VideoPlayer-719076c4.js} +21 -16
  41. package/lib/esm/{Vidyard-57e2834a.js → Vidyard-4625527b.js} +1 -1
  42. package/lib/esm/{Vimeo-faa058a2.js → Vimeo-03b960e6.js} +1 -1
  43. package/lib/esm/{Wistia-24fb5120.js → Wistia-48f9c303.js} +1 -1
  44. package/lib/esm/{YouTube-01b3e51f.js → YouTube-5b29a3d9.js} +1 -1
  45. package/lib/esm/components/Card/Card.js +41 -0
  46. package/lib/esm/components/Card/CardGroup.js +23 -0
  47. package/lib/esm/components/Card/index.js +14 -0
  48. package/lib/esm/components/LocalNav/LocalNav.js +5 -3
  49. package/lib/esm/components/LocalNav/index.js +1 -0
  50. package/lib/esm/components/Logo/Logo.js +151 -0
  51. package/lib/esm/components/Logo/index.js +7 -0
  52. package/lib/esm/components/Navigation/Navigation.js +46 -0
  53. package/lib/esm/components/Navigation/index.js +14 -0
  54. package/lib/esm/components/Video/Video.js +1 -1
  55. package/lib/esm/components/Video/VideoPlayer.js +1 -1
  56. package/lib/esm/components/Video/index.js +1 -1
  57. package/lib/esm/components/index.js +6 -1
  58. package/lib/esm/index.js +6 -1
  59. package/lib/types/react/src/components/Card/Card.d.ts +4 -0
  60. package/lib/types/react/src/components/Card/Card.props.d.ts +110 -0
  61. package/lib/types/react/src/components/Card/CardGroup.d.ts +4 -0
  62. package/lib/types/react/src/components/Card/CardGroup.props.d.ts +16 -0
  63. package/lib/types/react/src/components/Card/index.d.ts +2 -0
  64. package/lib/types/react/src/components/LocalNav/LocalNav.props.d.ts +4 -7
  65. package/lib/types/react/src/components/Logo/Logo.d.ts +4 -0
  66. package/lib/types/react/src/components/Logo/Logo.props.d.ts +55 -0
  67. package/lib/types/react/src/components/Logo/index.d.ts +1 -0
  68. package/lib/types/react/src/components/Navigation/Navigation.d.ts +4 -0
  69. package/lib/types/react/src/components/Navigation/Navigation.props.d.ts +99 -0
  70. package/lib/types/react/src/components/Navigation/index.d.ts +1 -0
  71. package/lib/types/react/src/components/index.d.ts +2 -0
  72. package/lib/types/react/src/types/index.d.ts +6 -0
  73. package/package.json +18 -17
  74. package/public/favicon.ico +0 -0
  75. package/src/components/Accordion/Accordion.args.ts +1 -4
  76. package/src/components/Card/Card.args.ts +215 -0
  77. package/src/components/Card/Card.props.ts +142 -0
  78. package/src/components/Card/Card.tsx +183 -0
  79. package/src/components/Card/CardGroup.args.ts +945 -0
  80. package/src/components/Card/CardGroup.props.ts +19 -0
  81. package/src/components/Card/CardGroup.tsx +55 -0
  82. package/src/components/Card/index.ts +2 -0
  83. package/src/components/LocalNav/LocalNav.args.ts +6 -6
  84. package/src/components/LocalNav/LocalNav.props.ts +4 -8
  85. package/src/components/LocalNav/LocalNav.tsx +21 -15
  86. package/src/components/Logo/Logo.args.ts +45 -0
  87. package/src/components/Logo/Logo.props.ts +67 -0
  88. package/src/components/Logo/Logo.tsx +247 -0
  89. package/src/components/Logo/index.ts +1 -0
  90. package/src/components/Navigation/Navigation.args.ts +112 -0
  91. package/src/components/Navigation/Navigation.props.ts +120 -0
  92. package/src/components/Navigation/Navigation.tsx +246 -0
  93. package/src/components/Navigation/index.ts +1 -0
  94. package/src/components/index.ts +2 -0
  95. package/src/types/index.ts +14 -0
@@ -9,6 +9,7 @@ export type HeroCardAlignment = "left" | "center" | "right";
9
9
  export type HeroCardTypes = "home" | "publication" | "graphic" | "project" | "article" | "portal";
10
10
  export type HeroCardTheme = "dark" | "light";
11
11
  export type InputTypes = "email" | "hidden" | "password" | "search" | "tel" | "text" | "url";
12
+ export type Language = "en" | "fr" | "es";
12
13
  export type LabelTypes = "default" | "actionable" | "light";
13
14
  export type LinkTypes = "light" | "dark" | "footer" | "button";
14
15
  export type LinkListThemes = "light" | "dark";
@@ -25,3 +26,8 @@ export type PositionTypes = "top" | "bottom" | "left" | "right";
25
26
  export type SizeTypes = "small" | "medium" | "large";
26
27
  export type TagTypes = "anchor" | "display" | "button";
27
28
  export type SocialTypes = "instagram" | "facebook" | "twitter" | "youtube";
29
+ export type CardColor = "turquoise" | "green" | "yellow" | "blue";
30
+ export type CardSize = "wide" | "standard" | "narrow";
31
+ export type CardCornerType = "cornercut" | "corner";
32
+ export type CardAlignment = "left" | "right";
33
+ export type CardTypes = "stat" | "multilink" | "graphic" | "graphicpromo" | "feature" | "detail" | "factlist" | "data";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/react",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "React components for the ILO's Design System",
5
5
  "keywords": [
6
6
  "ui_patterns",
@@ -9,6 +9,7 @@
9
9
  "designsystem",
10
10
  "components"
11
11
  ],
12
+ "homepage": "https://react.ui.ilo.org",
12
13
  "repository": {
13
14
  "type": "git",
14
15
  "url": "https://github.com/international-labour-organization/designsystem.git",
@@ -74,7 +75,7 @@
74
75
  "@ilo-org/brand-assets": "0.1.0",
75
76
  "@ilo-org/fonts": "0.1.0",
76
77
  "@ilo-org/icons-react": "0.0.18",
77
- "@ilo-org/styles": "0.1.19",
78
+ "@ilo-org/styles": "0.2.0",
78
79
  "@ilo-org/themes": "0.1.15",
79
80
  "@ilo-org/utils": "0.0.11"
80
81
  },
@@ -82,24 +83,24 @@
82
83
  "@rollup/plugin-commonjs": "^23.0.2",
83
84
  "@rollup/plugin-json": "^5.0.1",
84
85
  "@rollup/plugin-node-resolve": "^15.0.1",
85
- "@storybook/addon-a11y": "next",
86
- "@storybook/addon-actions": "next",
87
- "@storybook/addon-docs": "next",
88
- "@storybook/addon-essentials": "next",
89
- "@storybook/addon-links": "next",
86
+ "@storybook/addon-a11y": "^7.0.6",
87
+ "@storybook/addon-actions": "^7.0.6",
88
+ "@storybook/addon-docs": "^7.0.6",
89
+ "@storybook/addon-essentials": "^7.0.6",
90
+ "@storybook/addon-links": "^7.0.6",
90
91
  "@storybook/addon-postcss": "^2.0.0",
91
- "@storybook/blocks": "next",
92
- "@storybook/builder-webpack5": "next",
93
- "@storybook/client-api": "next",
94
- "@storybook/manager-api": "next",
92
+ "@storybook/blocks": "^7.0.6",
93
+ "@storybook/builder-webpack5": "^7.0.6",
94
+ "@storybook/client-api": "^7.0.6",
95
+ "@storybook/manager-api": "^7.0.6",
95
96
  "@storybook/manager-webpack5": "6.5.15",
96
- "@storybook/node-logger": "next",
97
- "@storybook/preset-create-react-app": "4.1.2",
97
+ "@storybook/node-logger": "^7.0.6",
98
+ "@storybook/preset-create-react-app": "7.0.6",
98
99
  "@storybook/preset-scss": "^1.0.3",
99
- "@storybook/react": "next",
100
- "@storybook/react-webpack5": "next",
101
- "@storybook/testing-react": "next",
102
- "@storybook/theming": "next",
100
+ "@storybook/react": "^7.0.6",
101
+ "@storybook/react-webpack5": "^7.0.6",
102
+ "@storybook/testing-react": "2.0.0",
103
+ "@storybook/theming": "^7.0.6",
103
104
  "@testing-library/jest-dom": "^5.16.5",
104
105
  "@testing-library/react": "^12.1.2",
105
106
  "@testing-library/user-event": "^13.5.0",
Binary file
@@ -12,8 +12,5 @@ const large: AccordionProps = {
12
12
  /**
13
13
  * Sample prop definitions for Accordions's enumerable properties (imported in stories and tests).
14
14
  */
15
- const AccordionArgs = {
16
- large,
17
- };
18
15
 
19
- export default AccordionArgs;
16
+ export { large };
@@ -0,0 +1,215 @@
1
+ import { CardProps } from "./Card.props";
2
+
3
+ const graphicTextCard: CardProps = {
4
+ variant: "graphic",
5
+ title: "Why we need greater social justice",
6
+ eyebrow: "Podcast",
7
+ date: {
8
+ human: "20 September 2022",
9
+ unix: "1670389200",
10
+ },
11
+ theme: "light",
12
+ link: "https:/www.ilo.org",
13
+ intro:
14
+ "A toxic combination of mutually-reinforcing crises – inflation, debt, food and fuel price rises, geopolitical tensions and conflict, climate change – are threatening to increase poverty, inequality and discrimination worldwide.",
15
+ profile: {
16
+ avatar: "/ilo-dg.jpg",
17
+ description:
18
+ "Gilbert Houngbo is the Director-General of the International Labour Organization",
19
+ name: "Gilbert Houngbo",
20
+ role: "ILO Director-General",
21
+ },
22
+ };
23
+
24
+ const statCard: CardProps = {
25
+ variant: "stat",
26
+ title: "Global employment growth down by half in 2023",
27
+ eyebrow: "Report",
28
+ intro:
29
+ "The current global economic slowdown is likely to force more workers to accept lower quality, poorly paid jobs which lack job security and social protection, so accentuating inequalities exacerbated by the COVID-19 crisis.",
30
+ color: "turquoise",
31
+ source: {
32
+ label: "World Employment and Social Outlook: Trends 2023",
33
+ url: "https://www.ilo.org",
34
+ },
35
+ };
36
+
37
+ const multilinkCard: CardProps = {
38
+ variant: "multilink",
39
+ title:
40
+ "ILO welcomes G7 call to make a just transition to a green economy happen",
41
+ eyebrow: "High-level meeting",
42
+ intro:
43
+ "At the end of their meeting the G7 Labour Ministers highlighted the urgent need to greater focus on rights and occupational safety and health.",
44
+ image: "/hero.jpg",
45
+ alignment: "left",
46
+ date: {
47
+ human: "6 September 2023",
48
+ unix: "1670389200",
49
+ },
50
+ linklist: {
51
+ headline: "",
52
+ linkgroup: [
53
+ {
54
+ links: [
55
+ {
56
+ label: "Read the press release",
57
+ url: "https://www.ilo.org",
58
+ },
59
+ {
60
+ label: "See the statement",
61
+ url: "https://www.ilo.org",
62
+ },
63
+ {
64
+ label: "Remarks to G7 Openening Session",
65
+ url: "https://www.ilo.org",
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ };
72
+
73
+ const graphicPromoCard: CardProps = {
74
+ variant: "graphicpromo",
75
+ title:
76
+ "ILO welcomes G7 call to make a just transition to a green economy happen",
77
+ eyebrow: "High-level meeting",
78
+ theme: "light",
79
+ cornercut: "cornercut",
80
+ intro:
81
+ "At the end of their meeting the G7 Labour Ministers highlighted the urgent need to greater focus on rights and occupational safety and health.",
82
+ link: "https:/www.ilo.org",
83
+ cta: {
84
+ label: "Read the press release",
85
+ url: "https://www.ilo.org",
86
+ },
87
+ };
88
+
89
+ const featureCard: CardProps = {
90
+ variant: "feature",
91
+ isvideo: false,
92
+ title:
93
+ "ILO welcomes G7 call to make a just transition to a green economy happen",
94
+ eyebrow: "High-level meeting",
95
+ theme: "light",
96
+ date: {
97
+ human: "18 March 2023",
98
+ unix: "1670389200",
99
+ },
100
+ image: "/hero.jpg",
101
+ link: "https:/www.ilo.org",
102
+ linklist: {
103
+ headline: "",
104
+ linkgroup: [
105
+ {
106
+ links: [
107
+ {
108
+ label: "Read the press release",
109
+ url: "http://www.google.com",
110
+ },
111
+ ],
112
+ },
113
+ ],
114
+ },
115
+ };
116
+
117
+ const detailCard: CardProps = {
118
+ variant: "detail",
119
+ title: "Technical meeting on digitalization in the construction sector",
120
+ eyebrow: "Meeting",
121
+ intro:
122
+ "The purpose of the meeting will be to discuss opportunities and challenges for the future of work in the construction industry as a vehicle to ensure a human-centred economic recovery.",
123
+ date: {
124
+ human: "18 March 2023",
125
+ unix: "1670389200",
126
+ },
127
+ image: "/medium.jpg",
128
+ link: "https:/www.ilo.org",
129
+ eventdetails: "8:30 - 12:00 CET | Geneva",
130
+ };
131
+
132
+ const factListCard: CardProps = {
133
+ variant: "factlist",
134
+ title:
135
+ "Economic slowdown likely to force workers to accept lower quality jobs",
136
+ eyebrow: "Report",
137
+ theme: "light",
138
+ cornercut: "cornercut",
139
+ intro:
140
+ "A toxic combination of mutually-reinforcing crises – inflation, debt, food and fuel price rises, geopolitical tensions and conflict, climate change – are threatening to increase poverty, inequality and discrimination worldwide.",
141
+ listitems: [
142
+ "Global employment growth will be only 1.0 per cent in 2023, less than half the level in 2022.",
143
+ "The labour market deterioration is mainly due to emerging geopolitical tensions and the Ukraine conflict.",
144
+ "The current slowdown means that many workers will have to accept lower quality jobs, often at very low pay.",
145
+ ],
146
+ };
147
+
148
+ const dataCard: CardProps = {
149
+ variant: "data",
150
+ title: "Technical meeting on digitalization in the construction sector",
151
+ eyebrow: "Meeting",
152
+ eventdetails:
153
+ "The purpose of the meeting will be to discuss opportunities and challenges for the future of work in the construction industry as a vehicle to ensure a human-centred economic recovery.",
154
+ dataset: {
155
+ content: {
156
+ items: [
157
+ {
158
+ label: "Date",
159
+ copy: "18 March 2023",
160
+ },
161
+ {
162
+ label: "Event type",
163
+ copy: "Technical meeting of experts",
164
+ },
165
+ ],
166
+ },
167
+ files: {
168
+ headline: "Files",
169
+ items: [
170
+ {
171
+ label: "Meeting agenda",
172
+ url: "https://www.ilo.org",
173
+ },
174
+ {
175
+ label: "Briefing notes",
176
+ url: "https://www.ilo.org",
177
+ },
178
+ {
179
+ label: "Practical info",
180
+ url: "https://www.ilo.org",
181
+ },
182
+ ],
183
+ },
184
+ links: {
185
+ headline: "Languages",
186
+ items: [
187
+ {
188
+ label: "English",
189
+ url: "https://www.ilo.org",
190
+ },
191
+ {
192
+ label: "Español",
193
+ url: "https://www.ilo.org",
194
+ },
195
+ {
196
+ label: "Français",
197
+ url: "https://www.ilo.org",
198
+ },
199
+ ],
200
+ },
201
+ },
202
+ };
203
+
204
+ const CardArgs = {
205
+ graphicTextCard,
206
+ statCard,
207
+ multilinkCard,
208
+ graphicPromoCard,
209
+ featureCard,
210
+ detailCard,
211
+ factListCard,
212
+ dataCard,
213
+ };
214
+
215
+ export default CardArgs;
@@ -0,0 +1,142 @@
1
+ import {
2
+ CardAlignment,
3
+ HeroCardTheme,
4
+ CardCornerType,
5
+ CardColor,
6
+ CardSize,
7
+ CardTypes,
8
+ } from "../../types";
9
+ import { LinkProps, LinkListProps } from "../LinkList/LinkList.props";
10
+ import { ProfileProps } from "../Profile/Profile.props";
11
+
12
+ export interface CardProps {
13
+ /**
14
+ * Specify whether the card should display a video icon (for Feature card). Possible options: true | false
15
+ */
16
+ isvideo?: boolean;
17
+
18
+ /**
19
+ * Eyebrow field for the card.
20
+ */
21
+ eyebrow: Required<string>;
22
+
23
+ /**
24
+ * Title field for the card
25
+ */
26
+ title: Required<string>;
27
+
28
+ /**
29
+ * Color of the stat cards, options are turquoise | green| yellow| blue. Only used for stat cards.
30
+ */
31
+ color?: CardColor;
32
+
33
+ /**
34
+ * The theme type for the card. Theme doesn't apply to these card types: Multilink, Data, Stat and Detail. Possible themes: light | dark.
35
+ */
36
+ theme?: HeroCardTheme;
37
+
38
+ /**
39
+ * Different variations of card: Graphic | Stat | Graphic Promo | Multilink | Feature | Detail | Fact List | Data.
40
+ */
41
+ variant: Required<CardTypes>;
42
+
43
+ /**
44
+ * Size of the cards (usually reduces padding). `Wide` on Multilink and Feature cause a two column structure above a desktop breakpoint. Possible options: Wide | Standard | Narrow.
45
+ */
46
+ size?: CardSize;
47
+
48
+ /**
49
+ * Specify whether the card has a cut corner. The only cards that use this setting are `Graphic Promo` and `Factlist`. Possible options: cornercut | corner.
50
+ */
51
+ cornercut?: CardCornerType;
52
+
53
+ /**
54
+ * Specify whether a card image is right-aligned or left-aligned for `Multilink` cards. Possible options: left | right.
55
+ */
56
+ alignment?: CardAlignment;
57
+
58
+ /**
59
+ * Intro text field for the card
60
+ */
61
+ intro?: string;
62
+
63
+ /**
64
+ * Specify the event Date, in both human and Unix format.
65
+ */
66
+ date?: EventDate;
67
+
68
+ /**
69
+ * Event details for `Detail` card
70
+ */
71
+ eventdetails?: string;
72
+
73
+ /**
74
+ * Profile to embed in the card for `Graphic Text`
75
+ */
76
+ profile?: ProfileProps;
77
+
78
+ /**
79
+ * A list of text itmes to be embed in the card, specifically used in `Factlist` card.
80
+ */
81
+ listitems?: Array<string>;
82
+
83
+ /**
84
+ * A Link behind a clickable card. Do no use on `Multilink`, `Factlist`, `Data`, or `Stat` cards.
85
+ */
86
+ link?: string;
87
+
88
+ /**
89
+ * Props of the LinkList component. Appears at the bottom of `Multilink` or `Feature` card.
90
+ */
91
+ linklist?: LinkListProps;
92
+
93
+ /**
94
+ * Items for clickable CTA button, specifically used for `Graphic Promo` card.
95
+ */
96
+ cta?: LinkProps;
97
+
98
+ /**
99
+ * The image used in a card. Images should be avoided on `Graphic Promo`, `Graphic Text`, `Factlist`, and `Stat` card.
100
+ */
101
+ image?: string;
102
+
103
+ /**
104
+ * Source link for `Stat` cards.
105
+ */
106
+ source?: LinkProps;
107
+
108
+ /**
109
+ * Dataset object for the `Data` card. An array of Content (label, copy), Files (optional headline, array of items with label and url), and Links (optional headline, array of items with label and url).
110
+ */
111
+ dataset?: CardDataset;
112
+ }
113
+
114
+ interface EventDate {
115
+ unix?: string;
116
+ human?: string;
117
+ }
118
+
119
+ interface CardDataset {
120
+ content?: DataContent;
121
+ files?: DataFile;
122
+ links?: DataLink;
123
+ }
124
+
125
+ interface DataContent {
126
+ items?: Array<ContentItem>;
127
+ }
128
+
129
+ interface ContentItem {
130
+ label?: string;
131
+ copy?: string;
132
+ }
133
+
134
+ interface DataFile {
135
+ headline?: string;
136
+ items?: Array<LinkProps>;
137
+ }
138
+
139
+ interface DataLink {
140
+ headline?: string;
141
+ items?: Array<LinkProps>;
142
+ }
@@ -0,0 +1,183 @@
1
+ import { FC } from "react";
2
+ import classnames from "classnames";
3
+ import useGlobalSettings from "../../hooks/useGlobalSettings";
4
+ import { CardProps } from "./Card.props";
5
+ import { Link } from "../Link";
6
+ import { List, ListItem } from "../List";
7
+ import { LinkList } from "../LinkList";
8
+ import { Profile } from "../Profile";
9
+
10
+ const Card: FC<CardProps> = ({
11
+ isvideo,
12
+ eyebrow,
13
+ title,
14
+ color,
15
+ theme,
16
+ variant,
17
+ size,
18
+ cornercut,
19
+ alignment,
20
+ intro,
21
+ date,
22
+ eventdetails,
23
+ profile,
24
+ listitems,
25
+ link,
26
+ linklist,
27
+ cta,
28
+ image,
29
+ source,
30
+ dataset,
31
+ }) => {
32
+ const { prefix } = useGlobalSettings();
33
+
34
+ const baseClass = `${prefix}--card`;
35
+ const cardClasses = classnames(
36
+ baseClass,
37
+ `${baseClass}--${variant}`,
38
+ `${baseClass}--${color}`,
39
+ {
40
+ [`${baseClass}--${cornercut}`]: cornercut,
41
+ [`${baseClass}--${alignment}`]: alignment,
42
+ [`${baseClass}--action`]: link,
43
+ [`${baseClass}--${size}`]: size,
44
+ [`${baseClass}--isvideo`]: isvideo,
45
+ [`${baseClass}--linklist`]: linklist,
46
+ [`${baseClass}--${theme}`]: theme,
47
+ }
48
+ );
49
+
50
+ return (
51
+ <div className={cardClasses}>
52
+ {link &&
53
+ variant != "data" &&
54
+ variant != "factlist" &&
55
+ variant != "stat" && (
56
+ <a className={`${baseClass}--link`} href={link} title={title}>
57
+ <span className={`${baseClass}--link--text`}>{title}</span>
58
+ </a>
59
+ )}
60
+ <div className={`${baseClass}--wrap`}>
61
+ {image && (
62
+ <div className={`${baseClass}--image--wrapper`}>
63
+ <picture>
64
+ <img className={`${baseClass}--image`} src={image} alt={title} />
65
+ </picture>
66
+ </div>
67
+ )}
68
+ <div className={`${baseClass}--content`}>
69
+ {eyebrow && <p className={`${baseClass}--eyebrow`}>{eyebrow}</p>}
70
+ {title && <h5 className={`${baseClass}--title`}>{title}</h5>}
71
+ {(variant == "multilink" || (variant == "data" && image)) && (
72
+ <div className={`${baseClass}--image--wrapper`}>
73
+ <picture>
74
+ <img
75
+ className={`${baseClass}--image`}
76
+ src={image}
77
+ alt={title}
78
+ />
79
+ </picture>
80
+ </div>
81
+ )}
82
+ {intro && <p className={`${baseClass}--intro`}>{intro}</p>}
83
+ {date &&
84
+ variant != "stat" &&
85
+ variant != "data" &&
86
+ variant != "graphicpromo" &&
87
+ variant != "factlist" && (
88
+ <time className={`${baseClass}--date`} dateTime={date.unix}>
89
+ {date.human}
90
+ </time>
91
+ )}
92
+ {eventdetails && (
93
+ <p className={`${baseClass}--event-date`}>{eventdetails}</p>
94
+ )}
95
+ {profile && profile.avatar && (
96
+ <Profile
97
+ avatar={profile.avatar}
98
+ description={profile.description}
99
+ link={profile.link}
100
+ name={profile.name}
101
+ role={profile.role}
102
+ className={`${prefix}--profile--contents--${theme}`}
103
+ />
104
+ )}
105
+ {listitems && (
106
+ <List alignment="default" ordered="unordered">
107
+ {listitems.map((item, index) => (
108
+ <ListItem id={`list${index}`}>
109
+ <p>{item}</p>
110
+ </ListItem>
111
+ ))}
112
+ </List>
113
+ )}
114
+ {cta && cta.label && (
115
+ <a
116
+ className={`${baseClass}--cta ${prefix}--button ${prefix}--button--medium ${prefix}--button--primary`}
117
+ href={cta.url}
118
+ >
119
+ <span className="link__label">{cta.label}</span>
120
+ </a>
121
+ )}
122
+ {source && (
123
+ <Link theme={theme} url={source.url}>
124
+ {source.label}
125
+ </Link>
126
+ )}
127
+ {linklist && (
128
+ <LinkList
129
+ headline={linklist.headline}
130
+ linkgroup={linklist.linkgroup}
131
+ />
132
+ )}
133
+ {dataset &&
134
+ dataset.content &&
135
+ dataset.content.items &&
136
+ dataset.content.items.map((item) => (
137
+ <>
138
+ <p className={`${baseClass}--data--content-label`}>
139
+ {item.label}
140
+ </p>
141
+ <p className={`${baseClass}--data--content-copy`}>
142
+ {item.copy}
143
+ </p>
144
+ </>
145
+ ))}
146
+ {dataset && dataset.files && (
147
+ <div className={`${baseClass}--data--content-files`}>
148
+ <p className={`${baseClass}--data--content-label`}>
149
+ {dataset.files.headline}
150
+ </p>
151
+ {dataset.files.items &&
152
+ dataset.files.items.map((item) => (
153
+ <a
154
+ className={`${baseClass}--data--file ${prefix}--button ${prefix}--button--primary ${prefix}--button--small`}
155
+ href={item.url}
156
+ download
157
+ >
158
+ <span className="button__label">{item.label}</span>
159
+ </a>
160
+ ))}
161
+ </div>
162
+ )}
163
+ {dataset && dataset.links && (
164
+ <div className={`${baseClass}--data--content-links`}>
165
+ <p className={`${baseClass}--data--content-label`}>
166
+ {dataset.links.headline}
167
+ </p>
168
+ {dataset.links.items &&
169
+ dataset.links.items.map((item) => (
170
+ <>
171
+ <Link url={item.url}>{item.label}</Link>
172
+ <span>&nbsp;&nbsp;</span>
173
+ </>
174
+ ))}
175
+ </div>
176
+ )}
177
+ </div>
178
+ </div>
179
+ </div>
180
+ );
181
+ };
182
+
183
+ export default Card;