@ndla/ui 13.0.0 → 13.2.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 -1
- package/es/Article/ArticleHeaderWrapper.js +4 -4
- package/es/Breadcrumb/BreadcrumbItem.js +7 -7
- package/es/Breadcrumb/HeaderBreadcrumb.js +19 -29
- package/es/Frontpage/FrontpageAllSubjects.js +8 -8
- package/es/Notion/ConceptNotion.js +25 -1
- package/es/Notion/FigureNotion.js +24 -20
- 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.d.ts +2 -1
- package/lib/Breadcrumb/HeaderBreadcrumb.js +20 -29
- package/lib/Frontpage/FrontpageAllSubjects.js +8 -8
- package/lib/Notion/ConceptNotion.js +25 -2
- package/lib/Notion/FigureNotion.js +23 -20
- 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 +17 -27
- package/src/Frontpage/FrontpageAllSubjects.tsx +1 -1
- package/src/Notion/ConceptNotion.tsx +17 -2
- package/src/Notion/FigureNotion.tsx +6 -12
- package/src/types.ts +1 -1
|
@@ -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)`
|
|
@@ -14,53 +14,43 @@ import React from 'react';
|
|
|
14
14
|
import Breadcrumb from './Breadcrumb';
|
|
15
15
|
import { IndexedBreadcrumbItem, SimpleBreadcrumbItem } from './BreadcrumbItem';
|
|
16
16
|
|
|
17
|
+
interface ThemeProps {
|
|
18
|
+
light: boolean | undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const HeaderBreadcrumbWrapper = styled.div<ThemeProps>`
|
|
22
|
+
color: ${({ light }) => (light ? colors.white : colors.brand.primary)};
|
|
23
|
+
`;
|
|
24
|
+
|
|
17
25
|
const StyledHeaderSafeLink = styled(SafeLink)`
|
|
18
26
|
${fonts.sizes(14)};
|
|
19
27
|
font-weight: ${fonts.weight.bold};
|
|
20
|
-
color:
|
|
28
|
+
color: inherit;
|
|
21
29
|
`;
|
|
22
30
|
|
|
23
|
-
const
|
|
24
|
-
color: ${colors.brand.primary};
|
|
31
|
+
const StyledRightChevron = styled(ChevronRight)`
|
|
25
32
|
margin: ${spacing.xxsmall};
|
|
26
|
-
|
|
27
|
-
const StyledBlueSpan = styled.span`
|
|
28
|
-
color: ${colors.brand.primary};
|
|
29
|
-
`;
|
|
30
|
-
const StyledBlueSafeLink = styled(SafeLink)`
|
|
31
|
-
color: ${colors.brand.primary};
|
|
33
|
+
color: inherit;
|
|
32
34
|
`;
|
|
33
35
|
|
|
34
36
|
interface Props {
|
|
35
37
|
items: SimpleBreadcrumbItem[];
|
|
38
|
+
light?: boolean;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
const HeaderBreadcrumb = ({ items }: Props) => {
|
|
39
|
-
const renderItem = (item: IndexedBreadcrumbItem, totalCount: number) => {
|
|
40
|
-
if (item.index === totalCount - 1) {
|
|
41
|
-
return <StyledBlueSpan>{item.name}</StyledBlueSpan>;
|
|
42
|
-
}
|
|
43
|
-
return <StyledBlueSafeLink to={item.to}>{item.name}</StyledBlueSafeLink>;
|
|
44
|
-
};
|
|
45
|
-
|
|
41
|
+
const HeaderBreadcrumb = ({ items, light }: Props) => {
|
|
46
42
|
const renderSeparator = (item: IndexedBreadcrumbItem, totalCount: number) => {
|
|
47
43
|
if (item.index === totalCount - 1) {
|
|
48
44
|
return null;
|
|
49
45
|
}
|
|
50
|
-
return <
|
|
46
|
+
return <StyledRightChevron />;
|
|
51
47
|
};
|
|
52
48
|
|
|
53
49
|
return (
|
|
54
|
-
<
|
|
50
|
+
<HeaderBreadcrumbWrapper light={light}>
|
|
55
51
|
<StyledHeaderSafeLink to={items[0]?.to}>{items[0]?.name}</StyledHeaderSafeLink>
|
|
56
|
-
<Breadcrumb
|
|
57
|
-
|
|
58
|
-
renderItem={renderItem}
|
|
59
|
-
renderSeparator={renderSeparator}
|
|
60
|
-
autoCollapse
|
|
61
|
-
collapseFirst
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
52
|
+
<Breadcrumb items={items.slice(1)} renderSeparator={renderSeparator} autoCollapse collapseFirst />
|
|
53
|
+
</HeaderBreadcrumbWrapper>
|
|
64
54
|
);
|
|
65
55
|
};
|
|
66
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,12 +62,12 @@ 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}
|
package/src/types.ts
CHANGED