@ndla/ui 8.2.5 → 9.0.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/ArticleNotions.js +9 -7
- package/es/Figure/Figure.js +6 -5
- package/es/Figure/FigureExpandButton.js +6 -6
- package/es/Figure/FigureOpenDialogButton.js +45 -0
- package/es/Figure/index.js +2 -1
- package/es/Image/Image.js +1 -1
- package/es/MessageBox/MessageBox.js +8 -8
- package/es/Notion/ConceptNotion.js +79 -28
- package/es/Notion/FigureNotion.js +5 -6
- package/es/Notion/Notion.js +19 -98
- package/es/Notion/NotionImage.js +25 -6
- package/es/Notion/NotionVisualElement.js +49 -10
- package/es/Topic/Topic.js +21 -21
- package/es/all.css +1 -1
- package/es/index.js +1 -2
- package/es/locale/messages-en.js +1 -1
- package/es/locale/messages-nb.js +1 -1
- package/es/locale/messages-nn.js +1 -1
- package/lib/Article/ArticleNotions.d.ts +2 -1
- package/lib/Article/ArticleNotions.js +9 -7
- package/lib/Figure/Figure.d.ts +2 -1
- package/lib/Figure/Figure.js +6 -5
- package/lib/Figure/FigureExpandButton.js +6 -6
- package/lib/Figure/FigureOpenDialogButton.d.ts +16 -0
- package/lib/Figure/FigureOpenDialogButton.js +57 -0
- package/lib/Figure/index.d.ts +1 -0
- package/lib/Figure/index.js +8 -0
- package/lib/Image/Image.js +1 -1
- package/lib/MessageBox/MessageBox.js +9 -9
- package/lib/Notion/ConceptNotion.d.ts +6 -7
- package/lib/Notion/ConceptNotion.js +84 -30
- package/lib/Notion/FigureNotion.d.ts +3 -2
- package/lib/Notion/FigureNotion.js +5 -7
- package/lib/Notion/Notion.d.ts +1 -12
- package/lib/Notion/Notion.js +23 -105
- package/lib/Notion/NotionImage.d.ts +2 -1
- package/lib/Notion/NotionImage.js +25 -7
- package/lib/Notion/NotionVisualElement.d.ts +6 -7
- package/lib/Notion/NotionVisualElement.js +48 -18
- package/lib/Topic/Topic.js +21 -21
- package/lib/all.css +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +7 -9
- package/lib/locale/messages-en.js +1 -1
- package/lib/locale/messages-nb.js +1 -1
- package/lib/locale/messages-nn.js +1 -1
- package/package.json +9 -9
- package/src/Article/ArticleNotions.tsx +3 -2
- package/src/Figure/Figure.tsx +49 -41
- package/src/Figure/FigureExpandButton.tsx +4 -4
- package/src/Figure/FigureOpenDialogButton.tsx +37 -0
- package/src/Figure/component.figure.scss +4 -0
- package/src/Figure/index.ts +1 -0
- package/src/Image/Image.tsx +1 -1
- package/src/MessageBox/MessageBox.tsx +1 -1
- package/src/Notion/ConceptNotion.tsx +136 -37
- package/src/Notion/FigureNotion.tsx +6 -6
- package/src/Notion/Notion.tsx +7 -145
- package/src/Notion/NotionImage.tsx +44 -15
- package/src/Notion/NotionVisualElement.tsx +35 -8
- package/src/Topic/Topic.tsx +1 -1
- package/src/index.ts +2 -2
- package/src/locale/messages-en.ts +1 -1
- package/src/locale/messages-nb.ts +1 -1
- package/src/locale/messages-nn.ts +1 -1
- package/es/CloseButton/CloseButton.js +0 -46
- package/es/CloseButton/index.js +0 -10
- package/lib/CloseButton/CloseButton.d.ts +0 -10
- package/lib/CloseButton/CloseButton.js +0 -54
- package/lib/CloseButton/index.d.ts +0 -10
- package/lib/CloseButton/index.js +0 -26
- package/src/CloseButton/CloseButton.tsx +0 -36
- package/src/CloseButton/index.ts +0 -13
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { default as Image, ImageLink } from './Image';
|
|
|
28
28
|
export { makeSrcQueryString } from './Image';
|
|
29
29
|
export { SubjectMaterialHero, TasksAndActivitiesHero, AssessmentResourcesHero, SubjectHero, ExternalLearningResourcesHero, SourceMaterialHero, Hero, NdlaFilmHero, } from './Hero';
|
|
30
30
|
export { Footer, EditorName, FooterText, FooterAuth } from './Footer';
|
|
31
|
-
export { Figure, FigureCaption, FigureLicenseDialog, FigureExpandButton } from './Figure';
|
|
31
|
+
export { Figure, FigureCaption, FigureLicenseDialog, FigureExpandButton, FigureOpenDialogButton } from './Figure';
|
|
32
32
|
export { LanguageSelector } from './LanguageSelector';
|
|
33
33
|
export { LearningPathWrapper, LearningPathContent, LearningPathMenu, LearningPathSticky, LearningPathInformation, LearningPathStickySibling, LearningPathStickyPlaceholder, LearningPathLastStepNavigation, LearningPathMobileStepInfo, LearningPathMobileHeader, } from './LearningPaths';
|
|
34
34
|
export { Translation, TranslationLine, TranslationBox } from './Translation';
|
|
@@ -43,7 +43,6 @@ export { default as CreatedBy } from './CreatedBy';
|
|
|
43
43
|
export { default as Breadcrumblist } from './Breadcrumblist';
|
|
44
44
|
export { MessageBox, MessageBoxTag, MessageBoxType } from './MessageBox';
|
|
45
45
|
export { ResourceBox } from './ResourceBox';
|
|
46
|
-
export { default as CloseButton } from './CloseButton';
|
|
47
46
|
export { default as AudioPlayer, initAudioPlayers } from './AudioPlayer';
|
|
48
47
|
export { NavigationHeading, NavigationBox, NavigationTopicAbout } from './Navigation';
|
|
49
48
|
export { default as Programme } from './Programme';
|
package/lib/index.js
CHANGED
|
@@ -66,6 +66,7 @@ var _exportNames = {
|
|
|
66
66
|
FigureCaption: true,
|
|
67
67
|
FigureLicenseDialog: true,
|
|
68
68
|
FigureExpandButton: true,
|
|
69
|
+
FigureOpenDialogButton: true,
|
|
69
70
|
LanguageSelector: true,
|
|
70
71
|
LearningPathWrapper: true,
|
|
71
72
|
LearningPathContent: true,
|
|
@@ -93,7 +94,6 @@ var _exportNames = {
|
|
|
93
94
|
MessageBoxTag: true,
|
|
94
95
|
MessageBoxType: true,
|
|
95
96
|
ResourceBox: true,
|
|
96
|
-
CloseButton: true,
|
|
97
97
|
AudioPlayer: true,
|
|
98
98
|
initAudioPlayers: true,
|
|
99
99
|
NavigationHeading: true,
|
|
@@ -535,6 +535,12 @@ Object.defineProperty(exports, "FigureExpandButton", {
|
|
|
535
535
|
return _Figure.FigureExpandButton;
|
|
536
536
|
}
|
|
537
537
|
});
|
|
538
|
+
Object.defineProperty(exports, "FigureOpenDialogButton", {
|
|
539
|
+
enumerable: true,
|
|
540
|
+
get: function get() {
|
|
541
|
+
return _Figure.FigureOpenDialogButton;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
538
544
|
Object.defineProperty(exports, "LanguageSelector", {
|
|
539
545
|
enumerable: true,
|
|
540
546
|
get: function get() {
|
|
@@ -697,12 +703,6 @@ Object.defineProperty(exports, "ResourceBox", {
|
|
|
697
703
|
return _ResourceBox.ResourceBox;
|
|
698
704
|
}
|
|
699
705
|
});
|
|
700
|
-
Object.defineProperty(exports, "CloseButton", {
|
|
701
|
-
enumerable: true,
|
|
702
|
-
get: function get() {
|
|
703
|
-
return _CloseButton["default"];
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
706
|
Object.defineProperty(exports, "AudioPlayer", {
|
|
707
707
|
enumerable: true,
|
|
708
708
|
get: function get() {
|
|
@@ -1267,8 +1267,6 @@ var _MessageBox = require("./MessageBox");
|
|
|
1267
1267
|
|
|
1268
1268
|
var _ResourceBox = require("./ResourceBox");
|
|
1269
1269
|
|
|
1270
|
-
var _CloseButton = _interopRequireDefault(require("./CloseButton"));
|
|
1271
|
-
|
|
1272
1270
|
var _AudioPlayer = _interopRequireWildcard(require("./AudioPlayer"));
|
|
1273
1271
|
|
|
1274
1272
|
var _Navigation = require("./Navigation");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/button": "^2.
|
|
35
|
-
"@ndla/carousel": "^1.2.
|
|
34
|
+
"@ndla/button": "^2.2.0",
|
|
35
|
+
"@ndla/carousel": "^1.2.6",
|
|
36
36
|
"@ndla/core": "^2.1.1",
|
|
37
37
|
"@ndla/hooks": "^1.1.3",
|
|
38
|
-
"@ndla/icons": "^1.
|
|
39
|
-
"@ndla/licenses": "^4.0
|
|
40
|
-
"@ndla/modal": "^1.2.
|
|
41
|
-
"@ndla/safelink": "^1.1.
|
|
38
|
+
"@ndla/icons": "^1.7.0",
|
|
39
|
+
"@ndla/licenses": "^4.1.0",
|
|
40
|
+
"@ndla/modal": "^1.2.6",
|
|
41
|
+
"@ndla/safelink": "^1.1.7",
|
|
42
42
|
"@ndla/switch": "^0.1.5",
|
|
43
|
-
"@ndla/tabs": "^1.1.
|
|
43
|
+
"@ndla/tabs": "^1.1.4",
|
|
44
44
|
"@ndla/tooltip": "^0.3.5",
|
|
45
45
|
"@ndla/util": "^2.0.5",
|
|
46
46
|
"@reach/menu-button": "^0.16.2",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "76c237a1e2d807c08054f066bbf5b274010c0e02"
|
|
84
84
|
}
|
|
@@ -159,9 +159,10 @@ type ArticleNotionsProps = {
|
|
|
159
159
|
notions: ConceptNotionType[];
|
|
160
160
|
relatedContent?: NotionRelatedContent[];
|
|
161
161
|
buttonOffsetRight: number;
|
|
162
|
+
type?: 'image' | 'video' | 'h5p' | 'iframe' | 'external';
|
|
162
163
|
};
|
|
163
164
|
|
|
164
|
-
export const ArticleNotions = ({ notions, relatedContent = [], buttonOffsetRight }: ArticleNotionsProps) => {
|
|
165
|
+
export const ArticleNotions = ({ notions, relatedContent = [], buttonOffsetRight, type }: ArticleNotionsProps) => {
|
|
165
166
|
const { t } = useTranslation();
|
|
166
167
|
const leftOffset = `${buttonOffsetRight - 32}px`;
|
|
167
168
|
return (
|
|
@@ -188,7 +189,7 @@ export const ArticleNotions = ({ notions, relatedContent = [], buttonOffsetRight
|
|
|
188
189
|
</ModalHeadingContainer>
|
|
189
190
|
<NotionsContainer>
|
|
190
191
|
{notions.map((notion) => (
|
|
191
|
-
<ConceptNotion key={notion.id} concept={notion} />
|
|
192
|
+
<ConceptNotion key={notion.id} concept={notion} type={type} />
|
|
192
193
|
))}
|
|
193
194
|
</NotionsContainer>
|
|
194
195
|
{relatedContent.length > 0 && (
|
package/src/Figure/Figure.tsx
CHANGED
|
@@ -35,57 +35,64 @@ export const FigureCaption = ({
|
|
|
35
35
|
link,
|
|
36
36
|
hideFigcaption,
|
|
37
37
|
hasLinkedVideo,
|
|
38
|
+
hideIconsAndAuthors,
|
|
38
39
|
}: FigureCaptionProps) => {
|
|
39
40
|
const { t } = useTranslation();
|
|
41
|
+
|
|
40
42
|
return (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
size="small"
|
|
53
|
-
type="button"
|
|
54
|
-
data-dialog-trigger-id={id}
|
|
55
|
-
data-dialog-source-id={figureId}>
|
|
56
|
-
{reuseLabel}
|
|
57
|
-
</Button>
|
|
58
|
-
{hasLinkedVideo && (
|
|
43
|
+
<>
|
|
44
|
+
<figcaption {...classes('caption', hideFigcaption ? 'hidden-caption' : undefined)}>
|
|
45
|
+
{caption ? <div {...classes('info')}>{parseMarkdown(caption)}</div> : null}
|
|
46
|
+
<footer {...classes('byline')}>
|
|
47
|
+
<div {...classes('byline-licenselist')}>
|
|
48
|
+
<LicenseByline licenseRights={hideIconsAndAuthors ? [] : licenseRights} locale={locale} marginRight>
|
|
49
|
+
<div {...classes('byline-author-buttons', hideIconsAndAuthors ? 'no-siblings' : undefined)}>
|
|
50
|
+
{!hideIconsAndAuthors && (
|
|
51
|
+
<span {...classes('byline-authors')}>{authors?.map((author) => author.name).join(', ')}</span>
|
|
52
|
+
)}
|
|
53
|
+
<div>
|
|
59
54
|
<Button
|
|
60
55
|
borderShape="rounded"
|
|
61
56
|
outline
|
|
62
57
|
size="small"
|
|
63
58
|
type="button"
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
data-dialog-trigger-id={id}
|
|
60
|
+
data-dialog-source-id={figureId}>
|
|
61
|
+
{reuseLabel}
|
|
67
62
|
</Button>
|
|
68
|
-
|
|
63
|
+
{hasLinkedVideo && (
|
|
64
|
+
<Button
|
|
65
|
+
borderShape="rounded"
|
|
66
|
+
outline
|
|
67
|
+
size="small"
|
|
68
|
+
type="button"
|
|
69
|
+
{...classes('toggleAlternativeVideo')}>
|
|
70
|
+
<span className="original">{t('figure.button.alternative')}</span>
|
|
71
|
+
<span className="alternative hidden">{t('figure.button.original')}</span>
|
|
72
|
+
</Button>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
{children}
|
|
76
|
+
</div>
|
|
77
|
+
</LicenseByline>
|
|
78
|
+
|
|
79
|
+
{link && (
|
|
80
|
+
<div {...classes('link-wrapper')}>
|
|
81
|
+
<SafeLink
|
|
82
|
+
to={link.url}
|
|
83
|
+
{...classes('link')}
|
|
84
|
+
target={link.external ? '_blank' : undefined}
|
|
85
|
+
rel={link.external ? 'noopener noreferrer' : undefined}>
|
|
86
|
+
<span {...classes('link-text')}>{link.text}</span>
|
|
87
|
+
<LinkIcon />
|
|
88
|
+
</SafeLink>
|
|
89
|
+
{link.description && <p {...classes('link-description')}>{link.description}</p>}
|
|
69
90
|
</div>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<SafeLink
|
|
76
|
-
to={link.url}
|
|
77
|
-
{...classes('link')}
|
|
78
|
-
target={link.external ? '_blank' : undefined}
|
|
79
|
-
rel={link.external ? 'noopener noreferrer' : undefined}>
|
|
80
|
-
<span {...classes('link-text')}>{link.text}</span>
|
|
81
|
-
<LinkIcon />
|
|
82
|
-
</SafeLink>
|
|
83
|
-
{link.description && <p {...classes('link-description')}>{link.description}</p>}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
</div>
|
|
87
|
-
</footer>
|
|
88
|
-
</figcaption>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
</footer>
|
|
94
|
+
</figcaption>
|
|
95
|
+
</>
|
|
89
96
|
);
|
|
90
97
|
};
|
|
91
98
|
|
|
@@ -116,6 +123,7 @@ interface FigureCaptionProps {
|
|
|
116
123
|
locale?: string;
|
|
117
124
|
hideFigcaption?: boolean;
|
|
118
125
|
hasLinkedVideo?: boolean;
|
|
126
|
+
hideIconsAndAuthors?: boolean;
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
const Figure = ({ children, type = 'full', resizeIframe, ...rest }: Props) => {
|
|
@@ -15,13 +15,13 @@ export function FigureExpandButton({ messages, typeClass }: Props) {
|
|
|
15
15
|
<button
|
|
16
16
|
className="c-figure__fullscreen-btn"
|
|
17
17
|
type="button"
|
|
18
|
-
data-figure-button
|
|
19
|
-
data-classtype={typeClass}
|
|
20
18
|
data-aria={messages.zoomImageButtonLabel}
|
|
21
19
|
data-ariaexpanded={messages.zoomOutImageButtonLabel}
|
|
22
|
-
aria-label={messages.zoomImageButtonLabel}
|
|
23
|
-
|
|
20
|
+
aria-label={messages.zoomImageButtonLabel}
|
|
21
|
+
data-figure-button
|
|
22
|
+
data-classtype={typeClass}>
|
|
24
23
|
<ExpandTwoArrows className="contracted-icon" />
|
|
24
|
+
<ArrowCollapse className="expanded-icon" />
|
|
25
25
|
</button>
|
|
26
26
|
);
|
|
27
27
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2012-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 React from 'react';
|
|
10
|
+
import { Play } from '@ndla/icons/common';
|
|
11
|
+
import { ExpandTwoArrows } from '@ndla/icons/action';
|
|
12
|
+
import { CursorClick } from '@ndla/icons/action';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
type?: 'image' | 'video' | 'h5p' | 'iframe' | 'external';
|
|
16
|
+
messages: {
|
|
17
|
+
zoomImageButtonLabel: string;
|
|
18
|
+
zoomOutImageButtonLabel: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function FigureOpenDialogButton({ messages, type }: Props) {
|
|
23
|
+
return (
|
|
24
|
+
<button
|
|
25
|
+
className="c-figure__fullscreen-btn"
|
|
26
|
+
type="button"
|
|
27
|
+
data-aria={messages.zoomImageButtonLabel}
|
|
28
|
+
data-ariaexpanded={messages.zoomOutImageButtonLabel}
|
|
29
|
+
aria-label={messages.zoomImageButtonLabel}>
|
|
30
|
+
{type === 'image' && <ExpandTwoArrows className="contracted-icon" />}
|
|
31
|
+
{type === 'h5p' && <CursorClick style={{ width: '24px', height: '24px' }} />}
|
|
32
|
+
{type === 'iframe' && <CursorClick style={{ width: '24px', height: '24px' }} />}
|
|
33
|
+
{type === 'external' && <CursorClick style={{ width: '24px', height: '24px' }} />}
|
|
34
|
+
{type === 'video' && <Play style={{ width: '24px', height: '24px' }} />}
|
|
35
|
+
</button>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -136,6 +136,10 @@
|
|
|
136
136
|
justify-content: space-between;
|
|
137
137
|
color: $primary-color;
|
|
138
138
|
}
|
|
139
|
+
.c-figure__byline-author-buttons--no-siblings {
|
|
140
|
+
//styling for button in licensewrapper when there are no other elements in it. Places the button to the right
|
|
141
|
+
justify-content: flex-end;
|
|
142
|
+
}
|
|
139
143
|
.c-figure__byline-authors {
|
|
140
144
|
@include font-size(14px, 20px);
|
|
141
145
|
margin-right: $spacing--small;
|
package/src/Figure/index.ts
CHANGED
|
@@ -11,5 +11,6 @@ export { Figure, FigureCaption };
|
|
|
11
11
|
export { FigureLicenseDialog } from './FigureLicenseDialog';
|
|
12
12
|
export { FigureExpandButton } from './FigureExpandButton';
|
|
13
13
|
export { FigureBylineExpandButton } from './FigureBylineExpandButton';
|
|
14
|
+
export { FigureOpenDialogButton } from './FigureOpenDialogButton';
|
|
14
15
|
|
|
15
16
|
export type { FigureType } from './Figure';
|
package/src/Image/Image.tsx
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import React, { ReactNode } from 'react';
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
import LazyLoadImage from './LazyLoadImage';
|
|
12
|
+
|
|
12
13
|
export interface ImageCrop {
|
|
13
14
|
startX: number;
|
|
14
15
|
startY: number;
|
|
@@ -39,7 +40,6 @@ const getSrcSet = (src: string, crop: ImageCrop | undefined, focalPoint: ImageFo
|
|
|
39
40
|
const StyledImageWrapper = styled.div`
|
|
40
41
|
position: relative;
|
|
41
42
|
`;
|
|
42
|
-
|
|
43
43
|
interface Props {
|
|
44
44
|
alt: string;
|
|
45
45
|
src: string;
|
|
@@ -14,7 +14,7 @@ import { WithTranslation, withTranslation } from 'react-i18next';
|
|
|
14
14
|
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
import { Remarkable } from 'remarkable';
|
|
17
|
-
import { CloseButton } from '
|
|
17
|
+
import { CloseButton } from '@ndla/button';
|
|
18
18
|
|
|
19
19
|
export enum MessageBoxType {
|
|
20
20
|
ghost = 'ghost',
|
|
@@ -4,16 +4,45 @@
|
|
|
4
4
|
* This source code is licensed under the GPLv3 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree. *
|
|
6
6
|
*/
|
|
7
|
+
import styled from '@emotion/styled';
|
|
7
8
|
|
|
8
9
|
import React, { useEffect } from 'react';
|
|
9
10
|
//@ts-ignore
|
|
10
11
|
import { initArticleScripts } from '@ndla/article-scripts';
|
|
11
|
-
import {
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
import { breakpoints, mq, spacing } from '@ndla/core';
|
|
14
|
+
import Notion, { NotionDialogContent, NotionDialogText, NotionDialogLicenses } from '@ndla/notion';
|
|
15
|
+
import { Notion as UINotion } from '.';
|
|
12
16
|
import { NotionImage } from './NotionImage';
|
|
13
17
|
import NotionVisualElement, { NotionVisualElementType } from './NotionVisualElement';
|
|
14
18
|
import FigureNotion from './FigureNotion';
|
|
15
19
|
import { Copyright } from '../types';
|
|
16
20
|
|
|
21
|
+
const ContentWrapper = styled.div<{ adjustSizeToFitWiderPage?: boolean }>`
|
|
22
|
+
position: relative;
|
|
23
|
+
right: auto;
|
|
24
|
+
left: ${(props) => (props.adjustSizeToFitWiderPage ? '0%' : '-16.6666666667%')};
|
|
25
|
+
width: ${(props) => (props.adjustSizeToFitWiderPage ? '100%' : '133.3333333333%')};
|
|
26
|
+
padding-left: 24px;
|
|
27
|
+
padding-right: 24px;
|
|
28
|
+
|
|
29
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
30
|
+
width: 100%;
|
|
31
|
+
left: 0;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const ImageWrapper = styled.div`
|
|
36
|
+
float: right;
|
|
37
|
+
padding-left: ${spacing.normal};
|
|
38
|
+
position: relative;
|
|
39
|
+
|
|
40
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
41
|
+
width: 100%;
|
|
42
|
+
padding-left: 0;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
17
46
|
export interface ConceptNotionType {
|
|
18
47
|
id: number;
|
|
19
48
|
copyright?: Partial<Copyright>;
|
|
@@ -21,62 +50,132 @@ export interface ConceptNotionType {
|
|
|
21
50
|
text: string;
|
|
22
51
|
subjectNames?: string[];
|
|
23
52
|
visualElement?: NotionVisualElementType;
|
|
53
|
+
authors: string[];
|
|
54
|
+
source?: string;
|
|
24
55
|
image?: {
|
|
25
56
|
src: string;
|
|
26
57
|
alt: string;
|
|
27
58
|
};
|
|
28
59
|
}
|
|
29
60
|
interface Props {
|
|
61
|
+
type?: 'image' | 'video' | 'h5p' | 'iframe' | 'external';
|
|
30
62
|
concept: ConceptNotionType;
|
|
31
63
|
disableScripts?: boolean;
|
|
64
|
+
hideIconsAndAuthors?: boolean;
|
|
65
|
+
adjustSizeToFitWiderPage?: boolean;
|
|
32
66
|
}
|
|
33
67
|
|
|
34
|
-
const ConceptNotion = ({ concept, disableScripts }: Props) => {
|
|
68
|
+
const ConceptNotion = ({ concept, disableScripts, type, hideIconsAndAuthors, adjustSizeToFitWiderPage }: Props) => {
|
|
35
69
|
const notionId = `notion-${concept.id}`;
|
|
36
70
|
const figureId = `notion-figure-${concept.id}`;
|
|
37
71
|
const visualElementId = `visual-element-${concept.id}`;
|
|
72
|
+
const { t } = useTranslation();
|
|
38
73
|
|
|
39
74
|
useEffect(() => {
|
|
40
75
|
if (!disableScripts) {
|
|
41
76
|
initArticleScripts();
|
|
42
77
|
}
|
|
43
78
|
}, [disableScripts]);
|
|
79
|
+
|
|
44
80
|
return (
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
<ContentWrapper adjustSizeToFitWiderPage={adjustSizeToFitWiderPage}>
|
|
82
|
+
<FigureNotion
|
|
83
|
+
resizeIframe
|
|
84
|
+
id={figureId}
|
|
85
|
+
figureId={visualElementId}
|
|
86
|
+
copyright={concept.copyright}
|
|
87
|
+
licenseString={concept.copyright?.license?.license ?? ''}
|
|
88
|
+
type="concept"
|
|
89
|
+
hideIconsAndAuthors={hideIconsAndAuthors}>
|
|
90
|
+
<UINotion
|
|
91
|
+
id={notionId}
|
|
92
|
+
title={concept.title}
|
|
93
|
+
text={concept.text}
|
|
94
|
+
imageElement={
|
|
95
|
+
concept.visualElement?.resource === 'image' && concept.visualElement.image ? (
|
|
96
|
+
<ImageWrapper>
|
|
97
|
+
<Notion
|
|
98
|
+
id={notionId}
|
|
99
|
+
ariaLabel={t('factbox.open')}
|
|
100
|
+
title={concept.title}
|
|
101
|
+
subTitle={t('searchPage.resultType.notionsHeading')}
|
|
102
|
+
hideBaselineIcon
|
|
103
|
+
content={
|
|
104
|
+
<>
|
|
105
|
+
<NotionDialogContent>
|
|
106
|
+
{concept.visualElement?.resource === 'image' && concept.visualElement.image ? (
|
|
107
|
+
<NotionVisualElement
|
|
108
|
+
visualElement={concept.visualElement}
|
|
109
|
+
id={notionId}
|
|
110
|
+
figureId={figureId}
|
|
111
|
+
/>
|
|
112
|
+
) : undefined}
|
|
113
|
+
<NotionDialogText>{concept.text}</NotionDialogText>
|
|
114
|
+
</NotionDialogContent>
|
|
115
|
+
<NotionDialogLicenses
|
|
116
|
+
license={concept.copyright?.license?.license ?? ''}
|
|
117
|
+
source={concept.source}
|
|
118
|
+
/>
|
|
119
|
+
</>
|
|
120
|
+
}>
|
|
121
|
+
{concept.visualElement.image && (
|
|
122
|
+
<NotionImage
|
|
123
|
+
type={type}
|
|
124
|
+
id={visualElementId}
|
|
125
|
+
src={concept.visualElement.image.src}
|
|
126
|
+
alt={concept.visualElement.image.alt ?? ''}
|
|
127
|
+
imageCopyright={concept.visualElement.copyright}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
</Notion>
|
|
131
|
+
</ImageWrapper>
|
|
132
|
+
) : undefined
|
|
133
|
+
}
|
|
134
|
+
visualElement={
|
|
135
|
+
concept.visualElement && concept.visualElement.resource !== 'image' && concept.visualElement.url ? (
|
|
136
|
+
<ImageWrapper>
|
|
137
|
+
<Notion
|
|
138
|
+
id={notionId}
|
|
139
|
+
ariaLabel={t('factbox.open')}
|
|
140
|
+
title={concept.title}
|
|
141
|
+
hideBaselineIcon
|
|
142
|
+
subTitle={t('searchPage.resultType.notionsHeading')}
|
|
143
|
+
content={
|
|
144
|
+
<>
|
|
145
|
+
<NotionDialogContent>
|
|
146
|
+
{concept.visualElement &&
|
|
147
|
+
concept.visualElement?.resource !== 'image' &&
|
|
148
|
+
concept.visualElement.url ? (
|
|
149
|
+
<NotionVisualElement
|
|
150
|
+
visualElement={concept.visualElement}
|
|
151
|
+
id={notionId}
|
|
152
|
+
figureId={figureId}
|
|
153
|
+
/>
|
|
154
|
+
) : undefined}
|
|
155
|
+
|
|
156
|
+
<NotionDialogText>{concept.text}</NotionDialogText>
|
|
157
|
+
</NotionDialogContent>
|
|
158
|
+
<NotionDialogLicenses
|
|
159
|
+
license={concept.copyright?.license?.license ?? ''}
|
|
160
|
+
source={concept.source}
|
|
161
|
+
/>
|
|
162
|
+
</>
|
|
163
|
+
}>
|
|
164
|
+
{concept.image && (
|
|
165
|
+
<NotionImage
|
|
166
|
+
type={type}
|
|
167
|
+
id={visualElementId}
|
|
168
|
+
src={concept.image?.src}
|
|
169
|
+
alt={concept.image?.alt ?? ''}
|
|
170
|
+
imageCopyright={concept.visualElement.copyright}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
</Notion>
|
|
174
|
+
</ImageWrapper>
|
|
175
|
+
) : undefined
|
|
176
|
+
}></UINotion>
|
|
177
|
+
</FigureNotion>
|
|
178
|
+
</ContentWrapper>
|
|
80
179
|
);
|
|
81
180
|
};
|
|
82
181
|
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree. *
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import Button from '@ndla/button';
|
|
9
8
|
import { getGroupedContributorDescriptionList, getLicenseByAbbreviation } from '@ndla/licenses';
|
|
10
9
|
import React, { ReactNode } from 'react';
|
|
11
10
|
import { useTranslation } from 'react-i18next';
|
|
@@ -17,11 +16,12 @@ interface Props {
|
|
|
17
16
|
figureId: string;
|
|
18
17
|
children: ReactNode | ((params: { typeClass: string }) => ReactNode);
|
|
19
18
|
id: string;
|
|
20
|
-
title
|
|
19
|
+
title?: string;
|
|
21
20
|
copyright?: Partial<Copyright>;
|
|
22
21
|
licenseString: string;
|
|
23
22
|
type: 'video' | 'h5p' | 'image' | 'concept';
|
|
24
23
|
hideFigCaption?: boolean;
|
|
24
|
+
hideIconsAndAuthors?: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const FigureNotion = ({
|
|
@@ -34,6 +34,7 @@ const FigureNotion = ({
|
|
|
34
34
|
title,
|
|
35
35
|
type,
|
|
36
36
|
hideFigCaption,
|
|
37
|
+
hideIconsAndAuthors,
|
|
37
38
|
}: Props) => {
|
|
38
39
|
const { t, i18n } = useTranslation();
|
|
39
40
|
const license = getLicenseByAbbreviation(licenseString, i18n.language);
|
|
@@ -59,7 +60,8 @@ const FigureNotion = ({
|
|
|
59
60
|
id={id}
|
|
60
61
|
reuseLabel={t(`${type}.reuse`)}
|
|
61
62
|
authors={contributors}
|
|
62
|
-
licenseRights={license.rights}
|
|
63
|
+
licenseRights={license.rights}
|
|
64
|
+
hideIconsAndAuthors={hideIconsAndAuthors}>
|
|
63
65
|
<FigureLicenseDialog
|
|
64
66
|
id={id}
|
|
65
67
|
authors={contributors}
|
|
@@ -73,9 +75,7 @@ const FigureNotion = ({
|
|
|
73
75
|
source: t('source'),
|
|
74
76
|
learnAboutLicenses: t('license.learnMore'),
|
|
75
77
|
title: t('title'),
|
|
76
|
-
}}>
|
|
77
|
-
{type === 'image' && <Button outline>{t('license.copyTitle')}</Button>}
|
|
78
|
-
</FigureLicenseDialog>
|
|
78
|
+
}}></FigureLicenseDialog>
|
|
79
79
|
</FigureCaption>
|
|
80
80
|
)}
|
|
81
81
|
</>
|