@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
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020-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, useEffect, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { useLocation } from "react-router";
|
|
12
|
-
import { ArrowDownShortLine } from "@ndla/icons";
|
|
13
|
-
import { AccordionItem, AccordionItemContent, AccordionItemIndicator, AccordionItemTrigger, AccordionRoot, Heading } from "@ndla/primitives";
|
|
14
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
15
|
-
import { ArticleFootNotes } from "./ArticleFootNotes";
|
|
16
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
const Wrapper = styled("div", {
|
|
18
|
-
base: {
|
|
19
|
-
// TODO: Figure out if we want to remove this margin. It's only here to add some gap between the article content and the byline.
|
|
20
|
-
marginBlockStart: "medium",
|
|
21
|
-
paddingBlockStart: "xsmall",
|
|
22
|
-
borderTop: "1px solid",
|
|
23
|
-
borderColor: "stroke.subtle"
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const TextWrapper = styled("div", {
|
|
27
|
-
base: {
|
|
28
|
-
display: "flex",
|
|
29
|
-
flexDirection: "column",
|
|
30
|
-
gap: "3xsmall",
|
|
31
|
-
width: "100%",
|
|
32
|
-
justifyContent: "space-between",
|
|
33
|
-
paddingBlock: "xsmall",
|
|
34
|
-
textStyle: "body.medium",
|
|
35
|
-
'& [data-contributors="false"]': {
|
|
36
|
-
marginInlineStart: "auto"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
variants: {
|
|
40
|
-
learningpath: {
|
|
41
|
-
true: {},
|
|
42
|
-
false: {
|
|
43
|
-
tabletWide: {
|
|
44
|
-
flexDirection: "row"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const renderContributors = (contributors, t) => {
|
|
51
|
-
const contributorsArray = contributors.map((contributor, index) => {
|
|
52
|
-
if (index < 1) return contributor.name;
|
|
53
|
-
const sep = index === contributors.length - 1 ? ` ${t("article.conjunction")} ` : ", ";
|
|
54
|
-
return `${sep}${contributor.name}`;
|
|
55
|
-
});
|
|
56
|
-
return contributorsArray.join("");
|
|
57
|
-
};
|
|
58
|
-
const getSuppliersText = (suppliers, t) => {
|
|
59
|
-
if (suppliers.length === 0) {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
return suppliers.length > 1 ? t("article.multipleSuppliersLabel", {
|
|
63
|
-
names: renderContributors(suppliers, t),
|
|
64
|
-
interpolation: {
|
|
65
|
-
escapeValue: false
|
|
66
|
-
}
|
|
67
|
-
}) : t("article.supplierLabel", {
|
|
68
|
-
name: renderContributors(suppliers, t),
|
|
69
|
-
interpolation: {
|
|
70
|
-
escapeValue: false
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
const StyledAccordionRoot = styled(AccordionRoot, {
|
|
75
|
-
base: {
|
|
76
|
-
paddingBlockStart: "xxlarge"
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
const refRegexp = /note\d/;
|
|
80
|
-
const footnotesAccordionId = "footnotes";
|
|
81
|
-
export const ArticleByline = _ref => {
|
|
82
|
-
let {
|
|
83
|
-
authors = [],
|
|
84
|
-
suppliers = [],
|
|
85
|
-
footnotes,
|
|
86
|
-
licenseBox,
|
|
87
|
-
published,
|
|
88
|
-
displayByline = true,
|
|
89
|
-
bylineType = "article",
|
|
90
|
-
bylineSuffix
|
|
91
|
-
} = _ref;
|
|
92
|
-
const {
|
|
93
|
-
t
|
|
94
|
-
} = useTranslation();
|
|
95
|
-
const {
|
|
96
|
-
pathname
|
|
97
|
-
} = useLocation();
|
|
98
|
-
const [openAccordions, setOpenAccordions] = useState([]);
|
|
99
|
-
const accordionItemValue = "rulesForUse";
|
|
100
|
-
const onHashChange = useCallback(e => {
|
|
101
|
-
const hash = e.newURL.split("#")[1];
|
|
102
|
-
if (hash?.match(refRegexp) && !openAccordions.includes(footnotesAccordionId)) {
|
|
103
|
-
setOpenAccordions([...openAccordions, footnotesAccordionId]);
|
|
104
|
-
const el = document.getElementById(`#${hash}`);
|
|
105
|
-
el?.click();
|
|
106
|
-
el?.focus();
|
|
107
|
-
}
|
|
108
|
-
}, [openAccordions]);
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
setOpenAccordions(prev => prev.filter(state => state !== accordionItemValue));
|
|
111
|
-
}, [pathname]);
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
window.addEventListener("hashchange", onHashChange);
|
|
114
|
-
return () => window.removeEventListener("hashchange", onHashChange);
|
|
115
|
-
}, [onHashChange]);
|
|
116
|
-
const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;
|
|
117
|
-
const authorLabel = {
|
|
118
|
-
article: "article.authorsLabel",
|
|
119
|
-
learningPath: "article.authorsLabelLearningpath",
|
|
120
|
-
external: "article.authorsLabelExternal"
|
|
121
|
-
};
|
|
122
|
-
return /*#__PURE__*/_jsxs(Wrapper, {
|
|
123
|
-
children: [!!displayByline && /*#__PURE__*/_jsxs(TextWrapper, {
|
|
124
|
-
learningpath: bylineType === "learningPath",
|
|
125
|
-
children: [!!showPrimaryContributors && /*#__PURE__*/_jsxs("span", {
|
|
126
|
-
children: [authors.length > 0 && `${t(authorLabel[bylineType], {
|
|
127
|
-
names: renderContributors(authors, t),
|
|
128
|
-
interpolation: {
|
|
129
|
-
escapeValue: false
|
|
130
|
-
}
|
|
131
|
-
})}. `, getSuppliersText(suppliers, t)]
|
|
132
|
-
}), published ? /*#__PURE__*/_jsxs("div", {
|
|
133
|
-
"data-contributors": showPrimaryContributors,
|
|
134
|
-
children: [t(`${bylineType}.lastUpdated`), " ", published]
|
|
135
|
-
}) : null, bylineSuffix]
|
|
136
|
-
}), (!!licenseBox || !!footnotes?.length) && /*#__PURE__*/_jsxs(StyledAccordionRoot, {
|
|
137
|
-
multiple: true,
|
|
138
|
-
value: openAccordions,
|
|
139
|
-
onValueChange: details => setOpenAccordions(details.value),
|
|
140
|
-
children: [!!licenseBox && /*#__PURE__*/_jsx(ArticleBylineAccordionItem, {
|
|
141
|
-
value: accordionItemValue,
|
|
142
|
-
accordionTitle: t("article.useContent"),
|
|
143
|
-
children: licenseBox
|
|
144
|
-
}), !!footnotes?.length && /*#__PURE__*/_jsx(ArticleBylineAccordionItem, {
|
|
145
|
-
value: footnotesAccordionId,
|
|
146
|
-
accordionTitle: t("article.footnotes"),
|
|
147
|
-
children: /*#__PURE__*/_jsx(ArticleFootNotes, {
|
|
148
|
-
footNotes: footnotes
|
|
149
|
-
})
|
|
150
|
-
})]
|
|
151
|
-
})]
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
export const ArticleBylineAccordionItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
155
|
-
let {
|
|
156
|
-
value,
|
|
157
|
-
accordionTitle,
|
|
158
|
-
children,
|
|
159
|
-
...props
|
|
160
|
-
} = _ref2;
|
|
161
|
-
return /*#__PURE__*/_jsxs(AccordionItem, {
|
|
162
|
-
value: value,
|
|
163
|
-
ref: ref,
|
|
164
|
-
...props,
|
|
165
|
-
children: [/*#__PURE__*/_jsx(Heading, {
|
|
166
|
-
asChild: true,
|
|
167
|
-
consumeCss: true,
|
|
168
|
-
textStyle: "label.medium",
|
|
169
|
-
fontWeight: "bold",
|
|
170
|
-
children: /*#__PURE__*/_jsx("h2", {
|
|
171
|
-
children: /*#__PURE__*/_jsxs(AccordionItemTrigger, {
|
|
172
|
-
children: [accordionTitle, /*#__PURE__*/_jsx(AccordionItemIndicator, {
|
|
173
|
-
asChild: true,
|
|
174
|
-
children: /*#__PURE__*/_jsx(ArrowDownShortLine, {})
|
|
175
|
-
})]
|
|
176
|
-
})
|
|
177
|
-
})
|
|
178
|
-
}), /*#__PURE__*/_jsx(AccordionItemContent, {
|
|
179
|
-
children: children
|
|
180
|
-
})]
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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 { styled } from "@ndla/styled-system/jsx";
|
|
11
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const citeDetailString = description => description ? `${description}. ` : "";
|
|
13
|
-
const StyledCite = styled("cite", {
|
|
14
|
-
base: {
|
|
15
|
-
display: "flex",
|
|
16
|
-
alignItems: "center",
|
|
17
|
-
gap: "xsmall"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const FootNote = _ref => {
|
|
21
|
-
let {
|
|
22
|
-
footNote
|
|
23
|
-
} = _ref;
|
|
24
|
-
return /*#__PURE__*/_jsx("li", {
|
|
25
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
26
|
-
id: `note${footNote.ref}`,
|
|
27
|
-
asChild: true,
|
|
28
|
-
consumeCss: true,
|
|
29
|
-
textStyle: "body.medium",
|
|
30
|
-
children: /*#__PURE__*/_jsxs(StyledCite, {
|
|
31
|
-
children: [/*#__PURE__*/_jsx("a", {
|
|
32
|
-
href: `#ref${footNote.ref}`,
|
|
33
|
-
target: "_self",
|
|
34
|
-
children: footNote.ref
|
|
35
|
-
}), `«${footNote.title}». ${footNote.authors.join(" ")}. ${citeDetailString(footNote.edition)}${citeDetailString(footNote.publisher)}${footNote.year}. `, footNote.url ? /*#__PURE__*/_jsxs("a", {
|
|
36
|
-
href: footNote.url,
|
|
37
|
-
children: [footNote.url, "."]
|
|
38
|
-
}) : null]
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
const FootnoteList = styled("ol", {
|
|
44
|
-
base: {
|
|
45
|
-
display: "flex",
|
|
46
|
-
flexDirection: "column",
|
|
47
|
-
gap: "medium",
|
|
48
|
-
listStyle: "none"
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
export const ArticleFootNotes = _ref2 => {
|
|
52
|
-
let {
|
|
53
|
-
footNotes
|
|
54
|
-
} = _ref2;
|
|
55
|
-
return /*#__PURE__*/_jsx(FootnoteList, {
|
|
56
|
-
children: footNotes.map(footNote => /*#__PURE__*/_jsx(FootNote, {
|
|
57
|
-
footNote: footNote
|
|
58
|
-
}, footNote.ref))
|
|
59
|
-
});
|
|
60
|
-
};
|
package/es/Article/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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 { Article, ArticleWrapper, ArticleHeader, ArticleFooter, ArticleTitle, ArticleHGroup, ArticleContent } from "./Article";
|
|
10
|
-
export { ArticleByline, ArticleBylineAccordionItem } from "./ArticleByline";
|
|
11
|
-
export { ArticleFootNotes } from "./ArticleFootNotes";
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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 { useId, useMemo, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { Heading, Text, Button } from "@ndla/primitives";
|
|
12
|
-
import { SafeLink } from "@ndla/safelink";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import Controls from "./Controls";
|
|
15
|
-
import SpeechControl from "./SpeechControl";
|
|
16
|
-
|
|
17
|
-
// TODO: Could the audio metadata be more tightly coupled to the audio player?
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
const AudioPlayerWrapper = styled("div", {
|
|
20
|
-
base: {
|
|
21
|
-
border: "1px solid",
|
|
22
|
-
borderColor: "stroke.default",
|
|
23
|
-
borderRadius: "xsmall",
|
|
24
|
-
boxShadow: "full",
|
|
25
|
-
marginBlockEnd: "4xsmall",
|
|
26
|
-
overflow: "hidden"
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const InfoWrapper = styled("div", {
|
|
30
|
-
base: {
|
|
31
|
-
display: "flex",
|
|
32
|
-
tabletWideDown: {
|
|
33
|
-
display: "block"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const ImageWrapper = styled("div", {
|
|
38
|
-
base: {
|
|
39
|
-
display: "flex",
|
|
40
|
-
alignItems: "center",
|
|
41
|
-
flex: "1 0 auto",
|
|
42
|
-
width: "surface.4xsmall",
|
|
43
|
-
height: "surface.4xsmall",
|
|
44
|
-
overflow: "hidden",
|
|
45
|
-
"& img": {
|
|
46
|
-
width: "100%",
|
|
47
|
-
height: "100%",
|
|
48
|
-
objectFit: "cover"
|
|
49
|
-
},
|
|
50
|
-
desktop: {
|
|
51
|
-
width: "260px",
|
|
52
|
-
height: "260px"
|
|
53
|
-
},
|
|
54
|
-
tabletWideDown: {
|
|
55
|
-
maxHeight: "surface.small",
|
|
56
|
-
maxWidth: "100%",
|
|
57
|
-
width: "100%",
|
|
58
|
-
height: "auto"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const TextWrapper = styled("div", {
|
|
63
|
-
base: {
|
|
64
|
-
display: "flex",
|
|
65
|
-
alignItems: "flex-start",
|
|
66
|
-
flexDirection: "column",
|
|
67
|
-
gap: "xsmall",
|
|
68
|
-
padding: "xsmall",
|
|
69
|
-
width: "100%",
|
|
70
|
-
"&[data-has-image='true']": {
|
|
71
|
-
tablet: {
|
|
72
|
-
paddingBlock: "xsmall",
|
|
73
|
-
paddingInline: "medium"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const TitleWrapper = styled("div", {
|
|
79
|
-
base: {
|
|
80
|
-
display: "flex",
|
|
81
|
-
flexDirection: "column",
|
|
82
|
-
gap: "xsmall",
|
|
83
|
-
fontFamily: "sans",
|
|
84
|
-
tabletWide: {
|
|
85
|
-
width: "100%",
|
|
86
|
-
flexDirection: "row",
|
|
87
|
-
justifyContent: "space-between"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
const TextVersionWrapper = styled("div", {
|
|
92
|
-
base: {
|
|
93
|
-
display: "flex",
|
|
94
|
-
flexDirection: "column",
|
|
95
|
-
gap: "xsmall",
|
|
96
|
-
borderBlockStart: "1px solid",
|
|
97
|
-
borderColor: "stroke.default",
|
|
98
|
-
paddingBlock: "medium",
|
|
99
|
-
paddingInline: "xsmall",
|
|
100
|
-
tablet: {
|
|
101
|
-
paddingInline: "medium"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const TextVersionText = styled("div", {
|
|
106
|
-
base: {
|
|
107
|
-
maxWidth: "surface.xlarge",
|
|
108
|
-
"& span > *": {
|
|
109
|
-
whiteSpace: "pre-wrap"
|
|
110
|
-
},
|
|
111
|
-
"& p:not(:first-child):not(:last-child)": {
|
|
112
|
-
marginBlock: "small"
|
|
113
|
-
},
|
|
114
|
-
'& p[data-align="center"]': {
|
|
115
|
-
textAlign: "center"
|
|
116
|
-
},
|
|
117
|
-
'& p:has(span[dir="rtl"])': {
|
|
118
|
-
direction: "rtl"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
const TextVersionButton = styled(Button, {
|
|
123
|
-
base: {
|
|
124
|
-
alignSelf: "flex-start"
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const ShowMoreButton = styled(Button, {
|
|
128
|
-
base: {
|
|
129
|
-
marginInlineStart: "3xsmall"
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
const DESCRIPTION_MAX_LENGTH = 200;
|
|
133
|
-
const AudioPlayer = _ref => {
|
|
134
|
-
let {
|
|
135
|
-
src,
|
|
136
|
-
title,
|
|
137
|
-
subtitle,
|
|
138
|
-
speech,
|
|
139
|
-
description,
|
|
140
|
-
img,
|
|
141
|
-
textVersion
|
|
142
|
-
} = _ref;
|
|
143
|
-
const {
|
|
144
|
-
t
|
|
145
|
-
} = useTranslation();
|
|
146
|
-
const [showTextVersion, setShowTextVersion] = useState(false);
|
|
147
|
-
const [showFullDescription, setShowFullDescription] = useState(false);
|
|
148
|
-
const truncatedDescription = useMemo(() => description?.slice(0, DESCRIPTION_MAX_LENGTH), [description]);
|
|
149
|
-
const textDescriptionId = useId();
|
|
150
|
-
if (speech) {
|
|
151
|
-
return /*#__PURE__*/_jsx(SpeechControl, {
|
|
152
|
-
src: src,
|
|
153
|
-
title: title
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
const toggleTextVersion = () => {
|
|
157
|
-
setShowTextVersion(curr => !curr);
|
|
158
|
-
};
|
|
159
|
-
const textVersionButton = /*#__PURE__*/_jsx(TextVersionButton, {
|
|
160
|
-
variant: "secondary",
|
|
161
|
-
"aria-expanded": showTextVersion,
|
|
162
|
-
"aria-controls": textDescriptionId,
|
|
163
|
-
size: "small",
|
|
164
|
-
onClick: toggleTextVersion,
|
|
165
|
-
children: t(showTextVersion ? "audio.textVersion.close" : "audio.textVersion.heading")
|
|
166
|
-
});
|
|
167
|
-
return /*#__PURE__*/_jsxs(AudioPlayerWrapper, {
|
|
168
|
-
children: [/*#__PURE__*/_jsxs(InfoWrapper, {
|
|
169
|
-
children: [!!img && /*#__PURE__*/_jsx(ImageWrapper, {
|
|
170
|
-
children: /*#__PURE__*/_jsx("img", {
|
|
171
|
-
src: img.url,
|
|
172
|
-
alt: img.alt
|
|
173
|
-
})
|
|
174
|
-
}), /*#__PURE__*/_jsxs(TextWrapper, {
|
|
175
|
-
"data-has-image": !!img,
|
|
176
|
-
children: [/*#__PURE__*/_jsxs(TitleWrapper, {
|
|
177
|
-
children: [/*#__PURE__*/_jsxs("div", {
|
|
178
|
-
children: [subtitle?.url ? /*#__PURE__*/_jsx(SafeLink, {
|
|
179
|
-
to: subtitle.url,
|
|
180
|
-
children: subtitle.title
|
|
181
|
-
}) : subtitle?.title, /*#__PURE__*/_jsx(Heading, {
|
|
182
|
-
asChild: true,
|
|
183
|
-
consumeCss: true,
|
|
184
|
-
textStyle: "title.large",
|
|
185
|
-
children: /*#__PURE__*/_jsx("h3", {
|
|
186
|
-
children: title
|
|
187
|
-
})
|
|
188
|
-
})]
|
|
189
|
-
}), !!textVersion && !img && textVersionButton]
|
|
190
|
-
}), !!description && /*#__PURE__*/_jsxs(Text, {
|
|
191
|
-
textStyle: "body.medium",
|
|
192
|
-
children: [showFullDescription || description.length < DESCRIPTION_MAX_LENGTH ? description : `${truncatedDescription}...`, description.length > DESCRIPTION_MAX_LENGTH && /*#__PURE__*/_jsx(ShowMoreButton, {
|
|
193
|
-
variant: "link",
|
|
194
|
-
onClick: () => setShowFullDescription(p => !p),
|
|
195
|
-
children: t(`audio.${showFullDescription ? "readLessDescriptionLabel" : "readMoreDescriptionLabel"}`)
|
|
196
|
-
})]
|
|
197
|
-
}), !!textVersion && !!img && textVersionButton]
|
|
198
|
-
})]
|
|
199
|
-
}), /*#__PURE__*/_jsx(Controls, {
|
|
200
|
-
src: src,
|
|
201
|
-
title: title
|
|
202
|
-
}), !!textVersion && /*#__PURE__*/_jsxs(TextVersionWrapper, {
|
|
203
|
-
id: textDescriptionId,
|
|
204
|
-
hidden: !showTextVersion,
|
|
205
|
-
children: [/*#__PURE__*/_jsx(Heading, {
|
|
206
|
-
asChild: true,
|
|
207
|
-
textStyle: "title.medium",
|
|
208
|
-
consumeCss: true,
|
|
209
|
-
children: /*#__PURE__*/_jsx("h4", {
|
|
210
|
-
children: t("audio.textVersion.heading")
|
|
211
|
-
})
|
|
212
|
-
}), /*#__PURE__*/_jsx(TextVersionText, {
|
|
213
|
-
children: textVersion
|
|
214
|
-
})]
|
|
215
|
-
})]
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
export default AudioPlayer;
|