@ndla/ui 54.0.2 → 54.0.4
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 +10 -9
- package/es/BlogPost/BlogPost.js +5 -4
- package/es/CampaignBlock/CampaignBlock.js +7 -6
- package/es/ContactBlock/ContactBlock.js +15 -13
- package/es/ContentTypeBadge/ContentTypeBadge.js +7 -6
- package/es/Embed/ImageEmbed.js +33 -21
- package/es/Embed/conceptComponents.js +10 -9
- package/es/FactBox/FactBox.js +7 -6
- package/es/Figure/Figure.js +11 -10
- package/es/Layout/LayoutItem.js +3 -2
- package/es/Layout/OneColumn.js +4 -2
- package/es/Layout/PageContainer.js +4 -2
- package/es/Logo/Logo.js +4 -3
- package/es/Notion/NotionImage.js +4 -3
- package/es/Resource/BlockResource.js +7 -6
- package/es/Resource/ListResource.js +7 -6
- package/es/Search/ContentTypeResult.js +2 -1
- package/es/Search/SearchResultSleeve.js +9 -8
- package/es/Table/Table.js +7 -6
- package/es/TagSelector/DropdownIndicator.js +2 -1
- package/es/TagSelector/Input.js +2 -1
- package/es/TagSelector/Menu.js +2 -1
- package/es/TagSelector/Option.js +4 -2
- package/es/TagSelector/ValueButton.js +3 -1
- package/lib/Article/Article.d.ts +1 -0
- package/lib/Article/Article.js +10 -10
- package/lib/Article/ArticleByline.d.ts +1 -1
- package/lib/Article/ArticleFootNotes.d.ts +1 -1
- package/lib/Article/ArticleHeaderWrapper.d.ts +1 -1
- package/lib/Article/ArticleParagraph.d.ts +1 -1
- package/lib/AudioPlayer/AudioPlayer.d.ts +1 -1
- package/lib/AudioPlayer/Controls.d.ts +1 -1
- package/lib/AudioPlayer/SpeechControl.d.ts +1 -1
- package/lib/BlogPost/BlogPost.js +6 -4
- package/lib/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/lib/Breadcrumb/HomeBreadcrumb.d.ts +1 -1
- package/lib/CampaignBlock/CampaignBlock.js +7 -7
- package/lib/CodeBlock/CodeBlock.d.ts +1 -1
- package/lib/ContactBlock/ContactBlock.js +14 -14
- package/lib/ContentLoader/index.d.ts +1 -1
- package/lib/ContentPlaceholder/ContentPlaceholder.d.ts +1 -1
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +1 -0
- package/lib/ContentTypeBadge/ContentTypeBadge.js +7 -7
- package/lib/CopyParagraphButton/CopyParagraphButton.d.ts +1 -1
- package/lib/CreatedBy/CreatedBy.d.ts +1 -1
- package/lib/Embed/AudioEmbed.d.ts +1 -1
- package/lib/Embed/BrightcoveEmbed.d.ts +1 -1
- package/lib/Embed/CodeEmbed.d.ts +1 -1
- package/lib/Embed/ConceptEmbed.d.ts +2 -2
- package/lib/Embed/ConceptListEmbed.d.ts +1 -1
- package/lib/Embed/ContentLinkEmbed.d.ts +1 -1
- package/lib/Embed/CopyrightEmbed.d.ts +1 -1
- package/lib/Embed/EmbedErrorPlaceholder.d.ts +1 -1
- package/lib/Embed/ExternalEmbed.d.ts +1 -1
- package/lib/Embed/FootnoteEmbed.d.ts +1 -1
- package/lib/Embed/H5pEmbed.d.ts +1 -1
- package/lib/Embed/IframeEmbed.d.ts +1 -1
- package/lib/Embed/ImageEmbed.js +34 -21
- package/lib/Embed/RelatedContentEmbed.d.ts +1 -1
- package/lib/Embed/UnknownEmbed.d.ts +1 -1
- package/lib/Embed/UuDisclaimerEmbed.d.ts +1 -1
- package/lib/Embed/conceptComponents.d.ts +1 -0
- package/lib/Embed/conceptComponents.js +11 -9
- package/lib/ErrorMessage/ErrorMessage.d.ts +1 -1
- package/lib/ErrorMessage/ErrorResourceAccessDenied.d.ts +1 -1
- package/lib/ExpandableBox/ExpandableBox.d.ts +2 -2
- package/lib/FactBox/FactBox.d.ts +1 -0
- package/lib/FactBox/FactBox.js +7 -7
- package/lib/Figure/Figure.d.ts +1 -0
- package/lib/Figure/Figure.js +12 -10
- package/lib/FileList/File.d.ts +1 -1
- package/lib/FileList/FileList.d.ts +1 -1
- package/lib/FileList/Format.d.ts +1 -1
- package/lib/FileList/PdfFile.d.ts +1 -1
- package/lib/FrontpageArticle/FrontpageArticle.d.ts +1 -1
- package/lib/Gloss/Gloss.d.ts +1 -1
- package/lib/Gloss/GlossExample.d.ts +1 -1
- package/lib/Grid/Grid.d.ts +2 -2
- package/lib/Hero/Hero.d.ts +8 -8
- package/lib/Image/Image.d.ts +1 -1
- package/lib/Image/ImageLink.d.ts +1 -1
- package/lib/KeyFigure/KeyFigure.d.ts +1 -1
- package/lib/LanguageSelector/LanguageSelector.d.ts +1 -1
- package/lib/Layout/LayoutItem.d.ts +1 -0
- package/lib/Layout/LayoutItem.js +3 -3
- package/lib/Layout/OneColumn.d.ts +1 -0
- package/lib/Layout/OneColumn.js +3 -3
- package/lib/Layout/PageContainer.d.ts +1 -0
- package/lib/Layout/PageContainer.js +3 -3
- package/lib/LetterFilter/LetterFilter.d.ts +1 -1
- package/lib/LicenseByline/EmbedByline.d.ts +1 -1
- package/lib/LicenseByline/LicenseDescription.d.ts +1 -1
- package/lib/LicenseByline/LicenseLink.d.ts +1 -1
- package/lib/LinkBlock/LinkBlock.d.ts +1 -1
- package/lib/LinkBlock/LinkBlockSection.d.ts +1 -1
- package/lib/Logo/Logo.js +4 -4
- package/lib/Logo/SvgLogo.d.ts +1 -1
- package/lib/MediaList/MediaList.d.ts +7 -7
- package/lib/Messages/MessageBanner.d.ts +1 -1
- package/lib/Messages/MessageBox.d.ts +1 -1
- package/lib/MyNdla/Resource/Folder.d.ts +1 -1
- package/lib/Notion/Notion.d.ts +1 -1
- package/lib/Notion/NotionImage.js +5 -3
- package/lib/ProgrammeCard/ProgrammeCard.d.ts +1 -1
- package/lib/RelatedArticleList/RelatedArticleList.d.ts +2 -2
- package/lib/Resource/BlockResource.d.ts +1 -0
- package/lib/Resource/BlockResource.js +7 -7
- package/lib/Resource/ListResource.d.ts +1 -0
- package/lib/Resource/ListResource.js +7 -7
- package/lib/Resource/resourceComponents.d.ts +4 -4
- package/lib/Resource/storyComponents.d.ts +1 -1
- package/lib/ResourceBox/ResourceBox.d.ts +1 -1
- package/lib/Search/ActiveFilters.d.ts +1 -1
- package/lib/Search/ContentTypeResult.js +3 -1
- package/lib/Search/LoadingWrapper.d.ts +1 -1
- package/lib/Search/SearchField.d.ts +1 -1
- package/lib/Search/SearchFieldForm.d.ts +1 -1
- package/lib/Search/SearchResult.d.ts +2 -2
- package/lib/Search/SearchResultSleeve.js +10 -8
- package/lib/SnackBar/DefaultSnackbar.d.ts +1 -1
- package/lib/SnackBar/SnackbarProvider.d.ts +2 -2
- package/lib/Table/Table.js +7 -7
- package/lib/TagSelector/Control.d.ts +1 -1
- package/lib/TagSelector/DropdownIndicator.js +2 -2
- package/lib/TagSelector/Input.d.ts +1 -0
- package/lib/TagSelector/Input.js +3 -1
- package/lib/TagSelector/Menu.d.ts +1 -0
- package/lib/TagSelector/Menu.js +3 -1
- package/lib/TagSelector/MenuList.d.ts +1 -1
- package/lib/TagSelector/Option.d.ts +1 -0
- package/lib/TagSelector/Option.js +4 -2
- package/lib/TagSelector/SelectContainer.d.ts +1 -1
- package/lib/TagSelector/TagSelector.d.ts +1 -1
- package/lib/TagSelector/ValueButton.d.ts +1 -0
- package/lib/TagSelector/ValueButton.js +3 -1
- package/lib/TreeStructure/AddFolderButton.d.ts +1 -1
- package/lib/TreeStructure/FolderItem.d.ts +1 -1
- package/lib/TreeStructure/FolderItems.d.ts +1 -1
- package/lib/TreeStructure/TreeStructure.d.ts +1 -1
- package/package.json +11 -11
- package/src/Article/Article.tsx +1 -0
- package/src/BlogPost/BlogPost.tsx +1 -0
- package/src/CampaignBlock/CampaignBlock.tsx +1 -0
- package/src/ContactBlock/ContactBlock.tsx +1 -0
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +1 -0
- package/src/Embed/ImageEmbed.tsx +30 -17
- package/src/Embed/conceptComponents.tsx +1 -0
- package/src/FactBox/FactBox.tsx +1 -0
- package/src/Figure/Figure.tsx +1 -0
- package/src/Layout/LayoutItem.tsx +1 -0
- package/src/Layout/OneColumn.tsx +1 -0
- package/src/Layout/PageContainer.tsx +1 -0
- package/src/Logo/Logo.tsx +1 -0
- package/src/Notion/NotionImage.tsx +1 -0
- package/src/Resource/BlockResource.tsx +1 -0
- package/src/Resource/ListResource.tsx +1 -0
- package/src/Search/ContentTypeResult.tsx +1 -0
- package/src/Search/SearchResultSleeve.tsx +1 -0
- package/src/Table/Table.tsx +1 -0
- package/src/TagSelector/DropdownIndicator.tsx +1 -0
- package/src/TagSelector/Input.tsx +1 -0
- package/src/TagSelector/Menu.tsx +1 -0
- package/src/TagSelector/Option.tsx +1 -0
- package/src/TagSelector/ValueButton.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "54.0.
|
|
3
|
+
"version": "54.0.4",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/accordion": "^4.0.
|
|
35
|
-
"@ndla/button": "^13.0.
|
|
34
|
+
"@ndla/accordion": "^4.0.5",
|
|
35
|
+
"@ndla/button": "^13.0.5",
|
|
36
36
|
"@ndla/core": "^5.0.1",
|
|
37
37
|
"@ndla/dropdown-menu": "^1.0.38",
|
|
38
|
-
"@ndla/forms": "^8.0.
|
|
38
|
+
"@ndla/forms": "^8.0.5",
|
|
39
39
|
"@ndla/hooks": "^2.1.7",
|
|
40
|
-
"@ndla/icons": "^6.1.
|
|
40
|
+
"@ndla/icons": "^6.1.8",
|
|
41
41
|
"@ndla/licenses": "^7.2.6",
|
|
42
|
-
"@ndla/modal": "^6.0.
|
|
43
|
-
"@ndla/notion": "^7.0.
|
|
44
|
-
"@ndla/safelink": "^5.1.
|
|
42
|
+
"@ndla/modal": "^6.0.4",
|
|
43
|
+
"@ndla/notion": "^7.0.4",
|
|
44
|
+
"@ndla/safelink": "^5.1.8",
|
|
45
45
|
"@ndla/tooltip": "^8.0.1",
|
|
46
46
|
"@ndla/typography": "^0.4.22",
|
|
47
47
|
"@ndla/util": "^4.0.4",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"react-router-dom": "> 6.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@ndla/types-backend": "^0.2.
|
|
70
|
-
"@ndla/types-embed": "^4.1.
|
|
69
|
+
"@ndla/types-backend": "^0.2.86",
|
|
70
|
+
"@ndla/types-embed": "^4.1.8",
|
|
71
71
|
"css-loader": "^6.7.3",
|
|
72
72
|
"mini-css-extract-plugin": "^2.7.5",
|
|
73
73
|
"sass-loader": "^13.2.2",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "c3c7ec99f9fa1bcd8e6d6f0c96d77f59773323cc"
|
|
81
81
|
}
|
package/src/Article/Article.tsx
CHANGED
package/src/Embed/ImageEmbed.tsx
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/** @jsxImportSource @emotion/react */
|
|
9
10
|
import parse from "html-react-parser";
|
|
10
11
|
import { MouseEventHandler, ReactNode, useMemo, useState } from "react";
|
|
11
12
|
import { useTranslation } from "react-i18next";
|
|
@@ -141,8 +142,13 @@ const ImageEmbed = ({
|
|
|
141
142
|
renderContext = "article",
|
|
142
143
|
children,
|
|
143
144
|
}: Props) => {
|
|
144
|
-
const [isBylineHidden, setIsBylineHidden] = useState(hideByline(embed.embedData
|
|
145
|
+
const [isBylineHidden, setIsBylineHidden] = useState(hideByline(embed.embedData));
|
|
145
146
|
const [imageSizes, setImageSizes] = useState<string | undefined>(undefined);
|
|
147
|
+
// Full-size figures automatically get a margin of {spacing.normal} on its y-axis if a float is not set (or if float is an empty string).
|
|
148
|
+
// This adds some margin to normal figures within an article, but should not happen for figures in a grid.
|
|
149
|
+
const [floatAttr, setFloatAttr] = useState<{ "data-float"?: string }>(() =>
|
|
150
|
+
inGrid && !embed.embedData.align ? {} : { "data-float": embed.embedData.align },
|
|
151
|
+
);
|
|
146
152
|
|
|
147
153
|
const parsedDescription = useMemo(() => {
|
|
148
154
|
if (embed.embedData.caption || renderContext === "article") {
|
|
@@ -161,10 +167,6 @@ const ImageEmbed = ({
|
|
|
161
167
|
|
|
162
168
|
const { data, embedData } = embed;
|
|
163
169
|
|
|
164
|
-
// Full-size figures automatically get a margin of {spacing.normal} on its y-axis if a float is not set (or if float is an empty string).
|
|
165
|
-
// This adds some margin to normal figures within an article, but should not happen for figures in a grid.
|
|
166
|
-
const floatAttr = inGrid && !embedData.align ? {} : { "data-float": embedData.align };
|
|
167
|
-
|
|
168
170
|
const altText = embedData.alt || "";
|
|
169
171
|
|
|
170
172
|
const figureType = getFigureType(embedData.size, embedData.align);
|
|
@@ -181,7 +183,7 @@ const ImageEmbed = ({
|
|
|
181
183
|
<ImageWrapper
|
|
182
184
|
src={!isCopyrighted ? canonicalUrl?.(data) : undefined}
|
|
183
185
|
crop={crop}
|
|
184
|
-
|
|
186
|
+
embedData={embedData}
|
|
185
187
|
pagePath={path}
|
|
186
188
|
>
|
|
187
189
|
<Image
|
|
@@ -194,10 +196,20 @@ const ImageEmbed = ({
|
|
|
194
196
|
border={embedData.border}
|
|
195
197
|
expandButton={
|
|
196
198
|
<ExpandButton
|
|
197
|
-
|
|
199
|
+
embedData={embedData}
|
|
198
200
|
expanded={!!imageSizes}
|
|
199
201
|
bylineHidden={isBylineHidden}
|
|
200
|
-
onExpand={() =>
|
|
202
|
+
onExpand={() => {
|
|
203
|
+
if (!imageSizes) {
|
|
204
|
+
setImageSizes(expandedSizes);
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
setFloatAttr({});
|
|
207
|
+
}, 400); //Removing the float parameter too quickly causes the image to be resized from left regardless
|
|
208
|
+
} else {
|
|
209
|
+
setImageSizes(undefined);
|
|
210
|
+
setFloatAttr({ "data-float": embedData.align });
|
|
211
|
+
}
|
|
212
|
+
}}
|
|
201
213
|
onHideByline={() => setIsBylineHidden((p) => !p)}
|
|
202
214
|
/>
|
|
203
215
|
}
|
|
@@ -235,15 +247,16 @@ interface ImageWrapperProps {
|
|
|
235
247
|
endX: number;
|
|
236
248
|
endY: number;
|
|
237
249
|
};
|
|
238
|
-
|
|
250
|
+
embedData: ImageEmbedData;
|
|
239
251
|
}
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
|
|
253
|
+
const hideByline = (embed: ImageEmbedData): boolean => {
|
|
254
|
+
return (!!embed.size && embed.size.endsWith("-hide-byline")) || embed.hideByline === "true";
|
|
242
255
|
};
|
|
243
256
|
|
|
244
|
-
const ImageWrapper = ({ src, crop,
|
|
257
|
+
const ImageWrapper = ({ src, crop, children, pagePath, embedData }: ImageWrapperProps) => {
|
|
245
258
|
const { t } = useTranslation();
|
|
246
|
-
if (isSmall(size) || hideByline(
|
|
259
|
+
if (isSmall(embedData.size) || hideByline(embedData) || !src || (pagePath && src.endsWith(pagePath))) {
|
|
247
260
|
return <>{children}</>;
|
|
248
261
|
}
|
|
249
262
|
|
|
@@ -256,7 +269,7 @@ const ImageWrapper = ({ src, crop, size, children, pagePath }: ImageWrapperProps
|
|
|
256
269
|
};
|
|
257
270
|
|
|
258
271
|
interface ExpandButtonProps {
|
|
259
|
-
|
|
272
|
+
embedData: ImageEmbedData;
|
|
260
273
|
expanded: boolean;
|
|
261
274
|
bylineHidden: boolean;
|
|
262
275
|
onExpand: MouseEventHandler<HTMLButtonElement>;
|
|
@@ -282,9 +295,9 @@ const BylineButton = styled.button`
|
|
|
282
295
|
}
|
|
283
296
|
`;
|
|
284
297
|
|
|
285
|
-
const ExpandButton = ({
|
|
298
|
+
const ExpandButton = ({ embedData, expanded, bylineHidden, onExpand, onHideByline }: ExpandButtonProps) => {
|
|
286
299
|
const { t } = useTranslation();
|
|
287
|
-
if (isSmall(size)) {
|
|
300
|
+
if (isSmall(embedData.size)) {
|
|
288
301
|
return (
|
|
289
302
|
<button
|
|
290
303
|
type="button"
|
|
@@ -297,7 +310,7 @@ const ExpandButton = ({ size, expanded, bylineHidden, onExpand, onHideByline }:
|
|
|
297
310
|
</button>
|
|
298
311
|
);
|
|
299
312
|
}
|
|
300
|
-
if (hideByline(
|
|
313
|
+
if (hideByline(embedData)) {
|
|
301
314
|
return (
|
|
302
315
|
<BylineButton
|
|
303
316
|
type="button"
|
package/src/FactBox/FactBox.tsx
CHANGED
package/src/Figure/Figure.tsx
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
// N.B These components is used to render static markup serverside
|
|
10
10
|
|
|
11
|
+
/** @jsxImportSource @emotion/react */
|
|
11
12
|
import { ComponentPropsWithRef, forwardRef, useMemo } from "react";
|
|
12
13
|
import { SerializedStyles, css } from "@emotion/react";
|
|
13
14
|
import styled from "@emotion/styled";
|
package/src/Layout/OneColumn.tsx
CHANGED
package/src/Logo/Logo.tsx
CHANGED
package/src/Table/Table.tsx
CHANGED
package/src/TagSelector/Menu.tsx
CHANGED