@ndla/ui 54.0.6 → 55.0.1-alpha.0
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/ContactBlock/ContactBlock.js +14 -15
- package/es/Embed/AudioEmbed.js +1 -32
- package/es/Embed/BrightcoveEmbed.js +6 -10
- package/es/Embed/ConceptEmbed.js +8 -33
- package/es/Embed/ImageEmbed.js +36 -79
- package/es/Embed/UuDisclaimerEmbed.js +4 -12
- package/es/Embed/conceptComponents.js +28 -29
- package/es/LicenseByline/EmbedByline.js +44 -61
- package/es/LicenseByline/LicenseDescription.js +44 -8
- package/es/LicenseByline/LicenseLink.js +7 -11
- package/es/Messages/MessageBox.js +6 -6
- package/es/index.js +1 -2
- package/es/locale/messages-en.js +34 -21
- package/es/locale/messages-nb.js +34 -21
- package/es/locale/messages-nn.js +33 -20
- package/es/locale/messages-se.js +35 -22
- package/es/locale/messages-sma.js +34 -21
- package/lib/ContactBlock/ContactBlock.js +14 -15
- package/lib/Embed/AudioEmbed.d.ts +1 -3
- package/lib/Embed/AudioEmbed.js +1 -32
- package/lib/Embed/BrightcoveEmbed.d.ts +2 -3
- package/lib/Embed/BrightcoveEmbed.js +6 -10
- package/lib/Embed/ConceptEmbed.d.ts +4 -9
- package/lib/Embed/ConceptEmbed.js +8 -33
- package/lib/Embed/ImageEmbed.d.ts +2 -5
- package/lib/Embed/ImageEmbed.js +34 -79
- package/lib/Embed/UuDisclaimerEmbed.js +3 -11
- package/lib/Embed/conceptComponents.d.ts +0 -3
- package/lib/Embed/conceptComponents.js +28 -29
- package/lib/LicenseByline/EmbedByline.d.ts +7 -6
- package/lib/LicenseByline/EmbedByline.js +46 -60
- package/lib/LicenseByline/LicenseDescription.d.ts +3 -2
- package/lib/LicenseByline/LicenseDescription.js +43 -7
- package/lib/LicenseByline/LicenseLink.d.ts +3 -4
- package/lib/LicenseByline/LicenseLink.js +6 -10
- package/lib/Messages/MessageBox.js +6 -6
- package/lib/index.d.ts +1 -3
- package/lib/index.js +6 -37
- package/lib/locale/messages-en.d.ts +18 -5
- package/lib/locale/messages-en.js +34 -21
- package/lib/locale/messages-nb.d.ts +18 -5
- package/lib/locale/messages-nb.js +34 -21
- package/lib/locale/messages-nn.d.ts +18 -5
- package/lib/locale/messages-nn.js +33 -20
- package/lib/locale/messages-se.d.ts +18 -5
- package/lib/locale/messages-se.js +35 -22
- package/lib/locale/messages-sma.d.ts +18 -5
- package/lib/locale/messages-sma.js +34 -21
- package/package.json +9 -10
- package/src/ContactBlock/ContactBlock.tsx +1 -1
- package/src/Embed/AudioEmbed.stories.tsx +0 -5
- package/src/Embed/AudioEmbed.tsx +3 -40
- package/src/Embed/BrightcoveEmbed.stories.tsx +0 -4
- package/src/Embed/BrightcoveEmbed.tsx +2 -5
- package/src/Embed/ConceptEmbed.stories.tsx +0 -5
- package/src/Embed/ConceptEmbed.tsx +4 -26
- package/src/Embed/ImageEmbed.stories.tsx +0 -12
- package/src/Embed/ImageEmbed.tsx +33 -89
- package/src/Embed/UuDisclaimerEmbed.tsx +2 -1
- package/src/Embed/conceptComponents.tsx +14 -12
- package/src/LicenseByline/EmbedByline.stories.tsx +1 -26
- package/src/LicenseByline/EmbedByline.tsx +50 -82
- package/src/LicenseByline/LicenseDescription.tsx +66 -8
- package/src/LicenseByline/LicenseLink.tsx +6 -12
- package/src/Messages/MessageBox.tsx +1 -0
- package/src/index.ts +1 -12
- package/src/locale/messages-en.ts +30 -17
- package/src/locale/messages-nb.ts +30 -17
- package/src/locale/messages-nn.ts +30 -17
- package/src/locale/messages-se.ts +31 -18
- package/src/locale/messages-sma.ts +30 -17
- package/es/MediaList/MediaList.js +0 -215
- package/es/MediaList/index.js +0 -8
- package/lib/MediaList/MediaList.d.ts +0 -49
- package/lib/MediaList/MediaList.js +0 -227
- package/lib/MediaList/index.d.ts +0 -9
- package/lib/MediaList/index.js +0 -42
- package/src/MediaList/MediaList.tsx +0 -285
- package/src/MediaList/index.ts +0 -17
|
@@ -1,285 +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 { ComponentProps, ReactNode } from "react";
|
|
10
|
-
import styled from "@emotion/styled";
|
|
11
|
-
import { breakpoints, colors, fonts, mq, spacing, stackOrder } from "@ndla/core";
|
|
12
|
-
import { Launch } from "@ndla/icons/common";
|
|
13
|
-
import {
|
|
14
|
-
getLicenseByAbbreviation,
|
|
15
|
-
getResourceTypeNamespace,
|
|
16
|
-
isCreativeCommonsLicense,
|
|
17
|
-
metaTypes,
|
|
18
|
-
} from "@ndla/licenses";
|
|
19
|
-
import type { MetaType } from "@ndla/licenses";
|
|
20
|
-
import { LicenseDescription } from "@ndla/notion";
|
|
21
|
-
import { SafeLink } from "@ndla/safelink";
|
|
22
|
-
import { Text } from "@ndla/typography";
|
|
23
|
-
import { uuid } from "@ndla/util";
|
|
24
|
-
|
|
25
|
-
const StyledMediaList = styled.ul`
|
|
26
|
-
padding-left: 0;
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: column;
|
|
29
|
-
margin: ${spacing.normal} 0;
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
export const MediaList = ({ children, ...rest }: ComponentProps<"ul">) => (
|
|
33
|
-
<StyledMediaList {...rest}>{children}</StyledMediaList>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const StyledMediaListItem = styled.li`
|
|
37
|
-
margin-bottom: ${spacing.small};
|
|
38
|
-
padding: ${spacing.small} 0;
|
|
39
|
-
border-bottom: 1px solid ${colors.brand.tertiary};
|
|
40
|
-
list-style: none;
|
|
41
|
-
${mq.range({ from: breakpoints.tablet })} {
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: row;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&:last-of-type {
|
|
47
|
-
border-bottom: none;
|
|
48
|
-
}
|
|
49
|
-
img {
|
|
50
|
-
width: 100%;
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
export const MediaListItem = ({ children, ...rest }: ComponentProps<"li">) => (
|
|
55
|
-
<StyledMediaListItem {...rest}>{children}</StyledMediaListItem>
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
interface MediaListItemImageProps {
|
|
59
|
-
children: ReactNode;
|
|
60
|
-
canOpen?: boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const ImageWrapper = styled.div`
|
|
64
|
-
position: relative;
|
|
65
|
-
align-self: flex-start;
|
|
66
|
-
margin-right: ${spacing.small};
|
|
67
|
-
${mq.range({ from: breakpoints.tablet })} {
|
|
68
|
-
width: 25%;
|
|
69
|
-
}
|
|
70
|
-
a {
|
|
71
|
-
display: block;
|
|
72
|
-
box-shadow: none;
|
|
73
|
-
}
|
|
74
|
-
&:hover,
|
|
75
|
-
&:focus-visible {
|
|
76
|
-
[data-open-indicator] {
|
|
77
|
-
background-color: ${colors.brand.dark};
|
|
78
|
-
padding: ${spacing.xsmall};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
const OpenIndicator = styled.div`
|
|
84
|
-
position: absolute;
|
|
85
|
-
display: flex;
|
|
86
|
-
align-items: center;
|
|
87
|
-
right: ${spacing.xsmall};
|
|
88
|
-
bottom: ${spacing.xsmall};
|
|
89
|
-
padding: ${spacing.xxsmall};
|
|
90
|
-
transition: all 50ms ease-in;
|
|
91
|
-
background-color: ${colors.brand.primary};
|
|
92
|
-
border-radius: 100%;
|
|
93
|
-
pointer-events: none;
|
|
94
|
-
z-index: ${stackOrder.offsetSingle};
|
|
95
|
-
svg {
|
|
96
|
-
color: ${colors.white};
|
|
97
|
-
width: ${spacing.normal};
|
|
98
|
-
height: ${spacing.normal};
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
export const MediaListItemImage = ({ children, canOpen }: MediaListItemImageProps) => (
|
|
103
|
-
<ImageWrapper>
|
|
104
|
-
{canOpen && (
|
|
105
|
-
<OpenIndicator data-open-indicator>
|
|
106
|
-
<Launch />
|
|
107
|
-
</OpenIndicator>
|
|
108
|
-
)}
|
|
109
|
-
{children}
|
|
110
|
-
</ImageWrapper>
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
interface MediaListItemBodyProps {
|
|
114
|
-
children: ReactNode;
|
|
115
|
-
license: string;
|
|
116
|
-
locale: string;
|
|
117
|
-
resourceUrl?: string;
|
|
118
|
-
resourceType?: "video" | "image" | "audio" | "text" | "h5p" | "podcast";
|
|
119
|
-
messages?: {
|
|
120
|
-
modelPremission?: string;
|
|
121
|
-
};
|
|
122
|
-
title?: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const StyledMediaListItemBody = styled.div`
|
|
126
|
-
${fonts.size.text.metaText.small};
|
|
127
|
-
${mq.range({ from: breakpoints.tablet })} {
|
|
128
|
-
max-width: 70%;
|
|
129
|
-
}
|
|
130
|
-
${mq.range({ from: breakpoints.desktop })} {
|
|
131
|
-
max-width: 75%;
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
|
|
135
|
-
const BodyTitle = styled(Text)`
|
|
136
|
-
color: ${colors.brand.primary};
|
|
137
|
-
font-weight: ${fonts.weight.bold};
|
|
138
|
-
margin-bottom: ${spacing.xsmall};
|
|
139
|
-
+ p {
|
|
140
|
-
margin-top: ${spacing.small};
|
|
141
|
-
}
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
export const MediaListItemBody = ({
|
|
145
|
-
children,
|
|
146
|
-
license: licenseAbbreviation,
|
|
147
|
-
messages,
|
|
148
|
-
title,
|
|
149
|
-
locale,
|
|
150
|
-
resourceUrl = "", // defaults to current page
|
|
151
|
-
resourceType,
|
|
152
|
-
}: MediaListItemBodyProps) => {
|
|
153
|
-
const license = getLicenseByAbbreviation(licenseAbbreviation, locale);
|
|
154
|
-
const containerProps = isCreativeCommonsLicense(license.rights)
|
|
155
|
-
? {
|
|
156
|
-
"xmlns:cc": "https://creativecommons.org/ns#",
|
|
157
|
-
"xmlns:dct": "http://purl.org/dc/terms/",
|
|
158
|
-
about: resourceUrl,
|
|
159
|
-
}
|
|
160
|
-
: {};
|
|
161
|
-
|
|
162
|
-
const metaResourceType = getResourceTypeNamespace(resourceType);
|
|
163
|
-
const hidden = {
|
|
164
|
-
display: "none",
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<StyledMediaListItemBody {...containerProps}>
|
|
169
|
-
{/* @ts-ignore */}
|
|
170
|
-
{metaResourceType && <span rel="dct:type" href={metaResourceType} style={hidden} />}
|
|
171
|
-
{title ? (
|
|
172
|
-
<BodyTitle element="h3" margin="none" textStyle="meta-text-medium">
|
|
173
|
-
{title}
|
|
174
|
-
</BodyTitle>
|
|
175
|
-
) : null}
|
|
176
|
-
<LicenseDescription locale={locale} messages={messages} licenseRights={license.rights} highlightCC />
|
|
177
|
-
<SafeLink rel="noopener noreferrer license" target="_blank" to={license.url}>
|
|
178
|
-
{license.linkText}
|
|
179
|
-
</SafeLink>
|
|
180
|
-
{children}
|
|
181
|
-
</StyledMediaListItemBody>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const StyledMediaListItemActions = styled.div`
|
|
186
|
-
margin: ${spacing.small} 0;
|
|
187
|
-
list-style: none;
|
|
188
|
-
width: 100%;
|
|
189
|
-
button,
|
|
190
|
-
a {
|
|
191
|
-
margin: 0 ${spacing.small} ${spacing.small} 0;
|
|
192
|
-
}
|
|
193
|
-
`;
|
|
194
|
-
|
|
195
|
-
export const MediaListItemActions = ({ children, ...rest }: ComponentProps<"div">) => (
|
|
196
|
-
<StyledMediaListItemActions {...rest}>{children}</StyledMediaListItemActions>
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
const isLink = (text: string) => text.startsWith("http") || text.startsWith("https");
|
|
200
|
-
|
|
201
|
-
interface HandleLinkProps {
|
|
202
|
-
text: string;
|
|
203
|
-
children: ReactNode;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export const HandleLink = ({ text, children }: HandleLinkProps) => {
|
|
207
|
-
if (isLink(text)) {
|
|
208
|
-
return (
|
|
209
|
-
<SafeLink to={text} target="_blank" rel="noopener noreferrer">
|
|
210
|
-
{children}
|
|
211
|
-
</SafeLink>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
return <span>{children}</span>;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
|
|
218
|
-
|
|
219
|
-
export type ItemType = ItemTypeWithDescription | DescriptionLessItemType;
|
|
220
|
-
|
|
221
|
-
interface ItemTypeWithDescription {
|
|
222
|
-
label: string;
|
|
223
|
-
description: string;
|
|
224
|
-
metaType: Omit<MetaType, "otherWithoutDescription">;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
interface DescriptionLessItemType {
|
|
228
|
-
label: string;
|
|
229
|
-
metaType: "otherWithoutDescription";
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function isOtherWithoutDescription(item: ItemType): item is DescriptionLessItemType {
|
|
233
|
-
return item.metaType === metaTypes.otherWithoutDescription;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
interface MediaListItemMetaProps {
|
|
237
|
-
items?: ItemType[];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const ItemText = ({ item }: { item: ItemType }) => {
|
|
241
|
-
if (isOtherWithoutDescription(item)) {
|
|
242
|
-
return <>{item.label}</>;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<>
|
|
247
|
-
{item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
|
|
248
|
-
</>
|
|
249
|
-
);
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
function isAttributionItem(item: ItemType): item is ItemTypeWithDescription {
|
|
253
|
-
if (isOtherWithoutDescription(item)) return false;
|
|
254
|
-
return attributionTypes.some((type) => type === item.metaType);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const StyledMediaListItemMeta = styled.ul`
|
|
258
|
-
margin: ${spacing.small} 0;
|
|
259
|
-
list-style: none;
|
|
260
|
-
width: 100%;
|
|
261
|
-
button,
|
|
262
|
-
a {
|
|
263
|
-
margin: 0 ${spacing.small} ${spacing.small} 0;
|
|
264
|
-
}
|
|
265
|
-
`;
|
|
266
|
-
|
|
267
|
-
const StyledMediaListMetaItem = styled.li`
|
|
268
|
-
margin: 0;
|
|
269
|
-
padding: 0;
|
|
270
|
-
`;
|
|
271
|
-
|
|
272
|
-
export const MediaListItemMeta = ({ items = [] }: MediaListItemMetaProps) => {
|
|
273
|
-
const attributionItems = items.filter(isAttributionItem);
|
|
274
|
-
const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(", ");
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<StyledMediaListItemMeta property="cc:attributionName" content={attributionMeta}>
|
|
278
|
-
{items.map((item) => (
|
|
279
|
-
<StyledMediaListMetaItem key={uuid()}>
|
|
280
|
-
<ItemText item={item} />
|
|
281
|
-
</StyledMediaListMetaItem>
|
|
282
|
-
))}
|
|
283
|
-
</StyledMediaListItemMeta>
|
|
284
|
-
);
|
|
285
|
-
};
|
package/src/MediaList/index.ts
DELETED
|
@@ -1,17 +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
|
-
export {
|
|
9
|
-
MediaList,
|
|
10
|
-
MediaListItem,
|
|
11
|
-
MediaListItemBody,
|
|
12
|
-
MediaListItemActions,
|
|
13
|
-
MediaListItemImage,
|
|
14
|
-
MediaListItemMeta,
|
|
15
|
-
} from "./MediaList";
|
|
16
|
-
|
|
17
|
-
export type { ItemType } from "./MediaList";
|