@ndla/ui 44.0.19 → 44.0.21
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 +18 -12
- package/es/BlogPost/BlogPost.js +9 -6
- package/es/CampaignBlock/CampaignBlock.js +10 -7
- package/es/ContactBlock/ContactBlock.js +30 -33
- package/es/Footer/FooterPrivacy.js +27 -14
- package/es/Grid/Grid.js +2 -2
- package/es/KeyFigure/KeyFigure.js +12 -10
- package/es/LearningPaths/LearningPathSticky.js +7 -3
- package/es/LinkBlock/LinkBlock.js +10 -7
- package/es/Masthead/MastheadSearchModal.js +4 -2
- package/es/ResourceGroup/ResourceItem.js +50 -63
- package/es/ResourceGroup/ResourceList.js +11 -19
- package/es/locale/messages-en.js +2 -2
- package/es/locale/messages-nb.js +2 -2
- package/es/locale/messages-nn.js +2 -2
- package/es/locale/messages-se.js +2 -2
- package/es/locale/messages-sma.js +2 -2
- package/es/utils/relativeUrl.js +18 -0
- package/lib/Article/ArticleByline.js +18 -12
- package/lib/BlogPost/BlogPost.d.ts +2 -1
- package/lib/BlogPost/BlogPost.js +9 -6
- package/lib/CampaignBlock/CampaignBlock.d.ts +2 -1
- package/lib/CampaignBlock/CampaignBlock.js +10 -7
- package/lib/ContactBlock/ContactBlock.js +30 -33
- package/lib/Footer/FooterPrivacy.js +32 -21
- package/lib/Grid/Grid.js +2 -2
- package/lib/KeyFigure/KeyFigure.js +12 -10
- package/lib/LearningPaths/LearningPathSticky.js +7 -3
- package/lib/LinkBlock/LinkBlock.d.ts +4 -1
- package/lib/LinkBlock/LinkBlock.js +10 -7
- package/lib/Masthead/MastheadSearchModal.js +4 -2
- package/lib/ResourceGroup/ResourceItem.d.ts +1 -1
- package/lib/ResourceGroup/ResourceItem.js +50 -63
- package/lib/ResourceGroup/ResourceList.js +11 -19
- package/lib/locale/messages-en.js +2 -2
- package/lib/locale/messages-nb.js +2 -2
- package/lib/locale/messages-nn.js +2 -2
- package/lib/locale/messages-se.js +2 -2
- package/lib/locale/messages-sma.js +2 -2
- package/lib/utils/relativeUrl.d.ts +8 -0
- package/lib/utils/relativeUrl.js +25 -0
- package/package.json +7 -7
- package/src/Article/ArticleByline.tsx +9 -3
- package/src/BlogPost/BlogPost.tsx +7 -4
- package/src/CampaignBlock/CampaignBlock.tsx +5 -1
- package/src/ContactBlock/ContactBlock.tsx +20 -7
- package/src/Footer/FooterPrivacy.tsx +21 -30
- package/src/Grid/Grid.tsx +1 -1
- package/src/KeyFigure/KeyFigure.tsx +6 -2
- package/src/LearningPaths/LearningPathSticky.tsx +17 -9
- package/src/LinkBlock/LinkBlock.tsx +8 -2
- package/src/Masthead/MastheadSearchModal.tsx +6 -1
- package/src/ResourceGroup/ResourceItem.tsx +45 -61
- package/src/ResourceGroup/ResourceList.tsx +2 -24
- package/src/locale/messages-en.ts +2 -2
- package/src/locale/messages-nb.ts +2 -2
- package/src/locale/messages-nn.ts +2 -2
- package/src/locale/messages-se.ts +2 -2
- package/src/locale/messages-sma.ts +2 -2
- package/src/utils/relativeUrl.ts +20 -0
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ReactNode } from 'react';
|
|
9
|
+
import { CSSProperties, ReactNode, useMemo } from 'react';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import styled from '@emotion/styled';
|
|
12
|
-
import {
|
|
12
|
+
import { keyframes } from '@emotion/react';
|
|
13
13
|
import SafeLink from '@ndla/safelink';
|
|
14
14
|
import { Additional, Core, HumanMaleBoard } from '@ndla/icons/common';
|
|
15
|
-
import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
|
|
16
|
-
import Tooltip from '@ndla/tooltip';
|
|
15
|
+
import { breakpoints, colors, fonts, misc, mq, spacing } from '@ndla/core';
|
|
17
16
|
import { Resource } from '../types';
|
|
18
17
|
import ContentTypeBadge from '../ContentTypeBadge';
|
|
19
18
|
import * as contentTypes from '../model/ContentType';
|
|
@@ -59,54 +58,42 @@ const fadeInAdditionalsKeyframe = keyframes`
|
|
|
59
58
|
}
|
|
60
59
|
`;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
contentType?: string;
|
|
66
|
-
active?: boolean;
|
|
67
|
-
hidden?: boolean;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const ListElement = styled.li<ListElementProps>`
|
|
71
|
-
border: 1px solid #d1d6db;
|
|
72
|
-
border-radius: 5px;
|
|
61
|
+
const ListElement = styled.li`
|
|
62
|
+
border: 1px solid ${colors.brand.neutral7};
|
|
63
|
+
border-radius: ${misc.borderRadius};
|
|
73
64
|
background: ${colors.white};
|
|
74
65
|
margin-bottom: ${spacing.xsmall};
|
|
75
66
|
display: flex;
|
|
76
67
|
justify-content: space-between;
|
|
77
68
|
align-items: center;
|
|
78
69
|
padding: ${spacing.small};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
animation-fill-mode: forwards;
|
|
86
|
-
animation: ${fadeInAdditionalsKeyframe};
|
|
87
|
-
`}
|
|
88
|
-
${(props) => props.extraBottomMargin && `margin-bottom: ${spacing.large};`}
|
|
70
|
+
&[data-additional='true'] {
|
|
71
|
+
border-style: dashed;
|
|
72
|
+
animation-duration: 0.8s;
|
|
73
|
+
animation-fill-mode: forwards;
|
|
74
|
+
animation: ${fadeInAdditionalsKeyframe};
|
|
75
|
+
}
|
|
89
76
|
|
|
90
77
|
* {
|
|
91
78
|
transition: height ease-out 0.2s, width ease-out 0.2s;
|
|
92
79
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
transform: translate(calc(-${spacing.normal} - ${spacing.small}));
|
|
105
|
-
background-color: ${listElementActiveColor(props.contentType)};
|
|
106
|
-
}
|
|
80
|
+
&[data-active='true'] {
|
|
81
|
+
&:before {
|
|
82
|
+
${mq.range({ from: breakpoints.tablet })} {
|
|
83
|
+
content: '';
|
|
84
|
+
display: block;
|
|
85
|
+
position: absolute;
|
|
86
|
+
width: ${spacing.small};
|
|
87
|
+
height: ${spacing.small};
|
|
88
|
+
border-radius: 100%;
|
|
89
|
+
transform: translate(-${spacing.mediumlarge});
|
|
90
|
+
background-color: var(--contentTypeBg);
|
|
107
91
|
}
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
&[hidden] {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
110
97
|
`;
|
|
111
98
|
|
|
112
99
|
const ResourceLink = styled(SafeLink)`
|
|
@@ -223,7 +210,6 @@ const ResourceItem = ({
|
|
|
223
210
|
contentType,
|
|
224
211
|
active,
|
|
225
212
|
additional,
|
|
226
|
-
extraBottomMargin,
|
|
227
213
|
showAdditionalResources,
|
|
228
214
|
access,
|
|
229
215
|
heartButton,
|
|
@@ -234,14 +220,18 @@ const ResourceItem = ({
|
|
|
234
220
|
const additionalId = `${id}-additional`;
|
|
235
221
|
const describedBy = `${coreId} ${additionalId} ${accessId}`;
|
|
236
222
|
const hidden = additional ? !showAdditionalResources : false;
|
|
223
|
+
const listElementVars = useMemo(() => {
|
|
224
|
+
if (!contentType) return {};
|
|
225
|
+
return { '--contentTypeBg': listElementActiveColor(contentType) } as unknown as CSSProperties;
|
|
226
|
+
}, [contentType]);
|
|
227
|
+
|
|
237
228
|
return (
|
|
238
229
|
<ListElement
|
|
239
230
|
aria-current={active ? 'page' : undefined}
|
|
240
|
-
contentType={contentType}
|
|
241
231
|
hidden={hidden && !active}
|
|
242
|
-
active={active}
|
|
243
|
-
additional={additional}
|
|
244
|
-
|
|
232
|
+
data-active={active}
|
|
233
|
+
data-additional={additional}
|
|
234
|
+
style={listElementVars}
|
|
245
235
|
>
|
|
246
236
|
<ResourceWrapper>
|
|
247
237
|
<ContentBadgeWrapper>
|
|
@@ -257,27 +247,21 @@ const ResourceItem = ({
|
|
|
257
247
|
<TypeWrapper>
|
|
258
248
|
{contentTypeName && <ContentTypeName>{contentTypeName}</ContentTypeName>}
|
|
259
249
|
{access && access === 'teacher' && (
|
|
260
|
-
<
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
</IconWrapper>
|
|
264
|
-
</Tooltip>
|
|
250
|
+
<IconWrapper aria-label={t('article.access.onlyTeacher')} title={t('article.access.onlyTeacher')}>
|
|
251
|
+
<HumanMaleBoard id={accessId} />
|
|
252
|
+
</IconWrapper>
|
|
265
253
|
)}
|
|
266
254
|
{showAdditionalResources && contentTypeDescription && (
|
|
267
255
|
<>
|
|
268
256
|
{additional && (
|
|
269
|
-
<
|
|
270
|
-
<
|
|
271
|
-
|
|
272
|
-
</IconWrapper>
|
|
273
|
-
</Tooltip>
|
|
257
|
+
<IconWrapper id={additionalId} aria-label={contentTypeDescription} title={contentTypeDescription}>
|
|
258
|
+
<Additional />
|
|
259
|
+
</IconWrapper>
|
|
274
260
|
)}
|
|
275
261
|
{!additional && (
|
|
276
|
-
<
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
</IconWrapper>
|
|
280
|
-
</Tooltip>
|
|
262
|
+
<IconWrapper id={coreId} aria-label={contentTypeDescription} title={contentTypeDescription}>
|
|
263
|
+
<Core />
|
|
264
|
+
</IconWrapper>
|
|
281
265
|
)}
|
|
282
266
|
</>
|
|
283
267
|
)}
|
|
@@ -8,39 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
import { ReactNode } from 'react';
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
|
-
import { css, keyframes } from '@emotion/react';
|
|
12
11
|
import { useTranslation } from 'react-i18next';
|
|
13
12
|
import { fonts } from '@ndla/core';
|
|
14
13
|
import NoContentBox from '../NoContentBox';
|
|
15
14
|
import ResourceItem from './ResourceItem';
|
|
16
15
|
import { Resource } from '../types';
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
0% {
|
|
20
|
-
opacity: 0.5;
|
|
21
|
-
}
|
|
22
|
-
99% {
|
|
23
|
-
opacity: 0.5;
|
|
24
|
-
}
|
|
25
|
-
100% {
|
|
26
|
-
opacity: 1;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
type StyledListProps = {
|
|
31
|
-
showAdditionalResources?: boolean;
|
|
32
|
-
};
|
|
33
|
-
const StyledResourceList = styled.ul<StyledListProps>`
|
|
17
|
+
const StyledResourceList = styled.ul`
|
|
34
18
|
list-style: none;
|
|
35
19
|
margin: 0;
|
|
36
20
|
padding: 0;
|
|
37
21
|
font-family: ${fonts.sans};
|
|
38
|
-
${({ showAdditionalResources }) =>
|
|
39
|
-
showAdditionalResources &&
|
|
40
|
-
css`
|
|
41
|
-
animation-name: ${fakeLoadingAnimation};
|
|
42
|
-
animation-duration: 0.4s;
|
|
43
|
-
`}
|
|
44
22
|
`;
|
|
45
23
|
|
|
46
24
|
export type ResourceListProps = {
|
|
@@ -68,7 +46,7 @@ const ResourceList = ({
|
|
|
68
46
|
|
|
69
47
|
return (
|
|
70
48
|
<div>
|
|
71
|
-
<StyledResourceList
|
|
49
|
+
<StyledResourceList>
|
|
72
50
|
{resources.map(({ id, ...resource }) => (
|
|
73
51
|
<ResourceItem
|
|
74
52
|
id={id}
|
|
@@ -882,8 +882,8 @@ const messages = {
|
|
|
882
882
|
},
|
|
883
883
|
openMenuTooltip: 'Open menu',
|
|
884
884
|
mobileStepInfo: '{{currentPage}} out of {{totalPages}}',
|
|
885
|
-
nextArrow: '
|
|
886
|
-
previousArrow: '
|
|
885
|
+
nextArrow: 'Go to next step',
|
|
886
|
+
previousArrow: 'Go to previous step',
|
|
887
887
|
},
|
|
888
888
|
dropdown: {
|
|
889
889
|
numberHits: `Search returned {{hits}} hits`,
|
|
@@ -881,8 +881,8 @@ const messages = {
|
|
|
881
881
|
},
|
|
882
882
|
openMenuTooltip: 'Vis læringssti',
|
|
883
883
|
mobileStepInfo: '{{currentPage}} av {{totalPages}}',
|
|
884
|
-
nextArrow: '
|
|
885
|
-
previousArrow: '
|
|
884
|
+
nextArrow: 'Gå til neste steg',
|
|
885
|
+
previousArrow: 'Gå til forrige steg',
|
|
886
886
|
},
|
|
887
887
|
dropdown: {
|
|
888
888
|
numberHits: `Søket gav {{hits}} treff`,
|
|
@@ -881,8 +881,8 @@ const messages = {
|
|
|
881
881
|
},
|
|
882
882
|
openMenuTooltip: 'Vis læringssti',
|
|
883
883
|
mobileStepInfo: '{{currentPage}} av {{totalPages}}',
|
|
884
|
-
nextArrow: '
|
|
885
|
-
previousArrow: '
|
|
884
|
+
nextArrow: 'Gå til neste steg',
|
|
885
|
+
previousArrow: 'Gå til førre steg',
|
|
886
886
|
},
|
|
887
887
|
dropdown: {
|
|
888
888
|
numberHits: `Søket gav {{hits}} treff`,
|
|
@@ -882,8 +882,8 @@ const messages = {
|
|
|
882
882
|
},
|
|
883
883
|
openMenuTooltip: 'Čájet oahppobálgá',
|
|
884
884
|
mobileStepInfo: '{{currentPage}} oktiibuot {{totalPages}} siidduin',
|
|
885
|
-
nextArrow: '
|
|
886
|
-
previousArrow: '
|
|
885
|
+
nextArrow: 'Gå til neste steg',
|
|
886
|
+
previousArrow: 'Gå til førre steg',
|
|
887
887
|
},
|
|
888
888
|
dropdown: {
|
|
889
889
|
numberHits: `Ohcamis ledje {{hits}} deaivama`,
|
|
@@ -885,8 +885,8 @@ const messages = {
|
|
|
885
885
|
},
|
|
886
886
|
openMenuTooltip: 'Vuesehth lïeremebaalkam',
|
|
887
887
|
mobileStepInfo: '{{currentPage}} ållesth {{totalPages}}:ste',
|
|
888
|
-
nextArrow: '
|
|
889
|
-
previousArrow: '
|
|
888
|
+
nextArrow: 'Gå til neste steg',
|
|
889
|
+
previousArrow: 'Gå til førre steg',
|
|
890
890
|
},
|
|
891
891
|
dropdown: {
|
|
892
892
|
numberHits: `Datne {{hits}} gaavnedimmieh åadtjoejih`,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const ENV_REGEX = /(staging|test)\.?/;
|
|
10
|
+
|
|
11
|
+
const NDLA_URL = /(.*\.)?ndla.no.*/;
|
|
12
|
+
|
|
13
|
+
export const usePossiblyRelativeUrl = (url: string, path?: string) => {
|
|
14
|
+
if (!path) return url;
|
|
15
|
+
if (!NDLA_URL.test(url) || !NDLA_URL.test(path)) return url;
|
|
16
|
+
const urlObj = new URL(url.replace(ENV_REGEX, ''));
|
|
17
|
+
const pathObj = new URL(path.replace(ENV_REGEX, ''));
|
|
18
|
+
if (urlObj.host === pathObj.host) return urlObj.pathname;
|
|
19
|
+
return url;
|
|
20
|
+
};
|