@ndla/ui 37.0.0 → 37.0.2

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 (56) hide show
  1. package/es/ContentTypeBadge/ContentTypeBadge.js +27 -6
  2. package/es/Embed/BrightcoveEmbed.js +10 -9
  3. package/es/Embed/H5pEmbed.js +2 -2
  4. package/es/Embed/RelatedContentEmbed.js +3 -3
  5. package/es/Resource/BlockResource.js +9 -9
  6. package/es/Resource/ListResource.js +14 -10
  7. package/es/Resource/resourceComponents.js +12 -12
  8. package/es/all.css +1 -1
  9. package/es/locale/messages-en.js +7 -1
  10. package/es/locale/messages-nb.js +7 -1
  11. package/es/locale/messages-nn.js +7 -1
  12. package/es/locale/messages-se.js +7 -1
  13. package/es/locale/messages-sma.js +7 -1
  14. package/es/model/ContentType.js +1 -1
  15. package/es/model/index.js +3 -2
  16. package/es/utils/resourceTypeColor.js +6 -0
  17. package/lib/ContentTypeBadge/ContentTypeBadge.js +27 -6
  18. package/lib/Embed/BrightcoveEmbed.js +10 -9
  19. package/lib/Embed/H5pEmbed.js +2 -2
  20. package/lib/Embed/RelatedContentEmbed.js +3 -3
  21. package/lib/Resource/BlockResource.js +8 -8
  22. package/lib/Resource/ListResource.js +13 -9
  23. package/lib/Resource/resourceComponents.js +11 -11
  24. package/lib/all.css +1 -1
  25. package/lib/locale/messages-en.d.ts +6 -0
  26. package/lib/locale/messages-en.js +7 -1
  27. package/lib/locale/messages-nb.d.ts +6 -0
  28. package/lib/locale/messages-nb.js +7 -1
  29. package/lib/locale/messages-nn.d.ts +6 -0
  30. package/lib/locale/messages-nn.js +7 -1
  31. package/lib/locale/messages-se.d.ts +6 -0
  32. package/lib/locale/messages-se.js +7 -1
  33. package/lib/locale/messages-sma.d.ts +6 -0
  34. package/lib/locale/messages-sma.js +7 -1
  35. package/lib/model/ContentType.d.ts +1 -1
  36. package/lib/model/ContentType.js +3 -3
  37. package/lib/model/index.d.ts +1 -0
  38. package/lib/model/index.js +2 -1
  39. package/lib/utils/resourceTypeColor.js +6 -0
  40. package/package.json +3 -3
  41. package/src/ContentTypeBadge/ContentTypeBadge.tsx +29 -6
  42. package/src/ContentTypeBadge/component.content-type-badge.scss +9 -3
  43. package/src/Embed/BrightcoveEmbed.tsx +5 -4
  44. package/src/Embed/H5pEmbed.tsx +1 -1
  45. package/src/Embed/RelatedContentEmbed.tsx +3 -1
  46. package/src/Resource/BlockResource.tsx +6 -2
  47. package/src/Resource/ListResource.tsx +7 -4
  48. package/src/Resource/resourceComponents.tsx +4 -2
  49. package/src/locale/messages-en.ts +6 -0
  50. package/src/locale/messages-nb.ts +6 -0
  51. package/src/locale/messages-nn.ts +6 -0
  52. package/src/locale/messages-se.ts +6 -0
  53. package/src/locale/messages-sma.ts +6 -0
  54. package/src/model/ContentType.ts +1 -1
  55. package/src/model/index.ts +2 -1
  56. package/src/utils/resourceTypeColor.tsx +6 -0
@@ -931,6 +931,12 @@ declare const messages: {
931
931
  'assessment-resources': string;
932
932
  topic: string;
933
933
  'multidisciplinary-topic': string;
934
+ image: string;
935
+ concept: string;
936
+ audio: string;
937
+ podcast: string;
938
+ h5p: string;
939
+ video: string;
934
940
  };
935
941
  modal: {
936
942
  closeModal: string;
@@ -659,7 +659,13 @@ var messages = _objectSpread(_objectSpread({
659
659
  'source-material': 'Source material',
660
660
  'assessment-resources': 'Assessment resource',
661
661
  topic: 'Topic',
662
- 'multidisciplinary-topic': 'Multidisciplinary case'
662
+ 'multidisciplinary-topic': 'Multidisciplinary case',
663
+ image: 'Image',
664
+ concept: 'Concept',
665
+ audio: 'Audio',
666
+ podcast: 'Podcast',
667
+ h5p: 'H5P',
668
+ video: 'Video'
663
669
  },
664
670
  modal: {
665
671
  closeModal: 'Close'
@@ -931,6 +931,12 @@ declare const messages: {
931
931
  'assessment-resources': string;
932
932
  topic: string;
933
933
  'multidisciplinary-topic': string;
934
+ image: string;
935
+ concept: string;
936
+ audio: string;
937
+ podcast: string;
938
+ h5p: string;
939
+ video: string;
934
940
  };
935
941
  modal: {
936
942
  closeModal: string;
@@ -659,7 +659,13 @@ var messages = _objectSpread(_objectSpread({
659
659
  'source-material': 'Kildemateriale',
660
660
  'assessment-resources': 'Vurderingsressurs',
661
661
  topic: 'Emne',
662
- 'multidisciplinary-topic': 'Tverrfaglig case'
662
+ 'multidisciplinary-topic': 'Tverrfaglig case',
663
+ image: 'Bilde',
664
+ concept: 'Forklaring',
665
+ audio: 'Lyd',
666
+ podcast: 'Podkast',
667
+ h5p: 'H5P',
668
+ video: 'Video'
663
669
  },
664
670
  modal: {
665
671
  closeModal: 'Lukk'
@@ -931,6 +931,12 @@ declare const messages: {
931
931
  'assessment-resources': string;
932
932
  topic: string;
933
933
  'multidisciplinary-topic': string;
934
+ image: string;
935
+ concept: string;
936
+ audio: string;
937
+ podcast: string;
938
+ h5p: string;
939
+ video: string;
934
940
  };
935
941
  modal: {
936
942
  closeModal: string;
@@ -659,7 +659,13 @@ var messages = _objectSpread(_objectSpread({
659
659
  'source-material': 'Kjeldemateriale',
660
660
  'assessment-resources': 'Vurderingsressurs',
661
661
  topic: 'Emne',
662
- 'multidisciplinary-topic': 'Tverrfagleg case'
662
+ 'multidisciplinary-topic': 'Tverrfagleg case',
663
+ image: 'Bilde',
664
+ concept: 'Forklaring',
665
+ audio: 'Lyd',
666
+ podcast: 'Podkast',
667
+ h5p: 'H5P',
668
+ video: 'Video'
663
669
  },
664
670
  modal: {
665
671
  closeModal: 'Lukk'
@@ -931,6 +931,12 @@ declare const messages: {
931
931
  'assessment-resources': string;
932
932
  topic: string;
933
933
  'multidisciplinary-topic': string;
934
+ image: string;
935
+ concept: string;
936
+ audio: string;
937
+ podcast: string;
938
+ h5p: string;
939
+ video: string;
934
940
  };
935
941
  modal: {
936
942
  closeModal: string;
@@ -659,7 +659,13 @@ var messages = _objectSpread(_objectSpread({
659
659
  'source-material': 'Gáldomateriála',
660
660
  'assessment-resources': 'Árvoštallanresursa',
661
661
  topic: 'Fáddá',
662
- 'multidisciplinary-topic': 'Fágaidrasttideaddji fáddá'
662
+ 'multidisciplinary-topic': 'Fágaidrasttideaddji fáddá',
663
+ image: 'Bilde',
664
+ concept: 'Forklaring',
665
+ audio: 'Lyd',
666
+ podcast: 'Podkast',
667
+ h5p: 'H5P',
668
+ video: 'Video'
663
669
  },
664
670
  modal: {
665
671
  closeModal: 'Govčča'
@@ -931,6 +931,12 @@ declare const messages: {
931
931
  'assessment-resources': string;
932
932
  topic: string;
933
933
  'multidisciplinary-topic': string;
934
+ image: string;
935
+ concept: string;
936
+ audio: string;
937
+ podcast: string;
938
+ h5p: string;
939
+ video: string;
934
940
  };
935
941
  modal: {
936
942
  closeModal: string;
@@ -659,7 +659,13 @@ var messages = _objectSpread(_objectSpread({
659
659
  'source-material': 'Gaaltijevierhtieh',
660
660
  'assessment-resources': 'Vuarjasjimmievierhtie',
661
661
  topic: 'Teema',
662
- 'multidisciplinary-topic': 'Tverrfaglig case'
662
+ 'multidisciplinary-topic': 'Tverrfaglig case',
663
+ image: 'Bilde',
664
+ concept: 'Forklaring',
665
+ audio: 'Lyd',
666
+ podcast: 'Podkast',
667
+ h5p: 'H5P',
668
+ video: 'Video'
663
669
  },
664
670
  modal: {
665
671
  closeModal: 'Dahph'
@@ -33,4 +33,4 @@ export declare const RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES = "urn:resourcety
33
33
  export declare const RESOURCE_TYPE_SOURCE_MATERIAL = "urn:resourcetype:SourceMaterial";
34
34
  export declare const ListOfContentTypes: string[];
35
35
  export declare const contentTypeMapping: Record<string, string>;
36
- export declare const resourceTypeMapping: Record<string, string>;
36
+ export declare const resourceEmbedTypeMapping: Record<string, string>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceTypeMapping = exports.contentTypes = exports.contentTypeMapping = exports.TOPIC = exports.TASKS_AND_ACTIVITIES = exports.SUBJECT_MATERIAL = exports.SUBJECT = exports.SOURCE_MATERIAL = exports.RESOURCE_TYPE_TASKS_AND_ACTIVITIES = exports.RESOURCE_TYPE_SUBJECT_MATERIAL = exports.RESOURCE_TYPE_SOURCE_MATERIAL = exports.RESOURCE_TYPE_LEARNING_PATH = exports.RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES = exports.RESOURCE_TYPE_ASSESSMENT_RESOURCES = exports.MULTIDISCIPLINARY_TOPIC = exports.ListOfContentTypes = exports.LEARNING_PATH = exports.EXTERNAL_LEARNING_RESOURCES = exports.ASSESSMENT_RESOURCES = void 0;
6
+ exports.resourceEmbedTypeMapping = exports.contentTypes = exports.contentTypeMapping = exports.TOPIC = exports.TASKS_AND_ACTIVITIES = exports.SUBJECT_MATERIAL = exports.SUBJECT = exports.SOURCE_MATERIAL = exports.RESOURCE_TYPE_TASKS_AND_ACTIVITIES = exports.RESOURCE_TYPE_SUBJECT_MATERIAL = exports.RESOURCE_TYPE_SOURCE_MATERIAL = exports.RESOURCE_TYPE_LEARNING_PATH = exports.RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES = exports.RESOURCE_TYPE_ASSESSMENT_RESOURCES = exports.MULTIDISCIPLINARY_TOPIC = exports.ListOfContentTypes = exports.LEARNING_PATH = exports.EXTERNAL_LEARNING_RESOURCES = exports.ASSESSMENT_RESOURCES = void 0;
7
7
  var _contentTypeMapping;
8
8
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
9
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -63,10 +63,10 @@ var ListOfContentTypes = ['SUBJECT_MATERIAL', 'TASKS_AND_ACTIVITIES', 'ASSESSMEN
63
63
  exports.ListOfContentTypes = ListOfContentTypes;
64
64
  var contentTypeMapping = (_contentTypeMapping = {}, _defineProperty(_contentTypeMapping, RESOURCE_TYPE_LEARNING_PATH, LEARNING_PATH), _defineProperty(_contentTypeMapping, RESOURCE_TYPE_SUBJECT_MATERIAL, SUBJECT_MATERIAL), _defineProperty(_contentTypeMapping, RESOURCE_TYPE_TASKS_AND_ACTIVITIES, TASKS_AND_ACTIVITIES), _defineProperty(_contentTypeMapping, RESOURCE_TYPE_ASSESSMENT_RESOURCES, ASSESSMENT_RESOURCES), _defineProperty(_contentTypeMapping, RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES, EXTERNAL_LEARNING_RESOURCES), _defineProperty(_contentTypeMapping, RESOURCE_TYPE_SOURCE_MATERIAL, SOURCE_MATERIAL), _defineProperty(_contentTypeMapping, "default", SUBJECT_MATERIAL), _contentTypeMapping);
65
65
  exports.contentTypeMapping = contentTypeMapping;
66
- var resourceTypeMapping = {
66
+ var resourceEmbedTypeMapping = {
67
67
  image: 'image',
68
68
  video: 'video',
69
69
  concept: 'concept',
70
70
  audio: 'audio'
71
71
  };
72
- exports.resourceTypeMapping = resourceTypeMapping;
72
+ exports.resourceEmbedTypeMapping = resourceEmbedTypeMapping;
@@ -22,5 +22,6 @@ declare const model: {
22
22
  subjectCategories: typeof subjectCategories;
23
23
  subjectTypes: typeof subjectTypes;
24
24
  contentTypeMapping: Record<string, string>;
25
+ resourceEmbedTypeMapping: Record<string, string>;
25
26
  };
26
27
  export default model;
@@ -22,7 +22,8 @@ var model = {
22
22
  contentTypes: _ContentType.contentTypes,
23
23
  subjectCategories: subjectCategories,
24
24
  subjectTypes: subjectTypes,
25
- contentTypeMapping: _ContentType.contentTypeMapping
25
+ contentTypeMapping: _ContentType.contentTypeMapping,
26
+ resourceEmbedTypeMapping: _ContentType.resourceEmbedTypeMapping
26
27
  };
27
28
  var _default = model;
28
29
  exports["default"] = _default;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.resourceTypeColor = exports["default"] = void 0;
7
7
  var _core = require("@ndla/core");
8
8
  var _model = _interopRequireDefault(require("../model"));
9
+ var _ContentType = require("../model/ContentType");
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
11
  /**
11
12
  * Copyright (c) 2022-present, NDLA.
@@ -36,6 +37,11 @@ var resourceTypeColor = function resourceTypeColor(type) {
36
37
  return _core.colors.learningPath.light;
37
38
  case contentTypes.MULTIDISCIPLINARY_TOPIC:
38
39
  return _core.colors.learningPath.background;
40
+ case _ContentType.resourceEmbedTypeMapping.image:
41
+ case _ContentType.resourceEmbedTypeMapping.video:
42
+ case _ContentType.resourceEmbedTypeMapping.concept:
43
+ case _ContentType.resourceEmbedTypeMapping.audio:
44
+ return _core.colors.brand.greyLight;
39
45
  default:
40
46
  return '';
41
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "37.0.0",
3
+ "version": "37.0.2",
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": "7ebc236f35b3cd624f5fec74672ef8213d58adae"
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.resourceEmbedTypeMapping.image:
69
+ icon = <Media />;
70
+ embedResource = true;
71
+ break;
72
+ case contentTypes.resourceEmbedTypeMapping.audio:
73
+ icon = <SquareAudio />;
74
+ embedResource = true;
75
+ break;
76
+ case contentTypes.resourceEmbedTypeMapping.video:
77
+ icon = <SquareVideo />;
78
+ embedResource = true;
79
+ break;
80
+ case contentTypes.resourceEmbedTypeMapping.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) {
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
  StyledContentIconWrapper,
23
23
  } from './resourceComponents';
24
24
  import ContentLoader from '../ContentLoader';
25
- import { contentTypeMapping } from '../model/ContentType';
25
+ import { contentTypeMapping, resourceEmbedTypeMapping } from '../model/ContentType';
26
26
  import { SettingsMenu } from '../MyNdla';
27
27
 
28
28
  const BlockElementWrapper = styled.div`
@@ -174,7 +174,11 @@ const BlockResource = ({
174
174
  <BlockImage
175
175
  image={resourceImage}
176
176
  loading={isLoading}
177
- contentType={contentTypeMapping[firstResourceType] ?? contentTypeMapping['default']}
177
+ contentType={
178
+ contentTypeMapping[firstResourceType] ??
179
+ resourceEmbedTypeMapping[firstResourceType] ??
180
+ contentTypeMapping['default']
181
+ }
178
182
  />
179
183
  </ImageWrapper>
180
184
  <BlockInfoWrapper>
@@ -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, resourceEmbedTypeMapping } from '../model/ContentType';
26
26
  import { SettingsMenu } from '../MyNdla';
27
27
 
28
28
  const ListResourceWrapper = styled.div`
@@ -131,14 +131,15 @@ interface ListResourceImageProps {
131
131
  loading?: boolean;
132
132
  type: 'normal' | 'compact';
133
133
  contentType: string;
134
+ background?: boolean;
134
135
  }
135
136
 
136
- const ListResourceImage = ({ resourceImage, loading, type, contentType }: ListResourceImageProps) => {
137
+ const ListResourceImage = ({ resourceImage, loading, type, contentType, background }: ListResourceImageProps) => {
137
138
  if (!loading) {
138
139
  if (resourceImage.src === '') {
139
140
  return (
140
141
  <StyledContentIconWrapper contentType={contentType}>
141
- <ContentTypeBadge type={contentType} size="x-small" />
142
+ <ContentTypeBadge type={contentType} background={background} size="x-small" />
142
143
  </StyledContentIconWrapper>
143
144
  );
144
145
  } else {
@@ -221,6 +222,7 @@ const ListResource = ({
221
222
  const showDescription = description !== undefined;
222
223
  const imageType = showDescription ? 'normal' : 'compact';
223
224
  const firstContentType = resourceTypes?.[0]?.id ?? '';
225
+ const embedResourceType = resourceEmbedTypeMapping[firstContentType];
224
226
 
225
227
  return (
226
228
  <ListResourceWrapper id={id}>
@@ -229,7 +231,8 @@ const ListResource = ({
229
231
  resourceImage={resourceImage}
230
232
  loading={isLoading}
231
233
  type={imageType}
232
- contentType={contentTypeMapping[firstContentType] ?? contentTypeMapping['default']}
234
+ background={!!embedResourceType}
235
+ contentType={contentTypeMapping[firstContentType] ?? embedResourceType ?? contentTypeMapping['default']}
233
236
  />
234
237
  </ImageWrapper>
235
238
  <TopicAndTitleWrapper>
@@ -15,7 +15,7 @@ import SafeLink from '@ndla/safelink';
15
15
  import { useNavigate } from 'react-router-dom';
16
16
  import { HashTag } from '@ndla/icons/common';
17
17
  import resourceTypeColor from '../utils/resourceTypeColor';
18
- import { resourceTypeMapping } from '../model/ContentType';
18
+ import { resourceEmbedTypeMapping } from '../model/ContentType';
19
19
 
20
20
  export interface ResourceImageProps {
21
21
  alt: string;
@@ -198,7 +198,9 @@ export const ResourceTypeList = ({ resourceTypes }: ResourceTypeListProps) => {
198
198
  <StyledResourceTypeList aria-label={t('navigation.topics')}>
199
199
  {resourceTypes.map((resource, i) => (
200
200
  <StyledResourceListElement key={resource.id}>
201
- {resourceTypeMapping[resource.id] ? t(`embed.type.${resourceTypeMapping[resource.id]}`) : resource.name}
201
+ {resourceEmbedTypeMapping[resource.id]
202
+ ? t(`embed.type.${resourceEmbedTypeMapping[resource.id]}`)
203
+ : resource.name}
202
204
  {i !== resourceTypes.length - 1 && <StyledTopicDivider aria-hidden="true">•</StyledTopicDivider>}
203
205
  </StyledResourceListElement>
204
206
  ))}
@@ -694,6 +694,12 @@ const messages = {
694
694
  'assessment-resources': 'Assessment resource',
695
695
  topic: 'Topic',
696
696
  'multidisciplinary-topic': 'Multidisciplinary case',
697
+ image: 'Image',
698
+ concept: 'Concept',
699
+ audio: 'Audio',
700
+ podcast: 'Podcast',
701
+ h5p: 'H5P',
702
+ video: 'Video',
697
703
  },
698
704
  modal: {
699
705
  closeModal: 'Close',
@@ -693,6 +693,12 @@ const messages = {
693
693
  'assessment-resources': 'Vurderingsressurs',
694
694
  topic: 'Emne',
695
695
  'multidisciplinary-topic': 'Tverrfaglig case',
696
+ image: 'Bilde',
697
+ concept: 'Forklaring',
698
+ audio: 'Lyd',
699
+ podcast: 'Podkast',
700
+ h5p: 'H5P',
701
+ video: 'Video',
696
702
  },
697
703
  modal: {
698
704
  closeModal: 'Lukk',
@@ -693,6 +693,12 @@ const messages = {
693
693
  'assessment-resources': 'Vurderingsressurs',
694
694
  topic: 'Emne',
695
695
  'multidisciplinary-topic': 'Tverrfagleg case',
696
+ image: 'Bilde',
697
+ concept: 'Forklaring',
698
+ audio: 'Lyd',
699
+ podcast: 'Podkast',
700
+ h5p: 'H5P',
701
+ video: 'Video',
696
702
  },
697
703
  modal: {
698
704
  closeModal: 'Lukk',
@@ -694,6 +694,12 @@ const messages = {
694
694
  'assessment-resources': 'Árvoštallanresursa',
695
695
  topic: 'Fáddá',
696
696
  'multidisciplinary-topic': 'Fágaidrasttideaddji fáddá',
697
+ image: 'Bilde',
698
+ concept: 'Forklaring',
699
+ audio: 'Lyd',
700
+ podcast: 'Podkast',
701
+ h5p: 'H5P',
702
+ video: 'Video',
697
703
  },
698
704
  modal: {
699
705
  closeModal: 'Govčča',
@@ -697,6 +697,12 @@ const messages = {
697
697
  'assessment-resources': 'Vuarjasjimmievierhtie',
698
698
  topic: 'Teema',
699
699
  'multidisciplinary-topic': 'Tverrfaglig case',
700
+ image: 'Bilde',
701
+ concept: 'Forklaring',
702
+ audio: 'Lyd',
703
+ podcast: 'Podkast',
704
+ h5p: 'H5P',
705
+ video: 'Video',
700
706
  },
701
707
  modal: {
702
708
  closeModal: 'Dahph',
@@ -57,7 +57,7 @@ export const contentTypeMapping: Record<string, string> = {
57
57
  default: SUBJECT_MATERIAL,
58
58
  };
59
59
 
60
- export const resourceTypeMapping: Record<string, string> = {
60
+ export const resourceEmbedTypeMapping: Record<string, string> = {
61
61
  image: 'image',
62
62
  video: 'video',
63
63
  concept: 'concept',
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { contentTypes, contentTypeMapping } from './ContentType';
9
+ import { contentTypes, contentTypeMapping, resourceEmbedTypeMapping } from './ContentType';
10
10
  import * as subjectCategories from './SubjectCategories';
11
11
  import * as subjectTypes from './SubjectTypes';
12
12
 
@@ -15,6 +15,7 @@ const model = {
15
15
  subjectCategories,
16
16
  subjectTypes,
17
17
  contentTypeMapping,
18
+ resourceEmbedTypeMapping,
18
19
  };
19
20
 
20
21
  export default model;
@@ -8,6 +8,7 @@
8
8
 
9
9
  import { colors } from '@ndla/core';
10
10
  import constants from '../model';
11
+ import { resourceEmbedTypeMapping } from '../model/ContentType';
11
12
  const { contentTypes } = constants;
12
13
 
13
14
  export const resourceTypeColor = (type: string) => {
@@ -30,6 +31,11 @@ export const resourceTypeColor = (type: string) => {
30
31
  return colors.learningPath.light;
31
32
  case contentTypes.MULTIDISCIPLINARY_TOPIC:
32
33
  return colors.learningPath.background;
34
+ case resourceEmbedTypeMapping.image:
35
+ case resourceEmbedTypeMapping.video:
36
+ case resourceEmbedTypeMapping.concept:
37
+ case resourceEmbedTypeMapping.audio:
38
+ return colors.brand.greyLight;
33
39
  default:
34
40
  return '';
35
41
  }