@ndla/ui 3.3.6 → 3.3.11
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/Article.js +23 -1
- package/es/Article/ArticleNotions.js +80 -32
- package/es/AudioPlayer/Controls.js +30 -30
- package/es/Breadcrumb/Breadcrumb.js +2 -1
- package/es/Breadcrumblist/Breadcrumblist.js +14 -10
- package/es/CloseButton/CloseButton.js +62 -0
- package/es/CloseButton/index.js +9 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +30 -10
- package/es/Frontpage/FrontpageProgramMenu.js +10 -10
- package/es/MediaList/MediaList.js +22 -73
- package/es/MessageBox/MessageBox.js +146 -78
- package/es/MessageBox/MessageBoxTag.js +37 -0
- package/es/MessageBox/index.js +3 -1
- package/es/NDLAFilm/FilmSlideshow.js +214 -247
- package/es/NDLAFilm/NavigationArrow.js +13 -60
- package/es/NDLAFilm/SlideshowIndicator.js +16 -63
- package/es/NDLAFilm/interfaces.js +0 -0
- package/es/Programme/Programme.js +18 -36
- package/es/Programme/ProgrammeSubjects.js +15 -42
- package/es/SearchTypeResult/SearchNotionItem.js +12 -12
- package/es/SearchTypeResult/SearchNotionsResult.js +9 -14
- package/es/SearchTypeResult/SearchTypeHeader.js +7 -6
- package/es/Spinner/Spinner.js +3 -3
- package/es/index.js +2 -1
- package/es/locale/messages-en.js +10 -0
- package/es/locale/messages-nb.js +10 -0
- package/es/locale/messages-nn.js +10 -0
- package/lib/Article/Article.d.ts +3 -1
- package/lib/Article/Article.js +25 -3
- package/lib/Article/ArticleNotions.js +79 -30
- package/lib/AudioPlayer/Controls.js +30 -30
- package/lib/Breadcrumb/Breadcrumb.js +2 -1
- package/lib/Breadcrumblist/Breadcrumblist.d.ts +2 -1
- package/lib/Breadcrumblist/Breadcrumblist.js +15 -10
- package/lib/CloseButton/CloseButton.d.ts +6 -0
- package/lib/CloseButton/CloseButton.js +69 -0
- package/lib/CloseButton/index.d.ts +9 -0
- package/lib/CloseButton/index.js +15 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +3 -1
- package/lib/ContentTypeBadge/ContentTypeBadge.js +30 -10
- package/lib/Frontpage/FrontpageProgramMenu.js +10 -10
- package/lib/MediaList/MediaList.d.ts +48 -0
- package/lib/MediaList/MediaList.js +24 -78
- package/lib/MediaList/index.d.ts +8 -0
- package/lib/MessageBox/MessageBox.d.ts +22 -6
- package/lib/MessageBox/MessageBox.js +146 -77
- package/lib/MessageBox/MessageBoxTag.d.ts +12 -0
- package/lib/MessageBox/MessageBoxTag.js +44 -0
- package/lib/MessageBox/index.d.ts +3 -1
- package/lib/MessageBox/index.js +22 -2
- package/lib/NDLAFilm/FilmSlideshow.d.ts +16 -0
- package/lib/NDLAFilm/FilmSlideshow.js +214 -248
- package/lib/NDLAFilm/NavigationArrow.d.ts +15 -0
- package/lib/NDLAFilm/NavigationArrow.js +20 -65
- package/lib/NDLAFilm/SlideshowIndicator.d.ts +15 -0
- package/lib/NDLAFilm/SlideshowIndicator.js +16 -69
- package/lib/NDLAFilm/interfaces.d.ts +10 -0
- package/lib/NDLAFilm/interfaces.js +1 -0
- package/lib/NDLAFilm/shapes.d.ts +15 -0
- package/lib/Programme/Programme.d.ts +2 -1
- package/lib/Programme/Programme.js +23 -39
- package/lib/Programme/ProgrammeSubjects.d.ts +3 -2
- package/lib/Programme/ProgrammeSubjects.js +23 -48
- package/lib/SearchTypeResult/SearchNotionItem.js +12 -12
- package/lib/SearchTypeResult/SearchNotionsResult.js +8 -13
- package/lib/SearchTypeResult/SearchTypeHeader.js +7 -6
- package/lib/Spinner/Spinner.d.ts +3 -3
- package/lib/Spinner/Spinner.js +2 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +23 -0
- package/lib/locale/messages-en.d.ts +10 -0
- package/lib/locale/messages-en.js +10 -0
- package/lib/locale/messages-nb.d.ts +10 -0
- package/lib/locale/messages-nb.js +10 -0
- package/lib/locale/messages-nn.d.ts +10 -0
- package/lib/locale/messages-nn.js +10 -0
- package/package.json +10 -10
- package/src/Article/Article.tsx +17 -0
- package/src/Article/ArticleNotions.tsx +10 -7
- package/src/AudioPlayer/Controls.tsx +2 -2
- package/src/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/Breadcrumblist/Breadcrumblist.tsx +5 -3
- package/src/CloseButton/CloseButton.tsx +40 -0
- package/src/CloseButton/index.ts +11 -0
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +11 -9
- package/src/Frontpage/FrontpageProgramMenu.tsx +1 -0
- package/src/MediaList/MediaList.tsx +158 -0
- package/src/MediaList/{index.js → index.ts} +0 -0
- package/src/MessageBox/MessageBox.tsx +117 -96
- package/src/MessageBox/MessageBoxTag.tsx +35 -0
- package/src/MessageBox/index.ts +3 -1
- package/src/NDLAFilm/FilmSlideshow.tsx +265 -0
- package/src/NDLAFilm/NavigationArrow.tsx +42 -0
- package/src/NDLAFilm/SlideshowIndicator.tsx +40 -0
- package/src/NDLAFilm/interfaces.ts +10 -0
- package/src/NDLAFilm/{shapes.js → shapes.ts} +0 -0
- package/src/Programme/Programme.tsx +9 -17
- package/src/Programme/ProgrammeSubjects.tsx +10 -28
- package/src/SearchTypeResult/SearchNotionItem.tsx +0 -1
- package/src/SearchTypeResult/SearchNotionsResult.tsx +3 -8
- package/src/SearchTypeResult/SearchTypeHeader.tsx +1 -1
- package/src/Spinner/Spinner.tsx +9 -5
- package/src/index.ts +2 -1
- package/src/locale/messages-en.ts +14 -0
- package/src/locale/messages-nb.ts +14 -0
- package/src/locale/messages-nn.ts +14 -0
- package/src/MediaList/MediaList.jsx +0 -182
- package/src/NDLAFilm/FilmSlideshow.jsx +0 -277
- package/src/NDLAFilm/NavigationArrow.jsx +0 -46
- package/src/NDLAFilm/SlideshowIndicator.jsx +0 -43
|
@@ -12,8 +12,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
12
12
|
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
import Modal, { ModalHeader, ModalCloseButton, ModalBody } from '@ndla/modal';
|
|
15
|
-
import { mq, breakpoints
|
|
16
|
-
import { Explanation
|
|
15
|
+
import { mq, breakpoints } from '@ndla/core';
|
|
16
|
+
import { Explanation } from '@ndla/icons/common';
|
|
17
17
|
import { Locale } from '../types';
|
|
18
18
|
import { Notion } from '../Notion';
|
|
19
19
|
import { NotionProps } from '../Notion/Notion';
|
|
@@ -25,6 +25,7 @@ const ArticleNotionsContainer = styled.div`
|
|
|
25
25
|
margin-bottom: 0;
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
|
+
/* Stored for later
|
|
28
29
|
|
|
29
30
|
const NotionsTrigger = styled.div`
|
|
30
31
|
padding: 0 16px;
|
|
@@ -33,7 +34,7 @@ const NotionsTrigger = styled.div`
|
|
|
33
34
|
background-color: ${colors.brand.greyLighter};
|
|
34
35
|
border-radius: 4px;
|
|
35
36
|
cursor: pointer;
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
${mq.range({ from: breakpoints.tablet })} {
|
|
38
39
|
position: fixed;
|
|
39
40
|
border: none;
|
|
@@ -81,7 +82,7 @@ const NotionsTrigger = styled.div`
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
`;
|
|
84
|
-
|
|
85
|
+
*/
|
|
85
86
|
const ModalHeadingContainer = styled.div`
|
|
86
87
|
display: flex;
|
|
87
88
|
align-items: center;
|
|
@@ -176,17 +177,19 @@ export const ArticleNotions = ({
|
|
|
176
177
|
buttonOffsetRight,
|
|
177
178
|
}: ArticleNotionsProps) => {
|
|
178
179
|
const { t } = useTranslation();
|
|
179
|
-
const leftOffset = `${buttonOffsetRight - 32}px`;
|
|
180
|
+
//const leftOffset = `${buttonOffsetRight - 32}px`;
|
|
180
181
|
return (
|
|
181
182
|
<ArticleNotionsContainer>
|
|
182
183
|
<Modal
|
|
183
|
-
|
|
184
|
+
/* Stored for later
|
|
185
|
+
|
|
186
|
+
activateButton={
|
|
184
187
|
<NotionsTrigger role="button" aria-label={t('article.notionsPrompt')} style={{ left: leftOffset }}>
|
|
185
188
|
<NotionFlip />
|
|
186
189
|
<Explanation />
|
|
187
190
|
<span>{t('article.notionsPrompt')}</span>
|
|
188
191
|
</NotionsTrigger>
|
|
189
|
-
}
|
|
192
|
+
} */
|
|
190
193
|
size="large"
|
|
191
194
|
backgroundColor="white">
|
|
192
195
|
{(onClose: () => void) => (
|
|
@@ -415,9 +415,9 @@ const Controls = ({ src, title }: Props) => {
|
|
|
415
415
|
<PlayButton type="button" onClick={togglePlay} title="play" aria-label="play">
|
|
416
416
|
<span aria-hidden>
|
|
417
417
|
{playing ? (
|
|
418
|
-
<Pause role="img" aria-label="
|
|
418
|
+
<Pause role="img" aria-label="Pause" title="Pause" />
|
|
419
419
|
) : (
|
|
420
|
-
<Play role="img" aria-label="
|
|
420
|
+
<Play role="img" aria-label="Play" title="Play" />
|
|
421
421
|
)}
|
|
422
422
|
</span>
|
|
423
423
|
</PlayButton>
|
|
@@ -43,7 +43,7 @@ const Breadcrumb: React.FunctionComponent<Props & WithTranslation> = ({ children
|
|
|
43
43
|
isCurrent={i === items.length - 1}
|
|
44
44
|
to={item.to}
|
|
45
45
|
name={item.name}>
|
|
46
|
-
{i === 0 ? <Home className="c-icon--20" /> : item.name}
|
|
46
|
+
{i === 0 ? <Home className="c-icon--20" title={item.name} /> : item.name}
|
|
47
47
|
</BreadcrumbItem>
|
|
48
48
|
))}
|
|
49
49
|
</ol>
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import React, { useEffect, useState } from 'react';
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
import { mq, breakpoints, colors } from '@ndla/core';
|
|
12
|
-
|
|
13
12
|
import {
|
|
14
13
|
School as SchoolIcon,
|
|
15
14
|
MenuBook as MenuBookIcon,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
} from '@ndla/icons/action';
|
|
21
20
|
import SafeLink from '@ndla/safelink';
|
|
22
21
|
import { useTranslation } from 'react-i18next';
|
|
22
|
+
import MessageBoxTag from '../MessageBox/MessageBoxTag';
|
|
23
23
|
|
|
24
24
|
type WrapperProps = {
|
|
25
25
|
startOffset?: number;
|
|
@@ -51,7 +51,6 @@ const Wrapper = styled.div<WrapperProps>`
|
|
|
51
51
|
${(props) =>
|
|
52
52
|
props.startOffset &&
|
|
53
53
|
`
|
|
54
|
-
position: absolute;
|
|
55
54
|
top: calc(${props.startOffset}px + 85px);
|
|
56
55
|
`}
|
|
57
56
|
}
|
|
@@ -87,7 +86,7 @@ const Heading = styled.div<InvertItProps>`
|
|
|
87
86
|
font-size: 12px;
|
|
88
87
|
line-height: 15px;
|
|
89
88
|
text-transform: uppercase;
|
|
90
|
-
padding: 0 0
|
|
89
|
+
padding: 0 0 10px 10px;
|
|
91
90
|
${(props) =>
|
|
92
91
|
props.invertedStyle &&
|
|
93
92
|
`
|
|
@@ -214,6 +213,7 @@ type BreadCrumbProps = {
|
|
|
214
213
|
leftAlign?: boolean;
|
|
215
214
|
hideOnNarrow?: boolean;
|
|
216
215
|
onNav?: (e: React.MouseEvent<HTMLElement>, item: BreadcrumbItemProps) => void;
|
|
216
|
+
messageBoxTagMessage?: string;
|
|
217
217
|
};
|
|
218
218
|
|
|
219
219
|
const Breadcrumblist = ({
|
|
@@ -225,6 +225,7 @@ const Breadcrumblist = ({
|
|
|
225
225
|
leftAlign,
|
|
226
226
|
hideOnNarrow,
|
|
227
227
|
onNav,
|
|
228
|
+
messageBoxTagMessage,
|
|
228
229
|
}: BreadCrumbProps) => {
|
|
229
230
|
const { t } = useTranslation();
|
|
230
231
|
const [wrapperOffset, setWrapperOffset] = useState(startOffset);
|
|
@@ -274,6 +275,7 @@ const Breadcrumblist = ({
|
|
|
274
275
|
{items.length > 0 && (
|
|
275
276
|
<>
|
|
276
277
|
<Heading invertedStyle={invertedStyle}>{t('breadcrumb.youAreHere')}</Heading>
|
|
278
|
+
{messageBoxTagMessage && <MessageBoxTag tagMessage={messageBoxTagMessage} />}
|
|
277
279
|
<List data-testid="breadcrumb-list">
|
|
278
280
|
{items.map((item: BreadcrumbItemProps) => {
|
|
279
281
|
const { id, label, url, typename, icon, isCurrent = false } = item;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022-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
|
+
import React from 'react';
|
|
9
|
+
import styled from '@emotion/styled';
|
|
10
|
+
import { Cross } from '@ndla/icons/action';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
const CloseButtonWrapper = styled.div`
|
|
13
|
+
position: relative;
|
|
14
|
+
top: 1px;
|
|
15
|
+
right: 1px;
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const CloseBut = styled.button`
|
|
19
|
+
background-color: transparent;
|
|
20
|
+
border: none;
|
|
21
|
+
display: flex;
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
type Props = {
|
|
25
|
+
onClick: () => void;
|
|
26
|
+
color: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const CloseButton = ({ onClick, color }: Props) => {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
return (
|
|
32
|
+
<CloseButtonWrapper aria-label={t('lukk')}>
|
|
33
|
+
<CloseBut onClick={onClick}>
|
|
34
|
+
<Cross style={{ width: '24px', height: '24px', color: color }} />
|
|
35
|
+
</CloseBut>
|
|
36
|
+
</CloseButtonWrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default CloseButton;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2019-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
|
+
import CloseButton from './CloseButton';
|
|
10
|
+
|
|
11
|
+
export { CloseButton };
|
|
@@ -26,11 +26,12 @@ const classes = new BEMHelper({
|
|
|
26
26
|
interface Props {
|
|
27
27
|
size: 'xx-small' | 'x-small' | 'small' | 'large';
|
|
28
28
|
type: string;
|
|
29
|
+
title?: string;
|
|
29
30
|
background?: boolean;
|
|
30
31
|
border?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
34
|
+
export const ContentTypeBadge = ({ type, background, title, size = 'small', border = true }: Props) => {
|
|
34
35
|
const modifiers = [type, size];
|
|
35
36
|
|
|
36
37
|
if (background) {
|
|
@@ -43,28 +44,28 @@ export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
|
43
44
|
let icon = null;
|
|
44
45
|
switch (type) {
|
|
45
46
|
case contentTypes.SUBJECT_MATERIAL:
|
|
46
|
-
icon = <SubjectMaterial />;
|
|
47
|
+
icon = <SubjectMaterial title={title} />;
|
|
47
48
|
break;
|
|
48
49
|
case contentTypes.TASKS_AND_ACTIVITIES:
|
|
49
|
-
icon = <TasksAndActivities />;
|
|
50
|
+
icon = <TasksAndActivities title={title} />;
|
|
50
51
|
break;
|
|
51
52
|
case contentTypes.ASSESSMENT_RESOURCES:
|
|
52
|
-
icon = <AssessmentResource />;
|
|
53
|
+
icon = <AssessmentResource title={title} />;
|
|
53
54
|
break;
|
|
54
55
|
case contentTypes.SUBJECT:
|
|
55
|
-
icon = <MenuBook />;
|
|
56
|
+
icon = <MenuBook title={title} />;
|
|
56
57
|
break;
|
|
57
58
|
case contentTypes.EXTERNAL_LEARNING_RESOURCES:
|
|
58
|
-
icon = <ExternalLearningResource />;
|
|
59
|
+
icon = <ExternalLearningResource title={title} />;
|
|
59
60
|
break;
|
|
60
61
|
case contentTypes.SOURCE_MATERIAL:
|
|
61
|
-
icon = <SharedResource />;
|
|
62
|
+
icon = <SharedResource title={title} />;
|
|
62
63
|
break;
|
|
63
64
|
case contentTypes.LEARNING_PATH:
|
|
64
|
-
icon = <LearningPath />;
|
|
65
|
+
icon = <LearningPath title={title} />;
|
|
65
66
|
break;
|
|
66
67
|
case contentTypes.TOPIC:
|
|
67
|
-
icon = <Subject />;
|
|
68
|
+
icon = <Subject title={title} />;
|
|
68
69
|
break;
|
|
69
70
|
default:
|
|
70
71
|
break;
|
|
@@ -75,6 +76,7 @@ export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
|
75
76
|
ContentTypeBadge.propTypes = {
|
|
76
77
|
size: PropTypes.oneOf(['xx-small', 'x-small', 'small', 'large']),
|
|
77
78
|
type: ContentTypeShape,
|
|
79
|
+
title: PropTypes.string,
|
|
78
80
|
background: PropTypes.bool,
|
|
79
81
|
border: PropTypes.bool,
|
|
80
82
|
};
|
|
@@ -120,6 +120,7 @@ const FrontpageProgramMenu = ({ programItems, subjectCategories, showBetaCursor
|
|
|
120
120
|
<Button onClick={() => toggleSubjects(true)} lighter={!showSubjects} size="medium" borderShape="rounded">
|
|
121
121
|
<StyledMenuItem>{t('frontpageMenu.allsubjects')}</StyledMenuItem>
|
|
122
122
|
</Button>
|
|
123
|
+
|
|
123
124
|
{showBetaCursor && (
|
|
124
125
|
<CursorPlaceholder>
|
|
125
126
|
<CursorWrapper>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-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
|
+
import React, { ReactNode } from 'react';
|
|
10
|
+
import {
|
|
11
|
+
LicenseDescription,
|
|
12
|
+
getLicenseByAbbreviation,
|
|
13
|
+
getResourceTypeNamespace,
|
|
14
|
+
isCreativeCommonsLicense,
|
|
15
|
+
metaTypes,
|
|
16
|
+
} from '@ndla/licenses';
|
|
17
|
+
import BEMHelper from 'react-bem-helper';
|
|
18
|
+
import { uuid } from '@ndla/util';
|
|
19
|
+
|
|
20
|
+
const oClasses = new BEMHelper({
|
|
21
|
+
name: 'media',
|
|
22
|
+
prefix: 'o-',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const cClasses = new BEMHelper({
|
|
26
|
+
name: 'medialist',
|
|
27
|
+
prefix: 'c-',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
interface MediaListProps {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MediaList = ({ children }: MediaListProps) => <ul {...cClasses()}>{children}</ul>;
|
|
35
|
+
|
|
36
|
+
interface MediaListItemProps {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
export const MediaListItem = ({ children }: MediaListItemProps) => (
|
|
40
|
+
<li {...oClasses(undefined, undefined, cClasses('item').className)}>{children}</li>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
interface MediaListItemImageProps {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
export const MediaListItemImage = ({ children }: MediaListItemImageProps) => (
|
|
47
|
+
<div {...oClasses('img', undefined, cClasses('img').className)}>
|
|
48
|
+
<div>{children}</div>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
interface MediaListCCLinkProps {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
url: string;
|
|
55
|
+
}
|
|
56
|
+
export const MediaListCCLink = ({ children, url }: MediaListCCLinkProps) => (
|
|
57
|
+
<a className="c-figure-license__link" target="_blank" rel="noopener noreferrer license" href={url}>
|
|
58
|
+
{children}
|
|
59
|
+
</a>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
interface MediaListItemBodyProps {
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
license: string;
|
|
65
|
+
locale: string;
|
|
66
|
+
resourceUrl?: string;
|
|
67
|
+
resourceType?: 'video' | 'image' | 'audio' | 'text' | 'h5p';
|
|
68
|
+
messages?: {
|
|
69
|
+
modelPremission?: string;
|
|
70
|
+
};
|
|
71
|
+
title?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const MediaListItemBody = ({
|
|
75
|
+
children,
|
|
76
|
+
license: licenseAbbreviation,
|
|
77
|
+
messages,
|
|
78
|
+
title,
|
|
79
|
+
locale,
|
|
80
|
+
resourceUrl = '', // defaults to current page
|
|
81
|
+
resourceType,
|
|
82
|
+
}: MediaListItemBodyProps) => {
|
|
83
|
+
const license = getLicenseByAbbreviation(licenseAbbreviation, locale);
|
|
84
|
+
const containerProps = isCreativeCommonsLicense(license.rights)
|
|
85
|
+
? {
|
|
86
|
+
...oClasses('body', undefined, cClasses('body').className),
|
|
87
|
+
'xmlns:cc': 'https://creativecommons.org/ns#',
|
|
88
|
+
'xmlns:dct': 'http://purl.org/dc/terms/',
|
|
89
|
+
about: resourceUrl,
|
|
90
|
+
}
|
|
91
|
+
: {
|
|
92
|
+
...oClasses('body', undefined, cClasses('body').className),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const metaResourceType = getResourceTypeNamespace(resourceType);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div {...containerProps}>
|
|
99
|
+
{/* @ts-ignore */}
|
|
100
|
+
{metaResourceType && <span rel="dct:type" href={metaResourceType} style={{ display: 'none' }} />}
|
|
101
|
+
{title ? <h3 className="c-medialist__title">{title} </h3> : null}
|
|
102
|
+
<LicenseDescription locale={locale} messages={messages} licenseRights={license.rights} highlightCC />
|
|
103
|
+
<MediaListCCLink url={license.url}>{license.linkText}</MediaListCCLink>
|
|
104
|
+
{children}
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
interface MediaListItemActionsProps {
|
|
110
|
+
children: ReactNode;
|
|
111
|
+
}
|
|
112
|
+
export const MediaListItemActions = ({ children }: MediaListItemActionsProps) => (
|
|
113
|
+
<div {...cClasses('actions')}>{children}</div>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const isLink = (text: string) => text.startsWith('http') || text.startsWith('https');
|
|
117
|
+
|
|
118
|
+
interface HandleLinkProps {
|
|
119
|
+
text: string;
|
|
120
|
+
children: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const HandleLink = ({ text, children }: HandleLinkProps) => {
|
|
124
|
+
if (isLink(text)) {
|
|
125
|
+
return (
|
|
126
|
+
<a href={text} target="_blank" rel="noopener noreferrer">
|
|
127
|
+
{children}
|
|
128
|
+
</a>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return <span>{children}</span>;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
|
|
135
|
+
|
|
136
|
+
interface MediaListItemMetaProps {
|
|
137
|
+
items?: {
|
|
138
|
+
label: string;
|
|
139
|
+
description: string;
|
|
140
|
+
metaType: string;
|
|
141
|
+
}[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const MediaListItemMeta = ({ items = [] }: MediaListItemMetaProps) => {
|
|
145
|
+
const attributionItems = items.filter((item) => attributionTypes.some((type) => type === item.metaType));
|
|
146
|
+
const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(', ');
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
//@ts-ignore
|
|
150
|
+
<ul {...cClasses('actions')} property="cc:attributionName" content={attributionMeta}>
|
|
151
|
+
{items.map((item) => (
|
|
152
|
+
<li key={uuid()} className="c-medialist__meta-item">
|
|
153
|
+
{item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
|
|
154
|
+
</li>
|
|
155
|
+
))}
|
|
156
|
+
</ul>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
File without changes
|