@ndla/ui 56.0.121-alpha.0 → 56.0.122-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/lib/i18n/index.d.ts +1 -1
- package/lib/i18n/useComponentTranslations.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/locale/messages-en.d.ts +34 -0
- package/lib/locale/messages-nb.d.ts +34 -0
- package/lib/locale/messages-nn.d.ts +34 -0
- package/lib/locale/messages-se.d.ts +34 -0
- package/package.json +6 -5
- package/src/Article/ArticleByline.tsx +1 -1
- package/src/i18n/index.ts +1 -0
- package/src/i18n/useComponentTranslations.ts +36 -1
- package/src/index.ts +1 -0
- package/src/locale/messages-en.ts +34 -0
- package/src/locale/messages-nb.ts +34 -0
- package/src/locale/messages-nn.ts +34 -0
- package/src/locale/messages-se.ts +34 -0
- package/es/Article/Article.js +0 -199
- package/es/Article/ArticleByline.js +0 -182
- package/es/Article/ArticleFootNotes.js +0 -60
- package/es/Article/index.js +0 -11
- package/es/AudioPlayer/AudioPlayer.js +0 -218
- package/es/AudioPlayer/Controls.js +0 -332
- package/es/AudioPlayer/SpeechControl.js +0 -56
- package/es/AudioPlayer/index.js +0 -10
- package/es/Breadcrumb/Breadcrumb.js +0 -60
- package/es/Breadcrumb/BreadcrumbItem.js +0 -62
- package/es/Breadcrumb/HomeBreadcrumb.js +0 -77
- package/es/Breadcrumb/index.js +0 -11
- package/es/CampaignBlock/CampaignBlock.js +0 -180
- package/es/CampaignBlock/index.js +0 -9
- package/es/CodeBlock/CodeBlock.js +0 -35
- package/es/CodeBlock/codeLanguageOptions.js +0 -84
- package/es/CodeBlock/index.js +0 -10
- package/es/Concept/Concept.js +0 -72
- package/es/ContactBlock/ContactBlock.js +0 -199
- package/es/ContactBlock/index.js +0 -9
- package/es/ContentTypeBadge/ContentTypeBadge.js +0 -50
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -32
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -32
- package/es/ContentTypeHero/ContentTypeHero.js +0 -50
- package/es/ContentTypeHero/index.js +0 -9
- package/es/CopyParagraphButton/CopyParagraphButton.js +0 -83
- package/es/CopyParagraphButton/index.js +0 -11
- package/es/Embed/AudioEmbed.js +0 -76
- package/es/Embed/BrightcoveEmbed.js +0 -133
- package/es/Embed/CodeEmbed.js +0 -79
- package/es/Embed/ConceptEmbed.js +0 -123
- package/es/Embed/ConceptInlineTriggerButton.js +0 -45
- package/es/Embed/ContentLinkEmbed.js +0 -51
- package/es/Embed/CopyrightEmbed.js +0 -33
- package/es/Embed/EmbedErrorPlaceholder.js +0 -58
- package/es/Embed/EmbedWrapper.js +0 -51
- package/es/Embed/ExternalEmbed.js +0 -74
- package/es/Embed/FootnoteEmbed.js +0 -44
- package/es/Embed/GlossEmbed.js +0 -80
- package/es/Embed/H5pEmbed.js +0 -61
- package/es/Embed/IframeEmbed.js +0 -93
- package/es/Embed/ImageEmbed.js +0 -238
- package/es/Embed/InlineTriggerButton.js +0 -37
- package/es/Embed/RelatedContentEmbed.js +0 -55
- package/es/Embed/UnknownEmbed.js +0 -31
- package/es/Embed/UuDisclaimerEmbed.js +0 -88
- package/es/Embed/index.js +0 -25
- package/es/Embed/types.js +0 -1
- package/es/ErrorMessage/ErrorMessage.js +0 -95
- package/es/ErrorMessage/index.js +0 -10
- package/es/FactBox/FactBox.js +0 -177
- package/es/FactBox/index.js +0 -10
- package/es/FileList/File.js +0 -101
- package/es/FileList/FileList.js +0 -47
- package/es/FileList/PdfFile.js +0 -50
- package/es/FileList/index.js +0 -11
- package/es/Gloss/Gloss.js +0 -175
- package/es/Gloss/GlossExample.js +0 -64
- package/es/Gloss/index.js +0 -10
- package/es/Grid/Grid.js +0 -94
- package/es/Grid/GridParallaxItem.js +0 -32
- package/es/Grid/index.js +0 -10
- package/es/KeyFigure/KeyFigure.js +0 -63
- package/es/KeyFigure/index.js +0 -9
- package/es/LicenseByline/EmbedByline.js +0 -212
- package/es/LicenseByline/LicenseLink.js +0 -56
- package/es/LicenseByline/index.js +0 -10
- package/es/LinkBlock/LinkBlock.js +0 -103
- package/es/LinkBlock/LinkBlockSection.js +0 -35
- package/es/LinkBlock/index.js +0 -10
- package/es/Pitch/Pitch.js +0 -83
- package/es/Pitch/index.js +0 -9
- package/es/RelatedArticleList/RelatedArticleList.js +0 -135
- package/es/RelatedArticleList/index.js +0 -11
- package/es/ResourceBox/ResourceBox.js +0 -99
- package/es/ResourceBox/index.js +0 -10
- package/es/TagSelector/TagSelector.js +0 -143
- package/es/ZendeskButton/ZendeskButton.js +0 -55
- package/es/i18n/formatNestedMessages.js +0 -25
- package/es/i18n/i18n.js +0 -35
- package/es/i18n/index.js +0 -11
- package/es/i18n/useComponentTranslations.js +0 -164
- package/es/index.js +0 -45
- package/es/locale/messages-en.js +0 -428
- package/es/locale/messages-nb.js +0 -428
- package/es/locale/messages-nn.js +0 -428
- package/es/locale/messages-se.js +0 -428
- package/es/model/ContentType.js +0 -68
- package/es/model/SubjectCategories.js +0 -12
- package/es/model/SubjectTypes.js +0 -11
- package/es/model/WordClass.js +0 -45
- package/es/model/index.js +0 -21
- package/es/types.js +0 -1
- package/es/utils/licenseAttributes.js +0 -18
- package/es/utils/relativeUrl.js +0 -37
- package/lib/Article/Article.js +0 -207
- package/lib/Article/ArticleByline.js +0 -189
- package/lib/Article/ArticleFootNotes.js +0 -67
- package/lib/Article/index.js +0 -68
- package/lib/AudioPlayer/AudioPlayer.js +0 -224
- package/lib/AudioPlayer/Controls.js +0 -338
- package/lib/AudioPlayer/SpeechControl.js +0 -62
- package/lib/AudioPlayer/index.js +0 -16
- package/lib/Breadcrumb/Breadcrumb.js +0 -67
- package/lib/Breadcrumb/BreadcrumbItem.js +0 -68
- package/lib/Breadcrumb/HomeBreadcrumb.js +0 -84
- package/lib/Breadcrumb/index.js +0 -23
- package/lib/CampaignBlock/CampaignBlock.js +0 -187
- package/lib/CampaignBlock/index.js +0 -13
- package/lib/CodeBlock/CodeBlock.js +0 -41
- package/lib/CodeBlock/codeLanguageOptions.js +0 -90
- package/lib/CodeBlock/index.js +0 -20
- package/lib/Concept/Concept.js +0 -78
- package/lib/ContactBlock/ContactBlock.js +0 -206
- package/lib/ContactBlock/index.js +0 -18
- package/lib/ContentTypeBadge/ContentTypeBadge.js +0 -57
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +0 -38
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +0 -38
- package/lib/ContentTypeHero/ContentTypeHero.js +0 -57
- package/lib/ContentTypeHero/index.js +0 -12
- package/lib/CopyParagraphButton/CopyParagraphButton.js +0 -89
- package/lib/CopyParagraphButton/index.js +0 -22
- package/lib/Embed/AudioEmbed.js +0 -84
- package/lib/Embed/BrightcoveEmbed.js +0 -142
- package/lib/Embed/CodeEmbed.js +0 -86
- package/lib/Embed/ConceptEmbed.js +0 -131
- package/lib/Embed/ConceptInlineTriggerButton.js +0 -51
- package/lib/Embed/ContentLinkEmbed.js +0 -57
- package/lib/Embed/CopyrightEmbed.js +0 -39
- package/lib/Embed/EmbedErrorPlaceholder.js +0 -64
- package/lib/Embed/EmbedWrapper.js +0 -57
- package/lib/Embed/ExternalEmbed.js +0 -81
- package/lib/Embed/FootnoteEmbed.js +0 -50
- package/lib/Embed/GlossEmbed.js +0 -88
- package/lib/Embed/H5pEmbed.js +0 -68
- package/lib/Embed/IframeEmbed.js +0 -100
- package/lib/Embed/ImageEmbed.js +0 -248
- package/lib/Embed/InlineTriggerButton.js +0 -43
- package/lib/Embed/RelatedContentEmbed.js +0 -61
- package/lib/Embed/UnknownEmbed.js +0 -37
- package/lib/Embed/UuDisclaimerEmbed.js +0 -94
- package/lib/Embed/index.js +0 -150
- package/lib/Embed/types.js +0 -5
- package/lib/ErrorMessage/ErrorMessage.js +0 -101
- package/lib/ErrorMessage/index.js +0 -16
- package/lib/FactBox/FactBox.js +0 -184
- package/lib/FactBox/index.js +0 -16
- package/lib/FileList/File.js +0 -108
- package/lib/FileList/FileList.js +0 -54
- package/lib/FileList/PdfFile.js +0 -57
- package/lib/FileList/index.js +0 -44
- package/lib/Gloss/Gloss.js +0 -181
- package/lib/Gloss/GlossExample.js +0 -70
- package/lib/Gloss/index.js +0 -20
- package/lib/Grid/Grid.js +0 -101
- package/lib/Grid/GridParallaxItem.js +0 -39
- package/lib/Grid/index.js +0 -19
- package/lib/KeyFigure/KeyFigure.js +0 -70
- package/lib/KeyFigure/index.js +0 -13
- package/lib/LicenseByline/EmbedByline.js +0 -220
- package/lib/LicenseByline/LicenseLink.js +0 -62
- package/lib/LicenseByline/index.js +0 -19
- package/lib/LinkBlock/LinkBlock.js +0 -110
- package/lib/LinkBlock/LinkBlockSection.js +0 -41
- package/lib/LinkBlock/index.js +0 -20
- package/lib/Pitch/Pitch.js +0 -91
- package/lib/Pitch/index.js +0 -12
- package/lib/RelatedArticleList/RelatedArticleList.js +0 -143
- package/lib/RelatedArticleList/index.js +0 -21
- package/lib/ResourceBox/ResourceBox.js +0 -106
- package/lib/ResourceBox/index.js +0 -13
- package/lib/TagSelector/TagSelector.js +0 -150
- package/lib/ZendeskButton/ZendeskButton.js +0 -61
- package/lib/i18n/formatNestedMessages.js +0 -32
- package/lib/i18n/i18n.js +0 -41
- package/lib/i18n/index.js +0 -62
- package/lib/i18n/useComponentTranslations.js +0 -176
- package/lib/index.js +0 -593
- package/lib/locale/messages-en.js +0 -435
- package/lib/locale/messages-nb.js +0 -435
- package/lib/locale/messages-nn.js +0 -435
- package/lib/locale/messages-se.js +0 -435
- package/lib/model/ContentType.js +0 -74
- package/lib/model/SubjectCategories.js +0 -18
- package/lib/model/SubjectTypes.js +0 -17
- package/lib/model/WordClass.js +0 -51
- package/lib/model/index.js +0 -28
- package/lib/types.js +0 -5
- package/lib/utils/licenseAttributes.js +0 -25
- package/lib/utils/relativeUrl.js +0 -44
package/es/Embed/ImageEmbed.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
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
|
-
import parse from "html-react-parser";
|
|
10
|
-
import { useMemo, useState } from "react";
|
|
11
|
-
import { useTranslation } from "react-i18next";
|
|
12
|
-
import { AddLine } from "@ndla/icons";
|
|
13
|
-
import { Figure, Image } from "@ndla/primitives";
|
|
14
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
15
|
-
import EmbedErrorPlaceholder from "./EmbedErrorPlaceholder";
|
|
16
|
-
import { EmbedByline } from "../LicenseByline";
|
|
17
|
-
import { licenseAttributes } from "../utils/licenseAttributes";
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
export const getLicenseCredits = copyright => {
|
|
20
|
-
return {
|
|
21
|
-
creators: copyright?.creators ?? [],
|
|
22
|
-
rightsholders: copyright?.rightsholders ?? [],
|
|
23
|
-
processors: copyright?.processors ?? []
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const getFigureProps = (size, float) => {
|
|
27
|
-
const actualFloat = float === "left" ? "left" : float === "right" ? "right" : undefined;
|
|
28
|
-
const replacedSize = size?.replace("-hide-byline", "") ?? "full";
|
|
29
|
-
const actualSize = replacedSize === "fullwidth" ? "full" : replacedSize;
|
|
30
|
-
return {
|
|
31
|
-
float: actualFloat,
|
|
32
|
-
// Figure expects you to set a size when floating. If you don't, the figure will simply take up the available width. Fallback to medium in those cases.
|
|
33
|
-
size: actualSize === "full" && float ? "medium" : actualSize
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const getSizes = (size, align) => {
|
|
37
|
-
if (align && size === "full") {
|
|
38
|
-
return "(min-width: 1024px) 512px, (min-width: 768px) 350px, 100vw";
|
|
39
|
-
}
|
|
40
|
-
if (align && size === "small") {
|
|
41
|
-
return "(min-width: 1024px) 350px, (min-width: 768px) 180px, 100vw";
|
|
42
|
-
}
|
|
43
|
-
if (align && size === "xsmall") {
|
|
44
|
-
return "(min-width: 1024px) 180px, (min-width: 768px) 180px, 100vw";
|
|
45
|
-
}
|
|
46
|
-
return "(min-width: 1024px) 1024px, 100vw";
|
|
47
|
-
};
|
|
48
|
-
export const getFocalPoint = data => {
|
|
49
|
-
const focalX = Number.parseFloat(data.focalX ?? "");
|
|
50
|
-
const focalY = Number.parseFloat(data.focalY ?? "");
|
|
51
|
-
if (!Number.isNaN(focalX) && !Number.isNaN(focalY)) {
|
|
52
|
-
return {
|
|
53
|
-
x: focalX,
|
|
54
|
-
y: focalY
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return undefined;
|
|
58
|
-
};
|
|
59
|
-
export const getCrop = data => {
|
|
60
|
-
const lowerRightX = Number.parseFloat(data.lowerRightX ?? "");
|
|
61
|
-
const lowerRightY = Number.parseFloat(data.lowerRightY ?? "");
|
|
62
|
-
const upperLeftX = Number.parseFloat(data.upperLeftX ?? "");
|
|
63
|
-
const upperLeftY = Number.parseFloat(data.upperLeftY ?? "");
|
|
64
|
-
if (!Number.isNaN(lowerRightX) && !Number.isNaN(lowerRightY) && !Number.isNaN(upperLeftX) && !Number.isNaN(upperLeftY)) {
|
|
65
|
-
return {
|
|
66
|
-
startX: lowerRightX,
|
|
67
|
-
startY: lowerRightY,
|
|
68
|
-
endX: upperLeftX,
|
|
69
|
-
endY: upperLeftY
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
};
|
|
74
|
-
const expandedSizes = "(min-width: 1024px) 1024px, 100vw";
|
|
75
|
-
const ImageWrapper = styled("div", {
|
|
76
|
-
base: {
|
|
77
|
-
overflow: "hidden",
|
|
78
|
-
position: "relative",
|
|
79
|
-
width: "100%",
|
|
80
|
-
"& img": {
|
|
81
|
-
width: "100%"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
variants: {
|
|
85
|
-
svg: {
|
|
86
|
-
true: {
|
|
87
|
-
display: "flex",
|
|
88
|
-
justifyContent: "center"
|
|
89
|
-
},
|
|
90
|
-
false: {}
|
|
91
|
-
},
|
|
92
|
-
border: {
|
|
93
|
-
true: {
|
|
94
|
-
border: "1px solid",
|
|
95
|
-
borderColor: "stroke.subtle",
|
|
96
|
-
borderRadius: "xsmall",
|
|
97
|
-
"& img": {
|
|
98
|
-
borderRadius: "0"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
false: {}
|
|
102
|
-
},
|
|
103
|
-
expandable: {
|
|
104
|
-
true: {
|
|
105
|
-
cursor: "pointer"
|
|
106
|
-
},
|
|
107
|
-
false: {}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
const StyledFigure = styled(Figure, {
|
|
112
|
-
base: {
|
|
113
|
-
zIndex: "docked",
|
|
114
|
-
_hover: {
|
|
115
|
-
"& [data-byline-button]": {
|
|
116
|
-
background: "background.default"
|
|
117
|
-
},
|
|
118
|
-
"& button[data-expanded]": {
|
|
119
|
-
transform: "scale(1.2)"
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
"& button[data-expanded='true']": {
|
|
123
|
-
"& svg": {
|
|
124
|
-
transform: "rotate(-45deg)"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const ExpandButton = styled("button", {
|
|
130
|
-
base: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
alignItems: "center",
|
|
133
|
-
justifyContent: "center",
|
|
134
|
-
cursor: "pointer",
|
|
135
|
-
position: "absolute",
|
|
136
|
-
padding: "0",
|
|
137
|
-
top: "xsmall",
|
|
138
|
-
right: "xsmall",
|
|
139
|
-
width: "medium",
|
|
140
|
-
height: "medium",
|
|
141
|
-
border: "2px solid",
|
|
142
|
-
borderColor: "background.default",
|
|
143
|
-
transitionProperty: "transform, background-color, color",
|
|
144
|
-
transitionDuration: "normal",
|
|
145
|
-
transitionTimingFunction: "ease-out",
|
|
146
|
-
color: "background.default",
|
|
147
|
-
backgroundColor: "surface.action",
|
|
148
|
-
borderRadius: "large",
|
|
149
|
-
"& svg": {
|
|
150
|
-
transitionProperty: "transform",
|
|
151
|
-
transitionDuration: "normal",
|
|
152
|
-
transitionTimingFunction: "ease-out"
|
|
153
|
-
},
|
|
154
|
-
tabletDown: {
|
|
155
|
-
display: "none"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
|
-
defaultProps: {
|
|
160
|
-
type: "button"
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
const ImageEmbed = _ref => {
|
|
164
|
-
let {
|
|
165
|
-
embed,
|
|
166
|
-
previewAlt,
|
|
167
|
-
lang,
|
|
168
|
-
renderContext = "article",
|
|
169
|
-
children
|
|
170
|
-
} = _ref;
|
|
171
|
-
const [imageSizes, setImageSizes] = useState(undefined);
|
|
172
|
-
const figureProps = getFigureProps(embed.embedData.size, embed.embedData.align);
|
|
173
|
-
const {
|
|
174
|
-
t
|
|
175
|
-
} = useTranslation();
|
|
176
|
-
const parsedDescription = useMemo(() => {
|
|
177
|
-
if (embed.embedData.caption || renderContext === "article") {
|
|
178
|
-
return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;
|
|
179
|
-
}
|
|
180
|
-
if (embed.status === "success" && embed.data.caption.caption) {
|
|
181
|
-
return parse(embed.data.caption.caption);
|
|
182
|
-
}
|
|
183
|
-
}, [embed, renderContext]);
|
|
184
|
-
if (embed.status === "error") {
|
|
185
|
-
return /*#__PURE__*/_jsx(EmbedErrorPlaceholder, {
|
|
186
|
-
type: "image",
|
|
187
|
-
figureType: figureProps?.size,
|
|
188
|
-
float: figureProps?.float
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
const {
|
|
192
|
-
data,
|
|
193
|
-
embedData
|
|
194
|
-
} = embed;
|
|
195
|
-
const altText = embedData.alt || "";
|
|
196
|
-
const sizes = getSizes(embedData.size, embedData.align);
|
|
197
|
-
const focalPoint = getFocalPoint(embedData);
|
|
198
|
-
const crop = getCrop(embedData);
|
|
199
|
-
const toggleImageSize = () => {
|
|
200
|
-
setImageSizes(sizes => !sizes ? expandedSizes : undefined);
|
|
201
|
-
};
|
|
202
|
-
const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);
|
|
203
|
-
const figureSize = figureProps?.float ? figureProps?.size ?? "medium" : "full";
|
|
204
|
-
return /*#__PURE__*/_jsxs(StyledFigure, {
|
|
205
|
-
float: figureProps?.float,
|
|
206
|
-
size: imageSizes ? "full" : figureSize,
|
|
207
|
-
"data-embed-type": "image",
|
|
208
|
-
...licenseProps,
|
|
209
|
-
children: [children, /*#__PURE__*/_jsxs(ImageWrapper, {
|
|
210
|
-
border: embedData.border === "true",
|
|
211
|
-
expandable: !!figureProps?.float,
|
|
212
|
-
children: [/*#__PURE__*/_jsx(Image, {
|
|
213
|
-
focalPoint: focalPoint,
|
|
214
|
-
contentType: data.image.contentType,
|
|
215
|
-
crop: crop,
|
|
216
|
-
sizes: imageSizes ?? sizes,
|
|
217
|
-
alt: altText,
|
|
218
|
-
src: data.image.imageUrl,
|
|
219
|
-
lang: lang,
|
|
220
|
-
onClick: figureProps?.float ? toggleImageSize : undefined,
|
|
221
|
-
variant: "rounded"
|
|
222
|
-
}), (embedData.align === "right" || embedData.align === "left") && /*#__PURE__*/_jsx(ExpandButton, {
|
|
223
|
-
"aria-label": t(`license.images.itemImage.zoom${imageSizes ? "Out" : ""}ImageButtonLabel`),
|
|
224
|
-
onClick: toggleImageSize,
|
|
225
|
-
"data-expanded": !!imageSizes,
|
|
226
|
-
children: /*#__PURE__*/_jsx(AddLine, {})
|
|
227
|
-
})]
|
|
228
|
-
}), /*#__PURE__*/_jsx(EmbedByline, {
|
|
229
|
-
type: "image",
|
|
230
|
-
copyright: data.copyright,
|
|
231
|
-
description: parsedDescription,
|
|
232
|
-
hideDescription: embedData.hideCaption === "true",
|
|
233
|
-
hideCopyright: embedData.hideByline === "true",
|
|
234
|
-
visibleAlt: previewAlt ? embed.embedData.alt : ""
|
|
235
|
-
})]
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
export default ImageEmbed;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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 { forwardRef, useCallback, useRef } from "react";
|
|
10
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
11
|
-
import { composeRefs } from "@ndla/util";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
const StyledSpan = styled("span", {
|
|
14
|
-
base: {}
|
|
15
|
-
});
|
|
16
|
-
export const InlineTriggerButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
17
|
-
let {
|
|
18
|
-
onClick,
|
|
19
|
-
...props
|
|
20
|
-
} = _ref;
|
|
21
|
-
const spanRef = useRef(null);
|
|
22
|
-
|
|
23
|
-
// Emulate a button click when pressing Enter or Space
|
|
24
|
-
const onKeyboardEvent = useCallback(event => {
|
|
25
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
26
|
-
spanRef.current?.click();
|
|
27
|
-
}
|
|
28
|
-
}, []);
|
|
29
|
-
return /*#__PURE__*/_jsx(StyledSpan, {
|
|
30
|
-
ref: composeRefs(spanRef, ref),
|
|
31
|
-
onKeyUp: onKeyboardEvent,
|
|
32
|
-
onClick: onClick,
|
|
33
|
-
role: "button",
|
|
34
|
-
tabIndex: 0,
|
|
35
|
-
...props
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
import { useTranslation } from "react-i18next";
|
|
10
|
-
import { contentTypeMapping } from "../model/ContentType";
|
|
11
|
-
import { RelatedArticle } from "../RelatedArticleList/RelatedArticleList";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
const RelatedContentEmbed = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
embed,
|
|
16
|
-
isOembed,
|
|
17
|
-
subject,
|
|
18
|
-
ndlaFrontendDomain
|
|
19
|
-
} = _ref;
|
|
20
|
-
const {
|
|
21
|
-
t
|
|
22
|
-
} = useTranslation();
|
|
23
|
-
if (embed.status === "error") {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const {
|
|
27
|
-
data,
|
|
28
|
-
embedData
|
|
29
|
-
} = embed;
|
|
30
|
-
if (embedData.articleId && data) {
|
|
31
|
-
const typeId = data.resource?.resourceTypes.find(rt => contentTypeMapping[rt.id])?.id;
|
|
32
|
-
const type = typeId ? contentTypeMapping[typeId] : undefined;
|
|
33
|
-
const context = data.resource?.contexts.find(c => c.rootId === subject);
|
|
34
|
-
const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
|
|
35
|
-
return /*#__PURE__*/_jsx(RelatedArticle, {
|
|
36
|
-
title: data.article.title?.title ?? "",
|
|
37
|
-
introduction: data.article.metaDescription?.metaDescription ?? "",
|
|
38
|
-
target: isOembed ? "_blank" : undefined,
|
|
39
|
-
to: `${ndlaFrontendDomain ?? ""}${url ?? ""}`,
|
|
40
|
-
type: type
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (typeof embedData.url === "string") {
|
|
44
|
-
return /*#__PURE__*/_jsx(RelatedArticle, {
|
|
45
|
-
title: embedData.title ?? "",
|
|
46
|
-
introduction: "",
|
|
47
|
-
to: embedData.url,
|
|
48
|
-
target: "_blank",
|
|
49
|
-
type: "external",
|
|
50
|
-
linkInfo: `${t("related.linkInfo")} ${embedData.urlDomain}`
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
};
|
|
55
|
-
export default RelatedContentEmbed;
|
package/es/Embed/UnknownEmbed.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
import { useTranslation } from "react-i18next";
|
|
10
|
-
import { Text } from "@ndla/primitives";
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
const UnknownEmbed = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
embed
|
|
15
|
-
} = _ref;
|
|
16
|
-
const {
|
|
17
|
-
t
|
|
18
|
-
} = useTranslation();
|
|
19
|
-
return /*#__PURE__*/_jsx(Text, {
|
|
20
|
-
color: "text.error",
|
|
21
|
-
asChild: true,
|
|
22
|
-
consumeCss: true,
|
|
23
|
-
"data-embed-type": "unknown",
|
|
24
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
25
|
-
children: t("embed.unsupported", {
|
|
26
|
-
type: embed.resource
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
export default UnknownEmbed;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-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 { useTranslation } from "react-i18next";
|
|
10
|
-
import { Portal } from "@ark-ui/react";
|
|
11
|
-
import { AccessibilityFill, ErrorWarningFill } from "@ndla/icons";
|
|
12
|
-
import { IconButton, PopoverContent, PopoverRoot, PopoverTrigger } from "@ndla/primitives";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const DisclaimerWrapper = styled("div", {
|
|
16
|
-
base: {
|
|
17
|
-
display: "flex",
|
|
18
|
-
flexDirection: "column",
|
|
19
|
-
gap: "3xsmall",
|
|
20
|
-
clear: "both"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const StyledIconButton = styled(IconButton, {
|
|
24
|
-
base: {
|
|
25
|
-
alignSelf: "flex-end"
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const StyledErrorWarningFill = styled(ErrorWarningFill, {
|
|
29
|
-
base: {
|
|
30
|
-
alignSelf: "flex-end",
|
|
31
|
-
fill: "icon.subtle"
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const StyledPopoverContent = styled(PopoverContent, {
|
|
35
|
-
base: {
|
|
36
|
-
width: "surface.xlarge",
|
|
37
|
-
maxHeight: "50vh",
|
|
38
|
-
overflowY: "auto"
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const UuDisclaimerEmbed = _ref => {
|
|
42
|
-
let {
|
|
43
|
-
embed,
|
|
44
|
-
transformedDisclaimer,
|
|
45
|
-
children
|
|
46
|
-
} = _ref;
|
|
47
|
-
const {
|
|
48
|
-
t
|
|
49
|
-
} = useTranslation();
|
|
50
|
-
if (embed.status === "error") {
|
|
51
|
-
return /*#__PURE__*/_jsxs(DisclaimerWrapper, {
|
|
52
|
-
children: [/*#__PURE__*/_jsx(StyledErrorWarningFill, {
|
|
53
|
-
"aria-label": t("embed.embedError", {
|
|
54
|
-
type: t("embed.type.disclaimer")
|
|
55
|
-
}),
|
|
56
|
-
title: t("embed.embedError", {
|
|
57
|
-
type: t("embed.type.disclaimer")
|
|
58
|
-
})
|
|
59
|
-
}), children]
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return /*#__PURE__*/_jsxs(DisclaimerWrapper, {
|
|
63
|
-
role: "region",
|
|
64
|
-
"data-embed-type": "uu-disclaimer",
|
|
65
|
-
children: [/*#__PURE__*/_jsxs(PopoverRoot, {
|
|
66
|
-
children: [/*#__PURE__*/_jsx(PopoverTrigger, {
|
|
67
|
-
asChild: true,
|
|
68
|
-
children: /*#__PURE__*/_jsx(StyledIconButton, {
|
|
69
|
-
size: "small",
|
|
70
|
-
variant: "secondary",
|
|
71
|
-
"aria-label": t("uuDisclaimer.title"),
|
|
72
|
-
title: t("uuDisclaimer.title"),
|
|
73
|
-
children: /*#__PURE__*/_jsx(AccessibilityFill, {})
|
|
74
|
-
})
|
|
75
|
-
}), /*#__PURE__*/_jsx(Portal, {
|
|
76
|
-
children: /*#__PURE__*/_jsx(StyledPopoverContent, {
|
|
77
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
78
|
-
children: transformedDisclaimer
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
})]
|
|
82
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
83
|
-
"data-uu-content": "",
|
|
84
|
-
children: children
|
|
85
|
-
})]
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
export default UuDisclaimerEmbed;
|
package/es/Embed/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
export { default as ImageEmbed, getCrop, getFocalPoint } from "./ImageEmbed";
|
|
10
|
-
export { InlineTriggerButton } from "./InlineTriggerButton";
|
|
11
|
-
export { default as AudioEmbed } from "./AudioEmbed";
|
|
12
|
-
export { default as H5pEmbed } from "./H5pEmbed";
|
|
13
|
-
export { default as ExternalEmbed } from "./ExternalEmbed";
|
|
14
|
-
export { default as IframeEmbed } from "./IframeEmbed";
|
|
15
|
-
export { default as FootnoteEmbed } from "./FootnoteEmbed";
|
|
16
|
-
export { default as BrightcoveEmbed } from "./BrightcoveEmbed";
|
|
17
|
-
export { default as ContentLinkEmbed } from "./ContentLinkEmbed";
|
|
18
|
-
export { default as RelatedContentEmbed } from "./RelatedContentEmbed";
|
|
19
|
-
export { ConceptEmbed, InlineConcept, BlockConcept } from "./ConceptEmbed";
|
|
20
|
-
export { default as UnknownEmbed } from "./UnknownEmbed";
|
|
21
|
-
export { default as UuDisclaimerEmbed } from "./UuDisclaimerEmbed";
|
|
22
|
-
export { default as CopyrightEmbed } from "./CopyrightEmbed";
|
|
23
|
-
export { default as CodeEmbed } from "./CodeEmbed";
|
|
24
|
-
export { EmbedWrapper } from "./EmbedWrapper";
|
|
25
|
-
export { ConceptInlineTriggerButton } from "./ConceptInlineTriggerButton";
|
package/es/Embed/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
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 { Text } from "@ndla/primitives";
|
|
10
|
-
import { SafeLink } from "@ndla/safelink";
|
|
11
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
12
|
-
|
|
13
|
-
// TODO: This has not been redesignet yet. This is just a rewrite of the previous design in panda
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const StyledErrorMessage = styled("article", {
|
|
16
|
-
base: {
|
|
17
|
-
textAlign: "center",
|
|
18
|
-
"& a": {
|
|
19
|
-
color: "text.strong"
|
|
20
|
-
},
|
|
21
|
-
"& h1": {
|
|
22
|
-
marginTop: "0"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const IllustrationWrapper = styled("div", {
|
|
27
|
-
base: {
|
|
28
|
-
display: "flex",
|
|
29
|
-
justifyContent: "center",
|
|
30
|
-
marginBottom: "medium",
|
|
31
|
-
tablet: {
|
|
32
|
-
marginTop: "xxlarge"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const Description = styled(Text, {
|
|
37
|
-
base: {
|
|
38
|
-
marginBottom: "medium",
|
|
39
|
-
tablet: {
|
|
40
|
-
marginBottom: "xxlarge"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const CustomElementWrapper = styled("div", {
|
|
45
|
-
base: {
|
|
46
|
-
marginBlock: "xxlarge"
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const MessageWrapper = styled("div", {
|
|
50
|
-
base: {
|
|
51
|
-
marginTop: "3xsmall"
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
export const ErrorMessage = _ref => {
|
|
55
|
-
let {
|
|
56
|
-
children,
|
|
57
|
-
messages,
|
|
58
|
-
illustration,
|
|
59
|
-
illustrationElement,
|
|
60
|
-
customElement
|
|
61
|
-
} = _ref;
|
|
62
|
-
return /*#__PURE__*/_jsxs(StyledErrorMessage, {
|
|
63
|
-
children: [!!illustration && /*#__PURE__*/_jsx(IllustrationWrapper, {
|
|
64
|
-
children: /*#__PURE__*/_jsx("img", {
|
|
65
|
-
src: illustration.url,
|
|
66
|
-
alt: illustration.altText
|
|
67
|
-
})
|
|
68
|
-
}), !!illustrationElement && /*#__PURE__*/_jsx(IllustrationWrapper, {
|
|
69
|
-
children: illustrationElement
|
|
70
|
-
}), /*#__PURE__*/_jsx("h1", {
|
|
71
|
-
children: messages.title
|
|
72
|
-
}), !!messages.description && /*#__PURE__*/_jsx(Description, {
|
|
73
|
-
children: messages.description
|
|
74
|
-
}), !!customElement && /*#__PURE__*/_jsx(CustomElementWrapper, {
|
|
75
|
-
children: customElement
|
|
76
|
-
}), !!messages.linksTitle && /*#__PURE__*/_jsx("h2", {
|
|
77
|
-
children: messages.linksTitle
|
|
78
|
-
}), !!messages.back && /*#__PURE__*/_jsx(SafeLink, {
|
|
79
|
-
to: `/#${encodeURI(messages.back)}`,
|
|
80
|
-
onClick: () => window.history.back(),
|
|
81
|
-
children: messages.back
|
|
82
|
-
}), !!messages.goToFrontPage && /*#__PURE__*/_jsx(MessageWrapper, {
|
|
83
|
-
children: /*#__PURE__*/_jsx(SafeLink, {
|
|
84
|
-
to: "/",
|
|
85
|
-
children: messages.goToFrontPage
|
|
86
|
-
})
|
|
87
|
-
}), !!messages.logInFailed && /*#__PURE__*/_jsx(MessageWrapper, {
|
|
88
|
-
children: /*#__PURE__*/_jsx(SafeLink, {
|
|
89
|
-
to: "/minndla",
|
|
90
|
-
children: messages.logInFailed
|
|
91
|
-
})
|
|
92
|
-
}), children]
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
export default ErrorMessage;
|
package/es/ErrorMessage/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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 ErrorMessage from "./ErrorMessage";
|
|
10
|
-
export default ErrorMessage;
|