@ndla/ui 37.0.1 → 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.
- package/es/ContentTypeBadge/ContentTypeBadge.js +5 -5
- package/es/Resource/BlockResource.js +9 -9
- package/es/Resource/ListResource.js +13 -9
- package/es/Resource/resourceComponents.js +12 -12
- package/es/locale/messages-en.js +7 -1
- package/es/locale/messages-nb.js +7 -1
- package/es/locale/messages-nn.js +7 -1
- package/es/locale/messages-se.js +7 -1
- package/es/locale/messages-sma.js +7 -1
- package/es/model/ContentType.js +1 -1
- package/es/model/index.js +3 -2
- package/es/utils/resourceTypeColor.js +6 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +5 -5
- package/lib/Resource/BlockResource.js +8 -8
- package/lib/Resource/ListResource.js +12 -8
- package/lib/Resource/resourceComponents.js +11 -11
- package/lib/locale/messages-en.d.ts +6 -0
- package/lib/locale/messages-en.js +7 -1
- package/lib/locale/messages-nb.d.ts +6 -0
- package/lib/locale/messages-nb.js +7 -1
- package/lib/locale/messages-nn.d.ts +6 -0
- package/lib/locale/messages-nn.js +7 -1
- package/lib/locale/messages-se.d.ts +6 -0
- package/lib/locale/messages-se.js +7 -1
- package/lib/locale/messages-sma.d.ts +6 -0
- package/lib/locale/messages-sma.js +7 -1
- package/lib/model/ContentType.d.ts +1 -1
- package/lib/model/ContentType.js +3 -3
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +2 -1
- package/lib/utils/resourceTypeColor.js +6 -0
- package/package.json +2 -2
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +5 -5
- package/src/Resource/BlockResource.tsx +6 -2
- package/src/Resource/ListResource.tsx +7 -8
- package/src/Resource/resourceComponents.tsx +4 -2
- package/src/locale/messages-en.ts +6 -0
- package/src/locale/messages-nb.ts +6 -0
- package/src/locale/messages-nn.ts +6 -0
- package/src/locale/messages-se.ts +6 -0
- package/src/locale/messages-sma.ts +6 -0
- package/src/model/ContentType.ts +1 -1
- package/src/model/index.ts +2 -1
- package/src/utils/resourceTypeColor.tsx +6 -0
package/lib/model/index.d.ts
CHANGED
package/lib/model/index.js
CHANGED
|
@@ -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.
|
|
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",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "7ebc236f35b3cd624f5fec74672ef8213d58adae"
|
|
90
90
|
}
|
|
@@ -65,19 +65,19 @@ export const ContentTypeBadge = ({ type, background, title, size = 'small', bord
|
|
|
65
65
|
case contentTypes.MULTIDISCIPLINARY_TOPIC:
|
|
66
66
|
icon = <MultidisciplinaryTopic />;
|
|
67
67
|
break;
|
|
68
|
-
case contentTypes.
|
|
68
|
+
case contentTypes.resourceEmbedTypeMapping.image:
|
|
69
69
|
icon = <Media />;
|
|
70
70
|
embedResource = true;
|
|
71
71
|
break;
|
|
72
|
-
case contentTypes.
|
|
72
|
+
case contentTypes.resourceEmbedTypeMapping.audio:
|
|
73
73
|
icon = <SquareAudio />;
|
|
74
74
|
embedResource = true;
|
|
75
75
|
break;
|
|
76
|
-
case contentTypes.
|
|
76
|
+
case contentTypes.resourceEmbedTypeMapping.video:
|
|
77
77
|
icon = <SquareVideo />;
|
|
78
78
|
embedResource = true;
|
|
79
79
|
break;
|
|
80
|
-
case contentTypes.
|
|
80
|
+
case contentTypes.resourceEmbedTypeMapping.concept:
|
|
81
81
|
icon = <Concept />;
|
|
82
82
|
embedResource = true;
|
|
83
83
|
break;
|
|
@@ -88,7 +88,7 @@ export const ContentTypeBadge = ({ type, background, title, size = 'small', bord
|
|
|
88
88
|
if (embedResource) {
|
|
89
89
|
modifiers.push('embed-resource');
|
|
90
90
|
}
|
|
91
|
-
if (background
|
|
91
|
+
if (background) {
|
|
92
92
|
modifiers.push('background');
|
|
93
93
|
}
|
|
94
94
|
if (border) {
|
|
@@ -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={
|
|
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,
|
|
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,11 +231,8 @@ const ListResource = ({
|
|
|
229
231
|
resourceImage={resourceImage}
|
|
230
232
|
loading={isLoading}
|
|
231
233
|
type={imageType}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
resourceTypeMapping[firstContentType] ??
|
|
235
|
-
contentTypeMapping['default']
|
|
236
|
-
}
|
|
234
|
+
background={!!embedResourceType}
|
|
235
|
+
contentType={contentTypeMapping[firstContentType] ?? embedResourceType ?? contentTypeMapping['default']}
|
|
237
236
|
/>
|
|
238
237
|
</ImageWrapper>
|
|
239
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 {
|
|
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
|
-
{
|
|
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',
|
package/src/model/ContentType.ts
CHANGED
|
@@ -57,7 +57,7 @@ export const contentTypeMapping: Record<string, string> = {
|
|
|
57
57
|
default: SUBJECT_MATERIAL,
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
export const
|
|
60
|
+
export const resourceEmbedTypeMapping: Record<string, string> = {
|
|
61
61
|
image: 'image',
|
|
62
62
|
video: 'video',
|
|
63
63
|
concept: 'concept',
|
package/src/model/index.ts
CHANGED
|
@@ -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
|
}
|