@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/Pitch/Pitch.js
DELETED
|
@@ -1,83 +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 parse from "html-react-parser";
|
|
10
|
-
import { CardHeading, CardImage, CardRoot, Text } from "@ndla/primitives";
|
|
11
|
-
import { SafeLink } from "@ndla/safelink";
|
|
12
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
13
|
-
import { linkOverlay } from "@ndla/styled-system/patterns";
|
|
14
|
-
import { getPossiblyRelativeUrl } from "../utils/relativeUrl";
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
const StyledCardHeading = styled(CardHeading, {
|
|
17
|
-
base: {
|
|
18
|
-
paddingBlockStart: "medium"
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
const StyledText = styled(Text, {
|
|
22
|
-
base: {
|
|
23
|
-
paddingBlockEnd: "medium"
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const StyledCardRoot = styled(CardRoot, {
|
|
27
|
-
base: {
|
|
28
|
-
border: "0",
|
|
29
|
-
display: "flex",
|
|
30
|
-
flexDirection: "column",
|
|
31
|
-
gap: "small"
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const StyledCardImage = styled(CardImage, {
|
|
35
|
-
base: {
|
|
36
|
-
aspectRatio: "16/9",
|
|
37
|
-
height: "unset"
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
export const Pitch = _ref => {
|
|
41
|
-
let {
|
|
42
|
-
title,
|
|
43
|
-
url,
|
|
44
|
-
metaImage,
|
|
45
|
-
path,
|
|
46
|
-
description
|
|
47
|
-
} = _ref;
|
|
48
|
-
const href = getPossiblyRelativeUrl(url, path);
|
|
49
|
-
return /*#__PURE__*/_jsx(StyledCardRoot, {
|
|
50
|
-
variant: "subtle",
|
|
51
|
-
"data-embed-type": "pitch",
|
|
52
|
-
asChild: true,
|
|
53
|
-
consumeCss: true,
|
|
54
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
55
|
-
children: [/*#__PURE__*/_jsx(StyledCardHeading, {
|
|
56
|
-
textStyle: "heading.small",
|
|
57
|
-
asChild: true,
|
|
58
|
-
consumeCss: true,
|
|
59
|
-
children: /*#__PURE__*/_jsx(SafeLink, {
|
|
60
|
-
to: href,
|
|
61
|
-
unstyled: true,
|
|
62
|
-
css: linkOverlay.raw(),
|
|
63
|
-
children: parse(title)
|
|
64
|
-
})
|
|
65
|
-
}), !!description && /*#__PURE__*/_jsx(StyledText, {
|
|
66
|
-
textStyle: "body.xlarge",
|
|
67
|
-
asChild: true,
|
|
68
|
-
consumeCss: true,
|
|
69
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
70
|
-
children: parse(description)
|
|
71
|
-
})
|
|
72
|
-
}), /*#__PURE__*/_jsx(StyledCardImage, {
|
|
73
|
-
variant: "rounded",
|
|
74
|
-
src: metaImage.url,
|
|
75
|
-
alt: metaImage.alt,
|
|
76
|
-
sizes: "480px",
|
|
77
|
-
fallbackWidth: 300,
|
|
78
|
-
width: 550,
|
|
79
|
-
height: 310
|
|
80
|
-
})]
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
};
|
package/es/Pitch/index.js
DELETED
|
@@ -1,135 +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 { Children, useMemo, useState } from "react";
|
|
10
|
-
import { useTranslation } from "react-i18next";
|
|
11
|
-
import { ExternalLinkLine } from "@ndla/icons";
|
|
12
|
-
import { CardContent, CardHeading, CardRoot, Text, Heading, Button } from "@ndla/primitives";
|
|
13
|
-
import { SafeLink } from "@ndla/safelink";
|
|
14
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
15
|
-
import { linkOverlay } from "@ndla/styled-system/patterns";
|
|
16
|
-
import { ContentTypeBadge } from "../ContentTypeBadge/ContentTypeBadge";
|
|
17
|
-
import { contentTypes } from "../model/ContentType";
|
|
18
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
const StyledSpan = styled("span", {
|
|
20
|
-
base: {
|
|
21
|
-
display: "flex",
|
|
22
|
-
gap: "3xsmall"
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
export const RelatedArticle = _ref => {
|
|
26
|
-
let {
|
|
27
|
-
title,
|
|
28
|
-
introduction,
|
|
29
|
-
to,
|
|
30
|
-
linkInfo = "",
|
|
31
|
-
target = "",
|
|
32
|
-
type = contentTypes.SUBJECT_MATERIAL
|
|
33
|
-
} = _ref;
|
|
34
|
-
return /*#__PURE__*/_jsx(CardRoot, {
|
|
35
|
-
"data-embed-type": "related-article",
|
|
36
|
-
children: /*#__PURE__*/_jsxs(CardContent, {
|
|
37
|
-
children: [/*#__PURE__*/_jsx(ContentTypeBadge, {
|
|
38
|
-
contentType: type
|
|
39
|
-
}), /*#__PURE__*/_jsx(CardHeading, {
|
|
40
|
-
asChild: true,
|
|
41
|
-
consumeCss: true,
|
|
42
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
43
|
-
children: /*#__PURE__*/_jsx(SafeLink, {
|
|
44
|
-
unstyled: true,
|
|
45
|
-
to: to,
|
|
46
|
-
target: target,
|
|
47
|
-
rel: linkInfo ? "noopener noreferrer" : undefined,
|
|
48
|
-
css: linkOverlay.raw(),
|
|
49
|
-
children: /*#__PURE__*/_jsxs(StyledSpan, {
|
|
50
|
-
children: [title, target === "_blank" && /*#__PURE__*/_jsx(ExternalLinkLine, {})]
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
55
|
-
dangerouslySetInnerHTML: {
|
|
56
|
-
__html: introduction
|
|
57
|
-
}
|
|
58
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
59
|
-
color: "text.subtle",
|
|
60
|
-
textStyle: "label.small",
|
|
61
|
-
children: linkInfo
|
|
62
|
-
})]
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const HeadingWrapper = styled("div", {
|
|
67
|
-
base: {
|
|
68
|
-
display: "flex",
|
|
69
|
-
width: "100%",
|
|
70
|
-
justifyContent: "space-between",
|
|
71
|
-
alignItems: "center",
|
|
72
|
-
alignSelf: "flex-start"
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const ArticlesWrapper = styled("div", {
|
|
76
|
-
base: {
|
|
77
|
-
display: "grid",
|
|
78
|
-
width: "100%",
|
|
79
|
-
gridTemplateColumns: "repeat(2, 1fr)",
|
|
80
|
-
gap: "medium",
|
|
81
|
-
tabletDown: {
|
|
82
|
-
gridTemplateColumns: "1fr"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const StyledSection = styled("section", {
|
|
87
|
-
base: {
|
|
88
|
-
display: "flex",
|
|
89
|
-
flexDirection: "column",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
gap: "medium",
|
|
92
|
-
clear: "both"
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const StyledButton = styled(Button, {
|
|
96
|
-
base: {
|
|
97
|
-
marginBlockStart: "xsmall"
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
export const RelatedArticleList = _ref2 => {
|
|
101
|
-
let {
|
|
102
|
-
children = [],
|
|
103
|
-
articleCount,
|
|
104
|
-
headingLevel: HeadingElement = "h2",
|
|
105
|
-
headingButtons,
|
|
106
|
-
...rest
|
|
107
|
-
} = _ref2;
|
|
108
|
-
const [expanded, setExpanded] = useState(false);
|
|
109
|
-
const {
|
|
110
|
-
t
|
|
111
|
-
} = useTranslation();
|
|
112
|
-
const childCount = useMemo(() => articleCount ?? Children.count(children), [children, articleCount]);
|
|
113
|
-
const childrenToShow = useMemo(() => childCount > 2 && !expanded ? children?.slice(0, 2) : children, [childCount, children, expanded]);
|
|
114
|
-
return /*#__PURE__*/_jsxs(StyledSection, {
|
|
115
|
-
...rest,
|
|
116
|
-
"data-embed-type": "related-content-list",
|
|
117
|
-
children: [/*#__PURE__*/_jsxs(HeadingWrapper, {
|
|
118
|
-
children: [/*#__PURE__*/_jsx(Heading, {
|
|
119
|
-
asChild: true,
|
|
120
|
-
consumeCss: true,
|
|
121
|
-
textStyle: "title.large",
|
|
122
|
-
fontWeight: "bold",
|
|
123
|
-
children: /*#__PURE__*/_jsx(HeadingElement, {
|
|
124
|
-
children: t("related.title")
|
|
125
|
-
})
|
|
126
|
-
}), headingButtons]
|
|
127
|
-
}), /*#__PURE__*/_jsx(ArticlesWrapper, {
|
|
128
|
-
children: childrenToShow
|
|
129
|
-
}), childCount > 2 ? /*#__PURE__*/_jsx(StyledButton, {
|
|
130
|
-
variant: "secondary",
|
|
131
|
-
onClick: () => setExpanded(p => !p),
|
|
132
|
-
children: t(`related.show${expanded ? "Less" : "More"}`)
|
|
133
|
-
}) : null]
|
|
134
|
-
});
|
|
135
|
-
};
|
|
@@ -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
|
-
import { RelatedArticle, RelatedArticleList } from "./RelatedArticleList";
|
|
10
|
-
export { RelatedArticle };
|
|
11
|
-
export default RelatedArticleList;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022-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 { breakpoints } from "@ndla/core";
|
|
10
|
-
import { ShareBoxLine } from "@ndla/icons";
|
|
11
|
-
import { Heading, Image, Text } from "@ndla/primitives";
|
|
12
|
-
import { SafeLinkButton } from "@ndla/safelink";
|
|
13
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const Container = styled("div", {
|
|
16
|
-
base: {
|
|
17
|
-
display: "flex",
|
|
18
|
-
padding: "medium",
|
|
19
|
-
borderRadius: "xsmall",
|
|
20
|
-
border: "1px solid",
|
|
21
|
-
borderColor: "stroke.default",
|
|
22
|
-
boxShadow: "full",
|
|
23
|
-
marginBlockEnd: "medium",
|
|
24
|
-
gap: "medium",
|
|
25
|
-
tabletWideDown: {
|
|
26
|
-
padding: "xsmall"
|
|
27
|
-
},
|
|
28
|
-
tabletDown: {
|
|
29
|
-
flexDirection: "column",
|
|
30
|
-
gap: "0",
|
|
31
|
-
padding: "0"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const ContentWrapper = styled("div", {
|
|
36
|
-
base: {
|
|
37
|
-
display: "flex",
|
|
38
|
-
flexDirection: "column",
|
|
39
|
-
alignItems: "flex-start",
|
|
40
|
-
gap: "xsmall",
|
|
41
|
-
flex: "1",
|
|
42
|
-
tabletDown: {
|
|
43
|
-
padding: "xsmall"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
const StyledImage = styled(Image, {
|
|
48
|
-
base: {
|
|
49
|
-
objectFit: "cover",
|
|
50
|
-
borderRadius: "xsmall",
|
|
51
|
-
width: "fit-content",
|
|
52
|
-
aspectRatio: "1/1",
|
|
53
|
-
tabletDown: {
|
|
54
|
-
width: "100%",
|
|
55
|
-
borderRadius: "0"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const StyledText = styled(Text, {
|
|
60
|
-
base: {
|
|
61
|
-
flex: "1"
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
export const ResourceBox = _ref => {
|
|
65
|
-
let {
|
|
66
|
-
image,
|
|
67
|
-
title,
|
|
68
|
-
caption,
|
|
69
|
-
url,
|
|
70
|
-
buttonText
|
|
71
|
-
} = _ref;
|
|
72
|
-
return /*#__PURE__*/_jsxs(Container, {
|
|
73
|
-
children: [image ? /*#__PURE__*/_jsx(StyledImage, {
|
|
74
|
-
src: image.src,
|
|
75
|
-
alt: image.alt,
|
|
76
|
-
sizes: `(min-width: ${breakpoints.desktop}) 150px, (max-width: ${breakpoints.tablet} ) 400px, 200px`,
|
|
77
|
-
variant: "rounded"
|
|
78
|
-
}) : null, /*#__PURE__*/_jsxs(ContentWrapper, {
|
|
79
|
-
children: [/*#__PURE__*/_jsx(Heading, {
|
|
80
|
-
textStyle: "label.large",
|
|
81
|
-
fontWeight: "bold",
|
|
82
|
-
asChild: true,
|
|
83
|
-
consumeCss: true,
|
|
84
|
-
children: /*#__PURE__*/_jsx("h3", {
|
|
85
|
-
children: title
|
|
86
|
-
})
|
|
87
|
-
}), /*#__PURE__*/_jsx(StyledText, {
|
|
88
|
-
textStyle: "body.medium",
|
|
89
|
-
children: caption
|
|
90
|
-
}), /*#__PURE__*/_jsxs(SafeLinkButton, {
|
|
91
|
-
to: url,
|
|
92
|
-
target: "_blank",
|
|
93
|
-
variant: "secondary",
|
|
94
|
-
children: [buttonText, /*#__PURE__*/_jsx(ShareBoxLine, {})]
|
|
95
|
-
})]
|
|
96
|
-
})]
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
export default ResourceBox;
|
package/es/ResourceBox/index.js
DELETED
|
@@ -1,143 +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, useEffect, useId, useRef } from "react";
|
|
10
|
-
import { useTagsInputContext, useComboboxContext } from "@ark-ui/react";
|
|
11
|
-
import { CloseLine } from "@ndla/icons";
|
|
12
|
-
import { ComboboxClearTrigger, ComboboxControl, ComboboxInput, ComboboxLabel, ComboboxRoot, ComboboxTrigger, TagsInputControl, TagsInputInput, TagsInputItem, TagsInputItemDeleteTrigger, TagsInputItemPreview, TagsInputItemText, TagsInputRoot, TagsInputItemInput } from "@ndla/primitives";
|
|
13
|
-
import { contains } from "@ndla/util";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
-
export const TagSelectorRoot = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
allowCustomValue = true,
|
|
18
|
-
multiple = true,
|
|
19
|
-
selectionBehavior = "clear",
|
|
20
|
-
editable,
|
|
21
|
-
addOnPaste = false,
|
|
22
|
-
onValueChange,
|
|
23
|
-
children,
|
|
24
|
-
value,
|
|
25
|
-
translations,
|
|
26
|
-
...rest
|
|
27
|
-
} = _ref;
|
|
28
|
-
const ids = {
|
|
29
|
-
root: useId(),
|
|
30
|
-
input: useId(),
|
|
31
|
-
control: useId()
|
|
32
|
-
};
|
|
33
|
-
const controlRef = useRef(undefined);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!controlRef.current) {
|
|
36
|
-
controlRef.current = document.getElementById(ids.control);
|
|
37
|
-
}
|
|
38
|
-
}, [ids.control]);
|
|
39
|
-
return /*#__PURE__*/_jsx(ComboboxRoot, {
|
|
40
|
-
ids: ids,
|
|
41
|
-
asChild: true,
|
|
42
|
-
allowCustomValue: allowCustomValue,
|
|
43
|
-
multiple: multiple,
|
|
44
|
-
selectionBehavior: selectionBehavior,
|
|
45
|
-
onValueChange: onValueChange,
|
|
46
|
-
translations: translations,
|
|
47
|
-
onPointerDownOutside: event => {
|
|
48
|
-
if (contains(controlRef.current, event.detail.originalEvent.target)) {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
value: value,
|
|
53
|
-
...rest,
|
|
54
|
-
children: /*#__PURE__*/_jsx(TagSelectorTagsInputRoot, {
|
|
55
|
-
ids: ids,
|
|
56
|
-
value: value,
|
|
57
|
-
editable: editable,
|
|
58
|
-
onValueChange: onValueChange,
|
|
59
|
-
addOnPaste: addOnPaste,
|
|
60
|
-
translations: translations,
|
|
61
|
-
children: children
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
const TagSelectorTagsInputRoot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
66
|
-
const comboboxApi = useComboboxContext();
|
|
67
|
-
return /*#__PURE__*/_jsx(TagsInputRoot, {
|
|
68
|
-
ref: ref,
|
|
69
|
-
onInputValueChange: details => comboboxApi.setInputValue(details.inputValue),
|
|
70
|
-
...props
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
export const TagSelectorLabel = ComboboxLabel;
|
|
74
|
-
export const TagSelectorItemInput = TagsInputItemInput;
|
|
75
|
-
export const TagSelectorTrigger = ComboboxTrigger;
|
|
76
|
-
export const TagSelectorControl = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
77
|
-
let {
|
|
78
|
-
children,
|
|
79
|
-
...props
|
|
80
|
-
} = _ref2;
|
|
81
|
-
return /*#__PURE__*/_jsx(ComboboxControl, {
|
|
82
|
-
ref: ref,
|
|
83
|
-
asChild: true,
|
|
84
|
-
children: /*#__PURE__*/_jsx(TagsInputControl, {
|
|
85
|
-
...props,
|
|
86
|
-
children: children
|
|
87
|
-
})
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
export const TagSelectorClearTrigger = ComboboxClearTrigger;
|
|
91
|
-
// If you need to modify the TagsInputItem, you can use this.
|
|
92
|
-
export const TagSelectorInputBase = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
93
|
-
let {
|
|
94
|
-
children,
|
|
95
|
-
...props
|
|
96
|
-
} = _ref3;
|
|
97
|
-
const tagsApi = useTagsInputContext();
|
|
98
|
-
return /*#__PURE__*/_jsx(ComboboxInput, {
|
|
99
|
-
ref: ref,
|
|
100
|
-
asChild: true,
|
|
101
|
-
children: /*#__PURE__*/_jsx(TagsInputInput, {
|
|
102
|
-
onKeyDown: event => {
|
|
103
|
-
if (event.key === "Enter") {
|
|
104
|
-
tagsApi.addValue(tagsApi.inputValue);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
...props,
|
|
108
|
-
children: children
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
export const TagSelectorInput = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
113
|
-
let {
|
|
114
|
-
children,
|
|
115
|
-
...props
|
|
116
|
-
} = _ref4;
|
|
117
|
-
const tagsApi = useTagsInputContext();
|
|
118
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
119
|
-
children: [tagsApi.value.map((value, index) => /*#__PURE__*/_jsxs(TagsInputItem, {
|
|
120
|
-
index: index,
|
|
121
|
-
value: value,
|
|
122
|
-
children: [/*#__PURE__*/_jsxs(TagsInputItemPreview, {
|
|
123
|
-
children: [/*#__PURE__*/_jsx(TagsInputItemText, {
|
|
124
|
-
children: value
|
|
125
|
-
}), /*#__PURE__*/_jsx(TagsInputItemDeleteTrigger, {
|
|
126
|
-
children: /*#__PURE__*/_jsx(CloseLine, {})
|
|
127
|
-
})]
|
|
128
|
-
}), /*#__PURE__*/_jsx(TagsInputItemInput, {})]
|
|
129
|
-
}, value)), /*#__PURE__*/_jsx(ComboboxInput, {
|
|
130
|
-
ref: ref,
|
|
131
|
-
asChild: true,
|
|
132
|
-
children: /*#__PURE__*/_jsx(TagsInputInput, {
|
|
133
|
-
onKeyDown: event => {
|
|
134
|
-
if (event.key === "Enter") {
|
|
135
|
-
tagsApi.addValue(tagsApi.inputValue);
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
...props,
|
|
139
|
-
children: children
|
|
140
|
-
})
|
|
141
|
-
})]
|
|
142
|
-
});
|
|
143
|
-
});
|
|
@@ -1,55 +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, useState } from "react";
|
|
10
|
-
import { Button } from "@ndla/primitives";
|
|
11
|
-
|
|
12
|
-
// TODO: Let's consider abandoning `disabled` on the button here. It should instead just open/close the widget based on its current state.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
export const ZendeskButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
|
-
let {
|
|
16
|
-
locale,
|
|
17
|
-
variant = "secondary",
|
|
18
|
-
widgetKey,
|
|
19
|
-
children,
|
|
20
|
-
...rest
|
|
21
|
-
} = _ref;
|
|
22
|
-
const [loading, setLoading] = useState(false);
|
|
23
|
-
const handleClick = () => {
|
|
24
|
-
if (window && !window.zE) {
|
|
25
|
-
setLoading(true);
|
|
26
|
-
// Asynchronously load zendesk scripts for better performance
|
|
27
|
-
const script = document.createElement("script");
|
|
28
|
-
script.id = "ze-snippet";
|
|
29
|
-
script.type = "text/javascript";
|
|
30
|
-
script.async = true;
|
|
31
|
-
script.onload = () => {
|
|
32
|
-
if (window.zE) {
|
|
33
|
-
window.zE("webWidget", "setLocale", locale);
|
|
34
|
-
window.zE("webWidget:on", "close", () => {
|
|
35
|
-
setLoading(false);
|
|
36
|
-
});
|
|
37
|
-
window.zE("webWidget", "open");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
script.src = `https://static.zdassets.com/ekr/snippet.js?key=${widgetKey}`;
|
|
41
|
-
document.body.appendChild(script);
|
|
42
|
-
} else if (window?.zE) {
|
|
43
|
-
window.zE("webWidget", "open");
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return /*#__PURE__*/_jsx(Button, {
|
|
47
|
-
onClick: handleClick,
|
|
48
|
-
variant: variant,
|
|
49
|
-
id: "zendeskButton",
|
|
50
|
-
disabled: loading,
|
|
51
|
-
...rest,
|
|
52
|
-
ref: ref,
|
|
53
|
-
children: children
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,25 +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 const formatNestedMessages = function (phrases) {
|
|
10
|
-
let formattedMessages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
11
|
-
let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
12
|
-
const messages = formattedMessages;
|
|
13
|
-
Object.keys(phrases).forEach(key => {
|
|
14
|
-
const value = phrases[key];
|
|
15
|
-
if ({}.hasOwnProperty.call(phrases, key)) {
|
|
16
|
-
const keyWithPrefix = prefix ? `${prefix}.${key}` : key;
|
|
17
|
-
if (typeof value === "object") {
|
|
18
|
-
formatNestedMessages(value, formattedMessages, keyWithPrefix);
|
|
19
|
-
} else {
|
|
20
|
-
messages[keyWithPrefix] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return messages;
|
|
25
|
-
};
|
package/es/i18n/i18n.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2021-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 i18n from "i18next";
|
|
10
|
-
import { initReactI18next } from "react-i18next";
|
|
11
|
-
import messagesEN from "../locale/messages-en";
|
|
12
|
-
import messagesNB from "../locale/messages-nb";
|
|
13
|
-
import messagesNN from "../locale/messages-nn";
|
|
14
|
-
import messagesSE from "../locale/messages-se";
|
|
15
|
-
export const supportedTranslationLanguages = ["nb", "nn", "en", "se"];
|
|
16
|
-
const i18nInstance = i18n.use(initReactI18next);
|
|
17
|
-
i18nInstance.init({
|
|
18
|
-
fallbackLng: "nb",
|
|
19
|
-
supportedLngs: supportedTranslationLanguages,
|
|
20
|
-
resources: {
|
|
21
|
-
en: {
|
|
22
|
-
translation: messagesEN
|
|
23
|
-
},
|
|
24
|
-
nn: {
|
|
25
|
-
translation: messagesNN
|
|
26
|
-
},
|
|
27
|
-
nb: {
|
|
28
|
-
translation: messagesNB
|
|
29
|
-
},
|
|
30
|
-
se: {
|
|
31
|
-
translation: messagesSE
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
export { i18nInstance };
|
package/es/i18n/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2021-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 { i18nInstance } from "./i18n";
|
|
10
|
-
export { formatNestedMessages } from "./formatNestedMessages";
|
|
11
|
-
export { useComboboxTranslations, useTagSelectorTranslations, useTagsInputTranslations, usePaginationTranslations, useAudioSearchTranslations, useImageSearchTranslations, useVideoSearchTranslations } from "./useComponentTranslations";
|