@ndla/ui 56.0.155-alpha.0 → 56.0.156-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 (41) hide show
  1. package/es/Article/Article.mjs +3 -2
  2. package/es/Article/Article.mjs.map +1 -1
  3. package/es/AudioPlayer/Controls.mjs +14 -13
  4. package/es/AudioPlayer/Controls.mjs.map +1 -1
  5. package/es/Embed/ImageEmbed.mjs +2 -1
  6. package/es/Embed/ImageEmbed.mjs.map +1 -1
  7. package/es/locale/messages-en.mjs +11 -1
  8. package/es/locale/messages-en.mjs.map +1 -1
  9. package/es/locale/messages-nb.mjs +11 -1
  10. package/es/locale/messages-nb.mjs.map +1 -1
  11. package/es/locale/messages-nn.mjs +11 -1
  12. package/es/locale/messages-nn.mjs.map +1 -1
  13. package/es/locale/messages-se.mjs +11 -1
  14. package/es/locale/messages-se.mjs.map +1 -1
  15. package/lib/Article/Article.d.ts +2 -1
  16. package/lib/Article/Article.js +3 -2
  17. package/lib/Article/Article.js.map +1 -1
  18. package/lib/AudioPlayer/Controls.js +14 -13
  19. package/lib/AudioPlayer/Controls.js.map +1 -1
  20. package/lib/Embed/ImageEmbed.js +2 -1
  21. package/lib/Embed/ImageEmbed.js.map +1 -1
  22. package/lib/locale/messages-en.d.ts +10 -0
  23. package/lib/locale/messages-en.js +11 -1
  24. package/lib/locale/messages-en.js.map +1 -1
  25. package/lib/locale/messages-nb.d.ts +10 -0
  26. package/lib/locale/messages-nb.js +11 -1
  27. package/lib/locale/messages-nb.js.map +1 -1
  28. package/lib/locale/messages-nn.d.ts +10 -0
  29. package/lib/locale/messages-nn.js +11 -1
  30. package/lib/locale/messages-nn.js.map +1 -1
  31. package/lib/locale/messages-se.d.ts +10 -0
  32. package/lib/locale/messages-se.js +11 -1
  33. package/lib/locale/messages-se.js.map +1 -1
  34. package/package.json +3 -3
  35. package/src/Article/Article.tsx +3 -0
  36. package/src/AudioPlayer/Controls.tsx +15 -14
  37. package/src/Embed/ImageEmbed.tsx +1 -0
  38. package/src/locale/messages-en.ts +10 -0
  39. package/src/locale/messages-nb.ts +10 -0
  40. package/src/locale/messages-nn.ts +10 -0
  41. package/src/locale/messages-se.ts +10 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
3
  "type": "module",
4
- "version": "56.0.155-alpha.0",
4
+ "version": "56.0.156-alpha.0",
5
5
  "description": "UI component library for NDLA",
6
6
  "license": "GPL-3.0",
7
7
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "@ark-ui/react": "^5.25.0",
40
40
  "@ndla/core": "^6.0.4-alpha.0",
41
41
  "@ndla/icons": "^8.0.71-alpha.0",
42
- "@ndla/licenses": "^10.0.2-alpha.0",
42
+ "@ndla/licenses": "^10.0.3-alpha.0",
43
43
  "@ndla/primitives": "^1.0.109-alpha.0",
44
44
  "@ndla/safelink": "^7.0.112-alpha.0",
45
45
  "@ndla/styled-system": "^0.0.42",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "a4a2fbf2afb8cdcb083a3e3a93bbbae3eee718d6"
65
+ "gitHead": "5a949912b848631d194d74fec102e8fe5657f194"
66
66
  }
@@ -130,6 +130,7 @@ interface ArticleTitleProps {
130
130
  title?: ReactNode;
131
131
  introduction?: ReactNode;
132
132
  disclaimer?: ReactNode;
133
+ children?: ReactNode;
133
134
  }
134
135
 
135
136
  export const ArticleTitle = ({
@@ -141,6 +142,7 @@ export const ArticleTitle = ({
141
142
  introduction,
142
143
  competenceGoals,
143
144
  disclaimer,
145
+ children,
144
146
  }: ArticleTitleProps) => {
145
147
  return (
146
148
  <ArticleHeader>
@@ -164,6 +166,7 @@ export const ArticleTitle = ({
164
166
  {competenceGoals}
165
167
  {disclaimer}
166
168
  </StyledWrapper>
169
+ {children}
167
170
  </ArticleHeader>
168
171
  );
169
172
  };
@@ -163,29 +163,23 @@ export const Controls = ({ src, title }: Props) => {
163
163
  const [speedValue, setSpeedValue] = useState(1);
164
164
  const [volumeValue, setVolumeValue] = useState(100);
165
165
  const [currentTime, setCurrentTime] = useState(0);
166
- const [remainingTime, setRemainingTime] = useState(0);
166
+ const [duration, setDuration] = useState(0);
167
167
  const [playing, setPlaying] = useState(false);
168
168
  const audioRef = useRef<HTMLAudioElement>(null);
169
169
 
170
- useEffect(() => {
171
- if (audioRef.current) {
172
- audioRef.current.playbackRate = speedValue;
173
- }
174
- }, [speedValue]);
175
-
176
170
  useEffect(() => {
177
171
  if (audioRef.current) {
178
172
  const audioElement = audioRef.current;
179
173
  const handleTimeUpdate = () => {
180
174
  const { currentTime, duration } = audioElement;
181
175
  setCurrentTime(Math.round(currentTime));
182
- setRemainingTime(Math.round(duration - currentTime));
176
+ setDuration(Math.round(duration));
183
177
  };
184
178
 
185
179
  const handleLoadedMetaData = () => {
186
180
  const { currentTime, duration } = audioElement;
187
181
  setCurrentTime(Math.round(currentTime));
188
- setRemainingTime(Math.round(duration - currentTime));
182
+ setDuration(Math.round(duration));
189
183
  };
190
184
 
191
185
  const handleTimeEnded = () => {
@@ -215,6 +209,13 @@ export const Controls = ({ src, title }: Props) => {
215
209
  }
216
210
  };
217
211
 
212
+ const onPlaybackRateChange = (rate: number) => {
213
+ setSpeedValue(rate);
214
+ if (audioRef.current) {
215
+ audioRef.current.playbackRate = rate;
216
+ }
217
+ };
218
+
218
219
  const onSeekSeconds = (seconds: number) => {
219
220
  if (audioRef.current) {
220
221
  audioRef.current.currentTime += seconds;
@@ -265,15 +266,15 @@ export const Controls = ({ src, title }: Props) => {
265
266
  <div>{formatTime(currentTime)}</div>
266
267
  </StyledText>
267
268
  <SliderRoot
268
- value={[audioRef.current?.currentTime || 0]}
269
+ value={[currentTime]}
269
270
  defaultValue={[0]}
270
271
  step={1}
271
- max={Math.round(audioRef.current?.duration || 0)}
272
+ max={duration}
272
273
  onValueChange={handleSliderChange}
273
274
  getAriaValueText={(value) =>
274
275
  t("audio.valueText", {
275
276
  start: formatTime(Math.round(value.value)),
276
- end: formatTime(Math.round(audioRef.current?.duration ?? 0)),
277
+ end: formatTime(Math.round(duration)),
277
278
  })
278
279
  }
279
280
  >
@@ -288,14 +289,14 @@ export const Controls = ({ src, title }: Props) => {
288
289
  </SliderControl>
289
290
  </SliderRoot>
290
291
  <StyledText textStyle="label.medium" asChild consumeCss>
291
- <div>-{formatTime(remainingTime)}</div>
292
+ <div>-{formatTime(Math.round(duration - currentTime))}</div>
292
293
  </StyledText>
293
294
  </ProgressWrapper>
294
295
  <FieldRoot>
295
296
  <StyledSelectRoot
296
297
  collection={speedValues}
297
298
  value={[speedValue.toString()]}
298
- onValueChange={(details) => setSpeedValue(parseFloat(details.value[0]))}
299
+ onValueChange={(details) => onPlaybackRateChange(parseFloat(details.value[0]))}
299
300
  positioning={{ placement: "top" }}
300
301
  >
301
302
  <SelectLabel srOnly>{t("audio.controls.selectSpeed")}</SelectLabel>
@@ -244,6 +244,7 @@ export const ImageEmbed = ({ embed, previewAlt, lang, renderContext = "article",
244
244
  lang={lang}
245
245
  onClick={figureProps?.float ? toggleImageSize : undefined}
246
246
  variant="rounded"
247
+ {...data.image.dimensions}
247
248
  />
248
249
  {(embedData.align === "right" || embedData.align === "left") && (
249
250
  <ExpandButton
@@ -465,6 +465,16 @@ const messages = {
465
465
  link: "Link ({{shortcut}})",
466
466
  },
467
467
  },
468
+ articleTraits: {
469
+ VIDEO: "Video",
470
+ AUDIO: "Audio",
471
+ H5P: "Interactive content",
472
+ PODCAST: "Podcast",
473
+ },
474
+ relevance: {
475
+ core: "Core content",
476
+ supplementary: "Supplementary content",
477
+ },
468
478
  };
469
479
 
470
480
  export default messages;
@@ -466,6 +466,16 @@ const messages = {
466
466
  link: "Lenke ({{shortcut}})",
467
467
  },
468
468
  },
469
+ articleTraits: {
470
+ VIDEO: "Video",
471
+ AUDIO: "Lyd",
472
+ H5P: "Interaktivt innhold",
473
+ PODCAST: "Podkast",
474
+ },
475
+ relevance: {
476
+ core: "Kjernestoff",
477
+ supplementary: "Tilleggsstoff",
478
+ },
469
479
  };
470
480
 
471
481
  export default messages;
@@ -466,6 +466,16 @@ const messages = {
466
466
  link: "Lenke ({{shortcut}})",
467
467
  },
468
468
  },
469
+ articleTraits: {
470
+ VIDEO: "Video",
471
+ AUDIO: "Lyd",
472
+ H5P: "Interaktivt innhald",
473
+ PODCAST: "Podkast",
474
+ },
475
+ relevance: {
476
+ core: "Kjernestoff",
477
+ supplementary: "Tilleggsstoff",
478
+ },
469
479
  };
470
480
 
471
481
  export default messages;
@@ -467,6 +467,16 @@ const messages = {
467
467
  link: "Lenke ({{shortcut}})",
468
468
  },
469
469
  },
470
+ articleTraits: {
471
+ VIDEO: "Video",
472
+ AUDIO: "Lyd",
473
+ H5P: "Interaktivt innhold",
474
+ PODCAST: "Podkast",
475
+ },
476
+ relevance: {
477
+ core: "Kjernestoff",
478
+ supplementary: "Tilleggsstoff",
479
+ },
470
480
  };
471
481
 
472
482
  export default messages;