@ndla/ui 56.0.122-alpha.0 → 56.0.124-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 +127 -0
- package/es/Article/Article.js.map +1 -0
- package/es/Article/ArticleByline.js +133 -0
- package/es/Article/ArticleByline.js.map +1 -0
- package/es/Article/ArticleFootNotes.js +40 -0
- package/es/Article/ArticleFootNotes.js.map +1 -0
- package/es/AudioPlayer/AudioPlayer.js +157 -0
- package/es/AudioPlayer/AudioPlayer.js.map +1 -0
- package/es/AudioPlayer/Controls.js +254 -0
- package/es/AudioPlayer/Controls.js.map +1 -0
- package/es/AudioPlayer/SpeechControl.js +40 -0
- package/es/AudioPlayer/SpeechControl.js.map +1 -0
- package/es/AudioPlayer/index.js +8 -0
- package/es/AudioPlayer/index.js.map +1 -0
- package/es/Breadcrumb/Breadcrumb.js +44 -0
- package/es/Breadcrumb/Breadcrumb.js.map +1 -0
- package/es/Breadcrumb/BreadcrumbItem.js +36 -0
- package/es/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/es/Breadcrumb/HomeBreadcrumb.js +44 -0
- package/es/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/es/Breadcrumb/index.js +9 -0
- package/es/Breadcrumb/index.js.map +1 -0
- package/es/CampaignBlock/CampaignBlock.js +131 -0
- package/es/CampaignBlock/CampaignBlock.js.map +1 -0
- package/es/CodeBlock/CodeBlock.js +25 -0
- package/es/CodeBlock/CodeBlock.js.map +1 -0
- package/es/CodeBlock/codeLanguageOptions.js +114 -0
- package/es/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/es/Concept/Concept.js +50 -0
- package/es/Concept/Concept.js.map +1 -0
- package/es/ContactBlock/ContactBlock.js +145 -0
- package/es/ContactBlock/ContactBlock.js.map +1 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js +41 -0
- package/es/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js +25 -0
- package/es/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js +25 -0
- package/es/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/es/ContentTypeHero/ContentTypeHero.js +39 -0
- package/es/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js +62 -0
- package/es/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/es/CopyParagraphButton/index.js +8 -0
- package/es/CopyParagraphButton/index.js.map +1 -0
- package/es/Embed/AudioEmbed.js +52 -0
- package/es/Embed/AudioEmbed.js.map +1 -0
- package/es/Embed/BrightcoveEmbed.js +96 -0
- package/es/Embed/BrightcoveEmbed.js.map +1 -0
- package/es/Embed/CodeEmbed.js +61 -0
- package/es/Embed/CodeEmbed.js.map +1 -0
- package/es/Embed/ConceptEmbed.js +78 -0
- package/es/Embed/ConceptEmbed.js.map +1 -0
- package/es/Embed/ConceptInlineTriggerButton.js +40 -0
- package/es/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/es/Embed/ContentLinkEmbed.js +31 -0
- package/es/Embed/ContentLinkEmbed.js.map +1 -0
- package/es/Embed/CopyrightEmbed.js +23 -0
- package/es/Embed/CopyrightEmbed.js.map +1 -0
- package/es/Embed/EmbedErrorPlaceholder.js +43 -0
- package/es/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/es/Embed/EmbedWrapper.js +26 -0
- package/es/Embed/EmbedWrapper.js.map +1 -0
- package/es/Embed/ExternalEmbed.js +54 -0
- package/es/Embed/ExternalEmbed.js.map +1 -0
- package/es/Embed/FootnoteEmbed.js +27 -0
- package/es/Embed/FootnoteEmbed.js.map +1 -0
- package/es/Embed/GlossEmbed.js +52 -0
- package/es/Embed/GlossEmbed.js.map +1 -0
- package/es/Embed/H5pEmbed.js +38 -0
- package/es/Embed/H5pEmbed.js.map +1 -0
- package/es/Embed/IframeEmbed.js +69 -0
- package/es/Embed/IframeEmbed.js.map +1 -0
- package/es/Embed/ImageEmbed.js +180 -0
- package/es/Embed/ImageEmbed.js.map +1 -0
- package/es/Embed/InlineTriggerButton.js +25 -0
- package/es/Embed/InlineTriggerButton.js.map +1 -0
- package/es/Embed/RelatedContentEmbed.js +38 -0
- package/es/Embed/RelatedContentEmbed.js.map +1 -0
- package/es/Embed/UnknownEmbed.js +20 -0
- package/es/Embed/UnknownEmbed.js.map +1 -0
- package/es/Embed/UuDisclaimerEmbed.js +54 -0
- package/es/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/es/ErrorMessage/ErrorMessage.js +54 -0
- package/es/ErrorMessage/ErrorMessage.js.map +1 -0
- package/es/ErrorMessage/index.js +8 -0
- package/es/ErrorMessage/index.js.map +1 -0
- package/es/FactBox/FactBox.js +121 -0
- package/es/FactBox/FactBox.js.map +1 -0
- package/es/FactBox/index.js +8 -0
- package/es/FactBox/index.js.map +1 -0
- package/es/FileList/File.js +76 -0
- package/es/FileList/File.js.map +1 -0
- package/es/FileList/FileList.js +32 -0
- package/es/FileList/FileList.js.map +1 -0
- package/es/FileList/PdfFile.js +28 -0
- package/es/FileList/PdfFile.js.map +1 -0
- package/es/Gloss/Gloss.js +142 -0
- package/es/Gloss/Gloss.js.map +1 -0
- package/es/Gloss/GlossExample.js +46 -0
- package/es/Gloss/GlossExample.js.map +1 -0
- package/es/Grid/Grid.js +66 -0
- package/es/Grid/Grid.js.map +1 -0
- package/es/Grid/GridParallaxItem.js +21 -0
- package/es/Grid/GridParallaxItem.js.map +1 -0
- package/es/KeyFigure/KeyFigure.js +46 -0
- package/es/KeyFigure/KeyFigure.js.map +1 -0
- package/es/LicenseByline/EmbedByline.js +132 -0
- package/es/LicenseByline/EmbedByline.js.map +1 -0
- package/es/LicenseByline/LicenseLink.js +31 -0
- package/es/LicenseByline/LicenseLink.js.map +1 -0
- package/es/LinkBlock/LinkBlock.js +74 -0
- package/es/LinkBlock/LinkBlock.js.map +1 -0
- package/es/LinkBlock/LinkBlockSection.js +23 -0
- package/es/LinkBlock/LinkBlockSection.js.map +1 -0
- package/es/Pitch/Pitch.js +62 -0
- package/es/Pitch/Pitch.js.map +1 -0
- package/es/RelatedArticleList/RelatedArticleList.js +97 -0
- package/es/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/es/RelatedArticleList/index.js +8 -0
- package/es/RelatedArticleList/index.js.map +1 -0
- package/es/ResourceBox/ResourceBox.js +74 -0
- package/es/ResourceBox/ResourceBox.js.map +1 -0
- package/es/TagSelector/TagSelector.js +100 -0
- package/es/TagSelector/TagSelector.js.map +1 -0
- package/es/ZendeskButton/ZendeskButton.js +41 -0
- package/es/ZendeskButton/ZendeskButton.js.map +1 -0
- package/es/_virtual/rolldown_runtime.js +11 -0
- package/es/i18n/formatNestedMessages.js +17 -0
- package/es/i18n/formatNestedMessages.js.map +1 -0
- package/es/i18n/i18n.js +29 -0
- package/es/i18n/i18n.js.map +1 -0
- package/es/i18n/useComponentTranslations.js +155 -0
- package/es/i18n/useComponentTranslations.js.map +1 -0
- package/es/index.js +65 -0
- package/es/locale/messages-en.js +438 -0
- package/es/locale/messages-en.js.map +1 -0
- package/es/locale/messages-nb.js +438 -0
- package/es/locale/messages-nb.js.map +1 -0
- package/es/locale/messages-nn.js +438 -0
- package/es/locale/messages-nn.js.map +1 -0
- package/es/locale/messages-se.js +438 -0
- package/es/locale/messages-se.js.map +1 -0
- package/es/model/ContentType.js +72 -0
- package/es/model/ContentType.js.map +1 -0
- package/es/model/SubjectCategories.js +25 -0
- package/es/model/SubjectCategories.js.map +1 -0
- package/es/model/SubjectTypes.js +23 -0
- package/es/model/SubjectTypes.js.map +1 -0
- package/es/model/WordClass.js +53 -0
- package/es/model/WordClass.js.map +1 -0
- package/es/model/index.js +19 -0
- package/es/model/index.js.map +1 -0
- package/es/utils/licenseAttributes.js +16 -0
- package/es/utils/licenseAttributes.js.map +1 -0
- package/es/utils/relativeUrl.js +26 -0
- package/es/utils/relativeUrl.js.map +1 -0
- package/lib/Article/Article.js +134 -0
- package/lib/Article/Article.js.map +1 -0
- package/lib/Article/ArticleByline.js +135 -0
- package/lib/Article/ArticleByline.js.map +1 -0
- package/lib/Article/ArticleFootNotes.js +41 -0
- package/lib/Article/ArticleFootNotes.js.map +1 -0
- package/lib/AudioPlayer/AudioPlayer.js +158 -0
- package/lib/AudioPlayer/AudioPlayer.js.map +1 -0
- package/lib/AudioPlayer/Controls.js +255 -0
- package/lib/AudioPlayer/Controls.js.map +1 -0
- package/lib/AudioPlayer/SpeechControl.js +41 -0
- package/lib/AudioPlayer/SpeechControl.js.map +1 -0
- package/lib/AudioPlayer/index.js +8 -0
- package/lib/AudioPlayer/index.js.map +1 -0
- package/lib/Breadcrumb/Breadcrumb.js +45 -0
- package/lib/Breadcrumb/Breadcrumb.js.map +1 -0
- package/lib/Breadcrumb/BreadcrumbItem.js +37 -0
- package/lib/Breadcrumb/BreadcrumbItem.js.map +1 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js +45 -0
- package/lib/Breadcrumb/HomeBreadcrumb.js.map +1 -0
- package/lib/Breadcrumb/index.js +9 -0
- package/lib/Breadcrumb/index.js.map +1 -0
- package/lib/CampaignBlock/CampaignBlock.js +132 -0
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -0
- package/lib/CodeBlock/CodeBlock.js +26 -0
- package/lib/CodeBlock/CodeBlock.js.map +1 -0
- package/lib/CodeBlock/codeLanguageOptions.js +115 -0
- package/lib/CodeBlock/codeLanguageOptions.js.map +1 -0
- package/lib/Concept/Concept.js +51 -0
- package/lib/Concept/Concept.js.map +1 -0
- package/lib/ContactBlock/ContactBlock.js +147 -0
- package/lib/ContactBlock/ContactBlock.js.map +1 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +43 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js +26 -0
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.js.map +1 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js +26 -0
- package/lib/ContentTypeFramedContent/ContentTypeFramedContent.js.map +1 -0
- package/lib/ContentTypeHero/ContentTypeHero.js +40 -0
- package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js +63 -0
- package/lib/CopyParagraphButton/CopyParagraphButton.js.map +1 -0
- package/lib/CopyParagraphButton/index.js +8 -0
- package/lib/CopyParagraphButton/index.js.map +1 -0
- package/lib/Embed/AudioEmbed.js +53 -0
- package/lib/Embed/AudioEmbed.js.map +1 -0
- package/lib/Embed/BrightcoveEmbed.js +97 -0
- package/lib/Embed/BrightcoveEmbed.js.map +1 -0
- package/lib/Embed/CodeEmbed.js +62 -0
- package/lib/Embed/CodeEmbed.js.map +1 -0
- package/lib/Embed/ConceptEmbed.js +81 -0
- package/lib/Embed/ConceptEmbed.js.map +1 -0
- package/lib/Embed/ConceptInlineTriggerButton.js +41 -0
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -0
- package/lib/Embed/ContentLinkEmbed.js +32 -0
- package/lib/Embed/ContentLinkEmbed.js.map +1 -0
- package/lib/Embed/CopyrightEmbed.js +24 -0
- package/lib/Embed/CopyrightEmbed.js.map +1 -0
- package/lib/Embed/EmbedErrorPlaceholder.js +44 -0
- package/lib/Embed/EmbedErrorPlaceholder.js.map +1 -0
- package/lib/Embed/EmbedWrapper.js +27 -0
- package/lib/Embed/EmbedWrapper.js.map +1 -0
- package/lib/Embed/ExternalEmbed.js +55 -0
- package/lib/Embed/ExternalEmbed.js.map +1 -0
- package/lib/Embed/FootnoteEmbed.js +28 -0
- package/lib/Embed/FootnoteEmbed.js.map +1 -0
- package/lib/Embed/GlossEmbed.js +53 -0
- package/lib/Embed/GlossEmbed.js.map +1 -0
- package/lib/Embed/H5pEmbed.js +39 -0
- package/lib/Embed/H5pEmbed.js.map +1 -0
- package/lib/Embed/IframeEmbed.js +70 -0
- package/lib/Embed/IframeEmbed.js.map +1 -0
- package/lib/Embed/ImageEmbed.js +183 -0
- package/lib/Embed/ImageEmbed.js.map +1 -0
- package/lib/Embed/InlineTriggerButton.js +26 -0
- package/lib/Embed/InlineTriggerButton.js.map +1 -0
- package/lib/Embed/RelatedContentEmbed.js +39 -0
- package/lib/Embed/RelatedContentEmbed.js.map +1 -0
- package/lib/Embed/UnknownEmbed.js +21 -0
- package/lib/Embed/UnknownEmbed.js.map +1 -0
- package/lib/Embed/UuDisclaimerEmbed.js +55 -0
- package/lib/Embed/UuDisclaimerEmbed.js.map +1 -0
- package/lib/ErrorMessage/ErrorMessage.js +55 -0
- package/lib/ErrorMessage/ErrorMessage.js.map +1 -0
- package/lib/ErrorMessage/index.js +8 -0
- package/lib/ErrorMessage/index.js.map +1 -0
- package/lib/FactBox/FactBox.js +122 -0
- package/lib/FactBox/FactBox.js.map +1 -0
- package/lib/FactBox/index.js +8 -0
- package/lib/FactBox/index.js.map +1 -0
- package/lib/FileList/File.js +78 -0
- package/lib/FileList/File.js.map +1 -0
- package/lib/FileList/FileList.js +35 -0
- package/lib/FileList/FileList.js.map +1 -0
- package/lib/FileList/PdfFile.js +29 -0
- package/lib/FileList/PdfFile.js.map +1 -0
- package/lib/Gloss/Gloss.js +143 -0
- package/lib/Gloss/Gloss.js.map +1 -0
- package/lib/Gloss/GlossExample.js +47 -0
- package/lib/Gloss/GlossExample.js.map +1 -0
- package/lib/Grid/Grid.js +67 -0
- package/lib/Grid/Grid.js.map +1 -0
- package/lib/Grid/GridParallaxItem.js +22 -0
- package/lib/Grid/GridParallaxItem.js.map +1 -0
- package/lib/KeyFigure/KeyFigure.js +47 -0
- package/lib/KeyFigure/KeyFigure.js.map +1 -0
- package/lib/LicenseByline/EmbedByline.js +134 -0
- package/lib/LicenseByline/EmbedByline.js.map +1 -0
- package/lib/LicenseByline/LicenseLink.js +32 -0
- package/lib/LicenseByline/LicenseLink.js.map +1 -0
- package/lib/LinkBlock/LinkBlock.js +75 -0
- package/lib/LinkBlock/LinkBlock.js.map +1 -0
- package/lib/LinkBlock/LinkBlockSection.js +24 -0
- package/lib/LinkBlock/LinkBlockSection.js.map +1 -0
- package/lib/Pitch/Pitch.js +63 -0
- package/lib/Pitch/Pitch.js.map +1 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +99 -0
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -0
- package/lib/RelatedArticleList/index.js +8 -0
- package/lib/RelatedArticleList/index.js.map +1 -0
- package/lib/ResourceBox/ResourceBox.js +75 -0
- package/lib/ResourceBox/ResourceBox.js.map +1 -0
- package/lib/TagSelector/TagSelector.js +108 -0
- package/lib/TagSelector/TagSelector.js.map +1 -0
- package/lib/ZendeskButton/ZendeskButton.js +42 -0
- package/lib/ZendeskButton/ZendeskButton.js.map +1 -0
- package/lib/_virtual/rolldown_runtime.js +42 -0
- package/lib/i18n/formatNestedMessages.js +18 -0
- package/lib/i18n/formatNestedMessages.js.map +1 -0
- package/lib/i18n/i18n.js +31 -0
- package/lib/i18n/i18n.js.map +1 -0
- package/lib/i18n/useComponentTranslations.js +163 -0
- package/lib/i18n/useComponentTranslations.js.map +1 -0
- package/lib/index.js +157 -0
- package/lib/locale/messages-en.js +439 -0
- package/lib/locale/messages-en.js.map +1 -0
- package/lib/locale/messages-nb.js +439 -0
- package/lib/locale/messages-nb.js.map +1 -0
- package/lib/locale/messages-nn.js +439 -0
- package/lib/locale/messages-nn.js.map +1 -0
- package/lib/locale/messages-se.js +439 -0
- package/lib/locale/messages-se.js.map +1 -0
- package/lib/model/ContentType.js +94 -0
- package/lib/model/ContentType.js.map +1 -0
- package/lib/model/SubjectCategories.js +30 -0
- package/lib/model/SubjectCategories.js.map +1 -0
- package/lib/model/SubjectTypes.js +28 -0
- package/lib/model/SubjectTypes.js.map +1 -0
- package/lib/model/WordClass.js +58 -0
- package/lib/model/WordClass.js.map +1 -0
- package/lib/model/index.js +19 -0
- package/lib/model/index.js.map +1 -0
- package/lib/utils/licenseAttributes.js +17 -0
- package/lib/utils/licenseAttributes.js.map +1 -0
- package/lib/utils/relativeUrl.js +26 -0
- package/lib/utils/relativeUrl.js.map +1 -0
- package/package.json +12 -11
package/es/Grid/Grid.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/Grid/Grid.tsx
|
|
6
|
+
const GridContainer = styled("div", {
|
|
7
|
+
base: {
|
|
8
|
+
display: "grid",
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
borderRadius: "xsmall",
|
|
11
|
+
gridRowGap: "large",
|
|
12
|
+
gridColumnGap: "medium",
|
|
13
|
+
width: "100%",
|
|
14
|
+
backgroundColor: "background.subtle",
|
|
15
|
+
minWidth: "surface.xxsmall",
|
|
16
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
17
|
+
"& :not(div[data-parallax-cell='true']) > div[data-embed-type='pitch']": {
|
|
18
|
+
height: "100%",
|
|
19
|
+
"& > :last-child": { marginTop: "auto" }
|
|
20
|
+
},
|
|
21
|
+
tabletDown: { gridTemplateColumns: "repeat(1, minmax(0, 1fr))" },
|
|
22
|
+
tabletToDesktop: {
|
|
23
|
+
gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
|
|
24
|
+
"& > div:nth-child(3):last-child": {
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexFlow: "column",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
gridColumn: "span 2"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
variants: {
|
|
34
|
+
columns: {
|
|
35
|
+
"2": {},
|
|
36
|
+
"2x2": {},
|
|
37
|
+
"3": { desktop: { gridTemplateColumns: "repeat(3, minmax(0, 1fr))" } },
|
|
38
|
+
"4": { desktop: { gridTemplateColumns: "repeat(4, minmax(0, 1fr))" } }
|
|
39
|
+
},
|
|
40
|
+
background: {
|
|
41
|
+
white: { backgroundColor: "surface.default" },
|
|
42
|
+
transparent: { backgroundColor: "transparent" },
|
|
43
|
+
gray: { backgroundColor: "background.subtle" }
|
|
44
|
+
},
|
|
45
|
+
border: { lightBlue: {
|
|
46
|
+
padding: "xsmall",
|
|
47
|
+
border: "1px solid",
|
|
48
|
+
borderColor: "surface.brand.2"
|
|
49
|
+
} }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const Grid = ({ columns, border, children, background = "gray",...rest }) => {
|
|
53
|
+
const amountOfColumns = children?.length === 3 ? "3" : columns;
|
|
54
|
+
return /* @__PURE__ */ jsx(GridContainer, {
|
|
55
|
+
"data-embed-type": "grid",
|
|
56
|
+
border: border === "none" ? void 0 : border,
|
|
57
|
+
columns: amountOfColumns,
|
|
58
|
+
background,
|
|
59
|
+
...rest,
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Grid };
|
|
66
|
+
//# sourceMappingURL=Grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Grid.js","names":[],"sources":["../../src/Grid/Grid.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type ComponentProps, type ReactNode } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst GridContainer = styled(\"div\", {\n base: {\n display: \"grid\",\n justifyContent: \"center\",\n borderRadius: \"xsmall\",\n gridRowGap: \"large\",\n gridColumnGap: \"medium\",\n width: \"100%\",\n backgroundColor: \"background.subtle\",\n minWidth: \"surface.xxsmall\",\n gridTemplateColumns: \"repeat(2, minmax(0, 1fr))\",\n\n \"& :not(div[data-parallax-cell='true']) > div[data-embed-type='pitch']\": {\n height: \"100%\",\n \"& > :last-child\": {\n marginTop: \"auto\",\n },\n },\n tabletDown: {\n gridTemplateColumns: \"repeat(1, minmax(0, 1fr))\",\n },\n tabletToDesktop: {\n gridTemplateColumns: \"repeat(2, minmax(0, 1fr))\",\n \"& > div:nth-child(3):last-child\": {\n display: \"flex\",\n flexFlow: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gridColumn: \"span 2\",\n },\n },\n },\n variants: {\n columns: {\n \"2\": {},\n \"2x2\": {},\n \"3\": { desktop: { gridTemplateColumns: \"repeat(3, minmax(0, 1fr))\" } },\n \"4\": { desktop: { gridTemplateColumns: \"repeat(4, minmax(0, 1fr))\" } },\n },\n background: {\n white: { backgroundColor: \"surface.default\" },\n transparent: { backgroundColor: \"transparent\" },\n gray: { backgroundColor: \"background.subtle\" },\n },\n border: {\n lightBlue: {\n padding: \"xsmall\",\n border: \"1px solid\",\n borderColor: \"surface.brand.2\",\n },\n },\n },\n});\n\nexport interface GridProps extends ComponentProps<\"div\"> {\n columns: \"2\" | \"3\" | \"4\" | \"2x2\";\n border?: \"none\" | \"lightBlue\";\n background?: \"transparent\" | \"white\" | \"gray\";\n children?: ReactNode[];\n}\n\nexport const Grid = ({ columns, border, children, background = \"gray\", ...rest }: GridProps) => {\n const amountOfColumns = children?.length === 3 ? \"3\" : columns;\n\n return (\n <GridContainer\n data-embed-type=\"grid\"\n border={border === \"none\" ? undefined : border}\n columns={amountOfColumns}\n background={background}\n {...rest}\n >\n {children}\n </GridContainer>\n );\n};\n"],"mappings":";;;;;AAWA,MAAM,gBAAgB,OAAO,OAAO;CAClC,MAAM;EACJ,SAAS;EACT,gBAAgB;EAChB,cAAc;EACd,YAAY;EACZ,eAAe;EACf,OAAO;EACP,iBAAiB;EACjB,UAAU;EACV,qBAAqB;EAErB,yEAAyE;GACvE,QAAQ;GACR,mBAAmB,EACjB,WAAW,OACZ;EACF;EACD,YAAY,EACV,qBAAqB,4BACtB;EACD,iBAAiB;GACf,qBAAqB;GACrB,mCAAmC;IACjC,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,YAAY;IACZ,YAAY;GACb;EACF;CACF;CACD,UAAU;EACR,SAAS;GACP,KAAK,CAAE;GACP,OAAO,CAAE;GACT,KAAK,EAAE,SAAS,EAAE,qBAAqB,4BAA6B,EAAE;GACtE,KAAK,EAAE,SAAS,EAAE,qBAAqB,4BAA6B,EAAE;EACvE;EACD,YAAY;GACV,OAAO,EAAE,iBAAiB,kBAAmB;GAC7C,aAAa,EAAE,iBAAiB,cAAe;GAC/C,MAAM,EAAE,iBAAiB,oBAAqB;EAC/C;EACD,QAAQ,EACN,WAAW;GACT,SAAS;GACT,QAAQ;GACR,aAAa;EACd,EACF;CACF;AACF,EAAC;AASF,MAAa,OAAO,CAAC,EAAE,SAAS,QAAQ,UAAU,aAAa,OAAQ,GAAG,MAAiB,KAAK;CAC9F,MAAM,kBAAkB,UAAU,WAAW,IAAI,MAAM;AAEvD,wBACE,IAAC;EACC,mBAAgB;EAChB,QAAQ,WAAW,kBAAqB;EACxC,SAAS;EACG;EACZ,GAAI;EAEH;GACa;AAEnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/Grid/GridParallaxItem.tsx
|
|
6
|
+
const StyledGridParallaxItem = styled("div", { base: {
|
|
7
|
+
position: "relative",
|
|
8
|
+
"& > div": {
|
|
9
|
+
top: "var(--masthead-height, 0px)",
|
|
10
|
+
position: "sticky"
|
|
11
|
+
}
|
|
12
|
+
} });
|
|
13
|
+
const GridParallaxItem = ({ children,...rest }) => /* @__PURE__ */ jsx(StyledGridParallaxItem, {
|
|
14
|
+
...rest,
|
|
15
|
+
"data-embed-type": "grid-parallax",
|
|
16
|
+
children: /* @__PURE__ */ jsx("div", { children })
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { GridParallaxItem };
|
|
21
|
+
//# sourceMappingURL=GridParallaxItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridParallaxItem.js","names":[],"sources":["../../src/Grid/GridParallaxItem.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type HTMLAttributes } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst StyledGridParallaxItem = styled(\"div\", {\n base: {\n position: \"relative\",\n \"& > div\": {\n top: \"var(--masthead-height, 0px)\",\n position: \"sticky\",\n },\n },\n});\n\nexport const GridParallaxItem = ({ children, ...rest }: HTMLAttributes<HTMLDivElement>) => (\n <StyledGridParallaxItem {...rest} data-embed-type=\"grid-parallax\">\n <div>{children}</div>\n </StyledGridParallaxItem>\n);\n"],"mappings":";;;;;AAWA,MAAM,yBAAyB,OAAO,OAAO,EAC3C,MAAM;CACJ,UAAU;CACV,WAAW;EACT,KAAK;EACL,UAAU;CACX;AACF,EACF,EAAC;AAEF,MAAa,mBAAmB,CAAC,EAAE,SAAU,GAAG,MAAsC,qBACpF,IAAC;CAAuB,GAAI;CAAM,mBAAgB;2BAChD,IAAC,SAAK,WAAe;EACE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
2
|
+
import parse from "html-react-parser";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/KeyFigure/KeyFigure.tsx
|
|
6
|
+
const ContentWrapper = styled("div", { base: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
justifyContent: "center",
|
|
11
|
+
gap: "xsmall",
|
|
12
|
+
"&:not(:has(> img))": { paddingBlock: "xxlarge" }
|
|
13
|
+
} });
|
|
14
|
+
const StyledImage = styled("img", { base: {
|
|
15
|
+
height: "surface.3xsmall",
|
|
16
|
+
width: "surface.3xsmall",
|
|
17
|
+
borderRadius: "xsmall"
|
|
18
|
+
} });
|
|
19
|
+
const TitleWrapper = styled("div", { base: {
|
|
20
|
+
textStyle: "heading.large",
|
|
21
|
+
textAlign: "center"
|
|
22
|
+
} });
|
|
23
|
+
const SubTitleWrapper = styled("div", { base: {
|
|
24
|
+
textStyle: "title.medium",
|
|
25
|
+
textAlign: "center"
|
|
26
|
+
} });
|
|
27
|
+
const KeyFigure = ({ image, title, subtitle }) => {
|
|
28
|
+
return /* @__PURE__ */ jsxs(ContentWrapper, {
|
|
29
|
+
"data-embed-type": "key-figure",
|
|
30
|
+
children: [
|
|
31
|
+
!!image && /* @__PURE__ */ jsx(StyledImage, {
|
|
32
|
+
src: `${image?.src}?width=150`,
|
|
33
|
+
width: 150,
|
|
34
|
+
height: 150,
|
|
35
|
+
alt: image?.alt
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ jsx(TitleWrapper, { children: parse(title) }),
|
|
38
|
+
/* @__PURE__ */ jsx(SubTitleWrapper, { children: parse(subtitle) })
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var KeyFigure_default = KeyFigure;
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { KeyFigure_default };
|
|
46
|
+
//# sourceMappingURL=KeyFigure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyFigure.js","names":[],"sources":["../../src/KeyFigure/KeyFigure.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n gap: \"xsmall\",\n\n \"&:not(:has(> img))\": {\n paddingBlock: \"xxlarge\",\n },\n },\n});\n\nconst StyledImage = styled(\"img\", {\n base: {\n height: \"surface.3xsmall\",\n width: \"surface.3xsmall\",\n borderRadius: \"xsmall\",\n },\n});\n\nconst TitleWrapper = styled(\"div\", {\n base: {\n textStyle: \"heading.large\",\n textAlign: \"center\",\n },\n});\n\nconst SubTitleWrapper = styled(\"div\", {\n base: {\n textStyle: \"title.medium\",\n textAlign: \"center\",\n },\n});\n\nexport interface Props {\n image?: {\n src?: string;\n alt?: string;\n };\n title: string;\n subtitle: string;\n}\n\nconst KeyFigure = ({ image, title, subtitle }: Props) => {\n return (\n <ContentWrapper data-embed-type=\"key-figure\">\n {!!image && <StyledImage src={`${image?.src}?width=150`} width={150} height={150} alt={image?.alt} />}\n <TitleWrapper>{parse(title)}</TitleWrapper>\n <SubTitleWrapper>{parse(subtitle)}</SubTitleWrapper>\n </ContentWrapper>\n );\n};\n\nexport default KeyFigure;\n"],"mappings":";;;;;AAWA,MAAM,iBAAiB,OAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,YAAY;CACZ,gBAAgB;CAChB,KAAK;CAEL,sBAAsB,EACpB,cAAc,UACf;AACF,EACF,EAAC;AAEF,MAAM,cAAc,OAAO,OAAO,EAChC,MAAM;CACJ,QAAQ;CACR,OAAO;CACP,cAAc;AACf,EACF,EAAC;AAEF,MAAM,eAAe,OAAO,OAAO,EACjC,MAAM;CACJ,WAAW;CACX,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,kBAAkB,OAAO,OAAO,EACpC,MAAM;CACJ,WAAW;CACX,WAAW;AACZ,EACF,EAAC;AAWF,MAAM,YAAY,CAAC,EAAE,OAAO,OAAO,UAAiB,KAAK;AACvD,wBACE,KAAC;EAAe,mBAAgB;;KAC3B,yBAAS,IAAC;IAAY,MAAM,EAAE,OAAO,IAAI;IAAa,OAAO;IAAK,QAAQ;IAAK,KAAK,OAAO;KAAO;mBACrG,IAAC,0BAAc,MAAM,MAAM,GAAgB;mBAC3C,IAAC,6BAAiB,MAAM,SAAS,GAAmB;;GACrC;AAEpB;AAED,wBAAe"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { LicenseLink } from "./LicenseLink.js";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Button, Text } from "@ndla/primitives";
|
|
4
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { AlertLine } from "@ndla/icons";
|
|
7
|
+
import { getLicenseByAbbreviation, getLicenseCredits } from "@ndla/licenses";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/LicenseByline/EmbedByline.tsx
|
|
11
|
+
const BylineWrapper = styled("figcaption", { base: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
flexDirection: "column",
|
|
14
|
+
paddingBlock: "xsmall",
|
|
15
|
+
textStyle: "label.medium",
|
|
16
|
+
color: "text.subtle"
|
|
17
|
+
} });
|
|
18
|
+
const ErrorBylineWrapper = styled(BylineWrapper, { base: {
|
|
19
|
+
border: "1px solid",
|
|
20
|
+
borderColor: "stroke.error",
|
|
21
|
+
borderRadius: "xsmall",
|
|
22
|
+
background: "surface.dangerSubtle",
|
|
23
|
+
paddingInline: "medium",
|
|
24
|
+
paddingBlock: "medium"
|
|
25
|
+
} });
|
|
26
|
+
const StyledText = styled(Text, { base: { fontStyle: "italic" } });
|
|
27
|
+
const ContentWrapper = styled("div", { base: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
gap: "xsmall",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
textStyle: "label.medium"
|
|
32
|
+
} });
|
|
33
|
+
const BaseDescription = styled("div", { base: {
|
|
34
|
+
display: "inline-flex",
|
|
35
|
+
whiteSpace: "pre-wrap"
|
|
36
|
+
} });
|
|
37
|
+
const EmbedByline = ({ type, description, children, visibleAlt, hideCopyright,...props }) => {
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
if (props.error) {
|
|
40
|
+
const typeString = type === "h5p" ? "H5P" : t(`embed.type.${type}`).toLowerCase();
|
|
41
|
+
return /* @__PURE__ */ jsx(ErrorBylineWrapper, { children: /* @__PURE__ */ jsxs(ContentWrapper, { children: [/* @__PURE__ */ jsx(AlertLine, {}), /* @__PURE__ */ jsx(BaseDescription, { children: /* @__PURE__ */ jsx("span", { children: t("embed.embedError", { type: typeString }) }) })] }) });
|
|
42
|
+
}
|
|
43
|
+
const { copyright } = props;
|
|
44
|
+
const hideByline = hideCopyright && !description;
|
|
45
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [!hideByline && /* @__PURE__ */ jsx(BylineWrapper, { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
46
|
+
!!hideCopyright && description,
|
|
47
|
+
!hideCopyright && /* @__PURE__ */ jsx(LicenseContainerContent, {
|
|
48
|
+
type,
|
|
49
|
+
copyright,
|
|
50
|
+
children: description
|
|
51
|
+
}),
|
|
52
|
+
children
|
|
53
|
+
] }) }), visibleAlt ? /* @__PURE__ */ jsx(StyledText, {
|
|
54
|
+
color: "text.subtle",
|
|
55
|
+
textStyle: "label.medium",
|
|
56
|
+
asChild: true,
|
|
57
|
+
consumeCss: true,
|
|
58
|
+
children: /* @__PURE__ */ jsx("span", { children: `Alt: ${visibleAlt}` })
|
|
59
|
+
}) : null] });
|
|
60
|
+
};
|
|
61
|
+
const StyledDescription = styled(BaseDescription, { base: { mobileWideDown: {
|
|
62
|
+
display: "grid",
|
|
63
|
+
gridTemplateColumns: "1fr auto",
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
overflow: "hidden",
|
|
66
|
+
_open: { display: "inline" }
|
|
67
|
+
} } });
|
|
68
|
+
const TextContent = styled("span", { base: { mobileWideDown: {
|
|
69
|
+
whiteSpace: "nowrap",
|
|
70
|
+
maxHeight: "large",
|
|
71
|
+
overflow: "hidden",
|
|
72
|
+
textOverflow: "ellipsis",
|
|
73
|
+
transitionProperty: "max-height",
|
|
74
|
+
transitionDuration: "slow",
|
|
75
|
+
transitionTimingFunction: "ease-in",
|
|
76
|
+
marginInlineEnd: "4xsmall",
|
|
77
|
+
_open: {
|
|
78
|
+
whiteSpace: "pre-wrap",
|
|
79
|
+
maxHeight: "none"
|
|
80
|
+
}
|
|
81
|
+
} } });
|
|
82
|
+
const StyledButton = styled(Button, { base: { mobileWide: { display: "none" } } });
|
|
83
|
+
const LicenseDescription = ({ children, isOpen, setIsOpen }) => {
|
|
84
|
+
const open = isOpen ? { "data-open": "" } : {};
|
|
85
|
+
const { t } = useTranslation();
|
|
86
|
+
const handleToggle = () => {
|
|
87
|
+
setIsOpen(!isOpen);
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ jsx(ContentWrapper, { children: /* @__PURE__ */ jsxs(StyledDescription, {
|
|
90
|
+
...open,
|
|
91
|
+
children: [/* @__PURE__ */ jsx(TextContent, {
|
|
92
|
+
...open,
|
|
93
|
+
children
|
|
94
|
+
}), /* @__PURE__ */ jsx(StyledButton, {
|
|
95
|
+
variant: "link",
|
|
96
|
+
size: "small",
|
|
97
|
+
onClick: handleToggle,
|
|
98
|
+
children: isOpen ? `${t("audio.readLessDescriptionLabel")}` : `${t("audio.readMoreDescriptionLabel")}`
|
|
99
|
+
})]
|
|
100
|
+
}) });
|
|
101
|
+
};
|
|
102
|
+
const LicenseContainerContent = ({ children, copyright, type }) => {
|
|
103
|
+
const { t, i18n } = useTranslation();
|
|
104
|
+
const license = copyright ? getLicenseByAbbreviation(copyright.license?.license ?? "", i18n.language) : void 0;
|
|
105
|
+
const authors = getLicenseCredits(copyright);
|
|
106
|
+
const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
|
|
107
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
108
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
109
|
+
children,
|
|
110
|
+
` ${t(`embed.type.${type}`)}${captionAuthors.length ? ": " : ""}`,
|
|
111
|
+
/* @__PURE__ */ jsx("span", { children: captionAuthors.map((author) => author.name).join(", ") }),
|
|
112
|
+
license ? /* @__PURE__ */ jsxs(Fragment$1, { children: [" / ", /* @__PURE__ */ jsx(LicenseLink, {
|
|
113
|
+
license,
|
|
114
|
+
hideLink: !isOpen && !!children
|
|
115
|
+
})] }) : null
|
|
116
|
+
] });
|
|
117
|
+
if (children) return /* @__PURE__ */ jsx(LicenseDescription, {
|
|
118
|
+
isOpen,
|
|
119
|
+
setIsOpen,
|
|
120
|
+
children: content
|
|
121
|
+
});
|
|
122
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
123
|
+
textStyle: "label.medium",
|
|
124
|
+
asChild: true,
|
|
125
|
+
consumeCss: true,
|
|
126
|
+
children: /* @__PURE__ */ jsx("span", { children: content })
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { EmbedByline, LicenseContainerContent };
|
|
132
|
+
//# sourceMappingURL=EmbedByline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbedByline.js","names":[],"sources":["../../src/LicenseByline/EmbedByline.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type Dispatch, type ReactNode, type SetStateAction, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AlertLine } from \"@ndla/icons\";\nimport { getLicenseByAbbreviation, getLicenseCredits } from \"@ndla/licenses\";\nimport { Button, Text } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { ICopyrightDTO as ArticleCopyright } from \"@ndla/types-backend/article-api\";\nimport type { ICopyrightDTO as AudioCopyright } from \"@ndla/types-backend/audio-api\";\nimport type { IDraftCopyrightDTO as ConceptCopyright } from \"@ndla/types-backend/concept-api\";\nimport type { ICopyrightDTO as ImageCopyright } from \"@ndla/types-backend/image-api\";\nimport type { BrightcoveCopyright } from \"@ndla/types-embed\";\nimport { LicenseLink } from \"./LicenseLink\";\n\ninterface BaseProps {\n description?: ReactNode;\n children?: ReactNode;\n visibleAlt?: string;\n error?: true | false;\n hideDescription?: boolean;\n hideCopyright?: boolean;\n}\n\nexport interface EmbedBylineErrorProps extends BaseProps {\n type: EmbedBylineTypeProps[\"type\"] | \"h5p\" | \"external\" | \"code\";\n error: true;\n}\n\ninterface ImageProps extends BaseProps {\n type: \"image\";\n copyright: ImageCopyright | undefined;\n}\n\ninterface BrightcoveProps extends BaseProps {\n type: \"video\";\n copyright: BrightcoveCopyright | undefined;\n}\n\ninterface AudioProps extends BaseProps {\n type: \"audio\";\n copyright: AudioCopyright | undefined;\n}\n\ninterface PodcastProps extends BaseProps {\n type: \"podcast\";\n copyright: AudioCopyright | undefined;\n}\n\ninterface ConceptProps extends BaseProps {\n type: \"concept\" | \"gloss\";\n copyright: ConceptCopyright | undefined;\n}\n\ninterface CopyrightProps extends BaseProps {\n type: \"copyright\";\n copyright: ArticleCopyright | undefined;\n}\n\nexport type EmbedBylineTypeProps =\n | ImageProps\n | BrightcoveProps\n | AudioProps\n | PodcastProps\n | ConceptProps\n | CopyrightProps;\n\ntype Props = EmbedBylineTypeProps | EmbedBylineErrorProps;\n\nconst BylineWrapper = styled(\"figcaption\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n paddingBlock: \"xsmall\",\n textStyle: \"label.medium\",\n color: \"text.subtle\",\n },\n});\n\nconst ErrorBylineWrapper = styled(BylineWrapper, {\n base: {\n border: \"1px solid\",\n borderColor: \"stroke.error\",\n borderRadius: \"xsmall\",\n background: \"surface.dangerSubtle\",\n paddingInline: \"medium\",\n paddingBlock: \"medium\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n fontStyle: \"italic\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n gap: \"xsmall\",\n alignItems: \"center\",\n textStyle: \"label.medium\",\n },\n});\n\nconst BaseDescription = styled(\"div\", {\n base: {\n display: \"inline-flex\",\n whiteSpace: \"pre-wrap\",\n },\n});\n\nexport const EmbedByline = ({ type, description, children, visibleAlt, hideCopyright, ...props }: Props) => {\n const { t } = useTranslation();\n\n if (props.error) {\n const typeString = type === \"h5p\" ? \"H5P\" : t(`embed.type.${type}`).toLowerCase();\n return (\n <ErrorBylineWrapper>\n <ContentWrapper>\n <AlertLine />\n <BaseDescription>\n <span>{t(\"embed.embedError\", { type: typeString })}</span>\n </BaseDescription>\n </ContentWrapper>\n </ErrorBylineWrapper>\n );\n }\n\n const { copyright } = props;\n const hideByline = hideCopyright && !description;\n\n return (\n <>\n {!hideByline && (\n <BylineWrapper>\n <div>\n {!!hideCopyright && description}\n {!hideCopyright && (\n <LicenseContainerContent type={type} copyright={copyright}>\n {description}\n </LicenseContainerContent>\n )}\n {children}\n </div>\n </BylineWrapper>\n )}\n {visibleAlt ? (\n <StyledText color=\"text.subtle\" textStyle=\"label.medium\" asChild consumeCss>\n <span>{`Alt: ${visibleAlt}`}</span>\n </StyledText>\n ) : null}\n </>\n );\n};\n\ninterface LicenseContainerProps {\n children?: ReactNode;\n copyright: EmbedBylineTypeProps[\"copyright\"];\n type: Props[\"type\"];\n}\n\nconst StyledDescription = styled(BaseDescription, {\n base: {\n mobileWideDown: {\n display: \"grid\",\n gridTemplateColumns: \"1fr auto\",\n alignItems: \"center\",\n overflow: \"hidden\",\n _open: {\n display: \"inline\",\n },\n },\n },\n});\n\nconst TextContent = styled(\"span\", {\n base: {\n mobileWideDown: {\n whiteSpace: \"nowrap\",\n maxHeight: \"large\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n transitionProperty: \"max-height\",\n transitionDuration: \"slow\",\n transitionTimingFunction: \"ease-in\",\n marginInlineEnd: \"4xsmall\",\n _open: {\n whiteSpace: \"pre-wrap\",\n maxHeight: \"none\",\n },\n },\n },\n});\n\nconst StyledButton = styled(Button, {\n base: {\n mobileWide: {\n display: \"none\",\n },\n },\n});\n\ninterface LicenseDescriptionProps {\n children?: ReactNode;\n isOpen: boolean;\n setIsOpen: Dispatch<SetStateAction<boolean>>;\n}\n\nconst LicenseDescription = ({ children, isOpen, setIsOpen }: LicenseDescriptionProps) => {\n const open = isOpen ? { \"data-open\": \"\" } : {};\n const { t } = useTranslation();\n\n const handleToggle = () => {\n setIsOpen(!isOpen);\n };\n\n return (\n <ContentWrapper>\n <StyledDescription {...open}>\n <TextContent {...open}>{children}</TextContent>\n <StyledButton variant=\"link\" size=\"small\" onClick={handleToggle}>\n {isOpen ? `${t(\"audio.readLessDescriptionLabel\")}` : `${t(\"audio.readMoreDescriptionLabel\")}`}\n </StyledButton>\n </StyledDescription>\n </ContentWrapper>\n );\n};\n\nexport const LicenseContainerContent = ({ children, copyright, type }: LicenseContainerProps) => {\n const { t, i18n } = useTranslation();\n const license = copyright ? getLicenseByAbbreviation(copyright.license?.license ?? \"\", i18n.language) : undefined;\n const authors = getLicenseCredits(copyright);\n const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];\n const [isOpen, setIsOpen] = useState<boolean>(false);\n\n const content = (\n <>\n {children}\n {` ${t(`embed.type.${type}`)}${captionAuthors.length ? \": \" : \"\"}`}\n <span>{captionAuthors.map((author) => author.name).join(\", \")}</span>\n {license ? (\n <>\n {\" / \"}\n {<LicenseLink license={license} hideLink={!isOpen && !!children} />}\n </>\n ) : null}\n </>\n );\n\n if (children) {\n return (\n <LicenseDescription isOpen={isOpen} setIsOpen={setIsOpen}>\n {content}\n </LicenseDescription>\n );\n }\n\n return (\n <Text textStyle=\"label.medium\" asChild consumeCss>\n <span>{content}</span>\n </Text>\n );\n};\n"],"mappings":";;;;;;;;;;AA2EA,MAAM,gBAAgB,OAAO,cAAc,EACzC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,cAAc;CACd,WAAW;CACX,OAAO;AACR,EACF,EAAC;AAEF,MAAM,qBAAqB,OAAO,eAAe,EAC/C,MAAM;CACJ,QAAQ;CACR,aAAa;CACb,cAAc;CACd,YAAY;CACZ,eAAe;CACf,cAAc;AACf,EACF,EAAC;AAEF,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM,EACJ,WAAW,SACZ,EACF,EAAC;AAEF,MAAM,iBAAiB,OAAO,OAAO,EACnC,MAAM;CACJ,SAAS;CACT,KAAK;CACL,YAAY;CACZ,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,kBAAkB,OAAO,OAAO,EACpC,MAAM;CACJ,SAAS;CACT,YAAY;AACb,EACF,EAAC;AAEF,MAAa,cAAc,CAAC,EAAE,MAAM,aAAa,UAAU,YAAY,cAAe,GAAG,OAAc,KAAK;CAC1G,MAAM,EAAE,GAAG,GAAG,gBAAgB;AAE9B,KAAI,MAAM,OAAO;EACf,MAAM,aAAa,SAAS,QAAQ,QAAQ,GAAG,aAAa,KAAK,EAAE,CAAC,aAAa;AACjF,yBACE,IAAC,gDACC,KAAC,6CACC,IAAC,cAAY,kBACb,IAAC,6CACC,IAAC,oBAAM,EAAE,oBAAoB,EAAE,MAAM,WAAY,EAAC,GAAQ,GAC1C,IACH,GACE;CAExB;CAED,MAAM,EAAE,WAAW,GAAG;CACtB,MAAM,aAAa,kBAAkB;AAErC,wBACE,+BACI,8BACA,IAAC,2CACC,KAAC;IACI,iBAAiB;GAClB,iCACA,IAAC;GAA8B;GAAiB;aAC7C;IACuB;EAE3B;KACG,GACQ,EAEjB,6BACC,IAAC;EAAW,OAAM;EAAc,WAAU;EAAe;EAAQ;4BAC/D,IAAC,qBAAO,OAAO,WAAW,IAAS;GACxB,GACX,QACH;AAEN;AAQD,MAAM,oBAAoB,OAAO,iBAAiB,EAChD,MAAM,EACJ,gBAAgB;CACd,SAAS;CACT,qBAAqB;CACrB,YAAY;CACZ,UAAU;CACV,OAAO,EACL,SAAS,SACV;AACF,EACF,EACF,EAAC;AAEF,MAAM,cAAc,OAAO,QAAQ,EACjC,MAAM,EACJ,gBAAgB;CACd,YAAY;CACZ,WAAW;CACX,UAAU;CACV,cAAc;CACd,oBAAoB;CACpB,oBAAoB;CACpB,0BAA0B;CAC1B,iBAAiB;CACjB,OAAO;EACL,YAAY;EACZ,WAAW;CACZ;AACF,EACF,EACF,EAAC;AAEF,MAAM,eAAe,OAAO,QAAQ,EAClC,MAAM,EACJ,YAAY,EACV,SAAS,OACV,EACF,EACF,EAAC;AAQF,MAAM,qBAAqB,CAAC,EAAE,UAAU,QAAQ,WAAoC,KAAK;CACvF,MAAM,OAAO,SAAS,EAAE,aAAa,GAAI,IAAG,CAAE;CAC9C,MAAM,EAAE,GAAG,GAAG,gBAAgB;CAE9B,MAAM,eAAe,MAAM;AACzB,aAAW,OAAO;CACnB;AAED,wBACE,IAAC,4CACC,KAAC;EAAkB,GAAI;6BACrB,IAAC;GAAY,GAAI;GAAO;IAAuB,kBAC/C,IAAC;GAAa,SAAQ;GAAO,MAAK;GAAQ,SAAS;aAChD,UAAU,EAAE,EAAE,iCAAiC,CAAC,KAAK,EAAE,EAAE,iCAAiC,CAAC;IAC/E;GACG,GACL;AAEpB;AAED,MAAa,0BAA0B,CAAC,EAAE,UAAU,WAAW,MAA6B,KAAK;CAC/F,MAAM,EAAE,GAAG,MAAM,GAAG,gBAAgB;CACpC,MAAM,UAAU,YAAY,yBAAyB,UAAU,SAAS,WAAW,IAAI,KAAK,SAAS;CACrG,MAAM,UAAU,kBAAkB,UAAU;CAC5C,MAAM,iBAAiB,OAAO,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAE;CAC7E,MAAM,CAAC,QAAQ,UAAU,GAAG,SAAkB,MAAM;CAEpD,MAAM,0BACJ;EACG;GACC,GAAG,GAAG,aAAa,KAAK,EAAE,CAAC,EAAE,eAAe,SAAS,OAAO,GAAG;kBACjE,IAAC,oBAAM,eAAe,IAAI,CAAC,WAAW,OAAO,KAAK,CAAC,KAAK,KAAK,GAAQ;EACpE,0BACC,8BACG,uBACA,IAAC;GAAqB;GAAS,WAAW,YAAY;IAAY,IAClE,GACD;KACH;AAGL,KAAI,SACF,wBACE,IAAC;EAA2B;EAAmB;YAC5C;GACkB;AAIzB,wBACE,IAAC;EAAK,WAAU;EAAe;EAAQ;4BACrC,IAAC,oBAAM,UAAe;GACjB;AAEV"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
3
|
+
import { SafeLink } from "@ndla/safelink";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/LicenseByline/LicenseLink.tsx
|
|
7
|
+
const StyledSafeLink = styled(SafeLink, { base: {
|
|
8
|
+
color: "text.link",
|
|
9
|
+
textDecoration: "underline",
|
|
10
|
+
whiteSpace: "nowrap",
|
|
11
|
+
_hover: { textDecoration: "none" },
|
|
12
|
+
_focusWithin: { textDecoration: "none" },
|
|
13
|
+
mobileWideDown: { _disabled: { display: "none" } }
|
|
14
|
+
} });
|
|
15
|
+
const LicenseLink = forwardRef(({ license, hideLink,...rest }, ref) => {
|
|
16
|
+
const disabled = hideLink ? { "data-disabled": "" } : {};
|
|
17
|
+
if (license.abbreviation === "unknown") return null;
|
|
18
|
+
if (license.url?.length) return /* @__PURE__ */ jsx(StyledSafeLink, {
|
|
19
|
+
to: license.url,
|
|
20
|
+
rel: "license",
|
|
21
|
+
...disabled,
|
|
22
|
+
...rest,
|
|
23
|
+
ref,
|
|
24
|
+
children: license.abbreviation
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx("span", { children: license.abbreviation });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { LicenseLink };
|
|
31
|
+
//# sourceMappingURL=LicenseLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LicenseLink.js","names":[],"sources":["../../src/LicenseByline/LicenseLink.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { forwardRef } from \"react\";\nimport type { LicenseLocaleType } from \"@ndla/licenses\";\nimport { SafeLink, type SafeLinkProps } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends Omit<SafeLinkProps, \"to\"> {\n license: LicenseLocaleType;\n hideLink?: boolean;\n}\n\nconst StyledSafeLink = styled(SafeLink, {\n base: {\n color: \"text.link\",\n textDecoration: \"underline\",\n whiteSpace: \"nowrap\",\n _hover: {\n textDecoration: \"none\",\n },\n _focusWithin: {\n textDecoration: \"none\",\n },\n mobileWideDown: {\n _disabled: {\n display: \"none\",\n },\n },\n },\n});\n\nexport const LicenseLink = forwardRef<HTMLAnchorElement, Props>(({ license, hideLink, ...rest }, ref) => {\n const disabled = hideLink ? { \"data-disabled\": \"\" } : {};\n if (license.abbreviation === \"unknown\") {\n return null;\n }\n if (license.url?.length) {\n return (\n <StyledSafeLink to={license.url} rel=\"license\" {...disabled} {...rest} ref={ref}>\n {license.abbreviation}\n </StyledSafeLink>\n );\n }\n return <span>{license.abbreviation}</span>;\n});\n"],"mappings":";;;;;;AAkBA,MAAM,iBAAiB,OAAO,UAAU,EACtC,MAAM;CACJ,OAAO;CACP,gBAAgB;CAChB,YAAY;CACZ,QAAQ,EACN,gBAAgB,OACjB;CACD,cAAc,EACZ,gBAAgB,OACjB;CACD,gBAAgB,EACd,WAAW,EACT,SAAS,OACV,EACF;AACF,EACF,EAAC;AAEF,MAAa,cAAc,WAAqC,CAAC,EAAE,SAAS,SAAU,GAAG,MAAM,EAAE,QAAQ;CACvG,MAAM,WAAW,WAAW,EAAE,iBAAiB,GAAI,IAAG,CAAE;AACxD,KAAI,QAAQ,iBAAiB,UAC3B,QAAO;AAET,KAAI,QAAQ,KAAK,OACf,wBACE,IAAC;EAAe,IAAI,QAAQ;EAAK,KAAI;EAAU,GAAI;EAAU,GAAI;EAAW;YACzE,QAAQ;GACM;AAGrB,wBAAO,IAAC,oBAAM,QAAQ,eAAoB;AAC3C,EAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getPossiblyRelativeUrl } from "../utils/relativeUrl.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { Heading } from "@ndla/primitives";
|
|
4
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
5
|
+
import parse from "html-react-parser";
|
|
6
|
+
import { ArrowRightLine, CalendarLine } from "@ndla/icons";
|
|
7
|
+
import { SafeLink } from "@ndla/safelink";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/LinkBlock/LinkBlock.tsx
|
|
11
|
+
const InfoWrapper = styled("div", { base: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
flexDirection: "column",
|
|
14
|
+
gap: "xsmall"
|
|
15
|
+
} });
|
|
16
|
+
const StyledSafeLink = styled(SafeLink, { base: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
justifyContent: "space-between",
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
background: "surface.default",
|
|
21
|
+
padding: "medium",
|
|
22
|
+
border: "1px solid",
|
|
23
|
+
borderColor: "stroke.subtle",
|
|
24
|
+
borderRadius: "xsmall",
|
|
25
|
+
"& h3": { textDecoration: "underline" },
|
|
26
|
+
"& [data-forward]": {
|
|
27
|
+
transitionProperty: "width, height",
|
|
28
|
+
transitionTimingFunction: "ease-in-out",
|
|
29
|
+
transitionDuration: "fast"
|
|
30
|
+
},
|
|
31
|
+
_hover: {
|
|
32
|
+
"& h3": { textDecoration: "none" },
|
|
33
|
+
"& [data-forward]": {
|
|
34
|
+
width: "large",
|
|
35
|
+
height: "large"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} });
|
|
39
|
+
const StyledDateContainer = styled("div", { base: {
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
gap: "xxsmall"
|
|
43
|
+
} });
|
|
44
|
+
const StyledCalendarEd = styled(CalendarLine, { base: { color: "icon.strong" } });
|
|
45
|
+
const LinkBlock = ({ title, articleLanguage, date, url, path }) => {
|
|
46
|
+
const href = getPossiblyRelativeUrl(url, path);
|
|
47
|
+
const formattedDate = useMemo(() => {
|
|
48
|
+
if (!date) return null;
|
|
49
|
+
return new Intl.DateTimeFormat(articleLanguage, {
|
|
50
|
+
timeZone: "CET",
|
|
51
|
+
day: "2-digit",
|
|
52
|
+
month: "long",
|
|
53
|
+
year: "numeric"
|
|
54
|
+
}).format(new Date(date));
|
|
55
|
+
}, [date, articleLanguage]);
|
|
56
|
+
return /* @__PURE__ */ jsxs(StyledSafeLink, {
|
|
57
|
+
to: href,
|
|
58
|
+
"data-embed-type": "link-block",
|
|
59
|
+
children: [/* @__PURE__ */ jsxs(InfoWrapper, { children: [/* @__PURE__ */ jsx(Heading, {
|
|
60
|
+
asChild: true,
|
|
61
|
+
consumeCss: true,
|
|
62
|
+
textStyle: "title.medium",
|
|
63
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
64
|
+
"data-heading": true,
|
|
65
|
+
children: parse(title)
|
|
66
|
+
})
|
|
67
|
+
}), !!date && /* @__PURE__ */ jsxs(StyledDateContainer, { children: [/* @__PURE__ */ jsx(StyledCalendarEd, {}), formattedDate] })] }), /* @__PURE__ */ jsx(ArrowRightLine, { "data-forward": true })]
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var LinkBlock_default = LinkBlock;
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { LinkBlock_default };
|
|
74
|
+
//# sourceMappingURL=LinkBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkBlock.js","names":[],"sources":["../../src/LinkBlock/LinkBlock.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { useMemo } from \"react\";\nimport { ArrowRightLine, CalendarLine } from \"@ndla/icons\";\nimport { Heading } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { LinkBlockEmbedData } from \"@ndla/types-embed\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\nconst InfoWrapper = styled(\"div\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n },\n});\n\nconst StyledSafeLink = styled(SafeLink, {\n base: {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n background: \"surface.default\",\n padding: \"medium\",\n border: \"1px solid\",\n borderColor: \"stroke.subtle\",\n borderRadius: \"xsmall\",\n \"& h3\": {\n textDecoration: \"underline\",\n },\n \"& [data-forward]\": {\n transitionProperty: \"width, height\",\n transitionTimingFunction: \"ease-in-out\",\n transitionDuration: \"fast\",\n },\n _hover: {\n \"& h3\": {\n textDecoration: \"none\",\n },\n \"& [data-forward]\": {\n width: \"large\",\n height: \"large\",\n },\n },\n },\n});\n\nconst StyledDateContainer = styled(\"div\", {\n base: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"xxsmall\",\n },\n});\n\nconst StyledCalendarEd = styled(CalendarLine, {\n base: {\n color: \"icon.strong\",\n },\n});\n\ninterface Props extends Omit<LinkBlockEmbedData, \"resource\"> {\n path?: string;\n articleLanguage?: string;\n}\n\nconst LinkBlock = ({ title, articleLanguage, date, url, path }: Props) => {\n const href = getPossiblyRelativeUrl(url, path);\n const formattedDate = useMemo(() => {\n if (!date) return null;\n return new Intl.DateTimeFormat(articleLanguage, {\n timeZone: \"CET\",\n day: \"2-digit\",\n month: \"long\",\n year: \"numeric\",\n }).format(new Date(date));\n }, [date, articleLanguage]);\n return (\n <StyledSafeLink to={href} data-embed-type=\"link-block\">\n <InfoWrapper>\n <Heading asChild consumeCss textStyle=\"title.medium\">\n <h3 data-heading>{parse(title)}</h3>\n </Heading>\n {!!date && (\n <StyledDateContainer>\n <StyledCalendarEd />\n {formattedDate}\n </StyledDateContainer>\n )}\n </InfoWrapper>\n <ArrowRightLine data-forward />\n </StyledSafeLink>\n );\n};\n\nexport default LinkBlock;\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,cAAc,OAAO,OAAO,EAChC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,iBAAiB,OAAO,UAAU,EACtC,MAAM;CACJ,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,aAAa;CACb,cAAc;CACd,QAAQ,EACN,gBAAgB,YACjB;CACD,oBAAoB;EAClB,oBAAoB;EACpB,0BAA0B;EAC1B,oBAAoB;CACrB;CACD,QAAQ;EACN,QAAQ,EACN,gBAAgB,OACjB;EACD,oBAAoB;GAClB,OAAO;GACP,QAAQ;EACT;CACF;AACF,EACF,EAAC;AAEF,MAAM,sBAAsB,OAAO,OAAO,EACxC,MAAM;CACJ,SAAS;CACT,YAAY;CACZ,KAAK;AACN,EACF,EAAC;AAEF,MAAM,mBAAmB,OAAO,cAAc,EAC5C,MAAM,EACJ,OAAO,cACR,EACF,EAAC;AAOF,MAAM,YAAY,CAAC,EAAE,OAAO,iBAAiB,MAAM,KAAK,MAAa,KAAK;CACxE,MAAM,OAAO,uBAAuB,KAAK,KAAK;CAC9C,MAAM,gBAAgB,QAAQ,MAAM;AAClC,OAAK,KAAM,QAAO;AAClB,SAAO,IAAI,KAAK,eAAe,iBAAiB;GAC9C,UAAU;GACV,KAAK;GACL,OAAO;GACP,MAAM;EACP,GAAE,OAAO,IAAI,KAAK,MAAM;CAC1B,GAAE,CAAC,MAAM,eAAgB,EAAC;AAC3B,wBACE,KAAC;EAAe,IAAI;EAAM,mBAAgB;6BACxC,KAAC,0CACC,IAAC;GAAQ;GAAQ;GAAW,WAAU;6BACpC,IAAC;IAAG;cAAc,MAAM,MAAM;KAAM;IAC5B,IACP,wBACD,KAAC,kDACC,IAAC,qBAAmB,EACnB,iBACmB,IAEZ,kBACd,IAAC,kBAAe,uBAAe;GAChB;AAEpB;AAED,wBAAe"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Children } from "react";
|
|
2
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/LinkBlock/LinkBlockSection.tsx
|
|
6
|
+
const StyledList = styled("ul", { base: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
gap: "xsmall",
|
|
10
|
+
listStyle: "none"
|
|
11
|
+
} });
|
|
12
|
+
const LinkBlockSection = ({ children,...rest }) => {
|
|
13
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
14
|
+
...rest,
|
|
15
|
+
"data-embed-type": "link-block-list",
|
|
16
|
+
children: /* @__PURE__ */ jsx(StyledList, { children: Children.map(children, (child) => /* @__PURE__ */ jsx("li", { children: child })) })
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var LinkBlockSection_default = LinkBlockSection;
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { LinkBlockSection_default };
|
|
23
|
+
//# sourceMappingURL=LinkBlockSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkBlockSection.js","names":[],"sources":["../../src/LinkBlock/LinkBlockSection.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { Children, type HTMLAttributes, type ReactNode } from \"react\";\nimport { styled } from \"@ndla/styled-system/jsx\";\n\ninterface Props extends HTMLAttributes<HTMLElement> {\n children: ReactNode;\n}\n\nconst StyledList = styled(\"ul\", {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"xsmall\",\n listStyle: \"none\",\n },\n});\n\nconst LinkBlockSection = ({ children, ...rest }: Props) => {\n return (\n <nav {...rest} data-embed-type=\"link-block-list\">\n <StyledList>\n {Children.map(children, (child) => (\n <li>{child}</li>\n ))}\n </StyledList>\n </nav>\n );\n};\n\nexport default LinkBlockSection;\n"],"mappings":";;;;;AAeA,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;CACL,WAAW;AACZ,EACF,EAAC;AAEF,MAAM,mBAAmB,CAAC,EAAE,SAAU,GAAG,MAAa,KAAK;AACzD,wBACE,IAAC;EAAI,GAAI;EAAM,mBAAgB;4BAC7B,IAAC,wBACE,SAAS,IAAI,UAAU,CAAC,0BACvB,IAAC,kBAAI,QAAW,CAChB,GACS;GACT;AAET;AAED,+BAAe"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getPossiblyRelativeUrl } from "../utils/relativeUrl.js";
|
|
2
|
+
import { CardHeading, CardImage, CardRoot, Text } from "@ndla/primitives";
|
|
3
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
4
|
+
import parse from "html-react-parser";
|
|
5
|
+
import { SafeLink } from "@ndla/safelink";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { linkOverlay } from "@ndla/styled-system/patterns";
|
|
8
|
+
|
|
9
|
+
//#region src/Pitch/Pitch.tsx
|
|
10
|
+
const StyledCardHeading = styled(CardHeading, { base: { paddingBlockStart: "medium" } });
|
|
11
|
+
const StyledText = styled(Text, { base: { paddingBlockEnd: "medium" } });
|
|
12
|
+
const StyledCardRoot = styled(CardRoot, { base: {
|
|
13
|
+
border: "0",
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "column",
|
|
16
|
+
gap: "small"
|
|
17
|
+
} });
|
|
18
|
+
const StyledCardImage = styled(CardImage, { base: {
|
|
19
|
+
aspectRatio: "16/9",
|
|
20
|
+
height: "unset"
|
|
21
|
+
} });
|
|
22
|
+
const Pitch = ({ title, url, metaImage, path, description }) => {
|
|
23
|
+
const href = getPossiblyRelativeUrl(url, path);
|
|
24
|
+
return /* @__PURE__ */ jsx(StyledCardRoot, {
|
|
25
|
+
variant: "subtle",
|
|
26
|
+
"data-embed-type": "pitch",
|
|
27
|
+
asChild: true,
|
|
28
|
+
consumeCss: true,
|
|
29
|
+
children: /* @__PURE__ */ jsxs("div", { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(StyledCardHeading, {
|
|
31
|
+
textStyle: "heading.small",
|
|
32
|
+
asChild: true,
|
|
33
|
+
consumeCss: true,
|
|
34
|
+
children: /* @__PURE__ */ jsx(SafeLink, {
|
|
35
|
+
to: href,
|
|
36
|
+
unstyled: true,
|
|
37
|
+
css: linkOverlay.raw(),
|
|
38
|
+
children: parse(title)
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
!!description && /* @__PURE__ */ jsx(StyledText, {
|
|
42
|
+
textStyle: "body.xlarge",
|
|
43
|
+
asChild: true,
|
|
44
|
+
consumeCss: true,
|
|
45
|
+
children: /* @__PURE__ */ jsx("div", { children: parse(description) })
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsx(StyledCardImage, {
|
|
48
|
+
variant: "rounded",
|
|
49
|
+
src: metaImage.url,
|
|
50
|
+
alt: metaImage.alt,
|
|
51
|
+
sizes: "480px",
|
|
52
|
+
fallbackWidth: 300,
|
|
53
|
+
width: 550,
|
|
54
|
+
height: 310
|
|
55
|
+
})
|
|
56
|
+
] })
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { Pitch };
|
|
62
|
+
//# sourceMappingURL=Pitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pitch.js","names":[],"sources":["../../src/Pitch/Pitch.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport parse from \"html-react-parser\";\nimport { CardHeading, CardImage, CardRoot, Text } from \"@ndla/primitives\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport { linkOverlay } from \"@ndla/styled-system/patterns\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\nexport interface Props {\n title: string;\n url: string;\n description?: string;\n metaImage: {\n url: string;\n alt: string;\n };\n path?: string;\n}\n\nconst StyledCardHeading = styled(CardHeading, {\n base: {\n paddingBlockStart: \"medium\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n paddingBlockEnd: \"medium\",\n },\n});\n\nconst StyledCardRoot = styled(CardRoot, {\n base: {\n border: \"0\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"small\",\n },\n});\n\nconst StyledCardImage = styled(CardImage, {\n base: {\n aspectRatio: \"16/9\",\n height: \"unset\",\n },\n});\n\nexport const Pitch = ({ title, url, metaImage, path, description }: Props) => {\n const href = getPossiblyRelativeUrl(url, path);\n\n return (\n <StyledCardRoot variant=\"subtle\" data-embed-type=\"pitch\" asChild consumeCss>\n <div>\n <StyledCardHeading textStyle=\"heading.small\" asChild consumeCss>\n <SafeLink to={href} unstyled css={linkOverlay.raw()}>\n {parse(title)}\n </SafeLink>\n </StyledCardHeading>\n {!!description && (\n <StyledText textStyle=\"body.xlarge\" asChild consumeCss>\n <div>{parse(description)}</div>\n </StyledText>\n )}\n <StyledCardImage\n variant=\"rounded\"\n src={metaImage.url}\n alt={metaImage.alt}\n sizes=\"480px\"\n fallbackWidth={300}\n width={550}\n height={310}\n />\n </div>\n </StyledCardRoot>\n );\n};\n"],"mappings":";;;;;;;;;AA0BA,MAAM,oBAAoB,OAAO,aAAa,EAC5C,MAAM,EACJ,mBAAmB,SACpB,EACF,EAAC;AAEF,MAAM,aAAa,OAAO,MAAM,EAC9B,MAAM,EACJ,iBAAiB,SAClB,EACF,EAAC;AAEF,MAAM,iBAAiB,OAAO,UAAU,EACtC,MAAM;CACJ,QAAQ;CACR,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,kBAAkB,OAAO,WAAW,EACxC,MAAM;CACJ,aAAa;CACb,QAAQ;AACT,EACF,EAAC;AAEF,MAAa,QAAQ,CAAC,EAAE,OAAO,KAAK,WAAW,MAAM,aAAoB,KAAK;CAC5E,MAAM,OAAO,uBAAuB,KAAK,KAAK;AAE9C,wBACE,IAAC;EAAe,SAAQ;EAAS,mBAAgB;EAAQ;EAAQ;4BAC/D,KAAC;mBACC,IAAC;IAAkB,WAAU;IAAgB;IAAQ;8BACnD,IAAC;KAAS,IAAI;KAAM;KAAS,KAAK,YAAY,KAAK;eAChD,MAAM,MAAM;MACJ;KACO;KACjB,+BACD,IAAC;IAAW,WAAU;IAAc;IAAQ;8BAC1C,IAAC,mBAAK,MAAM,YAAY,GAAO;KACpB;mBAEf,IAAC;IACC,SAAQ;IACR,KAAK,UAAU;IACf,KAAK,UAAU;IACf,OAAM;IACN,eAAe;IACf,OAAO;IACP,QAAQ;KACR;MACE;GACS;AAEpB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { contentTypes } from "../model/ContentType.js";
|
|
2
|
+
import { ContentTypeBadge } from "../ContentTypeBadge/ContentTypeBadge.js";
|
|
3
|
+
import { Children, useMemo, useState } from "react";
|
|
4
|
+
import { Button, CardContent, CardHeading, CardRoot, Heading, Text } from "@ndla/primitives";
|
|
5
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { ExternalLinkLine } from "@ndla/icons";
|
|
8
|
+
import { SafeLink } from "@ndla/safelink";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { linkOverlay } from "@ndla/styled-system/patterns";
|
|
11
|
+
|
|
12
|
+
//#region src/RelatedArticleList/RelatedArticleList.tsx
|
|
13
|
+
const StyledSpan = styled("span", { base: {
|
|
14
|
+
display: "flex",
|
|
15
|
+
gap: "3xsmall"
|
|
16
|
+
} });
|
|
17
|
+
const RelatedArticle = ({ title, introduction, to, linkInfo = "", target = "", type = contentTypes.SUBJECT_MATERIAL }) => {
|
|
18
|
+
return /* @__PURE__ */ jsx(CardRoot, {
|
|
19
|
+
"data-embed-type": "related-article",
|
|
20
|
+
children: /* @__PURE__ */ jsxs(CardContent, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(ContentTypeBadge, { contentType: type }),
|
|
22
|
+
/* @__PURE__ */ jsx(CardHeading, {
|
|
23
|
+
asChild: true,
|
|
24
|
+
consumeCss: true,
|
|
25
|
+
children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(SafeLink, {
|
|
26
|
+
unstyled: true,
|
|
27
|
+
to,
|
|
28
|
+
target,
|
|
29
|
+
rel: linkInfo ? "noopener noreferrer" : void 0,
|
|
30
|
+
css: linkOverlay.raw(),
|
|
31
|
+
children: /* @__PURE__ */ jsxs(StyledSpan, { children: [title, target === "_blank" && /* @__PURE__ */ jsx(ExternalLinkLine, {})] })
|
|
32
|
+
}) })
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx(Text, { dangerouslySetInnerHTML: { __html: introduction } }),
|
|
35
|
+
/* @__PURE__ */ jsx(Text, {
|
|
36
|
+
color: "text.subtle",
|
|
37
|
+
textStyle: "label.small",
|
|
38
|
+
children: linkInfo
|
|
39
|
+
})
|
|
40
|
+
] })
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const HeadingWrapper = styled("div", { base: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
width: "100%",
|
|
46
|
+
justifyContent: "space-between",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
alignSelf: "flex-start"
|
|
49
|
+
} });
|
|
50
|
+
const ArticlesWrapper = styled("div", { base: {
|
|
51
|
+
display: "grid",
|
|
52
|
+
width: "100%",
|
|
53
|
+
gridTemplateColumns: "repeat(2, 1fr)",
|
|
54
|
+
gap: "medium",
|
|
55
|
+
tabletDown: { gridTemplateColumns: "1fr" }
|
|
56
|
+
} });
|
|
57
|
+
const StyledSection = styled("section", { base: {
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
gap: "medium",
|
|
62
|
+
clear: "both"
|
|
63
|
+
} });
|
|
64
|
+
const StyledButton = styled(Button, { base: { marginBlockStart: "xsmall" } });
|
|
65
|
+
const RelatedArticleList = ({ children = [], articleCount, headingLevel: HeadingElement = "h2", headingButtons,...rest }) => {
|
|
66
|
+
const [expanded, setExpanded] = useState(false);
|
|
67
|
+
const { t } = useTranslation();
|
|
68
|
+
const childCount = useMemo(() => articleCount ?? Children.count(children), [children, articleCount]);
|
|
69
|
+
const childrenToShow = useMemo(() => childCount > 2 && !expanded ? children?.slice(0, 2) : children, [
|
|
70
|
+
childCount,
|
|
71
|
+
children,
|
|
72
|
+
expanded
|
|
73
|
+
]);
|
|
74
|
+
return /* @__PURE__ */ jsxs(StyledSection, {
|
|
75
|
+
...rest,
|
|
76
|
+
"data-embed-type": "related-content-list",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsxs(HeadingWrapper, { children: [/* @__PURE__ */ jsx(Heading, {
|
|
79
|
+
asChild: true,
|
|
80
|
+
consumeCss: true,
|
|
81
|
+
textStyle: "title.large",
|
|
82
|
+
fontWeight: "bold",
|
|
83
|
+
children: /* @__PURE__ */ jsx(HeadingElement, { children: t("related.title") })
|
|
84
|
+
}), headingButtons] }),
|
|
85
|
+
/* @__PURE__ */ jsx(ArticlesWrapper, { children: childrenToShow }),
|
|
86
|
+
childCount > 2 ? /* @__PURE__ */ jsx(StyledButton, {
|
|
87
|
+
variant: "secondary",
|
|
88
|
+
onClick: () => setExpanded((p) => !p),
|
|
89
|
+
children: t(`related.show${expanded ? "Less" : "More"}`)
|
|
90
|
+
}) : null
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { RelatedArticle, RelatedArticleList };
|
|
97
|
+
//# sourceMappingURL=RelatedArticleList.js.map
|