@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.
@@ -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: ${colors.brand.primary};
28
+ color: inherit;
21
29
  `;
22
30
 
23
- const StyledBlueRightChevron = styled(ChevronRight)`
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 <StyledBlueRightChevron />;
46
+ return <StyledRightChevron />;
51
47
  };
52
48
 
53
49
  return (
54
- <div>
50
+ <HeaderBreadcrumbWrapper light={light}>
55
51
  <StyledHeaderSafeLink to={items[0]?.to}>{items[0]?.name}</StyledHeaderSafeLink>
56
- <Breadcrumb
57
- items={items.slice(1)}
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
 
@@ -216,7 +216,7 @@ const FrontpageAllSubjects = ({
216
216
  });
217
217
  });
218
218
 
219
- data.unshift({
219
+ data.push({
220
220
  title: t('frontpageMenu.allsubjects'),
221
221
  content: renderList(allSubjects, onNavigate, onToggleSubject, subjectViewType, selectedSubjects),
222
222
  });
@@ -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 license={concept.copyright?.license?.license ?? ''} source={concept.source} />
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 license={concept.copyright?.license?.license ?? ''} source={concept.source} />
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 { getGroupedContributorDescriptionList, getLicenseByAbbreviation } from '@ndla/licenses';
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, processors, rightsholders } = copyright ?? {};
51
- const contributors = getGroupedContributorDescriptionList(
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={contributors}
65
+ authors={authors}
72
66
  licenseRights={license.rights}
73
67
  hideIconsAndAuthors={hideIconsAndAuthors}>
74
68
  <FigureLicenseDialog
75
69
  id={id}
76
- authors={contributors}
70
+ authors={authors}
77
71
  locale={i18n.language}
78
72
  title={title}
79
73
  origin={copyright?.origin}
package/src/types.ts CHANGED
@@ -68,7 +68,7 @@ export interface FootNote {
68
68
  export interface Article {
69
69
  title: string;
70
70
  introduction: string;
71
- content: string;
71
+ content: string | (() => ReactNode) | ReactNode;
72
72
  footNotes: Array<FootNote>;
73
73
  copyright: Copyright;
74
74
  published: string;