@ndla/ui 37.0.0 → 37.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "37.0.0",
3
+ "version": "37.0.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -75,7 +75,7 @@
75
75
  "devDependencies": {
76
76
  "@babel/plugin-proposal-optional-chaining": "^7.11.0",
77
77
  "@ndla/types-backend": "^0.2.5",
78
- "@ndla/types-embed": "^2.0.0",
78
+ "@ndla/types-embed": "^2.0.1",
79
79
  "@types/reach__dialog": "^0.1.0",
80
80
  "css-loader": "^6.7.3",
81
81
  "mini-css-extract-plugin": "^2.7.5",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "3961942d13c313b37bba92395f6a430ed31dc954"
89
+ "gitHead": "38258e7be60bc71be478fe407775f43bfa505d7b"
90
90
  }
@@ -13,6 +13,7 @@ import {
13
13
  } from '@ndla/icons/contentType';
14
14
 
15
15
  import { MenuBook } from '@ndla/icons/action';
16
+ import { Concept, Media, SquareAudio, SquareVideo } from '@ndla/icons/editor';
16
17
 
17
18
  import * as contentTypes from '../model/ContentType';
18
19
 
@@ -32,12 +33,8 @@ interface Props {
32
33
 
33
34
  export const ContentTypeBadge = ({ type, background, title, size = 'small', border = true, className }: Props) => {
34
35
  const modifiers = [type, size];
35
- if (background) {
36
- modifiers.push('background');
37
- }
38
- if (border) {
39
- modifiers.push('border');
40
- }
36
+
37
+ let embedResource = false;
41
38
 
42
39
  let icon = null;
43
40
  switch (type) {
@@ -68,9 +65,35 @@ export const ContentTypeBadge = ({ type, background, title, size = 'small', bord
68
65
  case contentTypes.MULTIDISCIPLINARY_TOPIC:
69
66
  icon = <MultidisciplinaryTopic />;
70
67
  break;
68
+ case contentTypes.resourceTypeMapping.image:
69
+ icon = <Media />;
70
+ embedResource = true;
71
+ break;
72
+ case contentTypes.resourceTypeMapping.audio:
73
+ icon = <SquareAudio />;
74
+ embedResource = true;
75
+ break;
76
+ case contentTypes.resourceTypeMapping.video:
77
+ icon = <SquareVideo />;
78
+ embedResource = true;
79
+ break;
80
+ case contentTypes.resourceTypeMapping.concept:
81
+ icon = <Concept />;
82
+ embedResource = true;
83
+ break;
71
84
  default:
72
85
  break;
73
86
  }
87
+
88
+ if (embedResource) {
89
+ modifiers.push('embed-resource');
90
+ }
91
+ if (background || embedResource) {
92
+ modifiers.push('background');
93
+ }
94
+ if (border) {
95
+ modifiers.push('border');
96
+ }
74
97
  return <div {...classes('', modifiers, className)}>{icon}</div>;
75
98
  };
76
99
 
@@ -6,10 +6,16 @@
6
6
  justify-content: center;
7
7
  border-radius: 100%;
8
8
  &--border {
9
-
10
9
  border: 2px solid $black;
11
10
  }
12
11
 
12
+ &--embed-resource {
13
+ border-color: $brand-grey;
14
+ &.c-content-type-badge--background {
15
+ background: $brand-grey--light;
16
+ }
17
+ }
18
+
13
19
  &--subject-material {
14
20
  border-color: $subject-material-dark;
15
21
 
@@ -165,9 +171,9 @@
165
171
  background: $subjecttype-background;
166
172
  }
167
173
  }
168
- &--multidisciplinary-topic{
174
+ &--multidisciplinary-topic {
169
175
  &.c-content-type-badge--background {
170
- background: #B9B37B;
176
+ background: #b9b37b;
171
177
  }
172
178
  }
173
179
 
@@ -61,6 +61,7 @@ const BrightcoveEmbed = ({ embed, isConcept, heartButton: HeartButton }: Props)
61
61
  const { t } = useTranslation();
62
62
  const iframeRef = useRef<HTMLIFrameElement>(null);
63
63
  const { embedData } = embed;
64
+ const fallbackTitle = `${t('embed.type.video')}: ${embedData.videoid}`;
64
65
 
65
66
  useEffect(() => {
66
67
  const iframe = iframeRef.current;
@@ -76,8 +77,8 @@ const BrightcoveEmbed = ({ embed, isConcept, heartButton: HeartButton }: Props)
76
77
  <EmbedErrorPlaceholder type="video">
77
78
  <BrightcoveIframe
78
79
  ref={iframeRef}
79
- title={`Video: ${embedData.videoid ?? ''}`}
80
- aria-label={`Video: ${embedData.videoid ?? ''}`}
80
+ title={embedData.alt ?? fallbackTitle}
81
+ aria-label={embedData.alt ?? fallbackTitle}
81
82
  frameBorder="0"
82
83
  {...getIframeProps(embedData, [])}
83
84
  allowFullScreen
@@ -101,8 +102,8 @@ const BrightcoveEmbed = ({ embed, isConcept, heartButton: HeartButton }: Props)
101
102
  <BrightcoveIframe
102
103
  ref={iframeRef}
103
104
  className="original"
104
- title={`Video: ${data.name}`}
105
- aria-label={`Video: ${data.name}`}
105
+ title={embedData.alt ?? data.name ?? fallbackTitle}
106
+ aria-label={embedData.alt ?? data.name ?? fallbackTitle}
106
107
  frameBorder="0"
107
108
  {...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps)}
108
109
  allowFullScreen
@@ -30,7 +30,7 @@ const H5pEmbed = ({ embed, isConcept }: Props) => {
30
30
  const classes = `c-figure ${fullColumnClass} c-figure--resize`;
31
31
 
32
32
  if (embed.data.oembed) {
33
- return <StyledFigure className={classes} dangerouslySetInnerHTML={{ __html: embed.data.oembed.html ?? '' }} />;
33
+ return <figure className={classes} dangerouslySetInnerHTML={{ __html: embed.data.oembed.html ?? '' }} />;
34
34
  }
35
35
 
36
36
  return (
@@ -30,7 +30,9 @@ const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }: P
30
30
  const typeId = data.resource?.resourceTypes.find((rt) => contentTypeMapping[rt.id])?.id;
31
31
  const type = typeId ? contentTypeMapping[typeId] : undefined;
32
32
  const path =
33
- data.resource?.paths.find((p) => p.split('/')[1] === subject?.replace('urn:', '')) ?? data.resource?.path;
33
+ data.resource?.paths.find((p) => p.split('/')[1] === subject?.replace('urn:', '')) ??
34
+ data.resource?.path ??
35
+ `/article/${embedData.articleId}`;
34
36
  return (
35
37
  <RelatedArticleV2
36
38
  title={data.article.title?.title ?? ''}
@@ -22,7 +22,7 @@ import {
22
22
  } from './resourceComponents';
23
23
  import ContentLoader from '../ContentLoader';
24
24
  import ContentTypeBadge from '../ContentTypeBadge';
25
- import { contentTypeMapping } from '../model/ContentType';
25
+ import { contentTypeMapping, resourceTypeMapping } from '../model/ContentType';
26
26
  import { SettingsMenu } from '../MyNdla';
27
27
 
28
28
  const ListResourceWrapper = styled.div`
@@ -229,7 +229,11 @@ const ListResource = ({
229
229
  resourceImage={resourceImage}
230
230
  loading={isLoading}
231
231
  type={imageType}
232
- contentType={contentTypeMapping[firstContentType] ?? contentTypeMapping['default']}
232
+ contentType={
233
+ contentTypeMapping[firstContentType] ??
234
+ resourceTypeMapping[firstContentType] ??
235
+ contentTypeMapping['default']
236
+ }
233
237
  />
234
238
  </ImageWrapper>
235
239
  <TopicAndTitleWrapper>