@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,332 +0,0 @@
1
- /**
2
- * Copyright (c) 2021-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 { useEffect, useRef, useState } from "react";
10
- import { useTranslation } from "react-i18next";
11
- import { createListCollection } from "@ark-ui/react";
12
- import { Replay15Line, Forward15Line, PlayFill, PauseLine, VolumeUpFill, CheckLine } from "@ndla/icons";
13
- import { Button, FieldRoot, IconButton, PopoverContent, PopoverRoot, PopoverTrigger, SelectContent, SelectControl, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectRoot, SelectTrigger, SliderControl, SliderHiddenInput, SliderLabel, SliderRange, SliderRoot, SliderThumb, SliderTrack, Text } from "@ndla/primitives";
14
- import { styled } from "@ndla/styled-system/jsx";
15
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
- const ControlsWrapper = styled("div", {
17
- base: {
18
- borderBlockStart: "1px solid",
19
- borderColor: "stroke.default",
20
- borderBottomRadius: "xsmall",
21
- display: "flex",
22
- alignItems: "center",
23
- justifyContent: "center",
24
- background: "background.default",
25
- gap: "xsmall",
26
- paddingBlock: "xsmall",
27
- paddingInline: "medium",
28
- tabletWideDown: {
29
- display: "grid",
30
- paddingBlock: "xsmall",
31
- paddingInline: "xsmall",
32
- gridTemplateColumns: "1fr repeat(5, auto) 1fr",
33
- gridTemplateAreas: `
34
- "track track track track track track track"
35
- ". speed backwards play forwards volume ."
36
- `
37
- },
38
- mobileWideDown: {
39
- columnGap: "3xsmall"
40
- }
41
- }
42
- });
43
- const PlayButton = styled(IconButton, {
44
- base: {
45
- gridArea: "play"
46
- }
47
- });
48
- const Forward15SecButton = styled(IconButton, {
49
- base: {
50
- gridArea: "forwards"
51
- }
52
- });
53
- const Back15SecButton = styled(IconButton, {
54
- base: {
55
- gridArea: "backwards"
56
- }
57
- });
58
- const ProgressWrapper = styled("div", {
59
- base: {
60
- flex: "1",
61
- display: "flex",
62
- alignItems: "center",
63
- gap: "xxsmall",
64
- gridArea: "track",
65
- paddingBlock: "xsmall",
66
- mobileDown: {
67
- paddingInline: "xsmall"
68
- }
69
- }
70
- });
71
- const StyledText = styled(Text, {
72
- base: {
73
- minWidth: "xxlarge",
74
- flexShrink: "0",
75
- textAlign: "center"
76
- }
77
- });
78
- const VolumeButton = styled(IconButton, {
79
- base: {
80
- gridArea: "volume"
81
- }
82
- });
83
- const SpeedButton = styled(Button, {
84
- base: {
85
- paddingBlock: "auto",
86
- paddingInline: "auto",
87
- maxWidth: "xxlarge",
88
- maxHeight: "xxlarge",
89
- minWidth: "xxlarge",
90
- minHeight: "xxlarge",
91
- "& span": {
92
- flex: "1"
93
- }
94
- }
95
- });
96
- const StyledSelectRoot = styled(SelectRoot, {
97
- base: {
98
- gridArea: "speed"
99
- }
100
- });
101
- const StyledSliderControl = styled(SliderControl, {
102
- base: {
103
- height: "surface.3xsmall",
104
- minWidth: "small"
105
- }
106
- });
107
- const StyledPopoverContent = styled(PopoverContent, {
108
- base: {
109
- paddingInline: "small"
110
- }
111
- });
112
- const formatTime = seconds => {
113
- const minutes = Math.floor(seconds / 60);
114
- const currentSeconds = seconds % 60;
115
- const formattedSeconds = currentSeconds < 10 ? `0${currentSeconds}` : currentSeconds;
116
- return `${minutes}:${formattedSeconds}`;
117
- };
118
- const speedValues = createListCollection({
119
- items: ["0.5", "0.75", "1", "1.25", "1.5", "1.75", "2"]
120
- });
121
- const Controls = _ref => {
122
- let {
123
- src,
124
- title
125
- } = _ref;
126
- const {
127
- t
128
- } = useTranslation();
129
- const [speedValue, setSpeedValue] = useState(1);
130
- const [volumeValue, setVolumeValue] = useState(100);
131
- const [currentTime, setCurrentTime] = useState(0);
132
- const [remainingTime, setRemainingTime] = useState(0);
133
- const [playing, setPlaying] = useState(false);
134
- const audioRef = useRef(null);
135
- useEffect(() => {
136
- if (audioRef.current) {
137
- audioRef.current.playbackRate = speedValue;
138
- }
139
- }, [speedValue]);
140
- useEffect(() => {
141
- if (audioRef.current) {
142
- const audioElement = audioRef.current;
143
- const handleTimeUpdate = () => {
144
- const {
145
- currentTime,
146
- duration
147
- } = audioElement;
148
- setCurrentTime(Math.round(currentTime));
149
- setRemainingTime(Math.round(duration - currentTime));
150
- };
151
- const handleLoadedMetaData = () => {
152
- const {
153
- currentTime,
154
- duration
155
- } = audioElement;
156
- setCurrentTime(Math.round(currentTime));
157
- setRemainingTime(Math.round(duration - currentTime));
158
- };
159
- const handleTimeEnded = () => {
160
- setPlaying(false);
161
- };
162
- audioElement.addEventListener("timeupdate", handleTimeUpdate);
163
- audioElement.addEventListener("loadedmetadata", handleLoadedMetaData);
164
- audioElement.addEventListener("ended", handleTimeEnded);
165
- return () => {
166
- audioElement.removeEventListener("timeupdate", handleTimeUpdate);
167
- audioElement.removeEventListener("loadedmetadata", handleLoadedMetaData);
168
- audioElement.removeEventListener("ended", handleTimeEnded);
169
- };
170
- }
171
- }, []);
172
- const togglePlay = () => {
173
- if (audioRef.current) {
174
- const audioElement = audioRef.current;
175
- if (!playing) {
176
- audioElement.play();
177
- } else {
178
- audioElement.pause();
179
- }
180
- setPlaying(!playing);
181
- }
182
- };
183
- const onSeekSeconds = seconds => {
184
- if (audioRef.current) {
185
- audioRef.current.currentTime += seconds;
186
- }
187
- };
188
- const handleSliderChange = details => {
189
- const newValue = details.value[0];
190
- if (audioRef.current && newValue != null && !isNaN(newValue)) {
191
- audioRef.current.currentTime = details.value[0];
192
- }
193
- };
194
- const handleVolumeSliderChange = details => {
195
- if (audioRef.current) {
196
- audioRef.current.volume = details.value[0] / 100;
197
- setVolumeValue(details.value[0]);
198
- }
199
- };
200
- return /*#__PURE__*/_jsxs("div", {
201
- children: [/*#__PURE__*/_jsx("audio", {
202
- ref: audioRef,
203
- src: src,
204
- title: title,
205
- preload: "metadata"
206
- }), /*#__PURE__*/_jsxs(ControlsWrapper, {
207
- children: [/*#__PURE__*/_jsx(Back15SecButton, {
208
- variant: "tertiary",
209
- title: t("audio.controls.rewind15sec"),
210
- "aria-label": t("audio.controls.rewind15sec"),
211
- onClick: () => onSeekSeconds(-15),
212
- children: /*#__PURE__*/_jsx(Replay15Line, {})
213
- }), /*#__PURE__*/_jsx(PlayButton, {
214
- "aria-label": t(playing ? t("audio.pause") : t("audio.play")),
215
- variant: "primary",
216
- onClick: togglePlay,
217
- children: playing ? /*#__PURE__*/_jsx(PauseLine, {}) : /*#__PURE__*/_jsx(PlayFill, {})
218
- }), /*#__PURE__*/_jsx(Forward15SecButton, {
219
- variant: "tertiary",
220
- title: t("audio.controls.forward15sec"),
221
- "aria-label": t("audio.controls.forward15sec"),
222
- onClick: () => onSeekSeconds(15),
223
- children: /*#__PURE__*/_jsx(Forward15Line, {})
224
- }), /*#__PURE__*/_jsxs(ProgressWrapper, {
225
- children: [/*#__PURE__*/_jsx(StyledText, {
226
- textStyle: "label.medium",
227
- asChild: true,
228
- consumeCss: true,
229
- children: /*#__PURE__*/_jsx("div", {
230
- children: formatTime(currentTime)
231
- })
232
- }), /*#__PURE__*/_jsxs(SliderRoot, {
233
- value: [audioRef.current?.currentTime ?? 0],
234
- defaultValue: [0],
235
- step: 1,
236
- max: Math.round(audioRef.current?.duration ?? 0),
237
- onValueChange: handleSliderChange,
238
- getAriaValueText: value => t("audio.valueText", {
239
- start: formatTime(Math.round(value.value)),
240
- end: formatTime(Math.round(audioRef.current?.duration ?? 0))
241
- }),
242
- children: [/*#__PURE__*/_jsx(SliderLabel, {
243
- srOnly: true,
244
- children: t("audio.progressBar")
245
- }), /*#__PURE__*/_jsxs(SliderControl, {
246
- children: [/*#__PURE__*/_jsx(SliderTrack, {
247
- children: /*#__PURE__*/_jsx(SliderRange, {})
248
- }), /*#__PURE__*/_jsx(SliderThumb, {
249
- index: 0,
250
- children: /*#__PURE__*/_jsx(SliderHiddenInput, {})
251
- })]
252
- })]
253
- }), /*#__PURE__*/_jsx(StyledText, {
254
- textStyle: "label.medium",
255
- asChild: true,
256
- consumeCss: true,
257
- children: /*#__PURE__*/_jsxs("div", {
258
- children: ["-", formatTime(remainingTime)]
259
- })
260
- })]
261
- }), /*#__PURE__*/_jsx(FieldRoot, {
262
- children: /*#__PURE__*/_jsxs(StyledSelectRoot, {
263
- collection: speedValues,
264
- value: [speedValue.toString()],
265
- onValueChange: details => setSpeedValue(parseFloat(details.value[0])),
266
- positioning: {
267
- placement: "top"
268
- },
269
- children: [/*#__PURE__*/_jsx(SelectLabel, {
270
- srOnly: true,
271
- children: t("audio.controls.selectSpeed")
272
- }), /*#__PURE__*/_jsx(SelectControl, {
273
- children: /*#__PURE__*/_jsx(SelectTrigger, {
274
- asChild: true,
275
- children: /*#__PURE__*/_jsx(SpeedButton, {
276
- variant: "tertiary",
277
- title: t("audio.controls.selectSpeed"),
278
- "aria-label": t("audio.controls.selectSpeed"),
279
- children: /*#__PURE__*/_jsx("span", {
280
- children: `${speedValue}x`
281
- })
282
- })
283
- })
284
- }), /*#__PURE__*/_jsx(SelectContent, {
285
- children: speedValues.items.map(speed => /*#__PURE__*/_jsxs(SelectItem, {
286
- item: speed,
287
- children: [/*#__PURE__*/_jsxs(SelectItemText, {
288
- children: [speed, "x"]
289
- }), /*#__PURE__*/_jsx(SelectItemIndicator, {
290
- children: /*#__PURE__*/_jsx(CheckLine, {})
291
- })]
292
- }, speed))
293
- })]
294
- })
295
- }), /*#__PURE__*/_jsxs(PopoverRoot, {
296
- positioning: {
297
- placement: "top"
298
- },
299
- children: [/*#__PURE__*/_jsx(PopoverTrigger, {
300
- asChild: true,
301
- children: /*#__PURE__*/_jsx(VolumeButton, {
302
- variant: "tertiary",
303
- "aria-label": t("audio.controls.adjustVolume"),
304
- children: /*#__PURE__*/_jsx(VolumeUpFill, {})
305
- })
306
- }), /*#__PURE__*/_jsx(StyledPopoverContent, {
307
- children: /*#__PURE__*/_jsxs(SliderRoot, {
308
- orientation: "vertical",
309
- value: [volumeValue],
310
- min: 0,
311
- max: 100,
312
- defaultValue: [100],
313
- step: 1,
314
- onValueChange: handleVolumeSliderChange,
315
- children: [/*#__PURE__*/_jsx(SliderLabel, {
316
- srOnly: true,
317
- children: t("audio.controls.adjustVolume")
318
- }), /*#__PURE__*/_jsxs(StyledSliderControl, {
319
- children: [/*#__PURE__*/_jsx(SliderTrack, {
320
- children: /*#__PURE__*/_jsx(SliderRange, {})
321
- }), /*#__PURE__*/_jsx(SliderThumb, {
322
- index: 0,
323
- children: /*#__PURE__*/_jsx(SliderHiddenInput, {})
324
- })]
325
- })]
326
- })
327
- })]
328
- })]
329
- })]
330
- });
331
- };
332
- export default Controls;
@@ -1,56 +0,0 @@
1
- /**
2
- * Copyright (c) 2021-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 { useRef } from "react";
10
- import { useTranslation } from "react-i18next";
11
- import { VolumeUpFill } from "@ndla/icons";
12
- import { TooltipRoot, TooltipTrigger, TooltipContent, IconButton } from "@ndla/primitives";
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const SpeechControl = _ref => {
15
- let {
16
- src,
17
- title,
18
- type = "audio"
19
- } = _ref;
20
- const {
21
- t
22
- } = useTranslation();
23
- const audioRef = useRef(null);
24
- const togglePlay = () => {
25
- if (audioRef.current) {
26
- const audioElement = audioRef.current;
27
- if (audioElement.paused) {
28
- audioElement.play();
29
- } else {
30
- audioElement.pause();
31
- }
32
- }
33
- };
34
- return /*#__PURE__*/_jsxs("div", {
35
- "data-embed-type": "speech",
36
- children: [/*#__PURE__*/_jsx("audio", {
37
- ref: audioRef,
38
- src: src,
39
- title: title,
40
- preload: "metadata"
41
- }), /*#__PURE__*/_jsxs(TooltipRoot, {
42
- children: [/*#__PURE__*/_jsx(TooltipTrigger, {
43
- asChild: true,
44
- children: /*#__PURE__*/_jsx(IconButton, {
45
- variant: "tertiary",
46
- "aria-label": t(`${type}.play`),
47
- onClick: togglePlay,
48
- children: /*#__PURE__*/_jsx(VolumeUpFill, {})
49
- })
50
- }), /*#__PURE__*/_jsx(TooltipContent, {
51
- children: t(`${type}.play`)
52
- })]
53
- })]
54
- });
55
- };
56
- export default SpeechControl;
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) 2021-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 AudioPlayer from "./AudioPlayer";
10
- export default AudioPlayer;
@@ -1,60 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-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 { useTranslation } from "react-i18next";
10
- import { styled } from "@ndla/styled-system/jsx";
11
- import BreadcrumbItem from "./BreadcrumbItem";
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- const StyledList = styled("ol", {
14
- base: {
15
- display: "flex",
16
- flexWrap: "wrap",
17
- alignItems: "center",
18
- listStyle: "none",
19
- gap: "xxsmall",
20
- mobileDown: {
21
- alignItems: "flex-start",
22
- justifyContent: "center",
23
- flexDirection: "column"
24
- }
25
- }
26
- });
27
- const Breadcrumb = _ref => {
28
- let {
29
- items,
30
- renderItem,
31
- renderSeparator,
32
- collapseFirst,
33
- collapseLast = true
34
- } = _ref;
35
- const {
36
- t
37
- } = useTranslation();
38
- return /*#__PURE__*/_jsx("nav", {
39
- "aria-label": t("breadcrumb.breadcrumb"),
40
- children: /*#__PURE__*/_jsx(StyledList, {
41
- children: items.map((item, index) => /*#__PURE__*/_jsx(BreadcrumbItem, {
42
- renderItem: renderItem,
43
- renderSeparator: renderSeparator,
44
- ref: element => {
45
- if (element === null || !collapseFirst && index === 0 || !collapseLast && index === items.length - 1) {
46
- if (element) {
47
- element.setMaxWidth("none");
48
- }
49
- }
50
- },
51
- totalCount: items.length,
52
- item: {
53
- ...item,
54
- index
55
- }
56
- }, typeof item.to === "string" ? item.to : item.to.pathname))
57
- })
58
- });
59
- };
60
- export default Breadcrumb;
@@ -1,62 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-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 { useRef, useImperativeHandle, forwardRef } from "react";
10
- import { ArrowRightShortLine } from "@ndla/icons";
11
- import { SafeLink } from "@ndla/safelink";
12
- import { styled } from "@ndla/styled-system/jsx";
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const StyledListItem = styled("li", {
15
- base: {
16
- display: "flex",
17
- color: "inherit",
18
- gap: "3xsmall",
19
- alignItems: "flex-end",
20
- tabletDown: {
21
- display: "block"
22
- },
23
- "& a": {
24
- _visited: {
25
- color: "inherit"
26
- }
27
- }
28
- }
29
- });
30
- const BreadcrumbItem = /*#__PURE__*/forwardRef((_ref, ref) => {
31
- let {
32
- renderItem,
33
- renderSeparator,
34
- item,
35
- totalCount
36
- } = _ref;
37
- const liRef = useRef(null);
38
- useImperativeHandle(ref, () => ({
39
- setMaxWidth: maxWidth => {
40
- liRef.current.children[0].style.maxWidth = maxWidth;
41
- }
42
- }));
43
- const {
44
- to,
45
- name,
46
- index
47
- } = item;
48
- const isLast = index === totalCount - 1;
49
- return /*#__PURE__*/_jsxs(StyledListItem, {
50
- ref: liRef,
51
- "aria-current": isLast ? "page" : undefined,
52
- children: [renderItem ? renderItem(item, totalCount) : isLast ? /*#__PURE__*/_jsx("span", {
53
- children: name
54
- }) : /*#__PURE__*/_jsx(SafeLink, {
55
- to: to,
56
- children: /*#__PURE__*/_jsx("span", {
57
- children: name
58
- })
59
- }), renderSeparator ? renderSeparator(item, totalCount) : !isLast && /*#__PURE__*/_jsx(ArrowRightShortLine, {})]
60
- });
61
- });
62
- export default BreadcrumbItem;
@@ -1,77 +0,0 @@
1
- /**
2
- * Copyright (c) 2022-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 { ArrowRightShortLine, HomeLine } from "@ndla/icons";
10
- import { SafeLink } from "@ndla/safelink";
11
- import { styled } from "@ndla/styled-system/jsx";
12
- import Breadcrumb from "./Breadcrumb";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- const StyledSafeLink = styled(SafeLink, {
15
- base: {
16
- color: "inherit",
17
- textDecoration: "underline",
18
- _hover: {
19
- textDecoration: "none"
20
- },
21
- _focusVisible: {
22
- textDecoration: "none"
23
- }
24
- }
25
- });
26
- const StyledArrowRight = styled(ArrowRightShortLine, {
27
- base: {
28
- tabletDown: {
29
- display: "none"
30
- }
31
- }
32
- });
33
- const IconSafeLink = styled(SafeLink, {
34
- base: {
35
- color: "inherit"
36
- }
37
- });
38
- const HomeBreadcrumb = _ref => {
39
- let {
40
- items
41
- } = _ref;
42
- const renderItem = (item, totalCount) => {
43
- if (item.index === totalCount - 1) {
44
- return /*#__PURE__*/_jsx("span", {
45
- children: item.name
46
- });
47
- }
48
- if (item.index === 0 && typeof item.name === "string") {
49
- return /*#__PURE__*/_jsx(IconSafeLink, {
50
- "aria-label": item.name,
51
- to: item.to,
52
- children: /*#__PURE__*/_jsx(HomeLine, {
53
- title: item.name
54
- })
55
- });
56
- }
57
- return /*#__PURE__*/_jsx(StyledSafeLink, {
58
- to: item.to,
59
- children: item.name
60
- });
61
- };
62
- const renderSeparator = (item, totalCount) => {
63
- if (item.index === totalCount - 1) {
64
- return null;
65
- }
66
- if (item.index === 0) {
67
- return /*#__PURE__*/_jsx(StyledArrowRight, {});
68
- }
69
- return /*#__PURE__*/_jsx(ArrowRightShortLine, {});
70
- };
71
- return /*#__PURE__*/_jsx(Breadcrumb, {
72
- items: items,
73
- renderItem: renderItem,
74
- renderSeparator: renderSeparator
75
- });
76
- };
77
- export default HomeBreadcrumb;
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-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 Breadcrumb from "./Breadcrumb";
10
- export { default as HomeBreadcrumb } from "./HomeBreadcrumb";
11
- export default Breadcrumb;