@ndla/ui 56.0.121-alpha.0 → 56.0.122-alpha.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 (206) hide show
  1. package/lib/i18n/index.d.ts +1 -1
  2. package/lib/i18n/useComponentTranslations.d.ts +2 -1
  3. package/lib/index.d.ts +1 -1
  4. package/lib/locale/messages-en.d.ts +34 -0
  5. package/lib/locale/messages-nb.d.ts +34 -0
  6. package/lib/locale/messages-nn.d.ts +34 -0
  7. package/lib/locale/messages-se.d.ts +34 -0
  8. package/package.json +6 -5
  9. package/src/Article/ArticleByline.tsx +1 -1
  10. package/src/i18n/index.ts +1 -0
  11. package/src/i18n/useComponentTranslations.ts +36 -1
  12. package/src/index.ts +1 -0
  13. package/src/locale/messages-en.ts +34 -0
  14. package/src/locale/messages-nb.ts +34 -0
  15. package/src/locale/messages-nn.ts +34 -0
  16. package/src/locale/messages-se.ts +34 -0
  17. package/es/Article/Article.js +0 -199
  18. package/es/Article/ArticleByline.js +0 -182
  19. package/es/Article/ArticleFootNotes.js +0 -60
  20. package/es/Article/index.js +0 -11
  21. package/es/AudioPlayer/AudioPlayer.js +0 -218
  22. package/es/AudioPlayer/Controls.js +0 -332
  23. package/es/AudioPlayer/SpeechControl.js +0 -56
  24. package/es/AudioPlayer/index.js +0 -10
  25. package/es/Breadcrumb/Breadcrumb.js +0 -60
  26. package/es/Breadcrumb/BreadcrumbItem.js +0 -62
  27. package/es/Breadcrumb/HomeBreadcrumb.js +0 -77
  28. package/es/Breadcrumb/index.js +0 -11
  29. package/es/CampaignBlock/CampaignBlock.js +0 -180
  30. package/es/CampaignBlock/index.js +0 -9
  31. package/es/CodeBlock/CodeBlock.js +0 -35
  32. package/es/CodeBlock/codeLanguageOptions.js +0 -84
  33. package/es/CodeBlock/index.js +0 -10
  34. package/es/Concept/Concept.js +0 -72
  35. package/es/ContactBlock/ContactBlock.js +0 -199
  36. package/es/ContactBlock/index.js +0 -9
  37. package/es/ContentTypeBadge/ContentTypeBadge.js +0 -50
  38. package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -32
  39. package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -32
  40. package/es/ContentTypeHero/ContentTypeHero.js +0 -50
  41. package/es/ContentTypeHero/index.js +0 -9
  42. package/es/CopyParagraphButton/CopyParagraphButton.js +0 -83
  43. package/es/CopyParagraphButton/index.js +0 -11
  44. package/es/Embed/AudioEmbed.js +0 -76
  45. package/es/Embed/BrightcoveEmbed.js +0 -133
  46. package/es/Embed/CodeEmbed.js +0 -79
  47. package/es/Embed/ConceptEmbed.js +0 -123
  48. package/es/Embed/ConceptInlineTriggerButton.js +0 -45
  49. package/es/Embed/ContentLinkEmbed.js +0 -51
  50. package/es/Embed/CopyrightEmbed.js +0 -33
  51. package/es/Embed/EmbedErrorPlaceholder.js +0 -58
  52. package/es/Embed/EmbedWrapper.js +0 -51
  53. package/es/Embed/ExternalEmbed.js +0 -74
  54. package/es/Embed/FootnoteEmbed.js +0 -44
  55. package/es/Embed/GlossEmbed.js +0 -80
  56. package/es/Embed/H5pEmbed.js +0 -61
  57. package/es/Embed/IframeEmbed.js +0 -93
  58. package/es/Embed/ImageEmbed.js +0 -238
  59. package/es/Embed/InlineTriggerButton.js +0 -37
  60. package/es/Embed/RelatedContentEmbed.js +0 -55
  61. package/es/Embed/UnknownEmbed.js +0 -31
  62. package/es/Embed/UuDisclaimerEmbed.js +0 -88
  63. package/es/Embed/index.js +0 -25
  64. package/es/Embed/types.js +0 -1
  65. package/es/ErrorMessage/ErrorMessage.js +0 -95
  66. package/es/ErrorMessage/index.js +0 -10
  67. package/es/FactBox/FactBox.js +0 -177
  68. package/es/FactBox/index.js +0 -10
  69. package/es/FileList/File.js +0 -101
  70. package/es/FileList/FileList.js +0 -47
  71. package/es/FileList/PdfFile.js +0 -50
  72. package/es/FileList/index.js +0 -11
  73. package/es/Gloss/Gloss.js +0 -175
  74. package/es/Gloss/GlossExample.js +0 -64
  75. package/es/Gloss/index.js +0 -10
  76. package/es/Grid/Grid.js +0 -94
  77. package/es/Grid/GridParallaxItem.js +0 -32
  78. package/es/Grid/index.js +0 -10
  79. package/es/KeyFigure/KeyFigure.js +0 -63
  80. package/es/KeyFigure/index.js +0 -9
  81. package/es/LicenseByline/EmbedByline.js +0 -212
  82. package/es/LicenseByline/LicenseLink.js +0 -56
  83. package/es/LicenseByline/index.js +0 -10
  84. package/es/LinkBlock/LinkBlock.js +0 -103
  85. package/es/LinkBlock/LinkBlockSection.js +0 -35
  86. package/es/LinkBlock/index.js +0 -10
  87. package/es/Pitch/Pitch.js +0 -83
  88. package/es/Pitch/index.js +0 -9
  89. package/es/RelatedArticleList/RelatedArticleList.js +0 -135
  90. package/es/RelatedArticleList/index.js +0 -11
  91. package/es/ResourceBox/ResourceBox.js +0 -99
  92. package/es/ResourceBox/index.js +0 -10
  93. package/es/TagSelector/TagSelector.js +0 -143
  94. package/es/ZendeskButton/ZendeskButton.js +0 -55
  95. package/es/i18n/formatNestedMessages.js +0 -25
  96. package/es/i18n/i18n.js +0 -35
  97. package/es/i18n/index.js +0 -11
  98. package/es/i18n/useComponentTranslations.js +0 -164
  99. package/es/index.js +0 -45
  100. package/es/locale/messages-en.js +0 -428
  101. package/es/locale/messages-nb.js +0 -428
  102. package/es/locale/messages-nn.js +0 -428
  103. package/es/locale/messages-se.js +0 -428
  104. package/es/model/ContentType.js +0 -68
  105. package/es/model/SubjectCategories.js +0 -12
  106. package/es/model/SubjectTypes.js +0 -11
  107. package/es/model/WordClass.js +0 -45
  108. package/es/model/index.js +0 -21
  109. package/es/types.js +0 -1
  110. package/es/utils/licenseAttributes.js +0 -18
  111. package/es/utils/relativeUrl.js +0 -37
  112. package/lib/Article/Article.js +0 -207
  113. package/lib/Article/ArticleByline.js +0 -189
  114. package/lib/Article/ArticleFootNotes.js +0 -67
  115. package/lib/Article/index.js +0 -68
  116. package/lib/AudioPlayer/AudioPlayer.js +0 -224
  117. package/lib/AudioPlayer/Controls.js +0 -338
  118. package/lib/AudioPlayer/SpeechControl.js +0 -62
  119. package/lib/AudioPlayer/index.js +0 -16
  120. package/lib/Breadcrumb/Breadcrumb.js +0 -67
  121. package/lib/Breadcrumb/BreadcrumbItem.js +0 -68
  122. package/lib/Breadcrumb/HomeBreadcrumb.js +0 -84
  123. package/lib/Breadcrumb/index.js +0 -23
  124. package/lib/CampaignBlock/CampaignBlock.js +0 -187
  125. package/lib/CampaignBlock/index.js +0 -13
  126. package/lib/CodeBlock/CodeBlock.js +0 -41
  127. package/lib/CodeBlock/codeLanguageOptions.js +0 -90
  128. package/lib/CodeBlock/index.js +0 -20
  129. package/lib/Concept/Concept.js +0 -78
  130. package/lib/ContactBlock/ContactBlock.js +0 -206
  131. package/lib/ContactBlock/index.js +0 -18
  132. package/lib/ContentTypeBadge/ContentTypeBadge.js +0 -57
  133. package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -38
  134. package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -38
  135. package/lib/ContentTypeHero/ContentTypeHero.js +0 -57
  136. package/lib/ContentTypeHero/index.js +0 -12
  137. package/lib/CopyParagraphButton/CopyParagraphButton.js +0 -89
  138. package/lib/CopyParagraphButton/index.js +0 -22
  139. package/lib/Embed/AudioEmbed.js +0 -84
  140. package/lib/Embed/BrightcoveEmbed.js +0 -142
  141. package/lib/Embed/CodeEmbed.js +0 -86
  142. package/lib/Embed/ConceptEmbed.js +0 -131
  143. package/lib/Embed/ConceptInlineTriggerButton.js +0 -51
  144. package/lib/Embed/ContentLinkEmbed.js +0 -57
  145. package/lib/Embed/CopyrightEmbed.js +0 -39
  146. package/lib/Embed/EmbedErrorPlaceholder.js +0 -64
  147. package/lib/Embed/EmbedWrapper.js +0 -57
  148. package/lib/Embed/ExternalEmbed.js +0 -81
  149. package/lib/Embed/FootnoteEmbed.js +0 -50
  150. package/lib/Embed/GlossEmbed.js +0 -88
  151. package/lib/Embed/H5pEmbed.js +0 -68
  152. package/lib/Embed/IframeEmbed.js +0 -100
  153. package/lib/Embed/ImageEmbed.js +0 -248
  154. package/lib/Embed/InlineTriggerButton.js +0 -43
  155. package/lib/Embed/RelatedContentEmbed.js +0 -61
  156. package/lib/Embed/UnknownEmbed.js +0 -37
  157. package/lib/Embed/UuDisclaimerEmbed.js +0 -94
  158. package/lib/Embed/index.js +0 -150
  159. package/lib/Embed/types.js +0 -5
  160. package/lib/ErrorMessage/ErrorMessage.js +0 -101
  161. package/lib/ErrorMessage/index.js +0 -16
  162. package/lib/FactBox/FactBox.js +0 -184
  163. package/lib/FactBox/index.js +0 -16
  164. package/lib/FileList/File.js +0 -108
  165. package/lib/FileList/FileList.js +0 -54
  166. package/lib/FileList/PdfFile.js +0 -57
  167. package/lib/FileList/index.js +0 -44
  168. package/lib/Gloss/Gloss.js +0 -181
  169. package/lib/Gloss/GlossExample.js +0 -70
  170. package/lib/Gloss/index.js +0 -20
  171. package/lib/Grid/Grid.js +0 -101
  172. package/lib/Grid/GridParallaxItem.js +0 -39
  173. package/lib/Grid/index.js +0 -19
  174. package/lib/KeyFigure/KeyFigure.js +0 -70
  175. package/lib/KeyFigure/index.js +0 -13
  176. package/lib/LicenseByline/EmbedByline.js +0 -220
  177. package/lib/LicenseByline/LicenseLink.js +0 -62
  178. package/lib/LicenseByline/index.js +0 -19
  179. package/lib/LinkBlock/LinkBlock.js +0 -110
  180. package/lib/LinkBlock/LinkBlockSection.js +0 -41
  181. package/lib/LinkBlock/index.js +0 -20
  182. package/lib/Pitch/Pitch.js +0 -91
  183. package/lib/Pitch/index.js +0 -12
  184. package/lib/RelatedArticleList/RelatedArticleList.js +0 -143
  185. package/lib/RelatedArticleList/index.js +0 -21
  186. package/lib/ResourceBox/ResourceBox.js +0 -106
  187. package/lib/ResourceBox/index.js +0 -13
  188. package/lib/TagSelector/TagSelector.js +0 -150
  189. package/lib/ZendeskButton/ZendeskButton.js +0 -61
  190. package/lib/i18n/formatNestedMessages.js +0 -32
  191. package/lib/i18n/i18n.js +0 -41
  192. package/lib/i18n/index.js +0 -62
  193. package/lib/i18n/useComponentTranslations.js +0 -176
  194. package/lib/index.js +0 -593
  195. package/lib/locale/messages-en.js +0 -435
  196. package/lib/locale/messages-nb.js +0 -435
  197. package/lib/locale/messages-nn.js +0 -435
  198. package/lib/locale/messages-se.js +0 -435
  199. package/lib/model/ContentType.js +0 -74
  200. package/lib/model/SubjectCategories.js +0 -18
  201. package/lib/model/SubjectTypes.js +0 -17
  202. package/lib/model/WordClass.js +0 -51
  203. package/lib/model/index.js +0 -28
  204. package/lib/types.js +0 -5
  205. package/lib/utils/licenseAttributes.js +0 -25
  206. package/lib/utils/relativeUrl.js +0 -44
@@ -1,182 +0,0 @@
1
- /**
2
- * Copyright (c) 2020-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { forwardRef, useCallback, useEffect, useState } from "react";
10
- import { useTranslation } from "react-i18next";
11
- import { useLocation } from "react-router";
12
- import { ArrowDownShortLine } from "@ndla/icons";
13
- import { AccordionItem, AccordionItemContent, AccordionItemIndicator, AccordionItemTrigger, AccordionRoot, Heading } from "@ndla/primitives";
14
- import { styled } from "@ndla/styled-system/jsx";
15
- import { ArticleFootNotes } from "./ArticleFootNotes";
16
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
17
- const Wrapper = styled("div", {
18
- base: {
19
- // TODO: Figure out if we want to remove this margin. It's only here to add some gap between the article content and the byline.
20
- marginBlockStart: "medium",
21
- paddingBlockStart: "xsmall",
22
- borderTop: "1px solid",
23
- borderColor: "stroke.subtle"
24
- }
25
- });
26
- const TextWrapper = styled("div", {
27
- base: {
28
- display: "flex",
29
- flexDirection: "column",
30
- gap: "3xsmall",
31
- width: "100%",
32
- justifyContent: "space-between",
33
- paddingBlock: "xsmall",
34
- textStyle: "body.medium",
35
- '& [data-contributors="false"]': {
36
- marginInlineStart: "auto"
37
- }
38
- },
39
- variants: {
40
- learningpath: {
41
- true: {},
42
- false: {
43
- tabletWide: {
44
- flexDirection: "row"
45
- }
46
- }
47
- }
48
- }
49
- });
50
- const renderContributors = (contributors, t) => {
51
- const contributorsArray = contributors.map((contributor, index) => {
52
- if (index < 1) return contributor.name;
53
- const sep = index === contributors.length - 1 ? ` ${t("article.conjunction")} ` : ", ";
54
- return `${sep}${contributor.name}`;
55
- });
56
- return contributorsArray.join("");
57
- };
58
- const getSuppliersText = (suppliers, t) => {
59
- if (suppliers.length === 0) {
60
- return "";
61
- }
62
- return suppliers.length > 1 ? t("article.multipleSuppliersLabel", {
63
- names: renderContributors(suppliers, t),
64
- interpolation: {
65
- escapeValue: false
66
- }
67
- }) : t("article.supplierLabel", {
68
- name: renderContributors(suppliers, t),
69
- interpolation: {
70
- escapeValue: false
71
- }
72
- });
73
- };
74
- const StyledAccordionRoot = styled(AccordionRoot, {
75
- base: {
76
- paddingBlockStart: "xxlarge"
77
- }
78
- });
79
- const refRegexp = /note\d/;
80
- const footnotesAccordionId = "footnotes";
81
- export const ArticleByline = _ref => {
82
- let {
83
- authors = [],
84
- suppliers = [],
85
- footnotes,
86
- licenseBox,
87
- published,
88
- displayByline = true,
89
- bylineType = "article",
90
- bylineSuffix
91
- } = _ref;
92
- const {
93
- t
94
- } = useTranslation();
95
- const {
96
- pathname
97
- } = useLocation();
98
- const [openAccordions, setOpenAccordions] = useState([]);
99
- const accordionItemValue = "rulesForUse";
100
- const onHashChange = useCallback(e => {
101
- const hash = e.newURL.split("#")[1];
102
- if (hash?.match(refRegexp) && !openAccordions.includes(footnotesAccordionId)) {
103
- setOpenAccordions([...openAccordions, footnotesAccordionId]);
104
- const el = document.getElementById(`#${hash}`);
105
- el?.click();
106
- el?.focus();
107
- }
108
- }, [openAccordions]);
109
- useEffect(() => {
110
- setOpenAccordions(prev => prev.filter(state => state !== accordionItemValue));
111
- }, [pathname]);
112
- useEffect(() => {
113
- window.addEventListener("hashchange", onHashChange);
114
- return () => window.removeEventListener("hashchange", onHashChange);
115
- }, [onHashChange]);
116
- const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;
117
- const authorLabel = {
118
- article: "article.authorsLabel",
119
- learningPath: "article.authorsLabelLearningpath",
120
- external: "article.authorsLabelExternal"
121
- };
122
- return /*#__PURE__*/_jsxs(Wrapper, {
123
- children: [!!displayByline && /*#__PURE__*/_jsxs(TextWrapper, {
124
- learningpath: bylineType === "learningPath",
125
- children: [!!showPrimaryContributors && /*#__PURE__*/_jsxs("span", {
126
- children: [authors.length > 0 && `${t(authorLabel[bylineType], {
127
- names: renderContributors(authors, t),
128
- interpolation: {
129
- escapeValue: false
130
- }
131
- })}. `, getSuppliersText(suppliers, t)]
132
- }), published ? /*#__PURE__*/_jsxs("div", {
133
- "data-contributors": showPrimaryContributors,
134
- children: [t(`${bylineType}.lastUpdated`), " ", published]
135
- }) : null, bylineSuffix]
136
- }), (!!licenseBox || !!footnotes?.length) && /*#__PURE__*/_jsxs(StyledAccordionRoot, {
137
- multiple: true,
138
- value: openAccordions,
139
- onValueChange: details => setOpenAccordions(details.value),
140
- children: [!!licenseBox && /*#__PURE__*/_jsx(ArticleBylineAccordionItem, {
141
- value: accordionItemValue,
142
- accordionTitle: t("article.useContent"),
143
- children: licenseBox
144
- }), !!footnotes?.length && /*#__PURE__*/_jsx(ArticleBylineAccordionItem, {
145
- value: footnotesAccordionId,
146
- accordionTitle: t("article.footnotes"),
147
- children: /*#__PURE__*/_jsx(ArticleFootNotes, {
148
- footNotes: footnotes
149
- })
150
- })]
151
- })]
152
- });
153
- };
154
- export const ArticleBylineAccordionItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
155
- let {
156
- value,
157
- accordionTitle,
158
- children,
159
- ...props
160
- } = _ref2;
161
- return /*#__PURE__*/_jsxs(AccordionItem, {
162
- value: value,
163
- ref: ref,
164
- ...props,
165
- children: [/*#__PURE__*/_jsx(Heading, {
166
- asChild: true,
167
- consumeCss: true,
168
- textStyle: "label.medium",
169
- fontWeight: "bold",
170
- children: /*#__PURE__*/_jsx("h2", {
171
- children: /*#__PURE__*/_jsxs(AccordionItemTrigger, {
172
- children: [accordionTitle, /*#__PURE__*/_jsx(AccordionItemIndicator, {
173
- asChild: true,
174
- children: /*#__PURE__*/_jsx(ArrowDownShortLine, {})
175
- })]
176
- })
177
- })
178
- }), /*#__PURE__*/_jsx(AccordionItemContent, {
179
- children: children
180
- })]
181
- });
182
- });
@@ -1,60 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { Text } from "@ndla/primitives";
10
- import { styled } from "@ndla/styled-system/jsx";
11
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
- const citeDetailString = description => description ? `${description}. ` : "";
13
- const StyledCite = styled("cite", {
14
- base: {
15
- display: "flex",
16
- alignItems: "center",
17
- gap: "xsmall"
18
- }
19
- });
20
- const FootNote = _ref => {
21
- let {
22
- footNote
23
- } = _ref;
24
- return /*#__PURE__*/_jsx("li", {
25
- children: /*#__PURE__*/_jsx(Text, {
26
- id: `note${footNote.ref}`,
27
- asChild: true,
28
- consumeCss: true,
29
- textStyle: "body.medium",
30
- children: /*#__PURE__*/_jsxs(StyledCite, {
31
- children: [/*#__PURE__*/_jsx("a", {
32
- href: `#ref${footNote.ref}`,
33
- target: "_self",
34
- children: footNote.ref
35
- }), `«${footNote.title}». ${footNote.authors.join(" ")}. ${citeDetailString(footNote.edition)}${citeDetailString(footNote.publisher)}${footNote.year}. `, footNote.url ? /*#__PURE__*/_jsxs("a", {
36
- href: footNote.url,
37
- children: [footNote.url, "."]
38
- }) : null]
39
- })
40
- })
41
- });
42
- };
43
- const FootnoteList = styled("ol", {
44
- base: {
45
- display: "flex",
46
- flexDirection: "column",
47
- gap: "medium",
48
- listStyle: "none"
49
- }
50
- });
51
- export const ArticleFootNotes = _ref2 => {
52
- let {
53
- footNotes
54
- } = _ref2;
55
- return /*#__PURE__*/_jsx(FootnoteList, {
56
- children: footNotes.map(footNote => /*#__PURE__*/_jsx(FootNote, {
57
- footNote: footNote
58
- }, footNote.ref))
59
- });
60
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- export { Article, ArticleWrapper, ArticleHeader, ArticleFooter, ArticleTitle, ArticleHGroup, ArticleContent } from "./Article";
10
- export { ArticleByline, ArticleBylineAccordionItem } from "./ArticleByline";
11
- export { ArticleFootNotes } from "./ArticleFootNotes";
@@ -1,218 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { useId, useMemo, useState } from "react";
10
- import { useTranslation } from "react-i18next";
11
- import { Heading, Text, Button } from "@ndla/primitives";
12
- import { SafeLink } from "@ndla/safelink";
13
- import { styled } from "@ndla/styled-system/jsx";
14
- import Controls from "./Controls";
15
- import SpeechControl from "./SpeechControl";
16
-
17
- // TODO: Could the audio metadata be more tightly coupled to the audio player?
18
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
- const AudioPlayerWrapper = styled("div", {
20
- base: {
21
- border: "1px solid",
22
- borderColor: "stroke.default",
23
- borderRadius: "xsmall",
24
- boxShadow: "full",
25
- marginBlockEnd: "4xsmall",
26
- overflow: "hidden"
27
- }
28
- });
29
- const InfoWrapper = styled("div", {
30
- base: {
31
- display: "flex",
32
- tabletWideDown: {
33
- display: "block"
34
- }
35
- }
36
- });
37
- const ImageWrapper = styled("div", {
38
- base: {
39
- display: "flex",
40
- alignItems: "center",
41
- flex: "1 0 auto",
42
- width: "surface.4xsmall",
43
- height: "surface.4xsmall",
44
- overflow: "hidden",
45
- "& img": {
46
- width: "100%",
47
- height: "100%",
48
- objectFit: "cover"
49
- },
50
- desktop: {
51
- width: "260px",
52
- height: "260px"
53
- },
54
- tabletWideDown: {
55
- maxHeight: "surface.small",
56
- maxWidth: "100%",
57
- width: "100%",
58
- height: "auto"
59
- }
60
- }
61
- });
62
- const TextWrapper = styled("div", {
63
- base: {
64
- display: "flex",
65
- alignItems: "flex-start",
66
- flexDirection: "column",
67
- gap: "xsmall",
68
- padding: "xsmall",
69
- width: "100%",
70
- "&[data-has-image='true']": {
71
- tablet: {
72
- paddingBlock: "xsmall",
73
- paddingInline: "medium"
74
- }
75
- }
76
- }
77
- });
78
- const TitleWrapper = styled("div", {
79
- base: {
80
- display: "flex",
81
- flexDirection: "column",
82
- gap: "xsmall",
83
- fontFamily: "sans",
84
- tabletWide: {
85
- width: "100%",
86
- flexDirection: "row",
87
- justifyContent: "space-between"
88
- }
89
- }
90
- });
91
- const TextVersionWrapper = styled("div", {
92
- base: {
93
- display: "flex",
94
- flexDirection: "column",
95
- gap: "xsmall",
96
- borderBlockStart: "1px solid",
97
- borderColor: "stroke.default",
98
- paddingBlock: "medium",
99
- paddingInline: "xsmall",
100
- tablet: {
101
- paddingInline: "medium"
102
- }
103
- }
104
- });
105
- const TextVersionText = styled("div", {
106
- base: {
107
- maxWidth: "surface.xlarge",
108
- "& span > *": {
109
- whiteSpace: "pre-wrap"
110
- },
111
- "& p:not(:first-child):not(:last-child)": {
112
- marginBlock: "small"
113
- },
114
- '& p[data-align="center"]': {
115
- textAlign: "center"
116
- },
117
- '& p:has(span[dir="rtl"])': {
118
- direction: "rtl"
119
- }
120
- }
121
- });
122
- const TextVersionButton = styled(Button, {
123
- base: {
124
- alignSelf: "flex-start"
125
- }
126
- });
127
- const ShowMoreButton = styled(Button, {
128
- base: {
129
- marginInlineStart: "3xsmall"
130
- }
131
- });
132
- const DESCRIPTION_MAX_LENGTH = 200;
133
- const AudioPlayer = _ref => {
134
- let {
135
- src,
136
- title,
137
- subtitle,
138
- speech,
139
- description,
140
- img,
141
- textVersion
142
- } = _ref;
143
- const {
144
- t
145
- } = useTranslation();
146
- const [showTextVersion, setShowTextVersion] = useState(false);
147
- const [showFullDescription, setShowFullDescription] = useState(false);
148
- const truncatedDescription = useMemo(() => description?.slice(0, DESCRIPTION_MAX_LENGTH), [description]);
149
- const textDescriptionId = useId();
150
- if (speech) {
151
- return /*#__PURE__*/_jsx(SpeechControl, {
152
- src: src,
153
- title: title
154
- });
155
- }
156
- const toggleTextVersion = () => {
157
- setShowTextVersion(curr => !curr);
158
- };
159
- const textVersionButton = /*#__PURE__*/_jsx(TextVersionButton, {
160
- variant: "secondary",
161
- "aria-expanded": showTextVersion,
162
- "aria-controls": textDescriptionId,
163
- size: "small",
164
- onClick: toggleTextVersion,
165
- children: t(showTextVersion ? "audio.textVersion.close" : "audio.textVersion.heading")
166
- });
167
- return /*#__PURE__*/_jsxs(AudioPlayerWrapper, {
168
- children: [/*#__PURE__*/_jsxs(InfoWrapper, {
169
- children: [!!img && /*#__PURE__*/_jsx(ImageWrapper, {
170
- children: /*#__PURE__*/_jsx("img", {
171
- src: img.url,
172
- alt: img.alt
173
- })
174
- }), /*#__PURE__*/_jsxs(TextWrapper, {
175
- "data-has-image": !!img,
176
- children: [/*#__PURE__*/_jsxs(TitleWrapper, {
177
- children: [/*#__PURE__*/_jsxs("div", {
178
- children: [subtitle?.url ? /*#__PURE__*/_jsx(SafeLink, {
179
- to: subtitle.url,
180
- children: subtitle.title
181
- }) : subtitle?.title, /*#__PURE__*/_jsx(Heading, {
182
- asChild: true,
183
- consumeCss: true,
184
- textStyle: "title.large",
185
- children: /*#__PURE__*/_jsx("h3", {
186
- children: title
187
- })
188
- })]
189
- }), !!textVersion && !img && textVersionButton]
190
- }), !!description && /*#__PURE__*/_jsxs(Text, {
191
- textStyle: "body.medium",
192
- children: [showFullDescription || description.length < DESCRIPTION_MAX_LENGTH ? description : `${truncatedDescription}...`, description.length > DESCRIPTION_MAX_LENGTH && /*#__PURE__*/_jsx(ShowMoreButton, {
193
- variant: "link",
194
- onClick: () => setShowFullDescription(p => !p),
195
- children: t(`audio.${showFullDescription ? "readLessDescriptionLabel" : "readMoreDescriptionLabel"}`)
196
- })]
197
- }), !!textVersion && !!img && textVersionButton]
198
- })]
199
- }), /*#__PURE__*/_jsx(Controls, {
200
- src: src,
201
- title: title
202
- }), !!textVersion && /*#__PURE__*/_jsxs(TextVersionWrapper, {
203
- id: textDescriptionId,
204
- hidden: !showTextVersion,
205
- children: [/*#__PURE__*/_jsx(Heading, {
206
- asChild: true,
207
- textStyle: "title.medium",
208
- consumeCss: true,
209
- children: /*#__PURE__*/_jsx("h4", {
210
- children: t("audio.textVersion.heading")
211
- })
212
- }), /*#__PURE__*/_jsx(TextVersionText, {
213
- children: textVersion
214
- })]
215
- })]
216
- });
217
- };
218
- export default AudioPlayer;