@ndla/ui 56.0.128-alpha.0 → 56.0.129-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/es/Article/Article.js +1 -0
- package/es/Article/Article.js.map +1 -1
- package/es/Article/ArticleByline.js +14 -28
- package/es/Article/ArticleByline.js.map +1 -1
- package/es/AudioPlayer/AudioPlayer.js +1 -1
- package/es/AudioPlayer/index.js +1 -1
- package/es/Breadcrumb/Breadcrumb.js +1 -1
- package/es/Breadcrumb/HomeBreadcrumb.js +1 -1
- package/es/Breadcrumb/index.js +1 -1
- package/es/CopyParagraphButton/CopyParagraphButton.js +1 -1
- package/es/CopyParagraphButton/index.js +1 -1
- package/es/ErrorMessage/ErrorMessage.js +1 -1
- package/es/ErrorMessage/index.js +1 -1
- package/es/FactBox/FactBox.js +1 -1
- package/es/FactBox/index.js +1 -1
- package/es/locale/messages-en.js +10 -5
- package/es/locale/messages-en.js.map +1 -1
- package/es/locale/messages-nb.js +10 -5
- package/es/locale/messages-nb.js.map +1 -1
- package/es/locale/messages-nn.js +10 -5
- package/es/locale/messages-nn.js.map +1 -1
- package/es/locale/messages-se.js +10 -5
- package/es/locale/messages-se.js.map +1 -1
- package/lib/Article/Article.js +5 -4
- package/lib/Article/Article.js.map +1 -1
- package/lib/Article/ArticleByline.d.ts +3 -1
- package/lib/Article/ArticleByline.js +16 -30
- package/lib/Article/ArticleByline.js.map +1 -1
- package/lib/AudioPlayer/AudioPlayer.js +5 -5
- package/lib/AudioPlayer/index.js +2 -2
- package/lib/Breadcrumb/Breadcrumb.js +3 -3
- package/lib/Breadcrumb/HomeBreadcrumb.js +2 -2
- package/lib/Breadcrumb/index.js +3 -3
- package/lib/CampaignBlock/CampaignBlock.js +2 -2
- package/lib/CampaignBlock/CampaignBlock.js.map +1 -1
- package/lib/Concept/Concept.js +11 -11
- package/lib/Concept/Concept.js.map +1 -1
- package/lib/ContactBlock/ContactBlock.js +2 -2
- package/lib/ContentTypeBadge/ContentTypeBadge.js +20 -20
- package/lib/ContentTypeBadge/ContentTypeBadge.js.map +1 -1
- package/lib/ContentTypeHero/ContentTypeHero.js +20 -20
- package/lib/ContentTypeHero/ContentTypeHero.js.map +1 -1
- package/lib/CopyParagraphButton/CopyParagraphButton.js +1 -1
- package/lib/CopyParagraphButton/index.js +2 -2
- package/lib/Embed/AudioEmbed.js +9 -9
- package/lib/Embed/AudioEmbed.js.map +1 -1
- package/lib/Embed/BrightcoveEmbed.js +6 -6
- package/lib/Embed/BrightcoveEmbed.js.map +1 -1
- package/lib/Embed/CodeEmbed.js +6 -6
- package/lib/Embed/CodeEmbed.js.map +1 -1
- package/lib/Embed/ConceptEmbed.js +9 -9
- package/lib/Embed/ConceptEmbed.js.map +1 -1
- package/lib/Embed/ConceptInlineTriggerButton.js +2 -2
- package/lib/Embed/ConceptInlineTriggerButton.js.map +1 -1
- package/lib/Embed/CopyrightEmbed.js +2 -2
- package/lib/Embed/EmbedErrorPlaceholder.js +2 -2
- package/lib/Embed/ExternalEmbed.js +4 -4
- package/lib/Embed/ExternalEmbed.js.map +1 -1
- package/lib/Embed/GlossEmbed.js +7 -7
- package/lib/Embed/GlossEmbed.js.map +1 -1
- package/lib/Embed/H5pEmbed.js +2 -2
- package/lib/Embed/H5pEmbed.js.map +1 -1
- package/lib/Embed/IframeEmbed.js +4 -4
- package/lib/Embed/IframeEmbed.js.map +1 -1
- package/lib/Embed/ImageEmbed.js +6 -6
- package/lib/Embed/ImageEmbed.js.map +1 -1
- package/lib/Embed/RelatedContentEmbed.js +6 -6
- package/lib/Embed/RelatedContentEmbed.js.map +1 -1
- package/lib/ErrorMessage/ErrorMessage.js +1 -1
- package/lib/ErrorMessage/index.js +2 -2
- package/lib/FactBox/FactBox.js +1 -1
- package/lib/FactBox/index.js +2 -2
- package/lib/FileList/File.js +2 -2
- package/lib/FileList/File.js.map +1 -1
- package/lib/Gloss/Gloss.js +4 -4
- package/lib/LicenseByline/EmbedByline.js +2 -2
- package/lib/LinkBlock/LinkBlock.js +2 -2
- package/lib/LinkBlock/LinkBlock.js.map +1 -1
- package/lib/Pitch/Pitch.js +2 -2
- package/lib/Pitch/Pitch.js.map +1 -1
- package/lib/RelatedArticleList/RelatedArticleList.js +4 -4
- package/lib/RelatedArticleList/RelatedArticleList.js.map +1 -1
- package/lib/RelatedArticleList/index.js +2 -2
- package/lib/i18n/i18n.js +8 -8
- package/lib/i18n/i18n.js.map +1 -1
- package/lib/index.js +156 -156
- package/lib/locale/messages-en.d.ts +12 -5
- package/lib/locale/messages-en.js +12 -7
- package/lib/locale/messages-en.js.map +1 -1
- package/lib/locale/messages-nb.d.ts +12 -5
- package/lib/locale/messages-nb.js +12 -7
- package/lib/locale/messages-nb.js.map +1 -1
- package/lib/locale/messages-nn.d.ts +12 -5
- package/lib/locale/messages-nn.js +12 -7
- package/lib/locale/messages-nn.js.map +1 -1
- package/lib/locale/messages-se.d.ts +12 -5
- package/lib/locale/messages-se.js +12 -7
- package/lib/locale/messages-se.js.map +1 -1
- package/lib/model/index.js +10 -10
- package/lib/utils/relativeUrl.js +2 -2
- package/lib/utils/relativeUrl.js.map +1 -1
- package/package.json +2 -2
- package/src/Article/Article.tsx +1 -0
- package/src/Article/ArticleByline.stories.tsx +25 -0
- package/src/Article/ArticleByline.tsx +15 -35
- package/src/locale/messages-en.ts +12 -5
- package/src/locale/messages-nb.ts +12 -5
- package/src/locale/messages-nn.ts +12 -5
- package/src/locale/messages-se.ts +12 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_relativeUrl = require('../utils/relativeUrl.js');
|
|
3
3
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
4
4
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
5
5
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
@@ -83,7 +83,7 @@ const StyledSafeLinkButton = (0, __ndla_styled_system_jsx.styled)(__ndla_safelin
|
|
|
83
83
|
} });
|
|
84
84
|
const LinkButton = ({ url, children, path }) => {
|
|
85
85
|
if (url) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSafeLinkButton, {
|
|
86
|
-
to:
|
|
86
|
+
to: require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_relativeUrl.getPossiblyRelativeUrl(url, path),
|
|
87
87
|
variant: "secondary",
|
|
88
88
|
rel: "noopener noreferrer",
|
|
89
89
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CampaignBlock.js","names":["Text","SafeLinkButton","ArrowRightLine"],"sources":["../../src/CampaignBlock/CampaignBlock.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 { type ReactNode } from \"react\";\nimport { ArrowRightLine } from \"@ndla/icons\";\nimport { Text } from \"@ndla/primitives\";\nimport { SafeLinkButton } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CampaignBlockEmbedData } from \"@ndla/types-embed\";\nimport type { HeadingLevel } from \"../types\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\ninterface Image {\n src: string;\n alt: string;\n}\n\ninterface Props {\n title: string;\n description: string;\n headingLevel?: HeadingLevel;\n url: {\n url?: string;\n text?: string;\n };\n image?: Image;\n imageSide?: CampaignBlockEmbedData[\"imageSide\"];\n className?: string;\n path?: string;\n background?: CampaignBlockEmbedData[\"background\"];\n}\n\nconst Wrapper = styled(\"div\", {\n base: {\n width: \"100%\",\n height: \"100%\",\n containerType: \"inline-size\",\n },\n});\n\nconst Container = styled(\"div\", {\n base: {\n display: \"grid\",\n gridTemplateColumns: \"1fr\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n backgroundColor: \"background.default\",\n borderRadius: \"xsmall\",\n boxShadow: \"full\",\n overflow: \"hidden\",\n },\n variants: {\n imageSide: {\n left: {\n \"@/tablet\": {\n gridTemplateColumns: \"minmax(230px, 455px) auto\", //required for campaign block in myNdla\n },\n \"@supports not (container-type: inline-size)\": {\n tabletWide: {\n gridTemplateColumns: \"minmax(230px, 455px) auto\",\n },\n },\n },\n right: {\n \"@/tablet\": {\n gridTemplateColumns: \"auto minmax(230px, 455px)\", //required for campaign block in myNdla\n },\n \"@supports not (container-type: inline-size)\": {\n tabletWide: {\n gridTemplateColumns: \"auto minmax(230px, 455px)\",\n },\n },\n },\n },\n background: {\n neutral: {},\n brand1: {\n backgroundColor: \"surface.brand.1\",\n },\n brand3: {\n backgroundColor: \"surface.brand.3\",\n },\n },\n },\n defaultVariants: {\n imageSide: \"left\",\n background: \"neutral\",\n },\n});\n\nconst StyledImg = styled(\"img\", {\n base: {\n objectFit: \"cover\",\n width: \"100%\",\n height: \"215px\",\n \"@/tablet\": {\n height: \"340px\",\n },\n \"@supports not (container-type: inline-size)\": {\n tablet: {\n height: \"265px\",\n },\n tabletWide: {\n height: \"340px\",\n },\n },\n backgroundColor: \"background.default\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"flex-start\",\n justifyContent: \"center\",\n paddingBlock: \"medium\",\n paddingInline: \"medium\",\n position: \"relative\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n tablet: {\n display: \"block\",\n overflow: \"hidden\",\n position: \"relative\",\n lineClamp: 4,\n boxOrient: \"vertical\",\n },\n },\n});\n\ninterface LinkButtonProps {\n url?: string;\n path?: string;\n children: ReactNode;\n}\n\nconst StyledSafeLinkButton = styled(SafeLinkButton, {\n base: {\n boxShadow: \"full\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n },\n});\n\nconst LinkButton = ({ url, children, path }: LinkButtonProps) => {\n if (url)\n return (\n <StyledSafeLinkButton to={getPossiblyRelativeUrl(url, path)} variant=\"secondary\" rel=\"noopener noreferrer\">\n {children}\n </StyledSafeLinkButton>\n );\n return children;\n};\n\nconst CampaignBlock = ({\n title,\n image,\n imageSide = \"left\",\n description,\n headingLevel: InternalHeading = \"h2\",\n url,\n path,\n className,\n background,\n}: Props) => {\n const imageComponent = image && <StyledImg src={`${image.src}?width=455`} height={340} width={455} alt={image.alt} />;\n\n return (\n <Wrapper>\n <Container className={className} data-embed-type=\"campaign-block\" imageSide={imageSide} background={background}>\n {imageSide === \"left\" && imageComponent}\n <ContentWrapper>\n <Text asChild consumeCss textStyle=\"heading.small\">\n <InternalHeading>{parse(title)}</InternalHeading>\n </Text>\n <StyledText textStyle=\"body.xlarge\">{parse(description)}</StyledText>\n {!!url?.url && (\n <LinkButton url={url.url} path={path}>\n {parse(url.text ?? \"\")}\n <ArrowRightLine />\n </LinkButton>\n )}\n </ContentWrapper>\n {imageSide !== \"left\" && imageComponent}\n </Container>\n </Wrapper>\n );\n};\n\nexport default CampaignBlock;\n"],"mappings":";;;;;;;;;;;AAsCA,MAAM,UAAU,qCAAO,OAAO,EAC5B,MAAM;CACJ,OAAO;CACP,QAAQ;CACR,eAAe;AAChB,EACF,EAAC;AAEF,MAAM,YAAY,qCAAO,OAAO;CAC9B,MAAM;EACJ,SAAS;EACT,qBAAqB;EACrB,QAAQ;EACR,aAAa;EACb,iBAAiB;EACjB,cAAc;EACd,WAAW;EACX,UAAU;CACX;CACD,UAAU;EACR,WAAW;GACT,MAAM;IACJ,YAAY,EACV,qBAAqB,4BACtB;IACD,+CAA+C,EAC7C,YAAY,EACV,qBAAqB,4BACtB,EACF;GACF;GACD,OAAO;IACL,YAAY,EACV,qBAAqB,4BACtB;IACD,+CAA+C,EAC7C,YAAY,EACV,qBAAqB,4BACtB,EACF;GACF;EACF;EACD,YAAY;GACV,SAAS,CAAE;GACX,QAAQ,EACN,iBAAiB,kBAClB;GACD,QAAQ,EACN,iBAAiB,kBAClB;EACF;CACF;CACD,iBAAiB;EACf,WAAW;EACX,YAAY;CACb;AACF,EAAC;AAEF,MAAM,YAAY,qCAAO,OAAO,EAC9B,MAAM;CACJ,WAAW;CACX,OAAO;CACP,QAAQ;CACR,YAAY,EACV,QAAQ,QACT;CACD,+CAA+C;EAC7C,QAAQ,EACN,QAAQ,QACT;EACD,YAAY,EACV,QAAQ,QACT;CACF;CACD,iBAAiB;AAClB,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,OAAO;CACP,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACZ,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,UAAU;AACX,EACF,EAAC;AAEF,MAAM,aAAa,qCAAOA,wBAAM,EAC9B,MAAM,EACJ,QAAQ;CACN,SAAS;CACT,UAAU;CACV,UAAU;CACV,WAAW;CACX,WAAW;AACZ,EACF,EACF,EAAC;AAQF,MAAM,uBAAuB,qCAAOC,gCAAgB,EAClD,MAAM;CACJ,WAAW;CACX,QAAQ;CACR,aAAa;AACd,EACF,EAAC;AAEF,MAAM,aAAa,CAAC,EAAE,KAAK,UAAU,MAAuB,KAAK;AAC/D,KAAI,IACF,wBACE,2BAAC;EAAqB,IAAI,
|
|
1
|
+
{"version":3,"file":"CampaignBlock.js","names":["Text","SafeLinkButton","ArrowRightLine"],"sources":["../../src/CampaignBlock/CampaignBlock.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 { type ReactNode } from \"react\";\nimport { ArrowRightLine } from \"@ndla/icons\";\nimport { Text } from \"@ndla/primitives\";\nimport { SafeLinkButton } from \"@ndla/safelink\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CampaignBlockEmbedData } from \"@ndla/types-embed\";\nimport type { HeadingLevel } from \"../types\";\nimport { getPossiblyRelativeUrl } from \"../utils/relativeUrl\";\n\ninterface Image {\n src: string;\n alt: string;\n}\n\ninterface Props {\n title: string;\n description: string;\n headingLevel?: HeadingLevel;\n url: {\n url?: string;\n text?: string;\n };\n image?: Image;\n imageSide?: CampaignBlockEmbedData[\"imageSide\"];\n className?: string;\n path?: string;\n background?: CampaignBlockEmbedData[\"background\"];\n}\n\nconst Wrapper = styled(\"div\", {\n base: {\n width: \"100%\",\n height: \"100%\",\n containerType: \"inline-size\",\n },\n});\n\nconst Container = styled(\"div\", {\n base: {\n display: \"grid\",\n gridTemplateColumns: \"1fr\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n backgroundColor: \"background.default\",\n borderRadius: \"xsmall\",\n boxShadow: \"full\",\n overflow: \"hidden\",\n },\n variants: {\n imageSide: {\n left: {\n \"@/tablet\": {\n gridTemplateColumns: \"minmax(230px, 455px) auto\", //required for campaign block in myNdla\n },\n \"@supports not (container-type: inline-size)\": {\n tabletWide: {\n gridTemplateColumns: \"minmax(230px, 455px) auto\",\n },\n },\n },\n right: {\n \"@/tablet\": {\n gridTemplateColumns: \"auto minmax(230px, 455px)\", //required for campaign block in myNdla\n },\n \"@supports not (container-type: inline-size)\": {\n tabletWide: {\n gridTemplateColumns: \"auto minmax(230px, 455px)\",\n },\n },\n },\n },\n background: {\n neutral: {},\n brand1: {\n backgroundColor: \"surface.brand.1\",\n },\n brand3: {\n backgroundColor: \"surface.brand.3\",\n },\n },\n },\n defaultVariants: {\n imageSide: \"left\",\n background: \"neutral\",\n },\n});\n\nconst StyledImg = styled(\"img\", {\n base: {\n objectFit: \"cover\",\n width: \"100%\",\n height: \"215px\",\n \"@/tablet\": {\n height: \"340px\",\n },\n \"@supports not (container-type: inline-size)\": {\n tablet: {\n height: \"265px\",\n },\n tabletWide: {\n height: \"340px\",\n },\n },\n backgroundColor: \"background.default\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n alignItems: \"flex-start\",\n justifyContent: \"center\",\n paddingBlock: \"medium\",\n paddingInline: \"medium\",\n position: \"relative\",\n },\n});\n\nconst StyledText = styled(Text, {\n base: {\n tablet: {\n display: \"block\",\n overflow: \"hidden\",\n position: \"relative\",\n lineClamp: 4,\n boxOrient: \"vertical\",\n },\n },\n});\n\ninterface LinkButtonProps {\n url?: string;\n path?: string;\n children: ReactNode;\n}\n\nconst StyledSafeLinkButton = styled(SafeLinkButton, {\n base: {\n boxShadow: \"full\",\n border: \"1px solid\",\n borderColor: \"stroke.default\",\n },\n});\n\nconst LinkButton = ({ url, children, path }: LinkButtonProps) => {\n if (url)\n return (\n <StyledSafeLinkButton to={getPossiblyRelativeUrl(url, path)} variant=\"secondary\" rel=\"noopener noreferrer\">\n {children}\n </StyledSafeLinkButton>\n );\n return children;\n};\n\nconst CampaignBlock = ({\n title,\n image,\n imageSide = \"left\",\n description,\n headingLevel: InternalHeading = \"h2\",\n url,\n path,\n className,\n background,\n}: Props) => {\n const imageComponent = image && <StyledImg src={`${image.src}?width=455`} height={340} width={455} alt={image.alt} />;\n\n return (\n <Wrapper>\n <Container className={className} data-embed-type=\"campaign-block\" imageSide={imageSide} background={background}>\n {imageSide === \"left\" && imageComponent}\n <ContentWrapper>\n <Text asChild consumeCss textStyle=\"heading.small\">\n <InternalHeading>{parse(title)}</InternalHeading>\n </Text>\n <StyledText textStyle=\"body.xlarge\">{parse(description)}</StyledText>\n {!!url?.url && (\n <LinkButton url={url.url} path={path}>\n {parse(url.text ?? \"\")}\n <ArrowRightLine />\n </LinkButton>\n )}\n </ContentWrapper>\n {imageSide !== \"left\" && imageComponent}\n </Container>\n </Wrapper>\n );\n};\n\nexport default CampaignBlock;\n"],"mappings":";;;;;;;;;;;AAsCA,MAAM,UAAU,qCAAO,OAAO,EAC5B,MAAM;CACJ,OAAO;CACP,QAAQ;CACR,eAAe;AAChB,EACF,EAAC;AAEF,MAAM,YAAY,qCAAO,OAAO;CAC9B,MAAM;EACJ,SAAS;EACT,qBAAqB;EACrB,QAAQ;EACR,aAAa;EACb,iBAAiB;EACjB,cAAc;EACd,WAAW;EACX,UAAU;CACX;CACD,UAAU;EACR,WAAW;GACT,MAAM;IACJ,YAAY,EACV,qBAAqB,4BACtB;IACD,+CAA+C,EAC7C,YAAY,EACV,qBAAqB,4BACtB,EACF;GACF;GACD,OAAO;IACL,YAAY,EACV,qBAAqB,4BACtB;IACD,+CAA+C,EAC7C,YAAY,EACV,qBAAqB,4BACtB,EACF;GACF;EACF;EACD,YAAY;GACV,SAAS,CAAE;GACX,QAAQ,EACN,iBAAiB,kBAClB;GACD,QAAQ,EACN,iBAAiB,kBAClB;EACF;CACF;CACD,iBAAiB;EACf,WAAW;EACX,YAAY;CACb;AACF,EAAC;AAEF,MAAM,YAAY,qCAAO,OAAO,EAC9B,MAAM;CACJ,WAAW;CACX,OAAO;CACP,QAAQ;CACR,YAAY,EACV,QAAQ,QACT;CACD,+CAA+C;EAC7C,QAAQ,EACN,QAAQ,QACT;EACD,YAAY,EACV,QAAQ,QACT;CACF;CACD,iBAAiB;AAClB,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,OAAO;CACP,SAAS;CACT,eAAe;CACf,KAAK;CACL,YAAY;CACZ,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,UAAU;AACX,EACF,EAAC;AAEF,MAAM,aAAa,qCAAOA,wBAAM,EAC9B,MAAM,EACJ,QAAQ;CACN,SAAS;CACT,UAAU;CACV,UAAU;CACV,WAAW;CACX,WAAW;AACZ,EACF,EACF,EAAC;AAQF,MAAM,uBAAuB,qCAAOC,gCAAgB,EAClD,MAAM;CACJ,WAAW;CACX,QAAQ;CACR,aAAa;AACd,EACF,EAAC;AAEF,MAAM,aAAa,CAAC,EAAE,KAAK,UAAU,MAAuB,KAAK;AAC/D,KAAI,IACF,wBACE,2BAAC;EAAqB,IAAI,+GAAuB,KAAK,KAAK;EAAE,SAAQ;EAAY,KAAI;EAClF;GACoB;AAE3B,QAAO;AACR;AAED,MAAM,gBAAgB,CAAC,EACrB,OACA,OACA,YAAY,QACZ,aACA,cAAc,kBAAkB,MAChC,KACA,MACA,WACA,YACM,KAAK;CACX,MAAM,iBAAiB,yBAAS,2BAAC;EAAU,MAAM,EAAE,MAAM,IAAI;EAAa,QAAQ;EAAK,OAAO;EAAK,KAAK,MAAM;GAAO;AAErH,wBACE,2BAAC,qCACC,4BAAC;EAAqB;EAAW,mBAAgB;EAA4B;EAAuB;;GACjG,cAAc,UAAU;mBACzB,4BAAC;oBACC,2BAACD;KAAK;KAAQ;KAAW,WAAU;+BACjC,2BAAC,6BAAiB,+BAAM,MAAM,GAAmB;MAC5C;oBACP,2BAAC;KAAW,WAAU;eAAe,+BAAM,YAAY;MAAc;MAClE,KAAK,uBACN,4BAAC;KAAW,KAAK,IAAI;KAAW;gBAC7B,+BAAM,IAAI,QAAQ,GAAG,kBACtB,2BAACE,gCAAiB;MACP;OAEA;GAChB,cAAc,UAAU;;GACf,GACJ;AAEb;AAED,4BAAe"}
|
package/lib/Concept/Concept.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
4
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ImageEmbed = require('../Embed/ImageEmbed.js');
|
|
5
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_H5pEmbed = require('../Embed/H5pEmbed.js');
|
|
6
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ExternalEmbed = require('../Embed/ExternalEmbed.js');
|
|
7
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_IframeEmbed = require('../Embed/IframeEmbed.js');
|
|
8
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_BrightcoveEmbed = require('../Embed/BrightcoveEmbed.js');
|
|
9
9
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
10
10
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
11
11
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
@@ -23,7 +23,7 @@ const ContentWrapper = (0, __ndla_styled_system_jsx.styled)("div", { base: {
|
|
|
23
23
|
"& p": { display: "inline" }
|
|
24
24
|
} });
|
|
25
25
|
const Concept = (0, react.forwardRef)(({ copyright, visualElement, lang, children, title, source, previewAlt,...rest }, ref) => {
|
|
26
|
-
const licenseProps =
|
|
26
|
+
const licenseProps = require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes.licenseAttributes(copyright?.license?.license, lang, source);
|
|
27
27
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
28
28
|
ref,
|
|
29
29
|
...rest,
|
|
@@ -33,12 +33,12 @@ const Concept = (0, react.forwardRef)(({ copyright, visualElement, lang, childre
|
|
|
33
33
|
lang,
|
|
34
34
|
children: [!!title && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: title }), ` – `] }), children]
|
|
35
35
|
}),
|
|
36
|
-
visualElement?.resource === "image" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
36
|
+
visualElement?.resource === "image" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ImageEmbed.ImageEmbed_default, {
|
|
37
37
|
embed: visualElement,
|
|
38
38
|
lang,
|
|
39
39
|
previewAlt
|
|
40
|
-
}) : visualElement?.resource === "brightcove" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
41
|
-
!!copyright && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
40
|
+
}) : visualElement?.resource === "brightcove" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_BrightcoveEmbed.BrightcoveEmbed_default, { embed: visualElement }) : visualElement?.resource === "h5p" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_H5pEmbed.H5pEmbed_default, { embed: visualElement }) : visualElement?.resource === "iframe" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_IframeEmbed.IframeEmbed_default, { embed: visualElement }) : visualElement?.resource === "external" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ExternalEmbed.ExternalEmbed_default, { embed: visualElement }) : null,
|
|
41
|
+
!!copyright && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline.EmbedByline, {
|
|
42
42
|
copyright,
|
|
43
43
|
type: "concept"
|
|
44
44
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Concept.js","names":["Figure","ImageEmbed","BrightcoveEmbed","H5pEmbed","IframeEmbed","ExternalEmbed","EmbedByline"],"sources":["../../src/Concept/Concept.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 ComponentPropsWithRef, type ReactNode, forwardRef } from \"react\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IDraftCopyrightDTO as ConceptCopyright } from \"@ndla/types-backend/concept-api\";\nimport type { ConceptVisualElementMeta } from \"@ndla/types-embed\";\nimport { BrightcoveEmbed, ExternalEmbed, H5pEmbed, IframeEmbed, ImageEmbed } from \"../Embed\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\nexport interface ConceptProps extends Omit<ComponentPropsWithRef<\"figure\">, \"title\"> {\n copyright?: ConceptCopyright;\n visualElement?: ConceptVisualElementMeta;\n lang?: string;\n title?: ReactNode;\n children?: ReactNode;\n source?: string;\n previewAlt?: boolean;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n textStyle: \"body.large\",\n display: \"inline\",\n \"& p\": {\n display: \"inline\",\n },\n },\n});\n\nexport const Concept = forwardRef<HTMLElement, ConceptProps>(\n ({ copyright, visualElement, lang, children, title, source, previewAlt, ...rest }, ref) => {\n const licenseProps = licenseAttributes(copyright?.license?.license, lang, source);\n\n return (\n <StyledFigure ref={ref} {...rest} {...licenseProps}>\n <ContentWrapper lang={lang}>\n {!!title && (\n <>\n <b>{title}</b>\n {` – `}\n </>\n )}\n {children}\n </ContentWrapper>\n {visualElement?.resource === \"image\" ? (\n <ImageEmbed embed={visualElement} lang={lang} previewAlt={previewAlt} />\n ) : visualElement?.resource === \"brightcove\" ? (\n <BrightcoveEmbed embed={visualElement} />\n ) : visualElement?.resource === \"h5p\" ? (\n <H5pEmbed embed={visualElement} />\n ) : visualElement?.resource === \"iframe\" ? (\n <IframeEmbed embed={visualElement} />\n ) : visualElement?.resource === \"external\" ? (\n <ExternalEmbed embed={visualElement} />\n ) : null}\n {!!copyright && <EmbedByline copyright={copyright} type=\"concept\" />}\n </StyledFigure>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,WAAW;CACX,SAAS;CACT,OAAO,EACL,SAAS,SACV;AACF,EACF,EAAC;AAEF,MAAa,UAAU,sBACrB,CAAC,EAAE,WAAW,eAAe,MAAM,UAAU,OAAO,QAAQ,WAAY,GAAG,MAAM,EAAE,QAAQ;CACzF,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"Concept.js","names":["Figure","ImageEmbed","BrightcoveEmbed","H5pEmbed","IframeEmbed","ExternalEmbed","EmbedByline"],"sources":["../../src/Concept/Concept.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 ComponentPropsWithRef, type ReactNode, forwardRef } from \"react\";\nimport { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { IDraftCopyrightDTO as ConceptCopyright } from \"@ndla/types-backend/concept-api\";\nimport type { ConceptVisualElementMeta } from \"@ndla/types-embed\";\nimport { BrightcoveEmbed, ExternalEmbed, H5pEmbed, IframeEmbed, ImageEmbed } from \"../Embed\";\nimport { EmbedByline } from \"../LicenseByline/EmbedByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\nexport interface ConceptProps extends Omit<ComponentPropsWithRef<\"figure\">, \"title\"> {\n copyright?: ConceptCopyright;\n visualElement?: ConceptVisualElementMeta;\n lang?: string;\n title?: ReactNode;\n children?: ReactNode;\n source?: string;\n previewAlt?: boolean;\n}\n\nconst StyledFigure = styled(Figure, {\n base: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"medium\",\n },\n});\n\nconst ContentWrapper = styled(\"div\", {\n base: {\n textStyle: \"body.large\",\n display: \"inline\",\n \"& p\": {\n display: \"inline\",\n },\n },\n});\n\nexport const Concept = forwardRef<HTMLElement, ConceptProps>(\n ({ copyright, visualElement, lang, children, title, source, previewAlt, ...rest }, ref) => {\n const licenseProps = licenseAttributes(copyright?.license?.license, lang, source);\n\n return (\n <StyledFigure ref={ref} {...rest} {...licenseProps}>\n <ContentWrapper lang={lang}>\n {!!title && (\n <>\n <b>{title}</b>\n {` – `}\n </>\n )}\n {children}\n </ContentWrapper>\n {visualElement?.resource === \"image\" ? (\n <ImageEmbed embed={visualElement} lang={lang} previewAlt={previewAlt} />\n ) : visualElement?.resource === \"brightcove\" ? (\n <BrightcoveEmbed embed={visualElement} />\n ) : visualElement?.resource === \"h5p\" ? (\n <H5pEmbed embed={visualElement} />\n ) : visualElement?.resource === \"iframe\" ? (\n <IframeEmbed embed={visualElement} />\n ) : visualElement?.resource === \"external\" ? (\n <ExternalEmbed embed={visualElement} />\n ) : null}\n {!!copyright && <EmbedByline copyright={copyright} type=\"concept\" />}\n </StyledFigure>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,SAAS;CACT,eAAe;CACf,KAAK;AACN,EACF,EAAC;AAEF,MAAM,iBAAiB,qCAAO,OAAO,EACnC,MAAM;CACJ,WAAW;CACX,SAAS;CACT,OAAO,EACL,SAAS,SACV;AACF,EACF,EAAC;AAEF,MAAa,UAAU,sBACrB,CAAC,EAAE,WAAW,eAAe,MAAM,UAAU,OAAO,QAAQ,WAAY,GAAG,MAAM,EAAE,QAAQ;CACzF,MAAM,eAAe,gHAAkB,WAAW,SAAS,SAAS,MAAM,OAAO;AAEjF,wBACE,4BAAC;EAAkB;EAAK,GAAI;EAAM,GAAI;;mBACpC,4BAAC;IAAqB;iBACjB,yBACD,qFACE,2BAAC,iBAAG,QAAU,GACZ,QACD,EAEJ;KACc;GAChB,eAAe,aAAa,0BAC3B,2BAACC;IAAW,OAAO;IAAqB;IAAkB;KAAc,GACtE,eAAe,aAAa,+BAC9B,2BAACC,uHAAgB,OAAO,gBAAiB,GACvC,eAAe,aAAa,wBAC9B,2BAACC,yGAAS,OAAO,gBAAiB,GAChC,eAAe,aAAa,2BAC9B,2BAACC,+GAAY,OAAO,gBAAiB,GACnC,eAAe,aAAa,6BAC9B,2BAACC,mHAAc,OAAO,gBAAiB,GACrC;KACD,6BAAa,2BAACC;IAAuB;IAAW,MAAK;KAAY;;GACvD;AAElB,EACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
3
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
4
4
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
5
5
|
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
@@ -133,7 +133,7 @@ const ContactBlock = ({ image, jobTitle, description, name, email, embedAlt, lan
|
|
|
133
133
|
src: image.image.imageUrl,
|
|
134
134
|
width: 300,
|
|
135
135
|
height: 300
|
|
136
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
136
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline.LicenseContainerContent, {
|
|
137
137
|
type: "image",
|
|
138
138
|
copyright: image.copyright
|
|
139
139
|
})]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType = require('../model/ContentType.js');
|
|
3
3
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
4
4
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
5
5
|
const react_i18next = require_rolldown_runtime.__toESM(require("react-i18next"));
|
|
@@ -7,25 +7,25 @@ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-ru
|
|
|
7
7
|
|
|
8
8
|
//#region src/ContentTypeBadge/ContentTypeBadge.tsx
|
|
9
9
|
const contentTypeToBadgeVariantMap = {
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
10
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SUBJECT_MATERIAL]: "brand1",
|
|
11
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.TASKS_AND_ACTIVITIES]: "brand2",
|
|
12
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.ASSESSMENT_RESOURCES]: "brand2",
|
|
13
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SUBJECT]: "neutral",
|
|
14
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SOURCE_MATERIAL]: "brand1",
|
|
15
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.LEARNING_PATH]: "brand3",
|
|
16
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.TOPIC]: "neutral",
|
|
17
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.MULTIDISCIPLINARY]: "neutral",
|
|
18
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.CONCEPT]: "brand1",
|
|
19
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.EXTERNAL]: "brand2",
|
|
20
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.IMAGE]: "brand1",
|
|
21
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.AUDIO]: "brand1",
|
|
22
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PODCAST]: "brand1",
|
|
23
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.VIDEO]: "brand1",
|
|
24
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.MISSING]: "neutral",
|
|
25
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PODCAST_SERIES]: "brand1",
|
|
26
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.GLOSS]: "brand1",
|
|
27
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PROGRAMME]: "neutral",
|
|
28
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.FRONTPAGE_ARTICLE]: "brand2"
|
|
29
29
|
};
|
|
30
30
|
const ContentTypeBadge = (0, react.forwardRef)(({ contentType, children,...props }, ref) => {
|
|
31
31
|
const { t } = (0, react_i18next.useTranslation)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTypeBadge.js","names":["contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant>","Badge"],"sources":["../../src/ContentTypeBadge/ContentTypeBadge.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 { forwardRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Badge, type BadgeProps, type BadgeVariant } from \"@ndla/primitives\";\nimport * as contentTypes from \"../model/ContentType\";\n\nexport interface ContentTypeBadgeProps extends Omit<BadgeProps, \"colorTheme\"> {\n contentType: ContentType | undefined;\n}\n\nexport type StrictContentType =\n | typeof contentTypes.SUBJECT_MATERIAL\n | typeof contentTypes.TASKS_AND_ACTIVITIES\n | typeof contentTypes.ASSESSMENT_RESOURCES\n | typeof contentTypes.SUBJECT\n | typeof contentTypes.SOURCE_MATERIAL\n | typeof contentTypes.LEARNING_PATH\n | typeof contentTypes.TOPIC\n | typeof contentTypes.MULTIDISCIPLINARY\n | typeof contentTypes.CONCEPT\n | typeof contentTypes.EXTERNAL\n | typeof contentTypes.IMAGE\n | typeof contentTypes.AUDIO\n | typeof contentTypes.VIDEO\n | typeof contentTypes.MISSING\n | typeof contentTypes.PODCAST\n | typeof contentTypes.GLOSS\n | typeof contentTypes.PROGRAMME\n | typeof contentTypes.PODCAST_SERIES\n | typeof contentTypes.FRONTPAGE_ARTICLE;\n\nexport type ContentType =\n | StrictContentType\n // This allows for us to fallback to string without getting a ts error, while still keeping intellisense\n | (string & {});\n\nexport const contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant> = {\n [contentTypes.SUBJECT_MATERIAL]: \"brand1\",\n [contentTypes.TASKS_AND_ACTIVITIES]: \"brand2\",\n [contentTypes.ASSESSMENT_RESOURCES]: \"brand2\",\n [contentTypes.SUBJECT]: \"neutral\",\n [contentTypes.SOURCE_MATERIAL]: \"brand1\",\n [contentTypes.LEARNING_PATH]: \"brand3\",\n [contentTypes.TOPIC]: \"neutral\",\n [contentTypes.MULTIDISCIPLINARY]: \"neutral\",\n [contentTypes.CONCEPT]: \"brand1\",\n [contentTypes.EXTERNAL]: \"brand2\",\n [contentTypes.IMAGE]: \"brand1\",\n [contentTypes.AUDIO]: \"brand1\",\n [contentTypes.PODCAST]: \"brand1\",\n [contentTypes.VIDEO]: \"brand1\",\n [contentTypes.MISSING]: \"neutral\",\n [contentTypes.PODCAST_SERIES]: \"brand1\",\n [contentTypes.GLOSS]: \"brand1\",\n [contentTypes.PROGRAMME]: \"neutral\",\n [contentTypes.FRONTPAGE_ARTICLE]: \"brand2\",\n};\n\nexport const ContentTypeBadge = forwardRef<HTMLDivElement, ContentTypeBadgeProps>(\n ({ contentType, children, ...props }, ref) => {\n const { t } = useTranslation();\n return (\n <Badge\n colorTheme={contentTypeToBadgeVariantMap[contentType ?? \"missing\"] ?? contentTypeToBadgeVariantMap[\"missing\"]}\n {...props}\n ref={ref}\n >\n {children ?? t(`contentTypes.${contentType}`)}\n </Badge>\n );\n },\n);\n"],"mappings":";;;;;;;;AA2CA,MAAaA,+BAAkE;
|
|
1
|
+
{"version":3,"file":"ContentTypeBadge.js","names":["contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant>","Badge"],"sources":["../../src/ContentTypeBadge/ContentTypeBadge.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 { forwardRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Badge, type BadgeProps, type BadgeVariant } from \"@ndla/primitives\";\nimport * as contentTypes from \"../model/ContentType\";\n\nexport interface ContentTypeBadgeProps extends Omit<BadgeProps, \"colorTheme\"> {\n contentType: ContentType | undefined;\n}\n\nexport type StrictContentType =\n | typeof contentTypes.SUBJECT_MATERIAL\n | typeof contentTypes.TASKS_AND_ACTIVITIES\n | typeof contentTypes.ASSESSMENT_RESOURCES\n | typeof contentTypes.SUBJECT\n | typeof contentTypes.SOURCE_MATERIAL\n | typeof contentTypes.LEARNING_PATH\n | typeof contentTypes.TOPIC\n | typeof contentTypes.MULTIDISCIPLINARY\n | typeof contentTypes.CONCEPT\n | typeof contentTypes.EXTERNAL\n | typeof contentTypes.IMAGE\n | typeof contentTypes.AUDIO\n | typeof contentTypes.VIDEO\n | typeof contentTypes.MISSING\n | typeof contentTypes.PODCAST\n | typeof contentTypes.GLOSS\n | typeof contentTypes.PROGRAMME\n | typeof contentTypes.PODCAST_SERIES\n | typeof contentTypes.FRONTPAGE_ARTICLE;\n\nexport type ContentType =\n | StrictContentType\n // This allows for us to fallback to string without getting a ts error, while still keeping intellisense\n | (string & {});\n\nexport const contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant> = {\n [contentTypes.SUBJECT_MATERIAL]: \"brand1\",\n [contentTypes.TASKS_AND_ACTIVITIES]: \"brand2\",\n [contentTypes.ASSESSMENT_RESOURCES]: \"brand2\",\n [contentTypes.SUBJECT]: \"neutral\",\n [contentTypes.SOURCE_MATERIAL]: \"brand1\",\n [contentTypes.LEARNING_PATH]: \"brand3\",\n [contentTypes.TOPIC]: \"neutral\",\n [contentTypes.MULTIDISCIPLINARY]: \"neutral\",\n [contentTypes.CONCEPT]: \"brand1\",\n [contentTypes.EXTERNAL]: \"brand2\",\n [contentTypes.IMAGE]: \"brand1\",\n [contentTypes.AUDIO]: \"brand1\",\n [contentTypes.PODCAST]: \"brand1\",\n [contentTypes.VIDEO]: \"brand1\",\n [contentTypes.MISSING]: \"neutral\",\n [contentTypes.PODCAST_SERIES]: \"brand1\",\n [contentTypes.GLOSS]: \"brand1\",\n [contentTypes.PROGRAMME]: \"neutral\",\n [contentTypes.FRONTPAGE_ARTICLE]: \"brand2\",\n};\n\nexport const ContentTypeBadge = forwardRef<HTMLDivElement, ContentTypeBadgeProps>(\n ({ contentType, children, ...props }, ref) => {\n const { t } = useTranslation();\n return (\n <Badge\n colorTheme={contentTypeToBadgeVariantMap[contentType ?? \"missing\"] ?? contentTypeToBadgeVariantMap[\"missing\"]}\n {...props}\n ref={ref}\n >\n {children ?? t(`contentTypes.${contentType}`)}\n </Badge>\n );\n },\n);\n"],"mappings":";;;;;;;;AA2CA,MAAaA,+BAAkE;6GAC5C;iHACI;iHACA;oGACb;4GACQ;0GACF;kGACR;8GACY;oGACV;qGACC;kGACH;kGACA;oGACE;kGACF;oGACE;2GACO;kGACT;sGACI;8GACQ;AACnC;AAED,MAAa,mBAAmB,sBAC9B,CAAC,EAAE,aAAa,SAAU,GAAG,OAAO,EAAE,QAAQ;CAC5C,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAC9B,wBACE,2BAACC;EACC,YAAY,6BAA6B,eAAe,cAAc,6BAA6B;EACnG,GAAI;EACC;YAEJ,YAAY,GAAG,eAAe,YAAY,EAAE;GACvC;AAEX,EACF"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType = require('../model/ContentType.js');
|
|
3
3
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
4
4
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
5
5
|
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
6
6
|
|
|
7
7
|
//#region src/ContentTypeHero/ContentTypeHero.tsx
|
|
8
8
|
const contentTypeToHeroMap = {
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
9
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SUBJECT_MATERIAL]: "primary",
|
|
10
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.TASKS_AND_ACTIVITIES]: "brand2Bold",
|
|
11
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.ASSESSMENT_RESOURCES]: "brand2",
|
|
12
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SUBJECT]: "primary",
|
|
13
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.SOURCE_MATERIAL]: "brand1",
|
|
14
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.LEARNING_PATH]: "primary",
|
|
15
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.TOPIC]: "neutral",
|
|
16
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.MULTIDISCIPLINARY]: "primary",
|
|
17
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.CONCEPT]: "brand1Moderate",
|
|
18
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.EXTERNAL]: "primary",
|
|
19
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.IMAGE]: "primary",
|
|
20
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.AUDIO]: "primary",
|
|
21
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PODCAST]: "primary",
|
|
22
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.VIDEO]: "primary",
|
|
23
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.MISSING]: "neutral",
|
|
24
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.GLOSS]: "brand1Moderate",
|
|
25
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PROGRAMME]: "primary",
|
|
26
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.PODCAST_SERIES]: "primary",
|
|
27
|
+
[require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_model_ContentType.FRONTPAGE_ARTICLE]: "primary"
|
|
28
28
|
};
|
|
29
29
|
const ContentTypeHero = (0, react.forwardRef)(({ contentType, children,...props }, ref) => {
|
|
30
30
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.Hero, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTypeHero.js","names":["contentTypeToHeroMap: Record<ContentType, HeroVariant>","Hero"],"sources":["../../src/ContentTypeHero/ContentTypeHero.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 { forwardRef } from \"react\";\nimport { Hero, type HeroProps, type HeroVariant } from \"@ndla/primitives\";\nimport type { ContentType } from \"../ContentTypeBadge/ContentTypeBadge\";\nimport * as contentTypes from \"../model/ContentType\";\n\nexport const contentTypeToHeroMap: Record<ContentType, HeroVariant> = {\n [contentTypes.SUBJECT_MATERIAL]: \"primary\",\n [contentTypes.TASKS_AND_ACTIVITIES]: \"brand2Bold\",\n [contentTypes.ASSESSMENT_RESOURCES]: \"brand2\",\n // This will never happen\n [contentTypes.SUBJECT]: \"primary\",\n [contentTypes.SOURCE_MATERIAL]: \"brand1\",\n // This will never happen\n [contentTypes.LEARNING_PATH]: \"primary\",\n [contentTypes.TOPIC]: \"neutral\",\n [contentTypes.MULTIDISCIPLINARY]: \"primary\",\n [contentTypes.CONCEPT]: \"brand1Moderate\",\n [contentTypes.EXTERNAL]: \"primary\",\n [contentTypes.IMAGE]: \"primary\",\n [contentTypes.AUDIO]: \"primary\",\n [contentTypes.PODCAST]: \"primary\",\n [contentTypes.VIDEO]: \"primary\",\n [contentTypes.MISSING]: \"neutral\",\n [contentTypes.GLOSS]: \"brand1Moderate\",\n // this will never happen\n [contentTypes.PROGRAMME]: \"primary\",\n // this will never happen\n [contentTypes.PODCAST_SERIES]: \"primary\",\n [contentTypes.FRONTPAGE_ARTICLE]: \"primary\",\n};\n\nexport interface ContentTypeHeroProps extends HeroProps {\n contentType: ContentType | undefined;\n}\n\nexport const ContentTypeHero = forwardRef<HTMLDivElement, ContentTypeHeroProps>(\n ({ contentType, children, ...props }, ref) => {\n return (\n <Hero\n variant={contentTypeToHeroMap[contentType ?? \"missing\"] ?? contentTypeToHeroMap[\"missing\"]}\n {...props}\n ref={ref}\n >\n {children}\n </Hero>\n );\n },\n);\n"],"mappings":";;;;;;;AAaA,MAAaA,uBAAyD;
|
|
1
|
+
{"version":3,"file":"ContentTypeHero.js","names":["contentTypeToHeroMap: Record<ContentType, HeroVariant>","Hero"],"sources":["../../src/ContentTypeHero/ContentTypeHero.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 { forwardRef } from \"react\";\nimport { Hero, type HeroProps, type HeroVariant } from \"@ndla/primitives\";\nimport type { ContentType } from \"../ContentTypeBadge/ContentTypeBadge\";\nimport * as contentTypes from \"../model/ContentType\";\n\nexport const contentTypeToHeroMap: Record<ContentType, HeroVariant> = {\n [contentTypes.SUBJECT_MATERIAL]: \"primary\",\n [contentTypes.TASKS_AND_ACTIVITIES]: \"brand2Bold\",\n [contentTypes.ASSESSMENT_RESOURCES]: \"brand2\",\n // This will never happen\n [contentTypes.SUBJECT]: \"primary\",\n [contentTypes.SOURCE_MATERIAL]: \"brand1\",\n // This will never happen\n [contentTypes.LEARNING_PATH]: \"primary\",\n [contentTypes.TOPIC]: \"neutral\",\n [contentTypes.MULTIDISCIPLINARY]: \"primary\",\n [contentTypes.CONCEPT]: \"brand1Moderate\",\n [contentTypes.EXTERNAL]: \"primary\",\n [contentTypes.IMAGE]: \"primary\",\n [contentTypes.AUDIO]: \"primary\",\n [contentTypes.PODCAST]: \"primary\",\n [contentTypes.VIDEO]: \"primary\",\n [contentTypes.MISSING]: \"neutral\",\n [contentTypes.GLOSS]: \"brand1Moderate\",\n // this will never happen\n [contentTypes.PROGRAMME]: \"primary\",\n // this will never happen\n [contentTypes.PODCAST_SERIES]: \"primary\",\n [contentTypes.FRONTPAGE_ARTICLE]: \"primary\",\n};\n\nexport interface ContentTypeHeroProps extends HeroProps {\n contentType: ContentType | undefined;\n}\n\nexport const ContentTypeHero = forwardRef<HTMLDivElement, ContentTypeHeroProps>(\n ({ contentType, children, ...props }, ref) => {\n return (\n <Hero\n variant={contentTypeToHeroMap[contentType ?? \"missing\"] ?? contentTypeToHeroMap[\"missing\"]}\n {...props}\n ref={ref}\n >\n {children}\n </Hero>\n );\n },\n);\n"],"mappings":";;;;;;;AAaA,MAAaA,uBAAyD;6GACnC;iHACI;iHACA;oGAEb;4GACQ;0GAEF;kGACR;8GACY;oGACV;qGACC;kGACH;kGACA;oGACE;kGACF;oGACE;kGACF;sGAEI;2GAEK;8GACG;AACnC;AAMD,MAAa,kBAAkB,sBAC7B,CAAC,EAAE,aAAa,SAAU,GAAG,OAAO,EAAE,QAAQ;AAC5C,wBACE,2BAACC;EACC,SAAS,qBAAqB,eAAe,cAAc,qBAAqB;EAChF,GAAI;EACC;EAEJ;GACI;AAEV,EACF"}
|
|
@@ -59,5 +59,5 @@ const CopyParagraphButton = ({ children, copyText, lang }) => {
|
|
|
59
59
|
var CopyParagraphButton_default = CopyParagraphButton;
|
|
60
60
|
|
|
61
61
|
//#endregion
|
|
62
|
-
exports.CopyParagraphButton_default = CopyParagraphButton_default;
|
|
62
|
+
exports.CopyParagraphButton_default$1 = CopyParagraphButton_default;
|
|
63
63
|
//# sourceMappingURL=CopyParagraphButton.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CopyParagraphButton_CopyParagraphButton = require('./CopyParagraphButton.js');
|
|
2
2
|
|
|
3
3
|
//#region src/CopyParagraphButton/index.tsx
|
|
4
|
-
var CopyParagraphButton_default$1 =
|
|
4
|
+
var CopyParagraphButton_default$1 = require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CopyParagraphButton_CopyParagraphButton.CopyParagraphButton_default$1;
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
exports.CopyParagraphButton_default = CopyParagraphButton_default$1;
|
package/lib/Embed/AudioEmbed.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
4
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
5
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_AudioPlayer_index = require('../AudioPlayer/index.js');
|
|
6
6
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
7
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
8
8
|
const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-runtime"));
|
|
@@ -11,9 +11,9 @@ const react_jsx_runtime = require_rolldown_runtime.__toESM(require("react/jsx-ru
|
|
|
11
11
|
const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figure, { base: { clear: "both" } });
|
|
12
12
|
const AudioEmbed = ({ embed, lang }) => {
|
|
13
13
|
const type = embed.embedData.type === "standard" ? "audio" : "podcast";
|
|
14
|
-
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type });
|
|
15
15
|
const { data, embedData } = embed;
|
|
16
|
-
if (embedData.type === "minimal") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
16
|
+
if (embedData.type === "minimal") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_AudioPlayer_index.AudioPlayer_default, {
|
|
17
17
|
speech: true,
|
|
18
18
|
src: data.audioFile.url,
|
|
19
19
|
title: data.title.title
|
|
@@ -27,19 +27,19 @@ const AudioEmbed = ({ embed, lang }) => {
|
|
|
27
27
|
url: coverPhoto.url,
|
|
28
28
|
alt: coverPhoto.altText
|
|
29
29
|
};
|
|
30
|
-
const licenseProps =
|
|
30
|
+
const licenseProps = require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes.licenseAttributes(data.copyright.license.license, lang, embedData.url);
|
|
31
31
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
32
32
|
lang,
|
|
33
33
|
"data-embed-type": type,
|
|
34
34
|
...licenseProps,
|
|
35
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
35
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_AudioPlayer_index.AudioPlayer_default, {
|
|
36
36
|
description: data.podcastMeta?.introduction ?? "",
|
|
37
37
|
img,
|
|
38
38
|
src: data.audioFile.url,
|
|
39
39
|
textVersion: data.manuscript?.manuscript.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { dangerouslySetInnerHTML: { __html: data.manuscript.manuscript } }) : void 0,
|
|
40
40
|
title: data.title.title,
|
|
41
41
|
subtitle
|
|
42
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
42
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline.EmbedByline, {
|
|
43
43
|
error: false,
|
|
44
44
|
type: data.audioType === "standard" ? "audio" : "podcast",
|
|
45
45
|
copyright: embed.data.copyright
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioEmbed.js","names":["Figure","EmbedErrorPlaceholder","AudioPlayer","EmbedByline"],"sources":["../../src/Embed/AudioEmbed.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 { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { AudioMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { Author } from \"./ImageEmbed\";\nimport AudioPlayer from \"../AudioPlayer\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\ninterface Props {\n embed: AudioMetaData;\n lang?: string;\n}\n\nexport const getFirstNonEmptyLicenseCredits = (authors: {\n creators: Author[];\n rightsholders: Author[];\n processors: Author[];\n}) => Object.values(authors).find((i) => i.length > 0) ?? [];\n\nconst AudioEmbed = ({ embed, lang }: Props) => {\n const type = embed.embedData.type === \"standard\" ? \"audio\" : \"podcast\";\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={type} />;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.type === \"minimal\") {\n return <AudioPlayer speech src={data.audioFile.url} title={data.title.title} />;\n }\n\n const subtitle = data.series ? { title: data.series.title.title, url: `/podkast/${data.series.id}` } : undefined;\n\n const coverPhoto = data.podcastMeta?.coverPhoto;\n\n const img = coverPhoto && { url: coverPhoto.url, alt: coverPhoto.altText };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n return (\n <StyledFigure lang={lang} data-embed-type={type} {...licenseProps}>\n <AudioPlayer\n description={data.podcastMeta?.introduction ?? \"\"}\n img={img}\n src={data.audioFile.url}\n textVersion={\n data.manuscript?.manuscript.length ? (\n <div dangerouslySetInnerHTML={{ __html: data.manuscript.manuscript }} />\n ) : undefined\n }\n title={data.title.title}\n subtitle={subtitle}\n />\n <EmbedByline\n error={false}\n type={data.audioType === \"standard\" ? \"audio\" : \"podcast\"}\n copyright={embed.data.copyright}\n />\n </StyledFigure>\n );\n};\n\nexport default AudioEmbed;\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,OAAO,OACR,EACF,EAAC;AAaF,MAAM,aAAa,CAAC,EAAE,OAAO,MAAa,KAAK;CAC7C,MAAM,OAAO,MAAM,UAAU,SAAS,aAAa,UAAU;AAC7D,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC
|
|
1
|
+
{"version":3,"file":"AudioEmbed.js","names":["Figure","EmbedErrorPlaceholder","AudioPlayer","EmbedByline"],"sources":["../../src/Embed/AudioEmbed.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 { Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { AudioMetaData } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { Author } from \"./ImageEmbed\";\nimport AudioPlayer from \"../AudioPlayer\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n },\n});\n\ninterface Props {\n embed: AudioMetaData;\n lang?: string;\n}\n\nexport const getFirstNonEmptyLicenseCredits = (authors: {\n creators: Author[];\n rightsholders: Author[];\n processors: Author[];\n}) => Object.values(authors).find((i) => i.length > 0) ?? [];\n\nconst AudioEmbed = ({ embed, lang }: Props) => {\n const type = embed.embedData.type === \"standard\" ? \"audio\" : \"podcast\";\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type={type} />;\n }\n\n const { data, embedData } = embed;\n\n if (embedData.type === \"minimal\") {\n return <AudioPlayer speech src={data.audioFile.url} title={data.title.title} />;\n }\n\n const subtitle = data.series ? { title: data.series.title.title, url: `/podkast/${data.series.id}` } : undefined;\n\n const coverPhoto = data.podcastMeta?.coverPhoto;\n\n const img = coverPhoto && { url: coverPhoto.url, alt: coverPhoto.altText };\n\n const licenseProps = licenseAttributes(data.copyright.license.license, lang, embedData.url);\n\n return (\n <StyledFigure lang={lang} data-embed-type={type} {...licenseProps}>\n <AudioPlayer\n description={data.podcastMeta?.introduction ?? \"\"}\n img={img}\n src={data.audioFile.url}\n textVersion={\n data.manuscript?.manuscript.length ? (\n <div dangerouslySetInnerHTML={{ __html: data.manuscript.manuscript }} />\n ) : undefined\n }\n title={data.title.title}\n subtitle={subtitle}\n />\n <EmbedByline\n error={false}\n type={data.audioType === \"standard\" ? \"audio\" : \"podcast\"}\n copyright={embed.data.copyright}\n />\n </StyledFigure>\n );\n};\n\nexport default AudioEmbed;\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM,EACJ,OAAO,OACR,EACF,EAAC;AAaF,MAAM,aAAa,CAAC,EAAE,OAAO,MAAa,KAAK;CAC7C,MAAM,OAAO,MAAM,UAAU,SAAS,aAAa,UAAU;AAC7D,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,mIAA4B,OAAQ;CAG9C,MAAM,EAAE,MAAM,WAAW,GAAG;AAE5B,KAAI,UAAU,SAAS,UACrB,wBAAO,2BAACC;EAAY;EAAO,KAAK,KAAK,UAAU;EAAK,OAAO,KAAK,MAAM;GAAS;CAGjF,MAAM,WAAW,KAAK,SAAS;EAAE,OAAO,KAAK,OAAO,MAAM;EAAO,MAAM,WAAW,KAAK,OAAO,GAAG;CAAG;CAEpG,MAAM,aAAa,KAAK,aAAa;CAErC,MAAM,MAAM,cAAc;EAAE,KAAK,WAAW;EAAK,KAAK,WAAW;CAAS;CAE1E,MAAM,eAAe,gHAAkB,KAAK,UAAU,QAAQ,SAAS,MAAM,UAAU,IAAI;AAE3F,wBACE,4BAAC;EAAmB;EAAM,mBAAiB;EAAM,GAAI;6BACnD,2BAACA;GACC,aAAa,KAAK,aAAa,gBAAgB;GAC1C;GACL,KAAK,KAAK,UAAU;GACpB,aACE,KAAK,YAAY,WAAW,yBAC1B,2BAAC,SAAI,yBAAyB,EAAE,QAAQ,KAAK,WAAW,WAAY,IAAI;GAG5E,OAAO,KAAK,MAAM;GACR;IACV,kBACF,2BAACC;GACC,OAAO;GACP,MAAM,KAAK,cAAc,aAAa,UAAU;GAChD,WAAW,MAAM,KAAK;IACtB;GACW;AAElB;AAED,yBAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline = require('../LicenseByline/EmbedByline.js');
|
|
3
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
4
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes = require('../utils/licenseAttributes.js');
|
|
5
5
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
6
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
7
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
@@ -45,7 +45,7 @@ const BrightcoveEmbed = ({ embed, renderContext = "article", lang }) => {
|
|
|
45
45
|
iframe.height = "";
|
|
46
46
|
}
|
|
47
47
|
}, []);
|
|
48
|
-
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
48
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, {
|
|
49
49
|
type: "video",
|
|
50
50
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BrightcoveIframe, {
|
|
51
51
|
ref: iframeRef,
|
|
@@ -62,7 +62,7 @@ const BrightcoveEmbed = ({ embed, renderContext = "article", lang }) => {
|
|
|
62
62
|
...embedData,
|
|
63
63
|
videoid: linkedVideoId
|
|
64
64
|
}, data.sources) : void 0;
|
|
65
|
-
const licenseProps =
|
|
65
|
+
const licenseProps = require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_utils_licenseAttributes.licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);
|
|
66
66
|
const title = data.name?.trim() ? `${t("embed.type.video")}: ${data.name}` : fallbackTitle;
|
|
67
67
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__ndla_primitives.Figure, {
|
|
68
68
|
"data-embed-type": "brightcove",
|
|
@@ -77,7 +77,7 @@ const BrightcoveEmbed = ({ embed, renderContext = "article", lang }) => {
|
|
|
77
77
|
...alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps,
|
|
78
78
|
allow: "fullscreen; encrypted-media"
|
|
79
79
|
})
|
|
80
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
80
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_LicenseByline_EmbedByline.EmbedByline, {
|
|
81
81
|
type: "video",
|
|
82
82
|
copyright: data.copyright,
|
|
83
83
|
description: parsedDescription,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrightcoveEmbed.js","names":["Button","value: any","data: BrightcoveEmbedData","sources: BrightcoveVideoSource[]","EmbedErrorPlaceholder","Figure","EmbedByline"],"sources":["../../src/Embed/BrightcoveEmbed.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 { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveEmbedData, BrightcoveMetaData, BrightcoveVideoSource } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\ninterface Props {\n embed: BrightcoveMetaData;\n renderContext?: RenderContext;\n lang?: string;\n}\n\nconst LinkedVideoButton = styled(Button, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst BrightcoveIframe = styled(\"iframe\", {\n base: {\n border: 0,\n height: \"auto\",\n width: \"100%\",\n },\n});\n\nexport const makeIframeString = (url: string, width: string | number, height: string | number, title = \"\") => {\n const strippedWidth = typeof width === \"number\" ? width : width.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height.replace(/\\s*px/, \"\");\n const urlOrTitle = title || url;\n return `<iframe title=\"${urlOrTitle}\" aria-label=\"${urlOrTitle}\" src=\"${url}\" width=\"${strippedWidth}\" height=\"${strippedHeight}\" allowfullscreen scrolling=\"no\" frameborder=\"0\" loading=\"lazy\"></iframe>`;\n};\n\nexport const isNumeric = (value: any) => !Number.isNaN(value - Number.parseFloat(value));\n\nconst getIframeProps = (data: BrightcoveEmbedData, sources: BrightcoveVideoSource[]) => {\n const { account, videoid, player = \"default\" } = data;\n\n const source = sources.filter((s) => s.width && s.height).toSorted((a, b) => a!.height! - b.height!)[0];\n\n return {\n src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,\n height: source?.height ?? \"480\",\n width: source?.width ?? \"640\",\n };\n};\nconst BrightcoveEmbed = ({ embed, renderContext = \"article\", lang }: Props) => {\n const [showOriginalVideo, setShowOriginalVideo] = useState(true);\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const { embedData } = embed;\n const fallbackTitle = `${t(\"embed.type.video\")}: ${embedData.videoid}`;\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n } else if (embed.status === \"success\" && embed.data.description) {\n return parse(embed.data.description);\n }\n }, [embed, renderContext]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width}/${height}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n if (embed.status === \"error\") {\n return (\n <EmbedErrorPlaceholder type=\"video\">\n <BrightcoveIframe\n ref={iframeRef}\n title={embedData.alt || fallbackTitle}\n aria-label={embedData.alt || fallbackTitle}\n {...getIframeProps(embedData, [])}\n allow=\"fullscreen; encrypted-media\"\n />\n </EmbedErrorPlaceholder>\n );\n }\n const { data } = embed;\n\n const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : undefined;\n\n const originalVideoProps = getIframeProps(embedData, data.sources);\n const alternativeVideoProps = linkedVideoId\n ? getIframeProps({ ...embedData, videoid: linkedVideoId }, data.sources)\n : undefined;\n\n const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);\n\n const title = data.name?.trim() ? `${t(\"embed.type.video\")}: ${data.name}` : fallbackTitle;\n\n return (\n <Figure data-embed-type=\"brightcove\" {...licenseProps}>\n <div className=\"brightcove-video\">\n <BrightcoveIframe\n ref={iframeRef}\n className=\"original\"\n title={title}\n aria-label={title}\n {...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps)}\n allow=\"fullscreen; encrypted-media\"\n />\n </div>\n <EmbedByline type=\"video\" copyright={data.copyright!} description={parsedDescription}>\n <div>\n {!!linkedVideoId && (\n <LinkedVideoButton size=\"small\" variant=\"secondary\" onClick={() => setShowOriginalVideo((p) => !p)}>\n {t(`figure.button.${!showOriginalVideo ? \"original\" : \"alternative\"}`)}\n </LinkedVideoButton>\n )}\n </div>\n </EmbedByline>\n </Figure>\n );\n};\n\nexport default BrightcoveEmbed;\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,oBAAoB,qCAAOA,0BAAQ,EACvC,MAAM,EACJ,kBAAkB,UACnB,EACF,EAAC;AAEF,MAAM,mBAAmB,qCAAO,UAAU,EACxC,MAAM;CACJ,QAAQ;CACR,QAAQ;CACR,OAAO;AACR,EACF,EAAC;AASF,MAAa,YAAY,CAACC,WAAgB,OAAO,MAAM,QAAQ,OAAO,WAAW,MAAM,CAAC;AAExF,MAAM,iBAAiB,CAACC,MAA2BC,YAAqC;CACtF,MAAM,EAAE,SAAS,SAAS,SAAS,WAAW,GAAG;CAEjD,MAAM,SAAS,QAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,EAAG,SAAU,EAAE,OAAQ,CAAC;AAErG,QAAO;EACL,MAAM,iCAAiC,QAAQ,GAAG,OAAO,8BAA8B,QAAQ;EAC/F,QAAQ,QAAQ,UAAU;EAC1B,OAAO,QAAQ,SAAS;CACzB;AACF;AACD,MAAM,kBAAkB,CAAC,EAAE,OAAO,gBAAgB,WAAW,MAAa,KAAK;CAC7E,MAAM,CAAC,mBAAmB,qBAAqB,GAAG,oBAAS,KAAK;CAChE,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,YAAY,kBAA0B,KAAK;CACjD,MAAM,EAAE,WAAW,GAAG;CACtB,MAAM,iBAAiB,EAAE,EAAE,mBAAmB,CAAC,IAAI,UAAU,QAAQ;CACrE,MAAM,oBAAoB,mBAAQ,MAAM;AACtC,MAAI,MAAM,UAAU,WAAW,kBAAkB,UAC/C,QAAO,MAAM,UAAU,UAAU,+BAAM,MAAM,UAAU,QAAQ;WACtD,MAAM,WAAW,aAAa,MAAM,KAAK,YAClD,QAAO,+BAAM,MAAM,KAAK,YAAY;CAEvC,GAAE,CAAC,OAAO,aAAc,EAAC;AAE1B,sBAAU,MAAM;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,OAAO,GAAG,CAAC,SAAS,OAAO,MAAM,EAAE,SAAS,OAAO,OAAO,AAAC;AACzE,UAAO,MAAM,eAAe,EAAE,MAAM,GAAG,OAAO;AAC9C,UAAO,QAAQ;AACf,UAAO,SAAS;EACjB;CACF,GAAE,CAAE,EAAC;AACN,KAAI,MAAM,WAAW,QACnB,wBACE,2BAACC;EAAsB,MAAK;4BAC1B,2BAAC;GACC,KAAK;GACL,OAAO,UAAU,OAAO;GACxB,cAAY,UAAU,OAAO;GAC7B,GAAI,eAAe,WAAW,CAAE,EAAC;GACjC,OAAM;IACN;GACoB;CAG5B,MAAM,EAAE,MAAM,GAAG;CAEjB,MAAM,gBAAgB,UAAU,KAAK,MAAM,KAAK,GAAG,KAAK,MAAM;CAE9D,MAAM,qBAAqB,eAAe,WAAW,KAAK,QAAQ;CAClE,MAAM,wBAAwB,gBAC1B,eAAe;EAAE,GAAG;EAAW,SAAS;CAAe,GAAE,KAAK,QAAQ;CAG1E,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"BrightcoveEmbed.js","names":["Button","value: any","data: BrightcoveEmbedData","sources: BrightcoveVideoSource[]","EmbedErrorPlaceholder","Figure","EmbedByline"],"sources":["../../src/Embed/BrightcoveEmbed.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 { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { BrightcoveEmbedData, BrightcoveMetaData, BrightcoveVideoSource } from \"@ndla/types-embed\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport type { RenderContext } from \"./types\";\nimport { EmbedByline } from \"../LicenseByline\";\nimport { licenseAttributes } from \"../utils/licenseAttributes\";\n\ninterface Props {\n embed: BrightcoveMetaData;\n renderContext?: RenderContext;\n lang?: string;\n}\n\nconst LinkedVideoButton = styled(Button, {\n base: {\n marginBlockStart: \"3xsmall\",\n },\n});\n\nconst BrightcoveIframe = styled(\"iframe\", {\n base: {\n border: 0,\n height: \"auto\",\n width: \"100%\",\n },\n});\n\nexport const makeIframeString = (url: string, width: string | number, height: string | number, title = \"\") => {\n const strippedWidth = typeof width === \"number\" ? width : width.replace(/\\s*px/, \"\");\n const strippedHeight = typeof height === \"number\" ? height : height.replace(/\\s*px/, \"\");\n const urlOrTitle = title || url;\n return `<iframe title=\"${urlOrTitle}\" aria-label=\"${urlOrTitle}\" src=\"${url}\" width=\"${strippedWidth}\" height=\"${strippedHeight}\" allowfullscreen scrolling=\"no\" frameborder=\"0\" loading=\"lazy\"></iframe>`;\n};\n\nexport const isNumeric = (value: any) => !Number.isNaN(value - Number.parseFloat(value));\n\nconst getIframeProps = (data: BrightcoveEmbedData, sources: BrightcoveVideoSource[]) => {\n const { account, videoid, player = \"default\" } = data;\n\n const source = sources.filter((s) => s.width && s.height).toSorted((a, b) => a!.height! - b.height!)[0];\n\n return {\n src: `https://players.brightcove.net/${account}/${player}_default/index.html?videoId=${videoid}`,\n height: source?.height ?? \"480\",\n width: source?.width ?? \"640\",\n };\n};\nconst BrightcoveEmbed = ({ embed, renderContext = \"article\", lang }: Props) => {\n const [showOriginalVideo, setShowOriginalVideo] = useState(true);\n const { t } = useTranslation();\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const { embedData } = embed;\n const fallbackTitle = `${t(\"embed.type.video\")}: ${embedData.videoid}`;\n const parsedDescription = useMemo(() => {\n if (embed.embedData.caption || renderContext === \"article\") {\n return embed.embedData.caption ? parse(embed.embedData.caption) : undefined;\n } else if (embed.status === \"success\" && embed.data.description) {\n return parse(embed.data.description);\n }\n }, [embed, renderContext]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (iframe) {\n const [width, height] = [parseInt(iframe.width), parseInt(iframe.height)];\n iframe.style.aspectRatio = `${width}/${height}`;\n iframe.width = \"\";\n iframe.height = \"\";\n }\n }, []);\n if (embed.status === \"error\") {\n return (\n <EmbedErrorPlaceholder type=\"video\">\n <BrightcoveIframe\n ref={iframeRef}\n title={embedData.alt || fallbackTitle}\n aria-label={embedData.alt || fallbackTitle}\n {...getIframeProps(embedData, [])}\n allow=\"fullscreen; encrypted-media\"\n />\n </EmbedErrorPlaceholder>\n );\n }\n const { data } = embed;\n\n const linkedVideoId = isNumeric(data.link?.text) ? data.link?.text : undefined;\n\n const originalVideoProps = getIframeProps(embedData, data.sources);\n const alternativeVideoProps = linkedVideoId\n ? getIframeProps({ ...embedData, videoid: linkedVideoId }, data.sources)\n : undefined;\n\n const licenseProps = licenseAttributes(data?.copyright?.license.license, lang, embedData.pageUrl);\n\n const title = data.name?.trim() ? `${t(\"embed.type.video\")}: ${data.name}` : fallbackTitle;\n\n return (\n <Figure data-embed-type=\"brightcove\" {...licenseProps}>\n <div className=\"brightcove-video\">\n <BrightcoveIframe\n ref={iframeRef}\n className=\"original\"\n title={title}\n aria-label={title}\n {...(alternativeVideoProps && !showOriginalVideo ? alternativeVideoProps : originalVideoProps)}\n allow=\"fullscreen; encrypted-media\"\n />\n </div>\n <EmbedByline type=\"video\" copyright={data.copyright!} description={parsedDescription}>\n <div>\n {!!linkedVideoId && (\n <LinkedVideoButton size=\"small\" variant=\"secondary\" onClick={() => setShowOriginalVideo((p) => !p)}>\n {t(`figure.button.${!showOriginalVideo ? \"original\" : \"alternative\"}`)}\n </LinkedVideoButton>\n )}\n </div>\n </EmbedByline>\n </Figure>\n );\n};\n\nexport default BrightcoveEmbed;\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,oBAAoB,qCAAOA,0BAAQ,EACvC,MAAM,EACJ,kBAAkB,UACnB,EACF,EAAC;AAEF,MAAM,mBAAmB,qCAAO,UAAU,EACxC,MAAM;CACJ,QAAQ;CACR,QAAQ;CACR,OAAO;AACR,EACF,EAAC;AASF,MAAa,YAAY,CAACC,WAAgB,OAAO,MAAM,QAAQ,OAAO,WAAW,MAAM,CAAC;AAExF,MAAM,iBAAiB,CAACC,MAA2BC,YAAqC;CACtF,MAAM,EAAE,SAAS,SAAS,SAAS,WAAW,GAAG;CAEjD,MAAM,SAAS,QAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,EAAG,SAAU,EAAE,OAAQ,CAAC;AAErG,QAAO;EACL,MAAM,iCAAiC,QAAQ,GAAG,OAAO,8BAA8B,QAAQ;EAC/F,QAAQ,QAAQ,UAAU;EAC1B,OAAO,QAAQ,SAAS;CACzB;AACF;AACD,MAAM,kBAAkB,CAAC,EAAE,OAAO,gBAAgB,WAAW,MAAa,KAAK;CAC7E,MAAM,CAAC,mBAAmB,qBAAqB,GAAG,oBAAS,KAAK;CAChE,MAAM,EAAE,GAAG,GAAG,mCAAgB;CAC9B,MAAM,YAAY,kBAA0B,KAAK;CACjD,MAAM,EAAE,WAAW,GAAG;CACtB,MAAM,iBAAiB,EAAE,EAAE,mBAAmB,CAAC,IAAI,UAAU,QAAQ;CACrE,MAAM,oBAAoB,mBAAQ,MAAM;AACtC,MAAI,MAAM,UAAU,WAAW,kBAAkB,UAC/C,QAAO,MAAM,UAAU,UAAU,+BAAM,MAAM,UAAU,QAAQ;WACtD,MAAM,WAAW,aAAa,MAAM,KAAK,YAClD,QAAO,+BAAM,MAAM,KAAK,YAAY;CAEvC,GAAE,CAAC,OAAO,aAAc,EAAC;AAE1B,sBAAU,MAAM;EACd,MAAM,SAAS,UAAU;AACzB,MAAI,QAAQ;GACV,MAAM,CAAC,OAAO,OAAO,GAAG,CAAC,SAAS,OAAO,MAAM,EAAE,SAAS,OAAO,OAAO,AAAC;AACzE,UAAO,MAAM,eAAe,EAAE,MAAM,GAAG,OAAO;AAC9C,UAAO,QAAQ;AACf,UAAO,SAAS;EACjB;CACF,GAAE,CAAE,EAAC;AACN,KAAI,MAAM,WAAW,QACnB,wBACE,2BAACC;EAAsB,MAAK;4BAC1B,2BAAC;GACC,KAAK;GACL,OAAO,UAAU,OAAO;GACxB,cAAY,UAAU,OAAO;GAC7B,GAAI,eAAe,WAAW,CAAE,EAAC;GACjC,OAAM;IACN;GACoB;CAG5B,MAAM,EAAE,MAAM,GAAG;CAEjB,MAAM,gBAAgB,UAAU,KAAK,MAAM,KAAK,GAAG,KAAK,MAAM;CAE9D,MAAM,qBAAqB,eAAe,WAAW,KAAK,QAAQ;CAClE,MAAM,wBAAwB,gBAC1B,eAAe;EAAE,GAAG;EAAW,SAAS;CAAe,GAAE,KAAK,QAAQ;CAG1E,MAAM,eAAe,gHAAkB,MAAM,WAAW,QAAQ,SAAS,MAAM,UAAU,QAAQ;CAEjG,MAAM,QAAQ,KAAK,MAAM,MAAM,IAAI,EAAE,EAAE,mBAAmB,CAAC,IAAI,KAAK,KAAK,IAAI;AAE7E,wBACE,4BAACC;EAAO,mBAAgB;EAAa,GAAI;6BACvC,2BAAC;GAAI,WAAU;6BACb,2BAAC;IACC,KAAK;IACL,WAAU;IACH;IACP,cAAY;IACZ,GAAK,0BAA0B,oBAAoB,wBAAwB;IAC3E,OAAM;KACN;IACE,kBACN,2BAACC;GAAY,MAAK;GAAQ,WAAW,KAAK;GAAY,aAAa;6BACjE,2BAAC,qBACI,iCACD,2BAAC;IAAkB,MAAK;IAAQ,SAAQ;IAAY,SAAS,MAAM,qBAAqB,CAAC,OAAO,EAAE;cAC/F,GAAG,iBAAiB,oBAAoB,aAAa,cAAc,EAAE;KACpD,GAElB;IACM;GACP;AAEZ;AAED,8BAAe"}
|
package/lib/Embed/CodeEmbed.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CodeBlock_CodeBlock = require('../CodeBlock/CodeBlock.js');
|
|
4
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CodeBlock_codeLanguageOptions = require('../CodeBlock/codeLanguageOptions.js');
|
|
5
5
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
6
6
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
7
7
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
@@ -20,7 +20,7 @@ const StyledFigure = (0, __ndla_styled_system_jsx.styled)(__ndla_primitives.Figu
|
|
|
20
20
|
"& > *:not(:where(:first-child))": { marginBlockStart: "xsmall" }
|
|
21
21
|
} });
|
|
22
22
|
const getTitleFromFormat = (format) => {
|
|
23
|
-
const selectedLanguage =
|
|
23
|
+
const selectedLanguage = require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CodeBlock_codeLanguageOptions.codeLanguageOptions.find((item) => item.format === format);
|
|
24
24
|
if (selectedLanguage) return selectedLanguage.title;
|
|
25
25
|
return;
|
|
26
26
|
};
|
|
@@ -35,12 +35,12 @@ const CodeEmbed = ({ embed }) => {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
}, [isCopied]);
|
|
38
|
-
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
38
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "code" });
|
|
39
39
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledFigure, {
|
|
40
40
|
"data-embed-type": "code-block",
|
|
41
41
|
children: [
|
|
42
42
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledFigCaption, { children: embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat) }),
|
|
43
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
43
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_CodeBlock_CodeBlock.CodeBlock_default, {
|
|
44
44
|
highlightedCode: embed.status === "success" ? embed.data.highlightedCode : "",
|
|
45
45
|
format: embed.embedData.codeFormat
|
|
46
46
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeEmbed.js","names":["Figure","format: string","item: ICodeLangugeOption","EmbedErrorPlaceholder","CodeBlock","Button","CheckLine","FileCopyLine"],"sources":["../../src/Embed/CodeEmbed.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 { useEffect, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { FileCopyLine, CheckLine } from \"@ndla/icons\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CodeMetaData } from \"@ndla/types-embed\";\nimport { copyTextToClipboard } from \"@ndla/util\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { CodeBlock, codeLanguageOptions } from \"../CodeBlock\";\nimport type { ICodeLangugeOption } from \"../CodeBlock/codeLanguageOptions\";\n\ninterface Props {\n embed: CodeMetaData;\n}\n\nconst StyledFigCaption = styled(\"figcaption\", {\n base: {\n textStyle: \"label.large\",\n fontWeight: \"bold\",\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n // We apply margin here to allow for the float and size props on figure to work as intended.\n \"& > *:not(:where(:first-child))\": {\n marginBlockStart: \"xsmall\",\n },\n },\n});\n\nconst getTitleFromFormat = (format: string) => {\n const selectedLanguage = codeLanguageOptions.find((item: ICodeLangugeOption) => item.format === format);\n if (selectedLanguage) {\n return selectedLanguage.title;\n }\n return;\n};\n\nconst CodeEmbed = ({ embed }: Props) => {\n const [isCopied, setIsCopied] = useState(false);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (isCopied) {\n const timer = setInterval(() => setIsCopied(false), 3000);\n // ensure interval is cleared - also if unmounted\n return () => {\n clearTimeout(timer);\n };\n }\n }, [isCopied]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"code\" />;\n }\n\n return (\n <StyledFigure data-embed-type=\"code-block\">\n <StyledFigCaption>{embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)}</StyledFigCaption>\n <CodeBlock\n highlightedCode={embed.status === \"success\" ? embed.data.highlightedCode : \"\"}\n format={embed.embedData.codeFormat}\n />\n <Button\n variant=\"secondary\"\n onClick={() => {\n copyTextToClipboard(embed.status === \"success\" ? embed.data.decodedContent : \"\");\n setIsCopied(true);\n }}\n >\n {isCopied ? <CheckLine /> : <FileCopyLine />}\n {isCopied ? t(\"codeBlock.copiedCode\") : t(\"codeBlock.copyCode\")}\n </Button>\n </StyledFigure>\n );\n};\n\nexport default CodeEmbed;\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,qCAAO,cAAc,EAC5C,MAAM;CACJ,WAAW;CACX,YAAY;AACb,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,OAAO;CAEP,mCAAmC,EACjC,kBAAkB,SACnB;AACF,EACF,EAAC;AAEF,MAAM,qBAAqB,CAACC,WAAmB;CAC7C,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"CodeEmbed.js","names":["Figure","format: string","item: ICodeLangugeOption","EmbedErrorPlaceholder","CodeBlock","Button","CheckLine","FileCopyLine"],"sources":["../../src/Embed/CodeEmbed.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 { useEffect, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { FileCopyLine, CheckLine } from \"@ndla/icons\";\nimport { Button, Figure } from \"@ndla/primitives\";\nimport { styled } from \"@ndla/styled-system/jsx\";\nimport type { CodeMetaData } from \"@ndla/types-embed\";\nimport { copyTextToClipboard } from \"@ndla/util\";\nimport EmbedErrorPlaceholder from \"./EmbedErrorPlaceholder\";\nimport { CodeBlock, codeLanguageOptions } from \"../CodeBlock\";\nimport type { ICodeLangugeOption } from \"../CodeBlock/codeLanguageOptions\";\n\ninterface Props {\n embed: CodeMetaData;\n}\n\nconst StyledFigCaption = styled(\"figcaption\", {\n base: {\n textStyle: \"label.large\",\n fontWeight: \"bold\",\n },\n});\n\nconst StyledFigure = styled(Figure, {\n base: {\n clear: \"both\",\n // We apply margin here to allow for the float and size props on figure to work as intended.\n \"& > *:not(:where(:first-child))\": {\n marginBlockStart: \"xsmall\",\n },\n },\n});\n\nconst getTitleFromFormat = (format: string) => {\n const selectedLanguage = codeLanguageOptions.find((item: ICodeLangugeOption) => item.format === format);\n if (selectedLanguage) {\n return selectedLanguage.title;\n }\n return;\n};\n\nconst CodeEmbed = ({ embed }: Props) => {\n const [isCopied, setIsCopied] = useState(false);\n const { t } = useTranslation();\n\n useEffect(() => {\n if (isCopied) {\n const timer = setInterval(() => setIsCopied(false), 3000);\n // ensure interval is cleared - also if unmounted\n return () => {\n clearTimeout(timer);\n };\n }\n }, [isCopied]);\n\n if (embed.status === \"error\") {\n return <EmbedErrorPlaceholder type=\"code\" />;\n }\n\n return (\n <StyledFigure data-embed-type=\"code-block\">\n <StyledFigCaption>{embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)}</StyledFigCaption>\n <CodeBlock\n highlightedCode={embed.status === \"success\" ? embed.data.highlightedCode : \"\"}\n format={embed.embedData.codeFormat}\n />\n <Button\n variant=\"secondary\"\n onClick={() => {\n copyTextToClipboard(embed.status === \"success\" ? embed.data.decodedContent : \"\");\n setIsCopied(true);\n }}\n >\n {isCopied ? <CheckLine /> : <FileCopyLine />}\n {isCopied ? t(\"codeBlock.copiedCode\") : t(\"codeBlock.copyCode\")}\n </Button>\n </StyledFigure>\n );\n};\n\nexport default CodeEmbed;\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,qCAAO,cAAc,EAC5C,MAAM;CACJ,WAAW;CACX,YAAY;AACb,EACF,EAAC;AAEF,MAAM,eAAe,qCAAOA,0BAAQ,EAClC,MAAM;CACJ,OAAO;CAEP,mCAAmC,EACjC,kBAAkB,SACnB;AACF,EACF,EAAC;AAEF,MAAM,qBAAqB,CAACC,WAAmB;CAC7C,MAAM,mBAAmB,wHAAoB,KAAK,CAACC,SAA6B,KAAK,WAAW,OAAO;AACvG,KAAI,iBACF,QAAO,iBAAiB;AAE1B;AACD;AAED,MAAM,YAAY,CAAC,EAAE,OAAc,KAAK;CACtC,MAAM,CAAC,UAAU,YAAY,GAAG,oBAAS,MAAM;CAC/C,MAAM,EAAE,GAAG,GAAG,mCAAgB;AAE9B,sBAAU,MAAM;AACd,MAAI,UAAU;GACZ,MAAM,QAAQ,YAAY,MAAM,YAAY,MAAM,EAAE,IAAK;AAEzD,UAAO,MAAM;AACX,iBAAa,MAAM;GACpB;EACF;CACF,GAAE,CAAC,QAAS,EAAC;AAEd,KAAI,MAAM,WAAW,QACnB,wBAAO,2BAACC,mIAAsB,MAAK,SAAS;AAG9C,wBACE,4BAAC;EAAa,mBAAgB;;mBAC5B,2BAAC,8BAAkB,MAAM,UAAU,SAAS,mBAAmB,MAAM,UAAU,WAAW,GAAoB;mBAC9G,2BAACC;IACC,iBAAiB,MAAM,WAAW,YAAY,MAAM,KAAK,kBAAkB;IAC3E,QAAQ,MAAM,UAAU;KACxB;mBACF,4BAACC;IACC,SAAQ;IACR,SAAS,MAAM;AACb,0CAAoB,MAAM,WAAW,YAAY,MAAM,KAAK,iBAAiB,GAAG;AAChF,iBAAY,KAAK;IAClB;eAEA,2BAAW,2BAACC,2BAAY,mBAAG,2BAACC,8BAAe,EAC3C,WAAW,EAAE,uBAAuB,GAAG,EAAE,qBAAqB;KACxD;;GACI;AAElB;AAED,wBAAe"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder = require('./EmbedErrorPlaceholder.js');
|
|
3
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ConceptInlineTriggerButton = require('./ConceptInlineTriggerButton.js');
|
|
4
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_GlossEmbed = require('./GlossEmbed.js');
|
|
5
|
+
const require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Concept_Concept = require('../Concept/Concept.js');
|
|
6
6
|
const react = require_rolldown_runtime.__toESM(require("react"));
|
|
7
7
|
const __ndla_primitives = require_rolldown_runtime.__toESM(require("@ndla/primitives"));
|
|
8
8
|
const __ndla_styled_system_jsx = require_rolldown_runtime.__toESM(require("@ndla/styled-system/jsx"));
|
|
@@ -23,9 +23,9 @@ const ConceptEmbed = ({ embed, renderContext, lang, previewAlt }) => {
|
|
|
23
23
|
}, [embed]);
|
|
24
24
|
const parsedTitle = (0, react.useMemo)(() => embed.status === "success" ? (0, html_react_parser.default)(embed.data.concept.title.htmlTitle) : void 0, [embed]);
|
|
25
25
|
if (embed.status === "error" && embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: embed.embedData.linkText });
|
|
26
|
-
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
26
|
+
if (embed.status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_EmbedErrorPlaceholder.EmbedErrorPlaceholder_default, { type: "gloss" });
|
|
27
27
|
const { concept, visualElement } = embed.data;
|
|
28
|
-
if (embed.data.concept.glossData) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
28
|
+
if (embed.data.concept.glossData) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_GlossEmbed.GlossEmbed, { embed });
|
|
29
29
|
if (embed.embedData.type === "inline") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineConcept, {
|
|
30
30
|
previewAlt,
|
|
31
31
|
linkText: embed.embedData.linkText,
|
|
@@ -54,10 +54,10 @@ const InlineConcept = (0, react.forwardRef)(({ linkText, copyright, visualElemen
|
|
|
54
54
|
asChild: true,
|
|
55
55
|
ref,
|
|
56
56
|
...rest,
|
|
57
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
57
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Embed_ConceptInlineTriggerButton.ConceptInlineTriggerButton, { children: linkText })
|
|
58
58
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ark_ui_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledPopoverContent, {
|
|
59
59
|
ref: contentRef,
|
|
60
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
60
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Concept_Concept.Concept, {
|
|
61
61
|
copyright,
|
|
62
62
|
visualElement,
|
|
63
63
|
title,
|
|
@@ -69,7 +69,7 @@ const InlineConcept = (0, react.forwardRef)(({ linkText, copyright, visualElemen
|
|
|
69
69
|
}) })]
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
const BlockConcept = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
72
|
+
const BlockConcept = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require__home_gunnar_kode_ndla_frontend_packages_packages_ndla_ui_src_Concept_Concept.Concept, {
|
|
73
73
|
...props,
|
|
74
74
|
"data-embed-type": "concept",
|
|
75
75
|
ref
|