@ndla/ui 3.3.9 → 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/Breadcrumblist/Breadcrumblist.js +14 -10
- package/es/CloseButton/CloseButton.js +62 -0
- package/es/CloseButton/index.js +9 -0
- 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 +2 -1
- package/es/Programme/Programme.js +15 -8
- package/es/SearchTypeResult/SearchNotionItem.js +12 -12
- package/es/SearchTypeResult/SearchNotionsResult.js +9 -14
- 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/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/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/Programme/Programme.d.ts +2 -1
- package/lib/Programme/Programme.js +18 -9
- package/lib/SearchTypeResult/SearchNotionItem.js +12 -12
- package/lib/SearchTypeResult/SearchNotionsResult.js +8 -13
- 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 +9 -9
- package/src/Article/Article.tsx +17 -0
- package/src/Article/ArticleNotions.tsx +10 -7
- package/src/Breadcrumblist/Breadcrumblist.tsx +5 -3
- package/src/CloseButton/CloseButton.tsx +40 -0
- package/src/CloseButton/index.ts +11 -0
- 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 +1 -0
- package/src/Programme/Programme.tsx +7 -3
- package/src/SearchTypeResult/SearchNotionItem.tsx +0 -1
- package/src/SearchTypeResult/SearchNotionsResult.tsx +3 -8
- 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
|
@@ -1,182 +0,0 @@
|
|
|
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 from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import {
|
|
12
|
-
LicenseDescription,
|
|
13
|
-
getLicenseByAbbreviation,
|
|
14
|
-
resourceTypes,
|
|
15
|
-
getResourceTypeNamespace,
|
|
16
|
-
isCreativeCommonsLicense,
|
|
17
|
-
metaTypes,
|
|
18
|
-
} from '@ndla/licenses';
|
|
19
|
-
import BEMHelper from 'react-bem-helper';
|
|
20
|
-
import { uuid } from '@ndla/util';
|
|
21
|
-
|
|
22
|
-
const oClasses = new BEMHelper({
|
|
23
|
-
name: 'media',
|
|
24
|
-
prefix: 'o-',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const cClasses = new BEMHelper({
|
|
28
|
-
name: 'medialist',
|
|
29
|
-
prefix: 'c-',
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export const MediaList = ({ children }) => <ul {...cClasses()}>{children}</ul>;
|
|
33
|
-
|
|
34
|
-
MediaList.propTypes = {
|
|
35
|
-
children: PropTypes.node.isRequired,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const MediaListItem = ({ children }) => (
|
|
39
|
-
<li {...oClasses(null, null, cClasses('item').className)}>{children}</li>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
MediaListItem.propTypes = {
|
|
43
|
-
children: PropTypes.node.isRequired,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const MediaListItemImage = ({ children }) => (
|
|
47
|
-
<div {...oClasses('img', null, cClasses('img').className)}>
|
|
48
|
-
<div>{children}</div>
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
MediaListItemImage.propTypes = {
|
|
53
|
-
children: PropTypes.node.isRequired,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const MediaListCCLink = ({ children, url }) => (
|
|
57
|
-
<a className="c-figure-license__link" target="_blank" rel="noopener noreferrer license" href={url}>
|
|
58
|
-
{children}
|
|
59
|
-
</a>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
MediaListCCLink.propTypes = {
|
|
63
|
-
children: PropTypes.node.isRequired,
|
|
64
|
-
url: PropTypes.string.isRequired,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
MediaListCCLink.defaultProps = {
|
|
68
|
-
language: 'no',
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const MediaListItemBody = ({
|
|
72
|
-
children,
|
|
73
|
-
license: licenseAbbreviation,
|
|
74
|
-
messages,
|
|
75
|
-
title,
|
|
76
|
-
locale,
|
|
77
|
-
resourceUrl,
|
|
78
|
-
resourceType,
|
|
79
|
-
}) => {
|
|
80
|
-
const license = getLicenseByAbbreviation(licenseAbbreviation, locale);
|
|
81
|
-
const containerProps = isCreativeCommonsLicense(license.rights)
|
|
82
|
-
? {
|
|
83
|
-
...oClasses('body', null, cClasses('body').className),
|
|
84
|
-
'xmlns:cc': 'https://creativecommons.org/ns#',
|
|
85
|
-
'xmlns:dct': 'http://purl.org/dc/terms/',
|
|
86
|
-
about: resourceUrl,
|
|
87
|
-
}
|
|
88
|
-
: {
|
|
89
|
-
...oClasses('body', null, cClasses('body').className),
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const metaResourceType = getResourceTypeNamespace(resourceType);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<div {...containerProps}>
|
|
96
|
-
{metaResourceType && <span rel="dct:type" href={metaResourceType} style={{ display: 'none' }} />}
|
|
97
|
-
{title ? <h3 className="c-medialist__title">{title} </h3> : null}
|
|
98
|
-
<LicenseDescription
|
|
99
|
-
withDescription
|
|
100
|
-
locale={locale}
|
|
101
|
-
messages={messages}
|
|
102
|
-
licenseRights={license.rights}
|
|
103
|
-
highlightCC
|
|
104
|
-
/>
|
|
105
|
-
<MediaListCCLink url={license.url}>{license.linkText}</MediaListCCLink>
|
|
106
|
-
{children}
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
MediaListItemBody.propTypes = {
|
|
112
|
-
children: PropTypes.node.isRequired,
|
|
113
|
-
license: PropTypes.string.isRequired,
|
|
114
|
-
locale: PropTypes.string.isRequired,
|
|
115
|
-
resourceUrl: PropTypes.string,
|
|
116
|
-
resourceType: PropTypes.oneOf(Object.keys(resourceTypes).map((key) => resourceTypes[key])),
|
|
117
|
-
messages: PropTypes.shape({
|
|
118
|
-
modelPremission: PropTypes.string,
|
|
119
|
-
}),
|
|
120
|
-
title: PropTypes.string,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
MediaListItemBody.defaultProps = {
|
|
124
|
-
resourceUrl: '', // defaults to current page
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const MediaListItemActions = ({ children }) => <div {...cClasses('actions')}>{children}</div>;
|
|
128
|
-
|
|
129
|
-
MediaListItemActions.propTypes = {
|
|
130
|
-
children: PropTypes.node.isRequired,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const isLink = (text) => text.startsWith('http') || text.startsWith('https');
|
|
134
|
-
|
|
135
|
-
export const HandleLink = ({ text, children }) => {
|
|
136
|
-
if (isLink(text)) {
|
|
137
|
-
return (
|
|
138
|
-
<a href={text} target="_blank" rel="noopener noreferrer">
|
|
139
|
-
{children}
|
|
140
|
-
</a>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
return <span>{children}</span>;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
HandleLink.propTypes = {
|
|
147
|
-
text: PropTypes.string.isRequired,
|
|
148
|
-
children: PropTypes.node.isRequired,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
|
|
152
|
-
|
|
153
|
-
export const MediaListItemMeta = ({ items }) => {
|
|
154
|
-
const attributionItems = items.filter((item) => attributionTypes.some((type) => type === item.metaType));
|
|
155
|
-
const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(', ');
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<ul {...cClasses('actions')} property="cc:attributionName" content={attributionMeta}>
|
|
159
|
-
{items.map((item) => (
|
|
160
|
-
<li key={uuid()} className="c-medialist__meta-item">
|
|
161
|
-
{item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
|
|
162
|
-
</li>
|
|
163
|
-
))}
|
|
164
|
-
</ul>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const mediaListItemShape = PropTypes.arrayOf(
|
|
169
|
-
PropTypes.shape({
|
|
170
|
-
label: PropTypes.string.isRequired,
|
|
171
|
-
description: PropTypes.string.isRequired,
|
|
172
|
-
metaType: PropTypes.oneOf(Object.keys(metaTypes).map((key) => metaTypes[key])).isRequired,
|
|
173
|
-
}),
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
MediaListItemMeta.propTypes = {
|
|
177
|
-
items: mediaListItemShape,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
MediaListItemMeta.defaultProps = {
|
|
181
|
-
items: [],
|
|
182
|
-
};
|