@ndla/ui 55.0.12-alpha.0 → 55.0.13-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/dist/all-aout.js +0 -0
- package/dist/all.css +1 -0
- package/dist/panda.buildinfo.json +170 -0
- package/dist/styles.css +686 -0
- package/es/Article/Article.js +3 -4
- package/es/Article/ArticleByline.js +9 -9
- package/es/Article/ArticleFootNotes.js +4 -4
- package/es/AudioPlayer/AudioPlayer.js +142 -163
- package/es/AudioPlayer/Controls.js +187 -203
- package/es/AudioPlayer/SpeechControl.js +13 -11
- package/es/BlogPost/BlogPost.js +85 -23
- package/es/CampaignBlock/CampaignBlock.js +3 -4
- package/es/CodeBlock/CodeBlock.js +88 -96
- package/es/ContactBlock/ContactBlock.js +54 -40
- package/es/ContentLoader/index.js +7 -7
- package/es/CopyParagraphButton/CopyParagraphButton.js +4 -4
- package/es/Embed/AudioEmbed.js +5 -9
- package/es/Embed/BrightcoveEmbed.js +12 -15
- package/es/Embed/CodeEmbed.js +58 -10
- package/es/Embed/ConceptEmbed.js +15 -20
- package/es/Embed/ContentLinkEmbed.js +1 -1
- package/es/Embed/EmbedErrorPlaceholder.js +32 -17
- package/es/Embed/ExternalEmbed.js +7 -10
- package/es/Embed/FootnoteEmbed.js +3 -3
- package/es/Embed/H5pEmbed.js +1 -2
- package/es/Embed/IframeEmbed.js +8 -9
- package/es/Embed/ImageEmbed.js +167 -122
- package/es/Embed/RelatedContentEmbed.js +8 -10
- package/es/Embed/UuDisclaimerEmbed.js +2 -2
- package/es/Embed/conceptComponents.js +9 -9
- package/es/ErrorMessage/ErrorMessage.js +1 -1
- package/es/FactBox/FactBox.js +2 -2
- package/es/FileList/File.js +1 -1
- package/es/FileList/Format.js +3 -3
- package/es/FrontpageArticle/FrontpageArticle.js +1 -1
- package/es/Gloss/Gloss.js +9 -11
- package/es/Gloss/GlossExample.js +3 -4
- package/es/Grid/Grid.js +1 -1
- package/es/Image/Image.js +7 -8
- package/es/Image/ImageLink.js +1 -1
- package/es/KeyFigure/KeyFigure.js +2 -2
- package/es/LanguageSelector/LanguageSelector.js +2 -2
- package/es/LetterFilter/LetterFilter.js +1 -1
- package/es/LicenseByline/EmbedByline.js +5 -6
- package/es/LicenseByline/LicenseDescription.js +1 -1
- package/es/LicenseByline/LicenseLink.js +1 -2
- package/es/Messages/MessageBox.js +1 -1
- package/es/Notion/Notion.js +2 -2
- package/es/Notion/NotionImage.js +12 -57
- package/es/RelatedArticleList/RelatedArticleList.js +3 -3
- package/es/ResourceBox/ResourceBox.js +12 -17
- package/es/Search/ActiveFilters.js +1 -1
- package/es/Search/ContentTypeResult.js +9 -6
- package/es/Search/ContentTypeResultStyles.js +1 -1
- package/es/Search/IsPathToHighlight.js +1 -1
- package/es/Search/SearchField.js +6 -8
- package/es/Search/SearchResult.js +14 -19
- package/es/Search/SearchResultSleeve.js +14 -16
- package/es/SnackBar/SnackbarProvider.js +8 -11
- package/es/TagSelector/TagSelector.js +1 -1
- package/es/TagSelector/ariaMessages.js +6 -6
- package/es/TreeStructure/AddFolderButton.js +4 -6
- package/es/TreeStructure/ComboboxButton.js +4 -7
- package/es/TreeStructure/FolderItem.js +12 -15
- package/es/TreeStructure/FolderItems.js +3 -3
- package/es/TreeStructure/TreeStructure.js +9 -12
- package/es/TreeStructure/helperFunctions.js +1 -1
- package/es/ZendeskButton/ZendeskButton.js +55 -0
- package/es/i18n/formatNestedMessages.js +1 -1
- package/es/index.js +2 -1
- package/es/locale/messages-en.js +9 -8
- package/es/locale/messages-nb.js +9 -8
- package/es/locale/messages-nn.js +9 -8
- package/es/locale/messages-se.js +9 -8
- package/es/locale/messages-sma.js +9 -8
- package/es/styles.css +686 -0
- package/es/utils/relativeUrl.js +3 -3
- package/lib/Article/Article.js +3 -4
- package/lib/Article/ArticleByline.js +9 -9
- package/lib/Article/ArticleFootNotes.js +4 -4
- package/lib/AudioPlayer/AudioPlayer.d.ts +1 -2
- package/lib/AudioPlayer/AudioPlayer.js +142 -162
- package/lib/AudioPlayer/Controls.js +190 -205
- package/lib/AudioPlayer/SpeechControl.js +13 -11
- package/lib/BlogPost/BlogPost.d.ts +2 -2
- package/lib/BlogPost/BlogPost.js +85 -24
- package/lib/CampaignBlock/CampaignBlock.js +3 -4
- package/lib/CodeBlock/CodeBlock.d.ts +5 -8
- package/lib/CodeBlock/CodeBlock.js +88 -96
- package/lib/ContactBlock/ContactBlock.js +55 -43
- package/lib/ContentLoader/index.js +7 -7
- package/lib/CopyParagraphButton/CopyParagraphButton.js +4 -4
- package/lib/Embed/AudioEmbed.js +5 -9
- package/lib/Embed/BrightcoveEmbed.js +12 -15
- package/lib/Embed/CodeEmbed.js +56 -8
- package/lib/Embed/ConceptEmbed.js +15 -20
- package/lib/Embed/ContentLinkEmbed.js +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.d.ts +4 -3
- package/lib/Embed/EmbedErrorPlaceholder.js +32 -18
- package/lib/Embed/ExternalEmbed.js +7 -10
- package/lib/Embed/FootnoteEmbed.js +3 -3
- package/lib/Embed/H5pEmbed.js +1 -2
- package/lib/Embed/IframeEmbed.js +8 -9
- package/lib/Embed/ImageEmbed.d.ts +1 -2
- package/lib/Embed/ImageEmbed.js +167 -123
- package/lib/Embed/RelatedContentEmbed.js +8 -10
- package/lib/Embed/UuDisclaimerEmbed.js +2 -2
- package/lib/Embed/conceptComponents.js +9 -9
- package/lib/ErrorMessage/ErrorMessage.js +1 -1
- package/lib/FactBox/FactBox.js +2 -2
- package/lib/FileList/File.js +1 -1
- package/lib/FileList/Format.js +3 -3
- package/lib/FrontpageArticle/FrontpageArticle.js +1 -1
- package/lib/Gloss/Gloss.js +9 -11
- package/lib/Gloss/GlossExample.js +3 -4
- package/lib/Grid/Grid.js +1 -1
- package/lib/Image/Image.js +7 -8
- package/lib/Image/ImageLink.js +1 -1
- package/lib/KeyFigure/KeyFigure.js +2 -2
- package/lib/LanguageSelector/LanguageSelector.js +2 -2
- package/lib/LetterFilter/LetterFilter.js +1 -1
- package/lib/LicenseByline/EmbedByline.js +5 -6
- package/lib/LicenseByline/LicenseDescription.js +1 -1
- package/lib/LicenseByline/LicenseLink.js +1 -2
- package/lib/Messages/MessageBox.js +1 -1
- package/lib/Notion/Notion.js +2 -2
- package/lib/Notion/NotionImage.d.ts +1 -11
- package/lib/Notion/NotionImage.js +12 -59
- package/lib/RelatedArticleList/RelatedArticleList.js +3 -3
- package/lib/ResourceBox/ResourceBox.js +13 -18
- package/lib/Search/ActiveFilters.js +1 -1
- package/lib/Search/ContentTypeResult.js +9 -6
- package/lib/Search/ContentTypeResultStyles.js +1 -1
- package/lib/Search/IsPathToHighlight.js +1 -1
- package/lib/Search/SearchField.js +6 -8
- package/lib/Search/SearchResult.js +14 -19
- package/lib/Search/SearchResultSleeve.js +14 -16
- package/lib/SnackBar/SnackbarProvider.js +8 -11
- package/lib/TagSelector/TagSelector.js +1 -1
- package/lib/TagSelector/ariaMessages.js +6 -6
- package/lib/TreeStructure/AddFolderButton.js +4 -6
- package/lib/TreeStructure/ComboboxButton.js +4 -7
- package/lib/TreeStructure/FolderItem.js +12 -15
- package/lib/TreeStructure/FolderItems.js +3 -3
- package/lib/TreeStructure/TreeStructure.js +9 -12
- package/lib/TreeStructure/helperFunctions.js +1 -1
- package/lib/ZendeskButton/ZendeskButton.d.ts +19 -0
- package/lib/ZendeskButton/ZendeskButton.js +61 -0
- package/lib/i18n/formatNestedMessages.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/locale/messages-en.d.ts +1 -0
- package/lib/locale/messages-en.js +9 -8
- package/lib/locale/messages-nb.d.ts +1 -0
- package/lib/locale/messages-nb.js +9 -8
- package/lib/locale/messages-nn.d.ts +1 -0
- package/lib/locale/messages-nn.js +9 -8
- package/lib/locale/messages-se.d.ts +1 -0
- package/lib/locale/messages-se.js +9 -8
- package/lib/locale/messages-sma.d.ts +1 -0
- package/lib/locale/messages-sma.js +9 -8
- package/lib/styles.css +686 -0
- package/lib/types.d.ts +1 -0
- package/lib/utils/relativeUrl.js +3 -3
- package/package.json +17 -12
- package/src/AudioPlayer/AudioPlayer.tsx +139 -176
- package/src/AudioPlayer/Controls.tsx +210 -250
- package/src/AudioPlayer/SpeechControl.tsx +9 -7
- package/src/BlogPost/BlogPost.tsx +82 -58
- package/src/CodeBlock/CodeBlock.stories.tsx +0 -43
- package/src/CodeBlock/CodeBlock.tsx +91 -202
- package/src/ContactBlock/ContactBlock.tsx +10 -2
- package/src/Embed/CodeEmbed.stories.tsx +95 -0
- package/src/Embed/CodeEmbed.tsx +62 -7
- package/src/Embed/ConceptEmbed.tsx +1 -9
- package/src/Embed/EmbedErrorPlaceholder.tsx +31 -28
- package/src/Embed/ImageEmbed.stories.tsx +53 -11
- package/src/Embed/ImageEmbed.tsx +162 -166
- package/src/Notion/NotionImage.tsx +4 -54
- package/src/ResourceBox/ResourceBox.tsx +3 -15
- package/src/Search/ContentTypeResult.tsx +9 -3
- package/src/Search/SearchResultSleeve.tsx +5 -2
- package/src/ZendeskButton/ZendeskButton.tsx +58 -0
- package/src/index.ts +4 -0
- package/src/locale/messages-en.ts +1 -0
- package/src/locale/messages-nb.ts +1 -0
- package/src/locale/messages-nn.ts +1 -0
- package/src/locale/messages-se.ts +1 -0
- package/src/locale/messages-sma.ts +1 -0
- package/src/types.ts +2 -0
- package/src/Image/__tests__/Image-test.tsx +0 -66
- package/src/Image/__tests__/__snapshots__/Image-test.tsx.snap +0 -194
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
10
|
+
import type { CodeEmbedData, CodeMetaData } from "@ndla/types-embed";
|
|
11
|
+
import CodeEmbed from "./CodeEmbed";
|
|
12
|
+
|
|
13
|
+
const codeEmbedData: CodeEmbedData = {
|
|
14
|
+
resource: "code-block",
|
|
15
|
+
title: "Litt css i hverdagen",
|
|
16
|
+
codeContent: `<div class="demo-content">
|
|
17
|
+
<h2>Lorem ipsum</h2>
|
|
18
|
+
<p>
|
|
19
|
+
<b>Lorem ipsum</b><br/>
|
|
20
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
21
|
+
</p>
|
|
22
|
+
<p>
|
|
23
|
+
<b>Lorem ipsum</b><br/>
|
|
24
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
25
|
+
</p>
|
|
26
|
+
<p>
|
|
27
|
+
<b>Lorem ipsum</b><br/>
|
|
28
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
29
|
+
</p>
|
|
30
|
+
</div>`,
|
|
31
|
+
codeFormat: "html",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const codeEmbed: CodeMetaData = {
|
|
35
|
+
status: "success",
|
|
36
|
+
resource: "code-block",
|
|
37
|
+
embedData: codeEmbedData,
|
|
38
|
+
data: {
|
|
39
|
+
highlightedCode: `<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>demo-content<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
|
|
40
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>h2</span><span class="token punctuation">></span></span>Lorem ipsum<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>h2</span><span class="token punctuation">></span></span>
|
|
41
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>
|
|
42
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>b</span><span class="token punctuation">></span></span>Lorem ipsum<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>b</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>br</span><span class="token punctuation">/></span></span>
|
|
43
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>span</span><span class="token punctuation">></span></span>is simply dummy text of the printing and typesetting industry<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>span</span><span class="token punctuation">></span></span>
|
|
44
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
|
|
45
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>
|
|
46
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>b</span><span class="token punctuation">></span></span>Lorem ipsum<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>b</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>br</span><span class="token punctuation">/></span></span>
|
|
47
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>span</span><span class="token punctuation">></span></span>is simply dummy text of the printing and typesetting industry<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>span</span><span class="token punctuation">></span></span>
|
|
48
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
|
|
49
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>
|
|
50
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>b</span><span class="token punctuation">></span></span>Lorem ipsum<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>b</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>br</span><span class="token punctuation">/></span></span>
|
|
51
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>span</span><span class="token punctuation">></span></span>is simply dummy text of the printing and typesetting industry<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>span</span><span class="token punctuation">></span></span>
|
|
52
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span>
|
|
53
|
+
<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>`,
|
|
54
|
+
decodedContent: `<div class="demo-content">
|
|
55
|
+
<h2>Lorem ipsum</h2>
|
|
56
|
+
<p>
|
|
57
|
+
<b>Lorem ipsum</b><br/>
|
|
58
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
59
|
+
</p>
|
|
60
|
+
<p>
|
|
61
|
+
<b>Lorem ipsum</b><br/>
|
|
62
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
63
|
+
</p>
|
|
64
|
+
<p>
|
|
65
|
+
<b>Lorem ipsum</b><br/>
|
|
66
|
+
<span>is simply dummy text of the printing and typesetting industry</span>
|
|
67
|
+
</p>
|
|
68
|
+
</div>`,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default {
|
|
73
|
+
title: "Embeds/CodeEmbed",
|
|
74
|
+
component: CodeEmbed,
|
|
75
|
+
tags: ["autodocs"],
|
|
76
|
+
parameters: {
|
|
77
|
+
inlineStories: true,
|
|
78
|
+
},
|
|
79
|
+
args: {
|
|
80
|
+
embed: codeEmbed,
|
|
81
|
+
},
|
|
82
|
+
} as Meta<typeof CodeEmbed>;
|
|
83
|
+
|
|
84
|
+
export const Default: StoryObj<typeof CodeEmbed> = {};
|
|
85
|
+
|
|
86
|
+
export const Failed: StoryObj<typeof CodeEmbed> = {
|
|
87
|
+
args: {
|
|
88
|
+
embed: {
|
|
89
|
+
resource: "code-block",
|
|
90
|
+
embedData: codeEmbedData,
|
|
91
|
+
status: "error",
|
|
92
|
+
message: "Something horrible happened",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
package/src/Embed/CodeEmbed.tsx
CHANGED
|
@@ -6,24 +6,79 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { useEffect, useState } from "react";
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
11
|
+
import { Copy } from "@ndla/icons/action";
|
|
12
|
+
import { Done } from "@ndla/icons/editor";
|
|
13
|
+
import { Button, Figure } from "@ndla/primitives";
|
|
14
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
9
15
|
import { CodeMetaData } from "@ndla/types-embed";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
16
|
+
import { copyTextToClipboard } from "@ndla/util";
|
|
17
|
+
import { CodeBlock, codeLanguageOptions } from "../CodeBlock";
|
|
18
|
+
import { ICodeLangugeOption } from "../CodeBlock/codeLanguageOptions";
|
|
19
|
+
|
|
20
|
+
// TODO: We need an error state for this
|
|
12
21
|
|
|
13
22
|
interface Props {
|
|
14
23
|
embed: CodeMetaData;
|
|
15
24
|
}
|
|
25
|
+
|
|
26
|
+
const StyledFigCaption = styled("figcaption", {
|
|
27
|
+
base: {
|
|
28
|
+
textStyle: "label.large",
|
|
29
|
+
fontWeight: "bold",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const StyledFigure = styled(Figure, {
|
|
34
|
+
base: {
|
|
35
|
+
// We apply margin here to allow for the float and size props on figure to work as intended.
|
|
36
|
+
"& > *:not(:where(:first-child))": {
|
|
37
|
+
marginBlockStart: "xsmall",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const getTitleFromFormat = (format: string) => {
|
|
43
|
+
const selectedLanguage = codeLanguageOptions.find((item: ICodeLangugeOption) => item.format === format);
|
|
44
|
+
if (selectedLanguage) {
|
|
45
|
+
return selectedLanguage.title;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
};
|
|
49
|
+
|
|
16
50
|
const CodeEmbed = ({ embed }: Props) => {
|
|
51
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
52
|
+
const { t } = useTranslation();
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (isCopied) {
|
|
56
|
+
const timer = setInterval(() => setIsCopied(false), 3000);
|
|
57
|
+
// ensure interval is cleared - also if unmounted
|
|
58
|
+
return () => {
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}, [isCopied]);
|
|
63
|
+
|
|
17
64
|
return (
|
|
18
|
-
<
|
|
65
|
+
<StyledFigure>
|
|
66
|
+
<StyledFigCaption>{embed.embedData.title || getTitleFromFormat(embed.embedData.codeFormat)}</StyledFigCaption>
|
|
19
67
|
<CodeBlock
|
|
20
|
-
title={embed.embedData.title}
|
|
21
|
-
code={embed.status === "success" ? embed.data.decodedContent : ""}
|
|
22
68
|
highlightedCode={embed.status === "success" ? embed.data.highlightedCode : ""}
|
|
23
69
|
format={embed.embedData.codeFormat}
|
|
24
|
-
showCopy
|
|
25
70
|
/>
|
|
26
|
-
|
|
71
|
+
<Button
|
|
72
|
+
variant="secondary"
|
|
73
|
+
onClick={() => {
|
|
74
|
+
copyTextToClipboard(embed.status === "success" ? embed.data.decodedContent : "");
|
|
75
|
+
setIsCopied(true);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{isCopied ? <Done /> : <Copy />}
|
|
79
|
+
{isCopied ? t("codeBlock.copiedCode") : t("codeBlock.copyCode")}
|
|
80
|
+
</Button>
|
|
81
|
+
</StyledFigure>
|
|
27
82
|
);
|
|
28
83
|
};
|
|
29
84
|
|
|
@@ -330,9 +330,6 @@ export const BlockConcept = ({
|
|
|
330
330
|
const anchorRef = useRef<HTMLDivElement>(null);
|
|
331
331
|
const [modalPos, setModalPos] = useState(-9999);
|
|
332
332
|
|
|
333
|
-
const visualElementType =
|
|
334
|
-
visualElement?.embedData.resource === "brightcove" ? "video" : visualElement?.embedData.resource;
|
|
335
|
-
|
|
336
333
|
const onOpenChange = useCallback((open: boolean) => {
|
|
337
334
|
if (open) {
|
|
338
335
|
const anchor = anchorRef.current;
|
|
@@ -369,16 +366,11 @@ export const BlockConcept = ({
|
|
|
369
366
|
>
|
|
370
367
|
{visualElement.resource === "image" ? (
|
|
371
368
|
<NotionImage
|
|
372
|
-
type={visualElementType}
|
|
373
369
|
src={visualElement.data.image.imageUrl}
|
|
374
370
|
alt={visualElement.data.alttext.alttext}
|
|
375
371
|
/>
|
|
376
372
|
) : metaImage ? (
|
|
377
|
-
<NotionImage
|
|
378
|
-
type={visualElementType}
|
|
379
|
-
src={metaImage?.url ?? ""}
|
|
380
|
-
alt={metaImage?.alt ?? ""}
|
|
381
|
-
/>
|
|
373
|
+
<NotionImage src={metaImage?.url ?? ""} alt={metaImage?.alt ?? ""} />
|
|
382
374
|
) : undefined}
|
|
383
375
|
</StyledButton>
|
|
384
376
|
</Trigger>
|
|
@@ -7,51 +7,54 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ReactNode } from "react";
|
|
10
|
-
import styled from "@emotion/styled";
|
|
11
|
-
import { colors, spacing } from "@ndla/core";
|
|
12
10
|
import { WarningOutline } from "@ndla/icons/common";
|
|
13
|
-
import { Figure,
|
|
11
|
+
import { Figure, type FigureFloat, type FigureSize } from "@ndla/primitives";
|
|
12
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
14
13
|
import { EmbedByline } from "../LicenseByline";
|
|
15
14
|
import { EmbedBylineErrorProps } from "../LicenseByline/EmbedByline";
|
|
16
15
|
|
|
17
16
|
interface Props {
|
|
18
17
|
type: EmbedBylineErrorProps["type"];
|
|
19
|
-
figureType?:
|
|
18
|
+
figureType?: FigureSize;
|
|
19
|
+
float?: FigureFloat;
|
|
20
20
|
children?: ReactNode;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const ErrorPlaceholder = styled
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const ErrorPlaceholder = styled("div", {
|
|
24
|
+
base: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
backgroundColor: "surface.disabled",
|
|
29
|
+
height: "surface.xsmall",
|
|
30
|
+
"& svg": {
|
|
31
|
+
fill: "text.subtle",
|
|
32
|
+
height: "90%",
|
|
33
|
+
width: "90%",
|
|
34
|
+
},
|
|
35
|
+
"&[data-embed-type='audio']": {
|
|
36
|
+
height: "surface.3xsmall",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
41
|
+
const StyledFigure = styled(Figure, {
|
|
42
|
+
base: {
|
|
43
|
+
"& > *:not(:first-child)": {
|
|
44
|
+
marginBlockStart: "3xsmall",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
39
48
|
|
|
40
|
-
const
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
gap: ${spacing.xsmall};
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
const EmbedErrorPlaceholder = ({ type, children, figureType }: Props) => {
|
|
49
|
+
const EmbedErrorPlaceholder = ({ type, children, figureType, float }: Props) => {
|
|
47
50
|
return (
|
|
48
|
-
<StyledFigure
|
|
51
|
+
<StyledFigure size={figureType} float={float}>
|
|
49
52
|
{children ?? (
|
|
50
53
|
<ErrorPlaceholder data-embed-type={type}>
|
|
51
54
|
<WarningOutline />
|
|
52
55
|
</ErrorPlaceholder>
|
|
53
56
|
)}
|
|
54
|
-
<EmbedByline error type={type}
|
|
57
|
+
<EmbedByline error type={type} />
|
|
55
58
|
</StyledFigure>
|
|
56
59
|
);
|
|
57
60
|
};
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ReactNode } from "react";
|
|
10
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
10
|
+
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
11
|
+
import { Text } from "@ndla/primitives";
|
|
12
|
+
import { css } from "@ndla/styled-system/css";
|
|
13
|
+
import { styled } from "@ndla/styled-system/jsx";
|
|
11
14
|
import { IImageMetaInformationV3 } from "@ndla/types-backend/image-api";
|
|
12
15
|
import { ImageEmbedData } from "@ndla/types-embed";
|
|
13
16
|
import ImageEmbed from "./ImageEmbed";
|
|
14
17
|
import { ArticleWrapper } from "../Article";
|
|
18
|
+
import { Grid } from "../Grid";
|
|
15
19
|
import LayoutItem, { OneColumn } from "../Layout";
|
|
16
20
|
|
|
17
21
|
const embedData: ImageEmbedData = {
|
|
@@ -184,26 +188,27 @@ export const Cropped: StoryObj<typeof ImageEmbed> = {
|
|
|
184
188
|
};
|
|
185
189
|
|
|
186
190
|
const TextWrapper = ({ children }: { children: ReactNode }) => (
|
|
187
|
-
|
|
188
|
-
|
|
191
|
+
// TODO: Replace this with regular css once we drop emotion
|
|
192
|
+
<styled.div css={css.raw({ "& > p": { marginBlock: "medium", width: "100%" } })}>
|
|
193
|
+
<Text>
|
|
189
194
|
Du har en kjempegod idé til en kortfilm. Men det koster mange penger å produsere filmen. Derfor er du avhengig av
|
|
190
195
|
at noen tenner på idéen din og bestemmer seg for å bruke ressurser på nettopp dette prosjektet.
|
|
191
|
-
</
|
|
196
|
+
</Text>
|
|
192
197
|
{children}
|
|
193
198
|
|
|
194
|
-
<
|
|
199
|
+
<Text>
|
|
195
200
|
Pitching er også en god måte å bevisstgjøre seg selv på. Når du pitcher, blir idéen og historien i den filmen du
|
|
196
201
|
planlegger å lage, tydeligere for både deg selv og dem du eventuelt jobber sammen med i klassen.
|
|
197
|
-
</
|
|
198
|
-
<
|
|
202
|
+
</Text>
|
|
203
|
+
<Text>
|
|
199
204
|
Pitching er også en god måte å bevisstgjøre seg selv på. Når du pitcher, blir idéen og historien i den filmen du
|
|
200
205
|
planlegger å lage, tydeligere for både deg selv og dem du eventuelt jobber sammen med i klassen.
|
|
201
|
-
</
|
|
202
|
-
<
|
|
206
|
+
</Text>
|
|
207
|
+
<Text>
|
|
203
208
|
Pitching er også en god måte å bevisstgjøre seg selv på. Når du pitcher, blir idéen og historien i den filmen du
|
|
204
209
|
planlegger å lage, tydeligere for både deg selv og dem du eventuelt jobber sammen med i klassen.
|
|
205
|
-
</
|
|
206
|
-
|
|
210
|
+
</Text>
|
|
211
|
+
</styled.div>
|
|
207
212
|
);
|
|
208
213
|
|
|
209
214
|
export const FloatLeft: StoryObj<typeof ImageEmbed> = {
|
|
@@ -324,3 +329,40 @@ export const FloatLeftExtraSmall: StoryObj<typeof ImageEmbed> = {
|
|
|
324
329
|
</TextWrapper>
|
|
325
330
|
),
|
|
326
331
|
};
|
|
332
|
+
|
|
333
|
+
export const In2x2Grid: StoryFn<typeof ImageEmbed> = (args) => {
|
|
334
|
+
const items = new Array(4).fill(
|
|
335
|
+
<ImageEmbed
|
|
336
|
+
{...args}
|
|
337
|
+
embed={{
|
|
338
|
+
resource: "image",
|
|
339
|
+
status: "success",
|
|
340
|
+
embedData: {
|
|
341
|
+
...embedData,
|
|
342
|
+
align: "left",
|
|
343
|
+
border: "true",
|
|
344
|
+
},
|
|
345
|
+
data: metaData,
|
|
346
|
+
}}
|
|
347
|
+
/>,
|
|
348
|
+
);
|
|
349
|
+
return <Grid columns="2x2">{items}</Grid>;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export const In4Grid: StoryFn<typeof ImageEmbed> = (args) => {
|
|
353
|
+
const items = new Array(4).fill(
|
|
354
|
+
<ImageEmbed
|
|
355
|
+
{...args}
|
|
356
|
+
embed={{
|
|
357
|
+
resource: "image",
|
|
358
|
+
status: "success",
|
|
359
|
+
embedData: {
|
|
360
|
+
...embedData,
|
|
361
|
+
border: "true",
|
|
362
|
+
},
|
|
363
|
+
data: metaData,
|
|
364
|
+
}}
|
|
365
|
+
/>,
|
|
366
|
+
);
|
|
367
|
+
return <Grid columns="4">{items}</Grid>;
|
|
368
|
+
};
|