@ndla/ui 56.0.122-alpha.0 → 56.0.123-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/README.md +1 -1
- package/es/Article/Article.js +199 -0
- package/es/Article/ArticleByline.js +182 -0
- package/es/Article/ArticleFootNotes.js +60 -0
- package/es/Article/index.js +11 -0
- package/es/AudioPlayer/AudioPlayer.js +218 -0
- package/es/AudioPlayer/Controls.js +332 -0
- package/es/AudioPlayer/SpeechControl.js +56 -0
- package/es/AudioPlayer/index.js +10 -0
- package/es/Breadcrumb/Breadcrumb.js +60 -0
- package/es/Breadcrumb/BreadcrumbItem.js +62 -0
- package/es/Breadcrumb/HomeBreadcrumb.js +77 -0
- package/es/Breadcrumb/index.js +11 -0
- package/es/CampaignBlock/CampaignBlock.js +180 -0
- package/es/CampaignBlock/index.js +9 -0
- package/es/CodeBlock/CodeBlock.js +35 -0
- package/es/CodeBlock/codeLanguageOptions.js +84 -0
- package/es/CodeBlock/index.js +10 -0
- package/es/Concept/Concept.js +72 -0
- package/es/ContactBlock/ContactBlock.js +199 -0
- package/es/ContactBlock/index.js +9 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +50 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +32 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +32 -0
- package/es/ContentTypeHero/ContentTypeHero.js +50 -0
- package/es/ContentTypeHero/index.js +9 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js +83 -0
- package/es/CopyParagraphButton/index.js +11 -0
- package/es/Embed/AudioEmbed.js +76 -0
- package/es/Embed/BrightcoveEmbed.js +133 -0
- package/es/Embed/CodeEmbed.js +79 -0
- package/es/Embed/ConceptEmbed.js +123 -0
- package/es/Embed/ConceptInlineTriggerButton.js +45 -0
- package/es/Embed/ContentLinkEmbed.js +51 -0
- package/es/Embed/CopyrightEmbed.js +33 -0
- package/es/Embed/EmbedErrorPlaceholder.js +58 -0
- package/es/Embed/EmbedWrapper.js +51 -0
- package/es/Embed/ExternalEmbed.js +74 -0
- package/es/Embed/FootnoteEmbed.js +44 -0
- package/es/Embed/GlossEmbed.js +80 -0
- package/es/Embed/H5pEmbed.js +61 -0
- package/es/Embed/IframeEmbed.js +93 -0
- package/es/Embed/ImageEmbed.js +238 -0
- package/es/Embed/InlineTriggerButton.js +37 -0
- package/es/Embed/RelatedContentEmbed.js +55 -0
- package/es/Embed/UnknownEmbed.js +31 -0
- package/es/Embed/UuDisclaimerEmbed.js +88 -0
- package/es/Embed/index.js +25 -0
- package/es/Embed/types.js +1 -0
- package/es/ErrorMessage/ErrorMessage.js +95 -0
- package/es/ErrorMessage/index.js +10 -0
- package/es/FactBox/FactBox.js +177 -0
- package/es/FactBox/index.js +10 -0
- package/es/FileList/File.js +101 -0
- package/es/FileList/FileList.js +47 -0
- package/es/FileList/PdfFile.js +50 -0
- package/es/FileList/index.js +11 -0
- package/es/Gloss/Gloss.js +175 -0
- package/es/Gloss/GlossExample.js +64 -0
- package/es/Gloss/index.js +10 -0
- package/es/Grid/Grid.js +94 -0
- package/es/Grid/GridParallaxItem.js +32 -0
- package/es/Grid/index.js +10 -0
- package/es/KeyFigure/KeyFigure.js +63 -0
- package/es/KeyFigure/index.js +9 -0
- package/es/LicenseByline/EmbedByline.js +212 -0
- package/es/LicenseByline/LicenseLink.js +56 -0
- package/es/LicenseByline/index.js +10 -0
- package/es/LinkBlock/LinkBlock.js +103 -0
- package/es/LinkBlock/LinkBlockSection.js +35 -0
- package/es/LinkBlock/index.js +10 -0
- package/es/Pitch/Pitch.js +83 -0
- package/es/Pitch/index.js +9 -0
- package/es/RelatedArticleList/RelatedArticleList.js +135 -0
- package/es/RelatedArticleList/index.js +11 -0
- package/es/ResourceBox/ResourceBox.js +99 -0
- package/es/ResourceBox/index.js +10 -0
- package/es/TagSelector/TagSelector.js +143 -0
- package/es/ZendeskButton/ZendeskButton.js +55 -0
- package/es/i18n/formatNestedMessages.js +25 -0
- package/es/i18n/i18n.js +35 -0
- package/es/i18n/index.js +11 -0
- package/es/i18n/useComponentTranslations.js +211 -0
- package/es/index.js +45 -0
- package/es/locale/messages-en.js +462 -0
- package/es/locale/messages-nb.js +462 -0
- package/es/locale/messages-nn.js +462 -0
- package/es/locale/messages-se.js +462 -0
- package/es/model/ContentType.js +68 -0
- package/es/model/SubjectCategories.js +12 -0
- package/es/model/SubjectTypes.js +11 -0
- package/es/model/WordClass.js +45 -0
- package/es/model/index.js +21 -0
- package/es/types.js +1 -0
- package/es/utils/licenseAttributes.js +18 -0
- package/es/utils/relativeUrl.js +37 -0
- package/lib/Article/Article.js +207 -0
- package/lib/Article/ArticleByline.js +189 -0
- package/lib/Article/ArticleFootNotes.js +67 -0
- package/lib/Article/index.js +68 -0
- package/lib/AudioPlayer/AudioPlayer.js +224 -0
- package/lib/AudioPlayer/Controls.js +338 -0
- package/lib/AudioPlayer/SpeechControl.js +62 -0
- package/lib/AudioPlayer/index.js +16 -0
- package/lib/Breadcrumb/Breadcrumb.js +67 -0
- package/lib/Breadcrumb/BreadcrumbItem.js +68 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js +84 -0
- package/lib/Breadcrumb/index.js +23 -0
- package/lib/CampaignBlock/CampaignBlock.js +187 -0
- package/lib/CampaignBlock/index.js +13 -0
- package/lib/CodeBlock/CodeBlock.js +41 -0
- package/lib/CodeBlock/codeLanguageOptions.js +90 -0
- package/lib/CodeBlock/index.js +20 -0
- package/lib/Concept/Concept.js +78 -0
- package/lib/ContactBlock/ContactBlock.js +206 -0
- package/lib/ContactBlock/index.js +18 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +57 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +38 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +38 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +57 -0
- package/lib/ContentTypeHero/index.js +12 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +89 -0
- package/lib/CopyParagraphButton/index.js +22 -0
- package/lib/Embed/AudioEmbed.js +84 -0
- package/lib/Embed/BrightcoveEmbed.js +142 -0
- package/lib/Embed/CodeEmbed.js +86 -0
- package/lib/Embed/ConceptEmbed.js +131 -0
- package/lib/Embed/ConceptInlineTriggerButton.js +51 -0
- package/lib/Embed/ContentLinkEmbed.js +57 -0
- package/lib/Embed/CopyrightEmbed.js +39 -0
- package/lib/Embed/EmbedErrorPlaceholder.js +64 -0
- package/lib/Embed/EmbedWrapper.js +57 -0
- package/lib/Embed/ExternalEmbed.js +81 -0
- package/lib/Embed/FootnoteEmbed.js +50 -0
- package/lib/Embed/GlossEmbed.js +88 -0
- package/lib/Embed/H5pEmbed.js +68 -0
- package/lib/Embed/IframeEmbed.js +100 -0
- package/lib/Embed/ImageEmbed.js +248 -0
- package/lib/Embed/InlineTriggerButton.js +43 -0
- package/lib/Embed/RelatedContentEmbed.js +61 -0
- package/lib/Embed/UnknownEmbed.js +37 -0
- package/lib/Embed/UuDisclaimerEmbed.js +94 -0
- package/lib/Embed/index.js +150 -0
- package/lib/Embed/types.js +5 -0
- package/lib/ErrorMessage/ErrorMessage.js +101 -0
- package/lib/ErrorMessage/index.js +16 -0
- package/lib/FactBox/FactBox.js +184 -0
- package/lib/FactBox/index.js +16 -0
- package/lib/FileList/File.js +108 -0
- package/lib/FileList/FileList.js +54 -0
- package/lib/FileList/PdfFile.js +57 -0
- package/lib/FileList/index.js +44 -0
- package/lib/Gloss/Gloss.js +181 -0
- package/lib/Gloss/GlossExample.js +70 -0
- package/lib/Gloss/index.js +20 -0
- package/lib/Grid/Grid.js +101 -0
- package/lib/Grid/GridParallaxItem.js +39 -0
- package/lib/Grid/index.js +19 -0
- package/lib/KeyFigure/KeyFigure.js +70 -0
- package/lib/KeyFigure/index.js +13 -0
- package/lib/LicenseByline/EmbedByline.js +220 -0
- package/lib/LicenseByline/LicenseLink.js +62 -0
- package/lib/LicenseByline/index.js +19 -0
- package/lib/LinkBlock/LinkBlock.js +110 -0
- package/lib/LinkBlock/LinkBlockSection.js +41 -0
- package/lib/LinkBlock/index.js +20 -0
- package/lib/Pitch/Pitch.js +91 -0
- package/lib/Pitch/index.js +12 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +143 -0
- package/lib/RelatedArticleList/index.js +21 -0
- package/lib/ResourceBox/ResourceBox.js +106 -0
- package/lib/ResourceBox/index.js +13 -0
- package/lib/TagSelector/TagSelector.js +150 -0
- package/lib/ZendeskButton/ZendeskButton.js +61 -0
- package/lib/i18n/formatNestedMessages.js +32 -0
- package/lib/i18n/i18n.js +41 -0
- package/lib/i18n/index.js +68 -0
- package/lib/i18n/useComponentTranslations.js +224 -0
- package/lib/index.js +599 -0
- package/lib/locale/messages-en.js +469 -0
- package/lib/locale/messages-nb.js +469 -0
- package/lib/locale/messages-nn.js +469 -0
- package/lib/locale/messages-se.js +469 -0
- package/lib/model/ContentType.js +74 -0
- package/lib/model/SubjectCategories.js +18 -0
- package/lib/model/SubjectTypes.js +17 -0
- package/lib/model/WordClass.js +51 -0
- package/lib/model/index.js +28 -0
- package/lib/types.js +5 -0
- package/lib/utils/licenseAttributes.js +25 -0
- package/lib/utils/relativeUrl.js +44 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
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 { forwardRef } from "react";
|
|
10
|
+
import { ark } from "@ark-ui/react";
|
|
11
|
+
import { Heading, Text } from "@ndla/primitives";
|
|
12
|
+
import { cx } from "@ndla/styled-system/css";
|
|
13
|
+
import { Stack, styled } from "@ndla/styled-system/jsx";
|
|
14
|
+
import { ArticleByline } from "./ArticleByline";
|
|
15
|
+
import { ContentTypeBadge } from "../ContentTypeBadge/ContentTypeBadge";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
const StyledArticleContent = styled(ark.section, {}, {
|
|
18
|
+
baseComponent: true
|
|
19
|
+
});
|
|
20
|
+
export const ArticleContent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
} = _ref;
|
|
25
|
+
return /*#__PURE__*/_jsx(StyledArticleContent, {
|
|
26
|
+
className: cx("ndla-article", className),
|
|
27
|
+
...props,
|
|
28
|
+
ref: ref
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const StyledArticleWrapper = styled(ark.article, {
|
|
32
|
+
base: {
|
|
33
|
+
background: "background.default",
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
color: "text.default",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
width: "100%",
|
|
39
|
+
overflowWrap: "break-word",
|
|
40
|
+
position: "relative",
|
|
41
|
+
"& mjx-stretchy-v > mjx-ext > mjx-c": {
|
|
42
|
+
transform: "scaleY(100) translateY(0.075em)"
|
|
43
|
+
},
|
|
44
|
+
_after: {
|
|
45
|
+
content: "",
|
|
46
|
+
display: "table",
|
|
47
|
+
clear: "both"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
baseComponent: true
|
|
52
|
+
});
|
|
53
|
+
export const ArticleWrapper = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(StyledArticleWrapper, {
|
|
54
|
+
"data-ndla-article": "",
|
|
55
|
+
ref: ref,
|
|
56
|
+
...props
|
|
57
|
+
}));
|
|
58
|
+
export const ArticleHGroup = styled(ark.hgroup, {
|
|
59
|
+
base: {
|
|
60
|
+
display: "flex",
|
|
61
|
+
width: "100%",
|
|
62
|
+
flexDirection: "column",
|
|
63
|
+
alignItems: "flex-start",
|
|
64
|
+
"& h1": {
|
|
65
|
+
overflowWrap: "anywhere"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
baseComponent: true
|
|
70
|
+
});
|
|
71
|
+
export const ArticleHeader = styled(ark.header, {
|
|
72
|
+
base: {
|
|
73
|
+
display: "flex",
|
|
74
|
+
flexDirection: "column",
|
|
75
|
+
gap: "medium",
|
|
76
|
+
alignItems: "flex-start",
|
|
77
|
+
width: "100%",
|
|
78
|
+
paddingBlockStart: "xxlarge",
|
|
79
|
+
overflowWrap: "anywhere"
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
baseComponent: true
|
|
83
|
+
});
|
|
84
|
+
export const ArticleFooter = styled(ark.footer, {
|
|
85
|
+
base: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
gap: "xxlarge",
|
|
89
|
+
width: "100%",
|
|
90
|
+
"& > :is(:last-child)": {
|
|
91
|
+
paddingBlockEnd: "5xlarge"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
baseComponent: true
|
|
96
|
+
});
|
|
97
|
+
const StyledStack = styled(Stack, {
|
|
98
|
+
base: {
|
|
99
|
+
width: "100%",
|
|
100
|
+
minHeight: "xxlarge"
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const StyledWrapper = styled("div", {
|
|
104
|
+
base: {
|
|
105
|
+
display: "flex",
|
|
106
|
+
gap: "small",
|
|
107
|
+
flexWrap: "wrap",
|
|
108
|
+
alignItems: "center"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
export const ArticleTitle = _ref2 => {
|
|
112
|
+
let {
|
|
113
|
+
contentType,
|
|
114
|
+
heartButton,
|
|
115
|
+
title,
|
|
116
|
+
lang,
|
|
117
|
+
id,
|
|
118
|
+
introduction,
|
|
119
|
+
contentTypeLabel,
|
|
120
|
+
competenceGoals,
|
|
121
|
+
disclaimer
|
|
122
|
+
} = _ref2;
|
|
123
|
+
return /*#__PURE__*/_jsxs(ArticleHeader, {
|
|
124
|
+
children: [/*#__PURE__*/_jsxs(ArticleHGroup, {
|
|
125
|
+
children: [(!!contentType || !!heartButton) && /*#__PURE__*/_jsxs(StyledStack, {
|
|
126
|
+
justify: "space-between",
|
|
127
|
+
align: "center",
|
|
128
|
+
direction: "row",
|
|
129
|
+
gap: "small",
|
|
130
|
+
children: [!!contentType && /*#__PURE__*/_jsx(ContentTypeBadge, {
|
|
131
|
+
contentType: contentType,
|
|
132
|
+
children: contentTypeLabel
|
|
133
|
+
}), heartButton]
|
|
134
|
+
}), /*#__PURE__*/_jsx(Heading, {
|
|
135
|
+
textStyle: "heading.medium",
|
|
136
|
+
id: id,
|
|
137
|
+
lang: lang,
|
|
138
|
+
property: "dct:title",
|
|
139
|
+
children: title
|
|
140
|
+
})]
|
|
141
|
+
}), !!introduction && /*#__PURE__*/_jsx(Text, {
|
|
142
|
+
lang: lang,
|
|
143
|
+
textStyle: "body.xlarge",
|
|
144
|
+
asChild: true,
|
|
145
|
+
consumeCss: true,
|
|
146
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
147
|
+
children: introduction
|
|
148
|
+
})
|
|
149
|
+
}), /*#__PURE__*/_jsxs(StyledWrapper, {
|
|
150
|
+
children: [competenceGoals, disclaimer]
|
|
151
|
+
})]
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
export const Article = _ref3 => {
|
|
155
|
+
let {
|
|
156
|
+
article,
|
|
157
|
+
contentType,
|
|
158
|
+
licenseBox,
|
|
159
|
+
children,
|
|
160
|
+
competenceGoals,
|
|
161
|
+
contentTypeLabel,
|
|
162
|
+
id,
|
|
163
|
+
heartButton,
|
|
164
|
+
lang,
|
|
165
|
+
disclaimer
|
|
166
|
+
} = _ref3;
|
|
167
|
+
const {
|
|
168
|
+
title,
|
|
169
|
+
introduction,
|
|
170
|
+
published,
|
|
171
|
+
content,
|
|
172
|
+
footNotes,
|
|
173
|
+
copyright
|
|
174
|
+
} = article;
|
|
175
|
+
const authors = copyright?.creators.length || copyright?.rightsholders.length ? copyright.creators : copyright?.processors;
|
|
176
|
+
return /*#__PURE__*/_jsxs(ArticleWrapper, {
|
|
177
|
+
children: [/*#__PURE__*/_jsx(ArticleTitle, {
|
|
178
|
+
id: id,
|
|
179
|
+
contentType: contentType,
|
|
180
|
+
heartButton: heartButton,
|
|
181
|
+
title: title,
|
|
182
|
+
introduction: introduction,
|
|
183
|
+
competenceGoals: competenceGoals,
|
|
184
|
+
lang: lang,
|
|
185
|
+
contentTypeLabel: contentTypeLabel,
|
|
186
|
+
disclaimer: disclaimer
|
|
187
|
+
}), /*#__PURE__*/_jsx(ArticleContent, {
|
|
188
|
+
children: content
|
|
189
|
+
}), /*#__PURE__*/_jsxs(ArticleFooter, {
|
|
190
|
+
children: [/*#__PURE__*/_jsx(ArticleByline, {
|
|
191
|
+
footnotes: footNotes,
|
|
192
|
+
authors: authors,
|
|
193
|
+
suppliers: copyright?.rightsholders,
|
|
194
|
+
published: published,
|
|
195
|
+
licenseBox: licenseBox
|
|
196
|
+
}), children]
|
|
197
|
+
})]
|
|
198
|
+
});
|
|
199
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
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-dom";
|
|
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
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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";
|
|
@@ -0,0 +1,218 @@
|
|
|
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;
|