@ndla/ui 27.1.5 → 27.1.7
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/Article/ArticleByline.js +38 -7
- package/es/Breadcrumb/ActionBreadcrumb.js +5 -4
- package/es/Breadcrumb/Breadcrumb.js +12 -4
- package/es/Resource/BlockResource.js +31 -18
- package/es/Resource/ListResource.js +32 -21
- package/es/Resource/resourceComponents.js +28 -20
- package/es/SearchTypeResult/SearchItem.js +8 -35
- package/es/SearchTypeResult/components/ItemResourceHeader.js +5 -5
- package/es/TreeStructure/TreeStructure.js +16 -10
- package/es/locale/messages-en.js +2 -0
- package/es/locale/messages-nb.js +3 -1
- package/es/locale/messages-nn.js +4 -2
- package/es/locale/messages-se.js +89 -87
- package/es/locale/messages-sma.js +2 -0
- package/es/model/ContentType.js +2 -1
- package/es/utils/resourceTypeColor.js +44 -0
- package/lib/Article/ArticleByline.d.ts +3 -1
- package/lib/Article/ArticleByline.js +38 -7
- package/lib/Breadcrumb/ActionBreadcrumb.js +5 -4
- package/lib/Breadcrumb/Breadcrumb.js +12 -4
- package/lib/Resource/BlockResource.d.ts +2 -1
- package/lib/Resource/BlockResource.js +31 -17
- package/lib/Resource/ListResource.d.ts +2 -1
- package/lib/Resource/ListResource.js +32 -20
- package/lib/Resource/resourceComponents.d.ts +5 -1
- package/lib/Resource/resourceComponents.js +32 -22
- package/lib/SearchTypeResult/SearchItem.d.ts +0 -1
- package/lib/SearchTypeResult/SearchItem.js +9 -39
- package/lib/SearchTypeResult/components/ItemResourceHeader.js +8 -8
- package/lib/TreeStructure/TreeStructure.js +16 -10
- package/lib/locale/messages-en.d.ts +2 -0
- package/lib/locale/messages-en.js +2 -0
- package/lib/locale/messages-nb.d.ts +2 -0
- package/lib/locale/messages-nb.js +3 -1
- package/lib/locale/messages-nn.d.ts +2 -0
- package/lib/locale/messages-nn.js +4 -2
- package/lib/locale/messages-se.d.ts +2 -0
- package/lib/locale/messages-se.js +89 -87
- package/lib/locale/messages-sma.d.ts +2 -0
- package/lib/locale/messages-sma.js +2 -0
- package/lib/model/ContentType.d.ts +1 -0
- package/lib/model/ContentType.js +4 -2
- package/lib/utils/resourceTypeColor.d.ts +9 -0
- package/lib/utils/resourceTypeColor.js +59 -0
- package/package.json +6 -6
- package/src/.DS_Store +0 -0
- package/src/Article/ArticleByline.tsx +40 -1
- package/src/Breadcrumb/ActionBreadcrumb.tsx +1 -2
- package/src/Breadcrumb/Breadcrumb.tsx +15 -6
- package/src/Resource/BlockResource.tsx +18 -7
- package/src/Resource/ListResource.tsx +30 -8
- package/src/Resource/resourceComponents.tsx +14 -2
- package/src/SearchTypeResult/SearchItem.tsx +0 -22
- package/src/SearchTypeResult/components/ItemResourceHeader.tsx +3 -1
- package/src/TreeStructure/TreeStructure.tsx +3 -3
- package/src/locale/messages-en.ts +2 -0
- package/src/locale/messages-nb.ts +3 -1
- package/src/locale/messages-nn.ts +4 -2
- package/src/locale/messages-se.ts +90 -87
- package/src/locale/messages-sma.ts +2 -0
- package/src/model/ContentType.ts +12 -0
- package/src/utils/resourceTypeColor.tsx +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "27.1.
|
|
3
|
+
"version": "27.1.7",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ndla/article-scripts": "^3.0.2",
|
|
35
|
-
"@ndla/button": "^3.6.
|
|
35
|
+
"@ndla/button": "^3.6.1",
|
|
36
36
|
"@ndla/carousel": "^1.2.23",
|
|
37
37
|
"@ndla/core": "^2.3.5",
|
|
38
|
-
"@ndla/forms": "^3.3.
|
|
38
|
+
"@ndla/forms": "^3.3.5",
|
|
39
39
|
"@ndla/hooks": "^1.1.6",
|
|
40
40
|
"@ndla/icons": "^1.13.0",
|
|
41
41
|
"@ndla/licenses": "^5.0.17",
|
|
42
42
|
"@ndla/modal": "^1.5.0",
|
|
43
|
-
"@ndla/notion": "^3.1.
|
|
44
|
-
"@ndla/safelink": "^2.2.
|
|
43
|
+
"@ndla/notion": "^3.1.46",
|
|
44
|
+
"@ndla/safelink": "^2.2.19",
|
|
45
45
|
"@ndla/switch": "^0.1.13",
|
|
46
46
|
"@ndla/tabs": "^1.1.22",
|
|
47
47
|
"@ndla/tooltip": "^2.2.1",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "a2bbbd2a97f3e3468c06cc1aea9849a24d9e5461"
|
|
89
89
|
}
|
package/src/.DS_Store
ADDED
|
Binary file
|
|
@@ -59,6 +59,8 @@ type Props = {
|
|
|
59
59
|
copyPageUrlLink?: string;
|
|
60
60
|
printUrl?: string;
|
|
61
61
|
locale?: string;
|
|
62
|
+
copyEmbedLink?: string;
|
|
63
|
+
copySourceReference?: string;
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
const renderContributors = (contributors: SupplierProps[] | AuthorProps[], t: TFunction) => {
|
|
@@ -91,16 +93,29 @@ const ArticleByline = ({
|
|
|
91
93
|
copyPageUrlLink,
|
|
92
94
|
printUrl,
|
|
93
95
|
locale,
|
|
96
|
+
copyEmbedLink,
|
|
97
|
+
copySourceReference,
|
|
94
98
|
}: Props) => {
|
|
95
99
|
const { t } = useTranslation();
|
|
100
|
+
|
|
96
101
|
const copyLinkHandler = () => {
|
|
97
102
|
if (copyPageUrlLink) {
|
|
98
103
|
copyTextToClipboard(copyPageUrlLink);
|
|
99
104
|
}
|
|
100
105
|
};
|
|
101
|
-
|
|
102
106
|
const licenseRights = getLicenseByAbbreviation(license, locale).rights;
|
|
103
107
|
|
|
108
|
+
const copyLicense = () => {
|
|
109
|
+
if (copySourceReference) {
|
|
110
|
+
copyTextToClipboard(copySourceReference);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const copyEmbededLink = () => {
|
|
114
|
+
if (copyEmbedLink) {
|
|
115
|
+
copyTextToClipboard(copyEmbedLink);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
104
119
|
const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;
|
|
105
120
|
const showSecondaryContributors = suppliers.length > 0 && authors.length > 0;
|
|
106
121
|
|
|
@@ -129,6 +144,18 @@ const ArticleByline = ({
|
|
|
129
144
|
)}
|
|
130
145
|
{showSecondaryContributors && <TextWrapper>{getSuppliersText(suppliers, t)}</TextWrapper>}
|
|
131
146
|
<ButtonWrapper>
|
|
147
|
+
{copySourceReference && (
|
|
148
|
+
<CopyButton
|
|
149
|
+
size="small"
|
|
150
|
+
borderShape="rounded"
|
|
151
|
+
outline
|
|
152
|
+
aria-live="assertive"
|
|
153
|
+
copyNode={t('license.hasCopiedTitle')}
|
|
154
|
+
data-copy-string={copySourceReference}
|
|
155
|
+
onClick={copyLicense}>
|
|
156
|
+
{`${t('license.copy')} ${t('license.copyTitle').toLowerCase()}`}
|
|
157
|
+
</CopyButton>
|
|
158
|
+
)}
|
|
132
159
|
{licenseBox && (
|
|
133
160
|
<Modal
|
|
134
161
|
labelledBy={buttonId}
|
|
@@ -162,6 +189,18 @@ const ArticleByline = ({
|
|
|
162
189
|
{t('article.copyPageLink')}
|
|
163
190
|
</CopyButton>
|
|
164
191
|
)}
|
|
192
|
+
{copyEmbedLink && (
|
|
193
|
+
<CopyButton
|
|
194
|
+
size="small"
|
|
195
|
+
borderShape="rounded"
|
|
196
|
+
outline
|
|
197
|
+
aria-live="assertive"
|
|
198
|
+
copyNode={t('license.hasCopiedTitle')}
|
|
199
|
+
data-copy-string={copyEmbedLink}
|
|
200
|
+
onClick={copyEmbededLink}>
|
|
201
|
+
{`${t('license.copy')} ${t('license.tabs.embedlink').toLowerCase()}`}
|
|
202
|
+
</CopyButton>
|
|
203
|
+
)}
|
|
165
204
|
{printUrl && (
|
|
166
205
|
<Button size="small" borderShape="rounded" outline onClick={() => printPage(printUrl)}>
|
|
167
206
|
{t('article.printPage')}
|
|
@@ -23,7 +23,6 @@ const StyledRightChevron = styled(ChevronRight)`
|
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
25
|
const StyledSpan = styled.span`
|
|
26
|
-
color: ${colors.text.primary};
|
|
27
26
|
font-weight: ${fonts.weight.bold};
|
|
28
27
|
`;
|
|
29
28
|
|
|
@@ -54,7 +53,7 @@ const ActionBreadcrumb = ({ items, actionItems }: Props) => {
|
|
|
54
53
|
}
|
|
55
54
|
if (item.index === totalCount - 1 && actionItems.length > 0) {
|
|
56
55
|
return (
|
|
57
|
-
<StyledMenuButton menuItems={actionItems} size="small">
|
|
56
|
+
<StyledMenuButton menuItems={actionItems} alignRight size="small">
|
|
58
57
|
<StyledSpan title={item.name}>{item.name}</StyledSpan>
|
|
59
58
|
</StyledMenuButton>
|
|
60
59
|
);
|
|
@@ -67,7 +67,7 @@ const Breadcrumb = ({
|
|
|
67
67
|
el.setMaxWidth('40px');
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
|
-
}, [size]);
|
|
70
|
+
}, [size, items]);
|
|
71
71
|
|
|
72
72
|
return (
|
|
73
73
|
<BreadcrumbNav ref={containerRef} aria-label={t('breadcrumb.breadcrumb')}>
|
|
@@ -77,11 +77,20 @@ const Breadcrumb = ({
|
|
|
77
77
|
autoCollapse={autoCollapse}
|
|
78
78
|
renderItem={renderItem}
|
|
79
79
|
renderSeparator={renderSeparator}
|
|
80
|
-
ref={(element) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
ref={(element) => {
|
|
81
|
+
if (
|
|
82
|
+
element === null ||
|
|
83
|
+
(!collapseFirst && index === 0) ||
|
|
84
|
+
(!collapseLast && index === items.length - 1)
|
|
85
|
+
) {
|
|
86
|
+
if (element) {
|
|
87
|
+
element.setMaxWidth('none');
|
|
88
|
+
}
|
|
89
|
+
breadcrumbItemRefs.delete(item.to);
|
|
90
|
+
} else {
|
|
91
|
+
breadcrumbItemRefs.set(item.to, element);
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
85
94
|
key={typeof item.to === 'string' ? item.to : item.to.pathname}
|
|
86
95
|
totalCount={items.length}
|
|
87
96
|
item={{ ...item, index }}
|
|
@@ -10,6 +10,7 @@ import styled from '@emotion/styled';
|
|
|
10
10
|
import React, { useRef } from 'react';
|
|
11
11
|
import { colors, fonts, spacing } from '@ndla/core';
|
|
12
12
|
import { MenuButton, MenuItemProps } from '@ndla/button';
|
|
13
|
+
import ContentTypeBadge from '../ContentTypeBadge';
|
|
13
14
|
import Image from '../Image';
|
|
14
15
|
import {
|
|
15
16
|
CompressedTagList,
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
TopicList,
|
|
20
21
|
ResourceTitleLink,
|
|
21
22
|
LoaderProps,
|
|
23
|
+
StyledContentIconWrapper,
|
|
22
24
|
} from './resourceComponents';
|
|
23
25
|
import ContentLoader from '../ContentLoader';
|
|
24
26
|
|
|
@@ -34,6 +36,7 @@ interface BlockResourceProps {
|
|
|
34
36
|
menuItems?: MenuItemProps[];
|
|
35
37
|
isLoading?: boolean;
|
|
36
38
|
targetBlank?: boolean;
|
|
39
|
+
contentType: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
const BlockElementWrapper = styled.div`
|
|
@@ -92,22 +95,21 @@ const BlockInfoWrapper = styled.div`
|
|
|
92
95
|
const ImageWrapper = styled.div`
|
|
93
96
|
display: flex;
|
|
94
97
|
width: 100%;
|
|
98
|
+
justify-content: center;
|
|
95
99
|
overflow: hidden;
|
|
96
100
|
align-items: center;
|
|
97
|
-
|
|
98
|
-
min-width: 100%;
|
|
99
|
-
}
|
|
101
|
+
aspect-ratio: 3/4;
|
|
100
102
|
img {
|
|
101
103
|
min-width: 100%;
|
|
102
104
|
}
|
|
103
105
|
`;
|
|
104
|
-
|
|
105
106
|
interface BlockImageProps {
|
|
106
107
|
image: ResourceImageProps;
|
|
107
108
|
loading?: boolean;
|
|
109
|
+
contentType: string;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
const BlockImage = ({ image, loading }: BlockImageProps) => {
|
|
112
|
+
const BlockImage = ({ image, loading, contentType }: BlockImageProps) => {
|
|
111
113
|
if (loading) {
|
|
112
114
|
return (
|
|
113
115
|
<ContentLoader height={'100%'} width={'100%'} viewBox={null} preserveAspectRatio="none">
|
|
@@ -115,7 +117,15 @@ const BlockImage = ({ image, loading }: BlockImageProps) => {
|
|
|
115
117
|
</ContentLoader>
|
|
116
118
|
);
|
|
117
119
|
}
|
|
118
|
-
|
|
120
|
+
if (image.src === '') {
|
|
121
|
+
return (
|
|
122
|
+
<StyledContentIconWrapper contentType={contentType}>
|
|
123
|
+
<ContentTypeBadge type={contentType} size="large" />
|
|
124
|
+
</StyledContentIconWrapper>
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
return <Image alt={image.alt} src={image.src} fallbackWidth={300} />;
|
|
128
|
+
}
|
|
119
129
|
};
|
|
120
130
|
|
|
121
131
|
const TopicAndTitleLoader = ({ children, loading }: LoaderProps) => {
|
|
@@ -143,6 +153,7 @@ const BlockResource = ({
|
|
|
143
153
|
menuItems,
|
|
144
154
|
isLoading,
|
|
145
155
|
targetBlank,
|
|
156
|
+
contentType,
|
|
146
157
|
}: BlockResourceProps) => {
|
|
147
158
|
const linkRef = useRef<HTMLAnchorElement>(null);
|
|
148
159
|
|
|
@@ -155,7 +166,7 @@ const BlockResource = ({
|
|
|
155
166
|
return (
|
|
156
167
|
<BlockElementWrapper onClick={handleClick} id={id}>
|
|
157
168
|
<ImageWrapper>
|
|
158
|
-
<BlockImage image={resourceImage} loading={isLoading} />
|
|
169
|
+
<BlockImage image={resourceImage} loading={isLoading} contentType={contentType} />
|
|
159
170
|
</ImageWrapper>
|
|
160
171
|
<BlockInfoWrapper>
|
|
161
172
|
<TopicAndTitleLoader loading={isLoading}>
|
|
@@ -17,9 +17,11 @@ import {
|
|
|
17
17
|
ResourceTitle,
|
|
18
18
|
ResourceTitleLink,
|
|
19
19
|
TopicList,
|
|
20
|
+
StyledContentIconWrapper,
|
|
20
21
|
LoaderProps,
|
|
21
22
|
} from './resourceComponents';
|
|
22
23
|
import ContentLoader from '../ContentLoader';
|
|
24
|
+
import ContentTypeBadge from '../ContentTypeBadge';
|
|
23
25
|
|
|
24
26
|
const StyledResourceDescription = styled.p`
|
|
25
27
|
grid-area: description;
|
|
@@ -90,18 +92,21 @@ const TagsandActionMenu = styled.div`
|
|
|
90
92
|
const StyledImageWrapper = styled.div<StyledImageProps>`
|
|
91
93
|
grid-area: image;
|
|
92
94
|
width: ${(p) => (p.imageSize === 'normal' ? '136px' : '56px')};
|
|
93
|
-
height: ${(p) => (p.imageSize === 'normal' ? '96px' : '40px')};
|
|
94
95
|
${mq.range({ until: breakpoints.mobileWide })} {
|
|
95
96
|
width: 54px;
|
|
96
97
|
height: 40px;
|
|
97
98
|
}
|
|
98
99
|
overflow: hidden;
|
|
100
|
+
border-radius: 2px;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
aspect-ratio: 4/3;
|
|
99
105
|
`;
|
|
100
106
|
|
|
101
107
|
const StyledImage = styled(Image)`
|
|
102
|
-
display: flex;
|
|
103
|
-
border-radius: 2px;
|
|
104
108
|
object-fit: cover;
|
|
109
|
+
aspect-ratio: 4/3;
|
|
105
110
|
`;
|
|
106
111
|
|
|
107
112
|
const TopicAndTitleWrapper = styled.div`
|
|
@@ -125,20 +130,31 @@ export interface ListResourceProps {
|
|
|
125
130
|
menuItems?: MenuItemProps[];
|
|
126
131
|
isLoading?: boolean;
|
|
127
132
|
targetBlank?: boolean;
|
|
133
|
+
contentType: string;
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
interface ListResourceImageProps {
|
|
131
137
|
resourceImage: ResourceImageProps;
|
|
132
138
|
loading?: boolean;
|
|
133
139
|
type: 'normal' | 'compact';
|
|
140
|
+
contentType: string;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
|
-
const ListResourceImage = ({ resourceImage, loading, type }: ListResourceImageProps) => {
|
|
143
|
+
const ListResourceImage = ({ resourceImage, loading, type, contentType }: ListResourceImageProps) => {
|
|
137
144
|
if (!loading) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
if (resourceImage.src === '') {
|
|
146
|
+
return (
|
|
147
|
+
<StyledContentIconWrapper contentType={contentType}>
|
|
148
|
+
<ContentTypeBadge type={contentType} size="x-small" />
|
|
149
|
+
</StyledContentIconWrapper>
|
|
150
|
+
);
|
|
151
|
+
} else {
|
|
152
|
+
return (
|
|
153
|
+
<StyledImage alt={resourceImage.alt} src={resourceImage.src} fallbackWidth={type === 'compact' ? 56 : 136} />
|
|
154
|
+
);
|
|
155
|
+
}
|
|
141
156
|
}
|
|
157
|
+
|
|
142
158
|
return (
|
|
143
159
|
<ContentLoader height={'100%'} width={'100%'} viewBox={null} preserveAspectRatio="none">
|
|
144
160
|
<rect
|
|
@@ -194,6 +210,7 @@ const ListResource = ({
|
|
|
194
210
|
menuItems,
|
|
195
211
|
isLoading = false,
|
|
196
212
|
targetBlank,
|
|
213
|
+
contentType,
|
|
197
214
|
}: ListResourceProps) => {
|
|
198
215
|
const showDescription = description !== undefined;
|
|
199
216
|
const imageType = showDescription ? 'normal' : 'compact';
|
|
@@ -207,7 +224,12 @@ const ListResource = ({
|
|
|
207
224
|
return (
|
|
208
225
|
<ResourceWrapper onClick={handleClick} id={id}>
|
|
209
226
|
<StyledImageWrapper imageSize={imageType}>
|
|
210
|
-
<ListResourceImage
|
|
227
|
+
<ListResourceImage
|
|
228
|
+
resourceImage={resourceImage}
|
|
229
|
+
loading={isLoading}
|
|
230
|
+
type={imageType}
|
|
231
|
+
contentType={contentType}
|
|
232
|
+
/>
|
|
211
233
|
</StyledImageWrapper>
|
|
212
234
|
<TopicAndTitleWrapper>
|
|
213
235
|
<TopicAndTitleLoader loading={isLoading}>
|
|
@@ -14,7 +14,7 @@ import { MenuButton } from '@ndla/button';
|
|
|
14
14
|
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
18
|
export interface ResourceImageProps {
|
|
19
19
|
alt: string;
|
|
20
20
|
src: string;
|
|
@@ -103,6 +103,19 @@ const TagCounterWrapper = styled.span`
|
|
|
103
103
|
padding: 5px;
|
|
104
104
|
`;
|
|
105
105
|
|
|
106
|
+
export interface ContentIconProps {
|
|
107
|
+
contentType: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const StyledContentIconWrapper = styled.span<ContentIconProps>`
|
|
111
|
+
width: 100%;
|
|
112
|
+
aspect-ratio: 4/3;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
background-color: ${({ contentType }) => resourceTypeColor(contentType)};
|
|
117
|
+
`;
|
|
118
|
+
|
|
106
119
|
interface TagListProps {
|
|
107
120
|
tags?: string[];
|
|
108
121
|
tagLinkPrefix?: string;
|
|
@@ -146,7 +159,6 @@ const TagMenuButton = styled(MenuButton)`
|
|
|
146
159
|
background-color: ${colors.brand.light};
|
|
147
160
|
}
|
|
148
161
|
`;
|
|
149
|
-
|
|
150
162
|
export const CompressedTagList = ({ tags, tagLinkPrefix }: CompressedTagListProps) => {
|
|
151
163
|
const navigate = useNavigate();
|
|
152
164
|
const { t } = useTranslation();
|
|
@@ -18,30 +18,8 @@ import constants from '../model';
|
|
|
18
18
|
import ItemContexts, { ItemContextsType } from './components/ItemContexts';
|
|
19
19
|
import ItemTopicHeader from './components/ItemTopicHeader';
|
|
20
20
|
import ItemResourceHeader from './components/ItemResourceHeader';
|
|
21
|
-
|
|
22
21
|
const { contentTypes } = constants;
|
|
23
22
|
|
|
24
|
-
export const resourceTypeColor = (type: string) => {
|
|
25
|
-
switch (type) {
|
|
26
|
-
case contentTypes.SUBJECT_MATERIAL:
|
|
27
|
-
return colors.subjectMaterial.light;
|
|
28
|
-
case contentTypes.TOPIC:
|
|
29
|
-
return colors.subject.light;
|
|
30
|
-
case contentTypes.TASKS_AND_ACTIVITIES:
|
|
31
|
-
return colors.tasksAndActivities.light;
|
|
32
|
-
case contentTypes.ASSESSMENT_RESOURCES:
|
|
33
|
-
return colors.assessmentResource.light;
|
|
34
|
-
case contentTypes.EXTERNAL_LEARNING_RESOURCES:
|
|
35
|
-
return colors.externalLearningResource.light;
|
|
36
|
-
case contentTypes.SOURCE_MATERIAL:
|
|
37
|
-
return colors.sourceMaterial.light;
|
|
38
|
-
case contentTypes.LEARNING_PATH:
|
|
39
|
-
return colors.learningPath.light;
|
|
40
|
-
default:
|
|
41
|
-
return '';
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
23
|
type ItemTypeProps = {
|
|
46
24
|
contentType?: ContentType;
|
|
47
25
|
isTopic?: boolean;
|
|
@@ -13,7 +13,9 @@ import styled from '@emotion/styled';
|
|
|
13
13
|
import { animations, fonts, spacing } from '@ndla/core';
|
|
14
14
|
|
|
15
15
|
import { ContentType } from '../SearchTypeResult';
|
|
16
|
-
import {
|
|
16
|
+
import { SearchItemType } from '../SearchItem';
|
|
17
|
+
|
|
18
|
+
import resourceTypeColor from '../../utils/resourceTypeColor';
|
|
17
19
|
import ContentTypeBadge from '../../ContentTypeBadge';
|
|
18
20
|
|
|
19
21
|
type ItemTypeProps = {
|
|
@@ -148,7 +148,7 @@ const TreeStructure = ({
|
|
|
148
148
|
_setFocusedFolder(folder);
|
|
149
149
|
setNewFolderParentId(undefined);
|
|
150
150
|
|
|
151
|
-
ref.current?.focus();
|
|
151
|
+
ref.current?.focus({ preventScroll: true });
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
const onOpenFolder = (id: string) => {
|
|
@@ -173,13 +173,13 @@ const TreeStructure = ({
|
|
|
173
173
|
setFocusedFolder(newFolder);
|
|
174
174
|
setOpenFolders(uniq(openFolders.concat(parentId)));
|
|
175
175
|
setNewFolderParentId?.(undefined);
|
|
176
|
-
ref.current?.focus();
|
|
176
|
+
ref.current?.focus({ preventScroll: true });
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
|
|
180
180
|
const onCancelNewFolder = () => {
|
|
181
181
|
setNewFolderParentId?.(undefined);
|
|
182
|
-
ref.current?.focus();
|
|
182
|
+
ref.current?.focus({ preventScroll: true });
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
const canAddFolder = selectedFolder && selectedFolder?.breadcrumbs.length < (maxLevel || 1);
|
|
@@ -432,6 +432,7 @@ const messages = {
|
|
|
432
432
|
},
|
|
433
433
|
license: {
|
|
434
434
|
heading: 'How to reuse content',
|
|
435
|
+
copy: 'Copy',
|
|
435
436
|
tabs: {
|
|
436
437
|
text: 'Text',
|
|
437
438
|
images: 'Images',
|
|
@@ -1048,6 +1049,7 @@ const messages = {
|
|
|
1048
1049
|
'Welcome to my NDLA! You can now save your favourite resources from NDLA and organise them in folders with tags',
|
|
1049
1050
|
read: { our: 'Read our', ours: 'Read our' },
|
|
1050
1051
|
privacy: 'privacy statement',
|
|
1052
|
+
privacyLink: 'https://om.ndla.no/gdpr',
|
|
1051
1053
|
questions: { question: 'Any questions?', ask: 'Ask us in the chat' },
|
|
1052
1054
|
wishToDelete: 'Do you wish to delete your account?',
|
|
1053
1055
|
terms: {
|
|
@@ -432,6 +432,7 @@ const messages = {
|
|
|
432
432
|
heading: 'Slik gjenbruker du innhold',
|
|
433
433
|
learnMore: 'Lær mer om åpne lisenser',
|
|
434
434
|
copyTitle: 'Kildehenvisning',
|
|
435
|
+
copy: 'Kopier',
|
|
435
436
|
hasCopiedTitle: 'Kopiert!',
|
|
436
437
|
embed: 'Bygg inn',
|
|
437
438
|
embedCopied: 'Kopierte innbyggingskode!',
|
|
@@ -826,7 +827,7 @@ const messages = {
|
|
|
826
827
|
},
|
|
827
828
|
frontPageToolbox: {
|
|
828
829
|
heading: 'Verktøykassa',
|
|
829
|
-
text: 'Har du lyst til å bli god til å presentere, eller vil du lære å studere smartere ved hjelp av riktig studieteknikk? Trenger du råd om hvordan du leser mest mulig effektivt til eksamen? I verktøykassa til NDLA finner du
|
|
830
|
+
text: 'Har du lyst til å bli god til å presentere, eller vil du lære å studere smartere ved hjelp av riktig studieteknikk? Trenger du råd om hvordan du leser mest mulig effektivt til eksamen? I verktøykassa til NDLA finner du mange gode tips og råd!',
|
|
830
831
|
linkTextStudents: 'Se alle tipsene for elever her',
|
|
831
832
|
linkTextTeachers: 'Se alle tipsene for lærere her',
|
|
832
833
|
cursorText: 'Tips',
|
|
@@ -1045,6 +1046,7 @@ const messages = {
|
|
|
1045
1046
|
'Velkommen til Min NDLA! Nå kan du lagre dine favorittressurser fra NDLA og organisere dem slik du ønsker i mapper og med emneknagger.',
|
|
1046
1047
|
read: { our: 'Les vår', ours: 'Les våre' },
|
|
1047
1048
|
privacy: 'personvernerklæring her',
|
|
1049
|
+
privacyLink: 'https://om.ndla.no/gdpr',
|
|
1048
1050
|
questions: { question: 'Lurer du på noe?', ask: 'Spør oss i chatten' },
|
|
1049
1051
|
wishToDelete: 'Vil du ikke ha brukerprofil hos oss lenger?',
|
|
1050
1052
|
terms: {
|
|
@@ -433,6 +433,7 @@ const messages = {
|
|
|
433
433
|
heading: 'Slik gjenbruker du innhald',
|
|
434
434
|
learnMore: 'Lær meir om opne lisensar',
|
|
435
435
|
copyTitle: 'Kjeldetilvising',
|
|
436
|
+
copy: 'Kopier',
|
|
436
437
|
hasCopiedTitle: 'Kopiert!',
|
|
437
438
|
embed: 'Bygg inn',
|
|
438
439
|
embedCopied: 'Kopierte innbyggingskode!',
|
|
@@ -827,7 +828,7 @@ const messages = {
|
|
|
827
828
|
},
|
|
828
829
|
frontPageToolbox: {
|
|
829
830
|
heading: 'Verktøykassa',
|
|
830
|
-
text: 'Har du lyst til å bli god til å presentere, eller vil du lære å studere smartare ved hjelp av riktig studieteknikk? Treng du råd om korleis du les mest mogleg effektivt til eksamen? I verktøykassa til NDLA finn du
|
|
831
|
+
text: 'Har du lyst til å bli god til å presentere, eller vil du lære å studere smartare ved hjelp av riktig studieteknikk? Treng du råd om korleis du les mest mogleg effektivt til eksamen? I verktøykassa til NDLA finn du mange gode tips og råd!',
|
|
831
832
|
linkTextStudents: 'Sjå alle tipsa for elever her',
|
|
832
833
|
linkTextTeachers: 'Sjå alle tipsa for lærarar her',
|
|
833
834
|
cursorText: 'Tips',
|
|
@@ -1043,9 +1044,10 @@ const messages = {
|
|
|
1043
1044
|
loginResourcePitch: 'Ønsker du å favorittmerke denne sida?',
|
|
1044
1045
|
loginWelcome: 'Velkommen til NDLA! Her kan du organisere fagstoffet på <i>din</i> måte!',
|
|
1045
1046
|
welcome:
|
|
1046
|
-
'Velkommen til Min NDLA!
|
|
1047
|
+
'Velkommen til Min NDLA! No kan du lagre dine favorittressursar frå NDLA og organisere dei slik du ønsker i mapper og med emneknaggar.',
|
|
1047
1048
|
read: { our: 'Les vår', ours: 'Les våre' },
|
|
1048
1049
|
privacy: 'personvernerklæring her',
|
|
1050
|
+
privacyLink: 'https://om.ndla.no/gdpr',
|
|
1049
1051
|
questions: { question: 'Lurer du på noko?', ask: 'Spør oss i chatten' },
|
|
1050
1052
|
wishToDelete: 'Vil du ikkje ha brukerprofil hos oss lenger?',
|
|
1051
1053
|
terms: {
|