@ndla/ui 13.1.0 → 13.2.1
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 -1
- package/es/Article/ArticleHeaderWrapper.js +4 -4
- package/es/Breadcrumb/BreadcrumbItem.js +7 -7
- package/es/Breadcrumb/HeaderBreadcrumb.js +17 -46
- package/es/Frontpage/FrontpageAllSubjects.js +8 -8
- package/es/Notion/ConceptNotion.js +25 -1
- package/es/Notion/FigureNotion.js +25 -21
- package/lib/Article/Article.d.ts +2 -2
- package/lib/Article/Article.js +1 -1
- package/lib/Article/ArticleHeaderWrapper.d.ts +1 -1
- package/lib/Article/ArticleHeaderWrapper.js +4 -4
- package/lib/Breadcrumb/BreadcrumbItem.js +7 -7
- package/lib/Breadcrumb/HeaderBreadcrumb.js +17 -45
- package/lib/Frontpage/FrontpageAllSubjects.js +8 -8
- package/lib/Notion/ConceptNotion.js +25 -2
- package/lib/Notion/FigureNotion.js +24 -21
- package/lib/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/Article/Article.tsx +2 -1
- package/src/Article/ArticleHeaderWrapper.tsx +1 -0
- package/src/Breadcrumb/BreadcrumbItem.tsx +2 -0
- package/src/Breadcrumb/HeaderBreadcrumb.tsx +13 -34
- package/src/Frontpage/FrontpageAllSubjects.tsx +1 -1
- package/src/Notion/ConceptNotion.tsx +17 -2
- package/src/Notion/FigureNotion.tsx +7 -13
- package/src/types.ts +1 -1
package/src/Article/Article.tsx
CHANGED
|
@@ -102,12 +102,13 @@ type Props = {
|
|
|
102
102
|
icon?: ReactNode;
|
|
103
103
|
licenseBox?: ReactNode;
|
|
104
104
|
modifier?: string;
|
|
105
|
-
children
|
|
105
|
+
children?: ReactNode;
|
|
106
106
|
messages: Messages;
|
|
107
107
|
locale: Locale;
|
|
108
108
|
messageBoxLinks?: [];
|
|
109
109
|
competenceGoals?:
|
|
110
110
|
| ((inp: { Dialog: ComponentType; dialogProps: { isOpen: boolean; onClose: () => void } }) => ReactNode)
|
|
111
|
+
| ReactNode
|
|
111
112
|
| null;
|
|
112
113
|
competenceGoalTypes?: string[];
|
|
113
114
|
id: string;
|
|
@@ -71,6 +71,7 @@ const CompetenceButtonWrapper = styled.div<CompetenceButtonWrapperProps>`
|
|
|
71
71
|
type Props = {
|
|
72
72
|
competenceGoals?:
|
|
73
73
|
| ((inp: { Dialog: ComponentType; dialogProps: { isOpen: boolean; onClose: () => void } }) => ReactNode)
|
|
74
|
+
| ReactNode
|
|
74
75
|
| null;
|
|
75
76
|
competenceGoalTypes?: string[];
|
|
76
77
|
children: ReactNode;
|
|
@@ -51,6 +51,7 @@ const StyledListItem = styled.li<AutoCollapseProps>`
|
|
|
51
51
|
|
|
52
52
|
const CollapseContainer = styled.div<AutoCollapseProps>`
|
|
53
53
|
display: inline-block;
|
|
54
|
+
color: inherit;
|
|
54
55
|
${({ autoCollapse }) =>
|
|
55
56
|
autoCollapse &&
|
|
56
57
|
css`
|
|
@@ -63,6 +64,7 @@ const CollapseContainer = styled.div<AutoCollapseProps>`
|
|
|
63
64
|
|
|
64
65
|
const StyledChevron = styled(ChevronRight)`
|
|
65
66
|
margin: ${spacing.xxsmall};
|
|
67
|
+
color: inherit;
|
|
66
68
|
`;
|
|
67
69
|
|
|
68
70
|
const StyledSafeLink = styled(SafeLink)`
|
|
@@ -18,21 +18,19 @@ interface ThemeProps {
|
|
|
18
18
|
light: boolean | undefined;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const HeaderBreadcrumbWrapper = styled.div<ThemeProps>`
|
|
22
|
+
color: ${({ light }) => (light ? colors.white : colors.brand.primary)};
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const StyledHeaderSafeLink = styled(SafeLink)`
|
|
22
26
|
${fonts.sizes(14)};
|
|
23
27
|
font-weight: ${fonts.weight.bold};
|
|
24
|
-
color:
|
|
28
|
+
color: inherit;
|
|
25
29
|
`;
|
|
26
30
|
|
|
27
|
-
const StyledRightChevron = styled(ChevronRight)
|
|
28
|
-
color: ${({ light }) => (light ? colors.white : colors.brand.primary)};
|
|
31
|
+
const StyledRightChevron = styled(ChevronRight)`
|
|
29
32
|
margin: ${spacing.xxsmall};
|
|
30
|
-
|
|
31
|
-
const StyledSpan = styled.span<ThemeProps>`
|
|
32
|
-
color: ${({ light }) => (light ? colors.white : colors.brand.primary)};
|
|
33
|
-
`;
|
|
34
|
-
const StyledSafeLink = styled(SafeLink)<ThemeProps>`
|
|
35
|
-
color: ${({ light }) => (light ? colors.white : colors.brand.primary)};
|
|
33
|
+
color: inherit;
|
|
36
34
|
`;
|
|
37
35
|
|
|
38
36
|
interface Props {
|
|
@@ -41,37 +39,18 @@ interface Props {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
const HeaderBreadcrumb = ({ items, light }: Props) => {
|
|
44
|
-
const renderItem = (item: IndexedBreadcrumbItem, totalCount: number) => {
|
|
45
|
-
if (item.index === totalCount - 1) {
|
|
46
|
-
return <StyledSpan light={light}>{item.name}</StyledSpan>;
|
|
47
|
-
}
|
|
48
|
-
return (
|
|
49
|
-
<StyledSafeLink light={light} to={item.to}>
|
|
50
|
-
{item.name}
|
|
51
|
-
</StyledSafeLink>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
42
|
const renderSeparator = (item: IndexedBreadcrumbItem, totalCount: number) => {
|
|
56
43
|
if (item.index === totalCount - 1) {
|
|
57
44
|
return null;
|
|
58
45
|
}
|
|
59
|
-
return <StyledRightChevron
|
|
46
|
+
return <StyledRightChevron />;
|
|
60
47
|
};
|
|
61
48
|
|
|
62
49
|
return (
|
|
63
|
-
<
|
|
64
|
-
<StyledHeaderSafeLink
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<Breadcrumb
|
|
68
|
-
items={items.slice(1)}
|
|
69
|
-
renderItem={renderItem}
|
|
70
|
-
renderSeparator={renderSeparator}
|
|
71
|
-
autoCollapse
|
|
72
|
-
collapseFirst
|
|
73
|
-
/>
|
|
74
|
-
</div>
|
|
50
|
+
<HeaderBreadcrumbWrapper light={light}>
|
|
51
|
+
<StyledHeaderSafeLink to={items[0]?.to}>{items[0]?.name}</StyledHeaderSafeLink>
|
|
52
|
+
<Breadcrumb items={items.slice(1)} renderSeparator={renderSeparator} autoCollapse collapseFirst />
|
|
53
|
+
</HeaderBreadcrumbWrapper>
|
|
75
54
|
);
|
|
76
55
|
};
|
|
77
56
|
|
|
@@ -12,6 +12,7 @@ import { initArticleScripts } from '@ndla/article-scripts';
|
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import { breakpoints, mq, spacing } from '@ndla/core';
|
|
14
14
|
import { parseMarkdown } from '@ndla/util';
|
|
15
|
+
import { getLicenseCredits } from '@ndla/licenses';
|
|
15
16
|
import Notion, { NotionDialogContent, NotionDialogText, NotionDialogLicenses } from '@ndla/notion';
|
|
16
17
|
import { Notion as UINotion } from '.';
|
|
17
18
|
import { NotionImage } from './NotionImage';
|
|
@@ -57,6 +58,12 @@ const ConceptNotion = ({ concept, disableScripts, type, hideIconsAndAuthors, fig
|
|
|
57
58
|
const visualElementId = `visual-element-${concept.id}`;
|
|
58
59
|
const { t } = useTranslation();
|
|
59
60
|
|
|
61
|
+
const { creators, rightsholders, processors } = getLicenseCredits(concept.copyright);
|
|
62
|
+
|
|
63
|
+
const authors = (creators.length || rightsholders.length ? [...creators, ...rightsholders] : [...processors]).map(
|
|
64
|
+
(author) => author.name,
|
|
65
|
+
);
|
|
66
|
+
|
|
60
67
|
useEffect(() => {
|
|
61
68
|
if (!disableScripts) {
|
|
62
69
|
initArticleScripts();
|
|
@@ -94,7 +101,11 @@ const ConceptNotion = ({ concept, disableScripts, type, hideIconsAndAuthors, fig
|
|
|
94
101
|
) : undefined}
|
|
95
102
|
<NotionDialogText>{parseMarkdown(concept.text, 'body')}</NotionDialogText>
|
|
96
103
|
</NotionDialogContent>
|
|
97
|
-
<NotionDialogLicenses
|
|
104
|
+
<NotionDialogLicenses
|
|
105
|
+
authors={authors}
|
|
106
|
+
license={concept.copyright?.license?.license ?? ''}
|
|
107
|
+
source={concept.source}
|
|
108
|
+
/>
|
|
98
109
|
</>
|
|
99
110
|
}>
|
|
100
111
|
{concept.visualElement.image && (
|
|
@@ -129,7 +140,11 @@ const ConceptNotion = ({ concept, disableScripts, type, hideIconsAndAuthors, fig
|
|
|
129
140
|
|
|
130
141
|
<NotionDialogText>{parseMarkdown(concept.text, 'body')}</NotionDialogText>
|
|
131
142
|
</NotionDialogContent>
|
|
132
|
-
<NotionDialogLicenses
|
|
143
|
+
<NotionDialogLicenses
|
|
144
|
+
authors={authors}
|
|
145
|
+
license={concept.copyright?.license?.license ?? ''}
|
|
146
|
+
source={concept.source}
|
|
147
|
+
/>
|
|
133
148
|
</>
|
|
134
149
|
}>
|
|
135
150
|
{concept.image && (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import styled from '@emotion/styled';
|
|
9
9
|
import { colors, spacing } from '@ndla/core';
|
|
10
|
-
import {
|
|
10
|
+
import { getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
|
|
11
11
|
import React, { ReactNode } from 'react';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import { Figure, FigureCaption, FigureLicenseDialog, FigureType } from '../Figure';
|
|
@@ -47,15 +47,9 @@ const FigureNotion = ({
|
|
|
47
47
|
}: Props) => {
|
|
48
48
|
const { t, i18n } = useTranslation();
|
|
49
49
|
const license = getLicenseByAbbreviation(licenseString, i18n.language);
|
|
50
|
-
const { creators,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
creators: creators ?? [],
|
|
54
|
-
processors: processors ?? [],
|
|
55
|
-
rightsholders: rightsholders ?? [],
|
|
56
|
-
},
|
|
57
|
-
i18n.language,
|
|
58
|
-
).map((i) => ({ name: i.description, type: i.label }));
|
|
50
|
+
const { creators, rightsholders, processors } = getLicenseCredits(copyright);
|
|
51
|
+
|
|
52
|
+
const authors = creators.length || rightsholders.length ? [...creators, ...rightsholders] : [...processors];
|
|
59
53
|
|
|
60
54
|
return (
|
|
61
55
|
<Figure resizeIframe={resizeIframe} id={figureId} type={figureType || 'full-column'}>
|
|
@@ -68,19 +62,19 @@ const FigureNotion = ({
|
|
|
68
62
|
figureId={figureId}
|
|
69
63
|
id={id}
|
|
70
64
|
reuseLabel={t(`${type}.reuse`)}
|
|
71
|
-
authors={
|
|
65
|
+
authors={authors}
|
|
72
66
|
licenseRights={license.rights}
|
|
73
67
|
hideIconsAndAuthors={hideIconsAndAuthors}>
|
|
74
68
|
<FigureLicenseDialog
|
|
75
69
|
id={id}
|
|
76
|
-
authors={
|
|
70
|
+
authors={authors}
|
|
77
71
|
locale={i18n.language}
|
|
78
72
|
title={title}
|
|
79
73
|
origin={copyright?.origin}
|
|
80
74
|
license={license}
|
|
81
75
|
messages={{
|
|
82
76
|
close: t('close'),
|
|
83
|
-
rulesForUse: t(
|
|
77
|
+
rulesForUse: t(`license.${type}.rules`),
|
|
84
78
|
source: t('source'),
|
|
85
79
|
learnAboutLicenses: t('license.learnMore'),
|
|
86
80
|
title: t('title'),
|
package/src/types.ts
CHANGED