@ndla/ui 45.0.17 → 46.0.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 +3 -3
- package/es/Article/ArticleByline.js +12 -10
- package/es/AudioPlayer/AudioPlayer.js +19 -19
- package/es/AudioPlayer/index.js +0 -2
- package/es/CampaignBlock/CampaignBlock.js +7 -7
- package/es/Embed/conceptComponents.js +15 -8
- package/es/Figure/Figure.js +11 -89
- package/es/Figure/index.js +1 -3
- package/es/FrontpageArticle/FrontpageArticle.js +4 -9
- package/es/Notion/index.js +1 -3
- package/es/all.css +1 -1
- package/es/index.js +3 -4
- package/lib/Article/Article.js +3 -3
- package/lib/Article/ArticleByline.d.ts +4 -3
- package/lib/Article/ArticleByline.js +12 -10
- package/lib/AudioPlayer/AudioPlayer.js +19 -19
- package/lib/AudioPlayer/index.d.ts +0 -2
- package/lib/AudioPlayer/index.js +0 -7
- package/lib/CampaignBlock/CampaignBlock.js +7 -7
- package/lib/Embed/conceptComponents.js +17 -10
- package/lib/Figure/Figure.d.ts +0 -38
- package/lib/Figure/Figure.js +20 -96
- package/lib/Figure/index.d.ts +1 -3
- package/lib/Figure/index.js +2 -17
- package/lib/FrontpageArticle/FrontpageArticle.js +4 -9
- package/lib/Notion/index.d.ts +0 -4
- package/lib/Notion/index.js +0 -14
- package/lib/all.css +1 -1
- package/lib/index.d.ts +3 -5
- package/lib/index.js +1 -32
- package/package.json +19 -23
- package/src/Article/Article.tsx +1 -1
- package/src/Article/ArticleByline.tsx +25 -21
- package/src/AudioPlayer/AudiPlayer.stories.tsx +88 -0
- package/src/AudioPlayer/AudioPlayer.tsx +3 -1
- package/src/AudioPlayer/index.ts +0 -2
- package/src/CampaignBlock/CampaignBlock.tsx +1 -1
- package/src/Embed/IframeEmbed.stories.tsx +15 -0
- package/src/Embed/ImageEmbed.stories.tsx +169 -2
- package/src/Embed/RelatedContentEmbed.stories.tsx +438 -0
- package/src/Embed/conceptComponents.tsx +13 -1
- package/src/Figure/Figure.tsx +1 -120
- package/src/Figure/index.ts +1 -3
- package/src/FrontpageArticle/FrontpageArticle.tsx +1 -12
- package/src/Notion/index.ts +0 -4
- package/src/index.ts +3 -13
- package/src/main.scss +0 -1
- package/es/Animation/Fade.js +0 -62
- package/es/Animation/index.js +0 -1
- package/es/AudioPlayer/initAudioPlayers.js +0 -60
- package/es/Dialog/Dialog.js +0 -70
- package/es/Dialog/index.js +0 -11
- package/es/Figure/FigureLicense.js +0 -72
- package/es/Figure/FigureLicenseDialog.js +0 -54
- package/es/Notion/ConceptNotion.js +0 -135
- package/es/Notion/FigureNotion.js +0 -93
- package/es/Notion/NotionVisualElement.js +0 -68
- package/es/utils/createUniversalPortal.js +0 -25
- package/lib/Animation/Fade.d.ts +0 -17
- package/lib/Animation/Fade.js +0 -70
- package/lib/Animation/index.d.ts +0 -1
- package/lib/Animation/index.js +0 -13
- package/lib/AudioPlayer/initAudioPlayers.d.ts +0 -11
- package/lib/AudioPlayer/initAudioPlayers.js +0 -69
- package/lib/Dialog/Dialog.d.ts +0 -23
- package/lib/Dialog/Dialog.js +0 -75
- package/lib/Dialog/index.d.ts +0 -10
- package/lib/Dialog/index.js +0 -22
- package/lib/Figure/FigureLicense.d.ts +0 -33
- package/lib/Figure/FigureLicense.js +0 -76
- package/lib/Figure/FigureLicenseDialog.d.ts +0 -29
- package/lib/Figure/FigureLicenseDialog.js +0 -57
- package/lib/Notion/ConceptNotion.d.ts +0 -24
- package/lib/Notion/ConceptNotion.js +0 -141
- package/lib/Notion/FigureNotion.d.ts +0 -27
- package/lib/Notion/FigureNotion.js +0 -97
- package/lib/Notion/NotionVisualElement.d.ts +0 -22
- package/lib/Notion/NotionVisualElement.js +0 -75
- package/lib/utils/createUniversalPortal.d.ts +0 -9
- package/lib/utils/createUniversalPortal.js +0 -32
- package/src/Animation/Fade.tsx +0 -46
- package/src/Animation/index.ts +0 -1
- package/src/AudioPlayer/initAudioPlayers.tsx +0 -57
- package/src/Dialog/Dialog.tsx +0 -80
- package/src/Dialog/component.dialog.scss +0 -144
- package/src/Dialog/index.ts +0 -13
- package/src/Figure/FigureLicense.tsx +0 -75
- package/src/Figure/FigureLicenseDialog.tsx +0 -51
- package/src/Notion/ConceptNotion.tsx +0 -170
- package/src/Notion/FigureNotion.tsx +0 -104
- package/src/Notion/NotionVisualElement.tsx +0 -80
- package/src/utils/createUniversalPortal.tsx +0 -23
package/src/Dialog/Dialog.tsx
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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
|
-
// N.B These component is used to render static markup serverside
|
|
10
|
-
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
|
-
|
|
12
|
-
import { ReactNode } from 'react';
|
|
13
|
-
import BEMHelper from 'react-bem-helper';
|
|
14
|
-
import { createUniversalPortal } from '../utils/createUniversalPortal';
|
|
15
|
-
|
|
16
|
-
const classes = new BEMHelper({
|
|
17
|
-
name: 'dialog',
|
|
18
|
-
prefix: 'c-',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
interface Props {
|
|
22
|
-
id: string;
|
|
23
|
-
labelledby?: string;
|
|
24
|
-
label?: string;
|
|
25
|
-
hidden?: boolean;
|
|
26
|
-
children?: ReactNode;
|
|
27
|
-
messages?: {
|
|
28
|
-
close: string;
|
|
29
|
-
};
|
|
30
|
-
modifier?: string | string[];
|
|
31
|
-
disablePortal?: boolean;
|
|
32
|
-
onClose?: () => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const Dialog = ({
|
|
36
|
-
children,
|
|
37
|
-
messages = { close: 'Lukk' },
|
|
38
|
-
id,
|
|
39
|
-
labelledby,
|
|
40
|
-
label,
|
|
41
|
-
modifier,
|
|
42
|
-
disablePortal = false,
|
|
43
|
-
hidden = true,
|
|
44
|
-
onClose,
|
|
45
|
-
...rest
|
|
46
|
-
}: Props) => {
|
|
47
|
-
const content = (
|
|
48
|
-
<div
|
|
49
|
-
{...classes('', modifier)}
|
|
50
|
-
data-dialog-id={id}
|
|
51
|
-
role="dialog"
|
|
52
|
-
aria-hidden={hidden}
|
|
53
|
-
aria-labelledby={labelledby}
|
|
54
|
-
aria-label={label}
|
|
55
|
-
{...rest}
|
|
56
|
-
>
|
|
57
|
-
<div {...classes('content')}>
|
|
58
|
-
<button
|
|
59
|
-
{...classes('close')}
|
|
60
|
-
type="button"
|
|
61
|
-
onClick={() => {
|
|
62
|
-
if (onClose) {
|
|
63
|
-
onClose();
|
|
64
|
-
}
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{messages.close}
|
|
68
|
-
</button>
|
|
69
|
-
{children}
|
|
70
|
-
</div>
|
|
71
|
-
<div className="o-backdrop" />
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
if (disablePortal) {
|
|
76
|
-
return content;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return createUniversalPortal(content, 'body');
|
|
80
|
-
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
.c-dialog {
|
|
2
|
-
text-align: left;
|
|
3
|
-
position: fixed;
|
|
4
|
-
top: 0;
|
|
5
|
-
bottom: 0;
|
|
6
|
-
left: 0;
|
|
7
|
-
right: 0;
|
|
8
|
-
display: none;
|
|
9
|
-
overflow: auto;
|
|
10
|
-
z-index: 9500;
|
|
11
|
-
align-items: center;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
font-family: $font;
|
|
14
|
-
.o-backdrop {
|
|
15
|
-
display: none;
|
|
16
|
-
z-index: 1;
|
|
17
|
-
}
|
|
18
|
-
&:not(&--large, &--fullscreen) {
|
|
19
|
-
h1 {
|
|
20
|
-
@include font-size(22px, 26px);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
&--small-heading {
|
|
24
|
-
h1 {
|
|
25
|
-
@include font-size(22px, 26px);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&--active {
|
|
30
|
-
display: flex;
|
|
31
|
-
.o-backdrop {
|
|
32
|
-
display: block;
|
|
33
|
-
animation-name: fadeIn;
|
|
34
|
-
animation-duration: 0.8s;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&__content {
|
|
39
|
-
overflow: hidden;
|
|
40
|
-
height: 0;
|
|
41
|
-
visibility: hidden;
|
|
42
|
-
position: relative;
|
|
43
|
-
z-index: 2;
|
|
44
|
-
color: $primary-color;
|
|
45
|
-
@include mq(tablet) {
|
|
46
|
-
min-width: 20rem;
|
|
47
|
-
}
|
|
48
|
-
@include font-size(18px, 1.33);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&--active &__content {
|
|
52
|
-
background-color: $brand-color--lighter;
|
|
53
|
-
box-shadow: 0 0 30px rgba($black, 0.2);
|
|
54
|
-
padding: $spacing--large $spacing;
|
|
55
|
-
@include mq($until: tablet) {
|
|
56
|
-
padding-left: 20px;
|
|
57
|
-
padding-right: 20px;
|
|
58
|
-
}
|
|
59
|
-
animation-name: zoomIn;
|
|
60
|
-
animation-duration: 0.3s;
|
|
61
|
-
overflow: auto;
|
|
62
|
-
height: 100vh;
|
|
63
|
-
width: 100vw;
|
|
64
|
-
-webkit-overflow-scrolling: touch;
|
|
65
|
-
|
|
66
|
-
@include mq(tablet) {
|
|
67
|
-
width: 90%;
|
|
68
|
-
max-height: 85vh;
|
|
69
|
-
// margin: 0 auto;
|
|
70
|
-
padding: $spacing--medium;
|
|
71
|
-
max-width: 613px;
|
|
72
|
-
min-width: 613px;
|
|
73
|
-
width: auto;
|
|
74
|
-
opacity: 1;
|
|
75
|
-
animation-name: fadeInBottomFixed;
|
|
76
|
-
height: auto;
|
|
77
|
-
}
|
|
78
|
-
visibility: visible;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&--active &__close {
|
|
82
|
-
display: block;
|
|
83
|
-
float: right;
|
|
84
|
-
position: relative;
|
|
85
|
-
z-index: 3;
|
|
86
|
-
background: transparent;
|
|
87
|
-
border: none;
|
|
88
|
-
color: $brand-color;
|
|
89
|
-
@include font-size(18px, 1.33);
|
|
90
|
-
font-weight: $font-weight-normal;
|
|
91
|
-
padding: 0;
|
|
92
|
-
box-shadow: $link;
|
|
93
|
-
height: 25px;
|
|
94
|
-
@include mq($until: tablet) {
|
|
95
|
-
+ * {
|
|
96
|
-
margin-top: $spacing--large;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
cursor: pointer;
|
|
100
|
-
&:hover {
|
|
101
|
-
box-shadow: $link--hover;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&--large &__content {
|
|
106
|
-
max-width: 970px;
|
|
107
|
-
width: 970px;
|
|
108
|
-
@include mq($until: 970px) {
|
|
109
|
-
max-height: 100vh;
|
|
110
|
-
min-height: 100vh;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&--medium &__content {
|
|
115
|
-
max-width: 790px;
|
|
116
|
-
width: 790px;
|
|
117
|
-
@include mq($until: 790px) {
|
|
118
|
-
max-height: 100vh;
|
|
119
|
-
min-height: 100vh;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
&--fullscreen &__content {
|
|
124
|
-
@include mq(tablet) {
|
|
125
|
-
height: 100vh;
|
|
126
|
-
width: 90vw;
|
|
127
|
-
max-width: 90vw;
|
|
128
|
-
.c-figure-license__img {
|
|
129
|
-
max-height: 85vh;
|
|
130
|
-
max-height: 85vh;
|
|
131
|
-
width: auto;
|
|
132
|
-
margin: auto;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/*
|
|
138
|
-
Hack for fixing top padding on devices
|
|
139
|
-
where had to add position fixed to <html />
|
|
140
|
-
to prevent scrolling on background
|
|
141
|
-
*/
|
|
142
|
-
html.scrollFix .c-dialog--active .c-dialog__content {
|
|
143
|
-
padding-top: $spacing--large;
|
|
144
|
-
}
|
package/src/Dialog/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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 { Dialog } from './Dialog';
|
|
10
|
-
|
|
11
|
-
export { Dialog };
|
|
12
|
-
|
|
13
|
-
export default Dialog;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2018-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
|
-
// N.B This component is used to render static markup serverside
|
|
10
|
-
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
|
-
|
|
12
|
-
import { ReactNode } from 'react';
|
|
13
|
-
import BEMHelper from 'react-bem-helper';
|
|
14
|
-
import { uuid } from '@ndla/util';
|
|
15
|
-
import { LicenseDescription } from '@ndla/notion';
|
|
16
|
-
import { FigureLicense } from './Figure';
|
|
17
|
-
import { Contributor } from '../types';
|
|
18
|
-
|
|
19
|
-
export const classLicenses = new BEMHelper({
|
|
20
|
-
name: 'figure-license',
|
|
21
|
-
prefix: 'c-',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
interface FigureLicenseCtaProps {
|
|
25
|
-
children?: ReactNode;
|
|
26
|
-
origin?: string;
|
|
27
|
-
authors?: Contributor[];
|
|
28
|
-
messages: {
|
|
29
|
-
source: string;
|
|
30
|
-
title: string;
|
|
31
|
-
};
|
|
32
|
-
title?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const FigureLicenseCta = ({ children, messages, authors, origin, title }: FigureLicenseCtaProps) => (
|
|
36
|
-
<div {...classLicenses('cta-wrapper')}>
|
|
37
|
-
<ul {...classLicenses('list')}>
|
|
38
|
-
{title && <li {...classLicenses('item')}>{`${messages.title}: ${title}`}</li>}
|
|
39
|
-
{authors?.map((author) => (
|
|
40
|
-
<li key={uuid()} {...classLicenses('item')}>{`${author.type}: ${author.name}`}</li>
|
|
41
|
-
))}
|
|
42
|
-
{origin && (
|
|
43
|
-
<li {...classLicenses('item')}>
|
|
44
|
-
{messages.source}:{' '}
|
|
45
|
-
{origin.startsWith('http') ? (
|
|
46
|
-
<a href={origin} target="_blank" rel="noopener noreferrer">
|
|
47
|
-
{origin}
|
|
48
|
-
</a>
|
|
49
|
-
) : (
|
|
50
|
-
origin
|
|
51
|
-
)}
|
|
52
|
-
</li>
|
|
53
|
-
)}
|
|
54
|
-
</ul>
|
|
55
|
-
<div {...classLicenses('cta-block')}>{children}</div>
|
|
56
|
-
</div>
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
interface Props {
|
|
60
|
-
messages: {
|
|
61
|
-
modelPremission?: string;
|
|
62
|
-
learnAboutLicenses: string;
|
|
63
|
-
};
|
|
64
|
-
license: FigureLicense;
|
|
65
|
-
locale: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const FigureLicenseByline = ({ messages, license, locale }: Props) => (
|
|
69
|
-
<>
|
|
70
|
-
<LicenseDescription key="byline" highlightCC locale={locale} messages={messages} licenseRights={license.rights} />
|
|
71
|
-
<a key="link" {...classLicenses('link')} target="_blank" rel="noopener noreferrer" href={license.url}>
|
|
72
|
-
{license.linkText}
|
|
73
|
-
</a>
|
|
74
|
-
</>
|
|
75
|
-
);
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017-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
|
-
// N.B This component is used to render static markup serverside
|
|
10
|
-
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
|
-
|
|
12
|
-
import { ReactNode } from 'react';
|
|
13
|
-
import Dialog from '../Dialog';
|
|
14
|
-
import { classLicenses, FigureLicenseByline, FigureLicenseCta } from './FigureLicense';
|
|
15
|
-
import { FigureLicense } from './Figure';
|
|
16
|
-
import { Contributor } from '../types';
|
|
17
|
-
|
|
18
|
-
export const FigureLicenseDialog = ({ children, messages, id, authors, origin, title, locale, license }: Props) => {
|
|
19
|
-
const headingLabelId = `heading-${id}`;
|
|
20
|
-
return (
|
|
21
|
-
<Dialog id={id} labelledby={headingLabelId} messages={messages}>
|
|
22
|
-
<div {...classLicenses()}>
|
|
23
|
-
<h1 id={headingLabelId} {...classLicenses('title')}>
|
|
24
|
-
{messages.rulesForUse}
|
|
25
|
-
</h1>
|
|
26
|
-
<FigureLicenseByline license={license} messages={messages} locale={locale} />
|
|
27
|
-
<FigureLicenseCta authors={authors} title={title} origin={origin} messages={messages}>
|
|
28
|
-
{children}
|
|
29
|
-
</FigureLicenseCta>
|
|
30
|
-
</div>
|
|
31
|
-
</Dialog>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
interface Props {
|
|
36
|
-
id: string;
|
|
37
|
-
children?: ReactNode;
|
|
38
|
-
origin?: string;
|
|
39
|
-
authors?: Contributor[];
|
|
40
|
-
messages: {
|
|
41
|
-
modelPremission?: string;
|
|
42
|
-
close: string;
|
|
43
|
-
rulesForUse: string;
|
|
44
|
-
source: string;
|
|
45
|
-
learnAboutLicenses: string;
|
|
46
|
-
title: string;
|
|
47
|
-
};
|
|
48
|
-
title?: string;
|
|
49
|
-
license: FigureLicense;
|
|
50
|
-
locale: string;
|
|
51
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022-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
|
-
import styled from '@emotion/styled';
|
|
8
|
-
|
|
9
|
-
import { useEffect } from 'react';
|
|
10
|
-
//@ts-ignore
|
|
11
|
-
import { initArticleScripts } from '@ndla/article-scripts';
|
|
12
|
-
import { useTranslation } from 'react-i18next';
|
|
13
|
-
import { breakpoints, mq, spacing } from '@ndla/core';
|
|
14
|
-
import { parseMarkdown } from '@ndla/util';
|
|
15
|
-
import { getLicenseCredits } from '@ndla/licenses';
|
|
16
|
-
import Notion, { NotionDialogContent, NotionDialogText, NotionDialogLicenses } from '@ndla/notion';
|
|
17
|
-
import { Notion as UINotion } from '.';
|
|
18
|
-
import { NotionImage } from './NotionImage';
|
|
19
|
-
import NotionVisualElement from './NotionVisualElement';
|
|
20
|
-
import type { NotionVisualElementType } from './NotionVisualElement';
|
|
21
|
-
import FigureNotion from './FigureNotion';
|
|
22
|
-
import { Copyright } from '../types';
|
|
23
|
-
import { FigureType } from '../Figure';
|
|
24
|
-
|
|
25
|
-
const ImageWrapper = styled.div`
|
|
26
|
-
float: right;
|
|
27
|
-
padding-left: ${spacing.normal};
|
|
28
|
-
position: relative;
|
|
29
|
-
|
|
30
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
31
|
-
width: 100%;
|
|
32
|
-
padding-left: 0;
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
export interface ConceptNotionType {
|
|
37
|
-
id: number;
|
|
38
|
-
copyright?: Partial<Copyright>;
|
|
39
|
-
title: string;
|
|
40
|
-
text: string;
|
|
41
|
-
visualElement?: NotionVisualElementType;
|
|
42
|
-
source?: string;
|
|
43
|
-
image?: {
|
|
44
|
-
src: string;
|
|
45
|
-
alt: string;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
interface Props {
|
|
49
|
-
type?: 'image' | 'video' | 'h5p' | 'iframe' | 'external';
|
|
50
|
-
concept: ConceptNotionType;
|
|
51
|
-
disableScripts?: boolean;
|
|
52
|
-
hideIconsAndAuthors?: boolean;
|
|
53
|
-
figureType?: FigureType;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const ConceptNotion = ({ concept, disableScripts, type, hideIconsAndAuthors, figureType }: Props) => {
|
|
57
|
-
const notionId = `notion-${concept.id}`;
|
|
58
|
-
const figureId = `notion-figure-${concept.id}`;
|
|
59
|
-
const visualElementId = `visual-element-${concept.id}`;
|
|
60
|
-
const { t } = useTranslation();
|
|
61
|
-
|
|
62
|
-
const { creators, rightsholders, processors } = getLicenseCredits(concept.copyright);
|
|
63
|
-
|
|
64
|
-
const authors = (creators.length || rightsholders.length ? [...creators, ...rightsholders] : [...processors]).map(
|
|
65
|
-
(author) => author.name,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!disableScripts) {
|
|
70
|
-
initArticleScripts();
|
|
71
|
-
}
|
|
72
|
-
}, [disableScripts]);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<FigureNotion
|
|
76
|
-
resizeIframe
|
|
77
|
-
id={figureId}
|
|
78
|
-
title={concept.title}
|
|
79
|
-
figureId={visualElementId}
|
|
80
|
-
copyright={concept.copyright}
|
|
81
|
-
licenseString={concept.copyright?.license?.license ?? ''}
|
|
82
|
-
type="concept"
|
|
83
|
-
hideIconsAndAuthors={hideIconsAndAuthors}
|
|
84
|
-
figureType={figureType}
|
|
85
|
-
>
|
|
86
|
-
<UINotion
|
|
87
|
-
id={notionId}
|
|
88
|
-
title={concept.title}
|
|
89
|
-
text={concept.text}
|
|
90
|
-
imageElement={
|
|
91
|
-
concept.visualElement?.resource === 'image' && concept.visualElement.image ? (
|
|
92
|
-
<ImageWrapper>
|
|
93
|
-
<Notion
|
|
94
|
-
id={notionId}
|
|
95
|
-
title={concept.title}
|
|
96
|
-
subTitle={t('searchPage.resultType.notionsHeading')}
|
|
97
|
-
hideBaselineIcon
|
|
98
|
-
content={
|
|
99
|
-
<>
|
|
100
|
-
<NotionDialogContent>
|
|
101
|
-
{concept.visualElement?.resource === 'image' && concept.visualElement.image ? (
|
|
102
|
-
<NotionVisualElement visualElement={concept.visualElement} id={notionId} figureId={figureId} />
|
|
103
|
-
) : undefined}
|
|
104
|
-
<NotionDialogText>{parseMarkdown(concept.text, 'body')}</NotionDialogText>
|
|
105
|
-
</NotionDialogContent>
|
|
106
|
-
<NotionDialogLicenses
|
|
107
|
-
authors={authors}
|
|
108
|
-
license={concept.copyright?.license?.license ?? ''}
|
|
109
|
-
source={concept.source}
|
|
110
|
-
/>
|
|
111
|
-
</>
|
|
112
|
-
}
|
|
113
|
-
>
|
|
114
|
-
{concept.visualElement.image && (
|
|
115
|
-
<NotionImage
|
|
116
|
-
type={type}
|
|
117
|
-
id={visualElementId}
|
|
118
|
-
src={concept.visualElement.image.src}
|
|
119
|
-
alt={concept.visualElement.image.alt ?? ''}
|
|
120
|
-
/>
|
|
121
|
-
)}
|
|
122
|
-
</Notion>
|
|
123
|
-
</ImageWrapper>
|
|
124
|
-
) : undefined
|
|
125
|
-
}
|
|
126
|
-
visualElement={
|
|
127
|
-
concept.visualElement && concept.visualElement.resource !== 'image' && concept.visualElement.url ? (
|
|
128
|
-
<ImageWrapper>
|
|
129
|
-
<Notion
|
|
130
|
-
id={notionId}
|
|
131
|
-
title={concept.title}
|
|
132
|
-
hideBaselineIcon
|
|
133
|
-
subTitle={t('searchPage.resultType.notionsHeading')}
|
|
134
|
-
content={
|
|
135
|
-
<>
|
|
136
|
-
<NotionDialogContent>
|
|
137
|
-
{concept.visualElement &&
|
|
138
|
-
concept.visualElement?.resource !== 'image' &&
|
|
139
|
-
concept.visualElement.url ? (
|
|
140
|
-
<NotionVisualElement visualElement={concept.visualElement} id={notionId} figureId={figureId} />
|
|
141
|
-
) : undefined}
|
|
142
|
-
|
|
143
|
-
<NotionDialogText>{parseMarkdown(concept.text, 'body')}</NotionDialogText>
|
|
144
|
-
</NotionDialogContent>
|
|
145
|
-
<NotionDialogLicenses
|
|
146
|
-
authors={authors}
|
|
147
|
-
license={concept.copyright?.license?.license ?? ''}
|
|
148
|
-
source={concept.source}
|
|
149
|
-
/>
|
|
150
|
-
</>
|
|
151
|
-
}
|
|
152
|
-
>
|
|
153
|
-
{concept.image && (
|
|
154
|
-
<NotionImage
|
|
155
|
-
type={type}
|
|
156
|
-
id={visualElementId}
|
|
157
|
-
src={concept.image?.src}
|
|
158
|
-
alt={concept.image?.alt ?? ''}
|
|
159
|
-
/>
|
|
160
|
-
)}
|
|
161
|
-
</Notion>
|
|
162
|
-
</ImageWrapper>
|
|
163
|
-
) : undefined
|
|
164
|
-
}
|
|
165
|
-
></UINotion>
|
|
166
|
-
</FigureNotion>
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export default ConceptNotion;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022-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
|
-
import styled from '@emotion/styled';
|
|
9
|
-
import { colors, spacing } from '@ndla/core';
|
|
10
|
-
import { getGroupedContributorDescriptionList, getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
|
|
11
|
-
import { ReactNode } from 'react';
|
|
12
|
-
import { useTranslation } from 'react-i18next';
|
|
13
|
-
import { Figure, FigureCaption, FigureLicenseDialog, FigureType } from '../Figure';
|
|
14
|
-
import { Copyright } from '../types';
|
|
15
|
-
|
|
16
|
-
const BottomBorder = styled.div`
|
|
17
|
-
margin-top: ${spacing.normal};
|
|
18
|
-
border-bottom: 1px solid ${colors.brand.greyLight};
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
interface Props {
|
|
22
|
-
resizeIframe?: boolean;
|
|
23
|
-
figureId: string;
|
|
24
|
-
children: ReactNode | ((params: { typeClass: string }) => ReactNode);
|
|
25
|
-
id: string;
|
|
26
|
-
title: string;
|
|
27
|
-
copyright?: Partial<Copyright>;
|
|
28
|
-
licenseString: string;
|
|
29
|
-
type: 'video' | 'h5p' | 'image' | 'concept' | 'other';
|
|
30
|
-
hideFigCaption?: boolean;
|
|
31
|
-
hideIconsAndAuthors?: boolean;
|
|
32
|
-
figureType?: FigureType;
|
|
33
|
-
licenseButtons?: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const FigureNotion = ({
|
|
37
|
-
resizeIframe,
|
|
38
|
-
figureId,
|
|
39
|
-
children,
|
|
40
|
-
id,
|
|
41
|
-
copyright,
|
|
42
|
-
licenseString,
|
|
43
|
-
title,
|
|
44
|
-
type,
|
|
45
|
-
hideFigCaption,
|
|
46
|
-
hideIconsAndAuthors,
|
|
47
|
-
figureType,
|
|
48
|
-
licenseButtons,
|
|
49
|
-
}: Props) => {
|
|
50
|
-
const { t, i18n } = useTranslation();
|
|
51
|
-
const license = getLicenseByAbbreviation(licenseString, i18n.language);
|
|
52
|
-
const licenseCredits = getLicenseCredits(copyright);
|
|
53
|
-
const { creators, rightsholders, processors } = licenseCredits;
|
|
54
|
-
|
|
55
|
-
const authors = creators.length || rightsholders.length ? [...creators, ...rightsholders] : [...processors];
|
|
56
|
-
|
|
57
|
-
const groupedAuthors = getGroupedContributorDescriptionList(licenseCredits, i18n.language).map((item) => ({
|
|
58
|
-
name: item.description,
|
|
59
|
-
type: item.label,
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<Figure resizeIframe={resizeIframe} id={figureId} type={figureType || 'full-column'}>
|
|
64
|
-
{({ typeClass }) => (
|
|
65
|
-
<>
|
|
66
|
-
{typeof children === 'function' ? children({ typeClass }) : children}
|
|
67
|
-
{copyright?.license?.license ? (
|
|
68
|
-
<FigureCaption
|
|
69
|
-
hideFigcaption={hideFigCaption}
|
|
70
|
-
figureId={figureId}
|
|
71
|
-
id={id}
|
|
72
|
-
reuseLabel={t(`${type}.reuse`)}
|
|
73
|
-
authors={authors}
|
|
74
|
-
licenseRights={license.rights}
|
|
75
|
-
hideIconsAndAuthors={hideIconsAndAuthors}
|
|
76
|
-
>
|
|
77
|
-
<FigureLicenseDialog
|
|
78
|
-
id={id}
|
|
79
|
-
authors={groupedAuthors}
|
|
80
|
-
locale={i18n.language}
|
|
81
|
-
title={title}
|
|
82
|
-
origin={copyright?.origin}
|
|
83
|
-
license={license}
|
|
84
|
-
messages={{
|
|
85
|
-
close: t('close'),
|
|
86
|
-
rulesForUse: t(`license.${type}.rules`),
|
|
87
|
-
source: t('source'),
|
|
88
|
-
learnAboutLicenses: t('license.learnMore'),
|
|
89
|
-
title: t('title'),
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{licenseButtons}
|
|
93
|
-
</FigureLicenseDialog>
|
|
94
|
-
</FigureCaption>
|
|
95
|
-
) : (
|
|
96
|
-
<BottomBorder />
|
|
97
|
-
)}
|
|
98
|
-
</>
|
|
99
|
-
)}
|
|
100
|
-
</Figure>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default FigureNotion;
|