@ndla/ui 3.2.1-alpha.8 → 3.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/AuthorInfo/AuthorInfo.js +1 -2
- package/lib/BackgroundImage/BackgroundImage.d.ts +11 -0
- package/{es/BackgroundImage/index.js → lib/BackgroundImage/index.d.ts} +1 -1
- package/lib/ContentLoader/index.d.ts +20 -0
- package/lib/Dialog/Dialog.d.ts +23 -0
- package/{es/Dialog/index.js → lib/Dialog/index.d.ts} +1 -1
- package/lib/Figure/Figure.d.ts +50 -0
- package/lib/Figure/FigureExpandButton.d.ts +16 -0
- package/lib/Figure/FigureLicense.d.ts +33 -0
- package/lib/Figure/FigureLicenseDialog.d.ts +29 -0
- package/{es/Figure/index.js → lib/Figure/index.d.ts} +1 -1
- package/lib/FileList/File.d.ts +7 -0
- package/lib/FileList/FileList.d.ts +17 -0
- package/{es/FileList/index.js → lib/FileList/index.d.ts} +1 -1
- package/lib/Hero/Hero.d.ts +26 -0
- package/{es/Hero/index.js → lib/Hero/index.d.ts} +1 -1
- package/lib/Image/Image.d.ts +25 -0
- package/lib/Image/ImageLink.d.ts +18 -0
- package/lib/Image/LazyLoadImage.d.ts +17 -0
- package/{es/Image/index.js → lib/Image/index.d.ts} +1 -1
- package/lib/InfoBox/InfoBox.d.ts +6 -0
- package/{src/InfoBox/index.js → lib/InfoBox/index.d.ts} +0 -0
- package/lib/InfoWidget/InfoWidget.d.ts +19 -0
- package/{es/InfoWidget/index.js → lib/InfoWidget/index.d.ts} +1 -1
- package/lib/Logo/Logo.d.ts +24 -0
- package/lib/Logo/SvgLogo.d.ts +14 -0
- package/{es/Logo/index.js → lib/Logo/index.d.ts} +1 -1
- package/lib/Masthead/Masthead.d.ts +27 -0
- package/{es/Masthead/index.js → lib/Masthead/index.d.ts} +1 -1
- package/lib/NoContentBox/NoContentBox.d.ts +14 -0
- package/{es/NoContentBox/index.js → lib/NoContentBox/index.d.ts} +1 -1
- package/lib/Portrait/Portrait.d.ts +15 -0
- package/{es/Portrait/index.js → lib/Portrait/index.d.ts} +1 -1
- package/lib/Topic/Topic.d.ts +3 -2
- package/lib/Translation/Translation.d.ts +14 -0
- package/lib/Translation/TranslationBox.d.ts +10 -0
- package/lib/Translation/TranslationLine.d.ts +16 -0
- package/{src/Translation/index.js → lib/Translation/index.d.ts} +0 -0
- package/lib/index.d.ts +14 -0
- package/lib/locale/messages-en.d.ts +4 -0
- package/lib/locale/messages-nb.d.ts +4 -0
- package/lib/locale/messages-nn.d.ts +4 -0
- package/lib/types.d.ts +10 -0
- package/package.json +6 -6
- package/src/Article/ArticleAuthorContent.tsx +0 -1
- package/src/AuthorInfo/AuthorInfo.tsx +0 -1
- package/src/BackgroundImage/BackgroundImage.tsx +32 -0
- package/src/BackgroundImage/{index.js → index.ts} +0 -0
- package/src/ContentLoader/{index.js → index.tsx} +20 -30
- package/src/Dialog/{Dialog.jsx → Dialog.tsx} +20 -32
- package/src/Dialog/{index.js → index.ts} +0 -0
- package/src/Figure/{Figure.js → Figure.tsx} +44 -54
- package/src/Figure/{FigureExpandButton.js → FigureExpandButton.tsx} +8 -9
- package/src/Figure/{FigureLicense.js → FigureLicense.tsx} +32 -30
- package/src/Figure/{FigureLicenseDialog.js → FigureLicenseDialog.tsx} +22 -22
- package/src/Figure/{index.js → index.ts} +0 -0
- package/src/FileList/{File.jsx → File.tsx} +8 -18
- package/src/FileList/FileList.tsx +36 -0
- package/src/FileList/{index.js → index.ts} +0 -0
- package/src/Hero/Hero.tsx +56 -0
- package/src/Hero/{index.js → index.ts} +0 -0
- package/src/Image/{Image.jsx → Image.tsx} +30 -30
- package/src/Image/{ImageLink.js → ImageLink.tsx} +11 -12
- package/src/Image/LazyLoadImage.tsx +40 -0
- package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +4 -3
- package/src/Image/{index.js → index.ts} +0 -0
- package/src/InfoBox/InfoBox.tsx +11 -0
- package/src/InfoBox/index.ts +1 -0
- package/src/InfoWidget/{InfoWidget.jsx → InfoWidget.tsx} +19 -26
- package/src/InfoWidget/{index.js → index.ts} +0 -0
- package/src/Logo/{Logo.jsx → Logo.tsx} +21 -28
- package/src/Logo/{SvgLogo.jsx → SvgLogo.tsx} +8 -14
- package/src/Logo/{index.js → index.ts} +0 -0
- package/src/Masthead/{Masthead.jsx → Masthead.tsx} +33 -35
- package/src/Masthead/{index.js → index.ts} +0 -0
- package/src/NoContentBox/{NoContentBox.jsx → NoContentBox.tsx} +7 -13
- package/src/NoContentBox/{index.js → index.ts} +0 -0
- package/src/Portrait/{Portrait.jsx → Portrait.tsx} +8 -14
- package/src/Portrait/{index.js → index.ts} +0 -0
- package/src/Topic/Topic.tsx +3 -2
- package/src/Translation/{Translation.jsx → Translation.tsx} +7 -8
- package/src/Translation/TranslationBox.tsx +20 -0
- package/src/Translation/{TranslationLine.jsx → TranslationLine.tsx} +11 -18
- package/{es/Translation/index.js → src/Translation/index.ts} +1 -1
- package/src/index-javascript.js +0 -29
- package/src/index.ts +35 -0
- package/src/locale/messages-en.ts +4 -0
- package/src/locale/messages-nb.ts +5 -1
- package/src/locale/messages-nn.ts +5 -1
- package/src/types.ts +12 -0
- package/es/BackgroundImage/BackgroundImage.js +0 -37
- package/es/ContentLoader/index.js +0 -96
- package/es/Dialog/Dialog.js +0 -82
- package/es/Figure/Figure.js +0 -125
- package/es/Figure/FigureExpandButton.js +0 -37
- package/es/Figure/FigureLicense.js +0 -74
- package/es/Figure/FigureLicenseDialog.js +0 -61
- package/es/FileList/File.js +0 -61
- package/es/FileList/FileList.js +0 -33
- package/es/Hero/Hero.js +0 -70
- package/es/Image/Image.js +0 -119
- package/es/Image/ImageLink.js +0 -55
- package/es/Image/LazyLoadImage.js +0 -56
- package/es/Image/shapes.js +0 -18
- package/es/InfoBox/InfoBox.js +0 -15
- package/es/InfoBox/index.js +0 -1
- package/es/InfoWidget/InfoWidget.js +0 -76
- package/es/Logo/Logo.js +0 -67
- package/es/Logo/SvgLogo.js +0 -62
- package/es/Masthead/Masthead.js +0 -88
- package/es/NoContentBox/NoContentBox.js +0 -35
- package/es/Portrait/Portrait.js +0 -41
- package/es/Translation/Translation.js +0 -27
- package/es/Translation/TranslationBox.js +0 -13
- package/es/Translation/TranslationLine.js +0 -48
- package/lib/BackgroundImage/BackgroundImage.js +0 -52
- package/lib/BackgroundImage/index.js +0 -13
- package/lib/ContentLoader/index.js +0 -102
- package/lib/Dialog/Dialog.js +0 -90
- package/lib/Dialog/index.js +0 -24
- package/lib/Figure/Figure.js +0 -139
- package/lib/Figure/FigureExpandButton.js +0 -52
- package/lib/Figure/FigureLicense.js +0 -88
- package/lib/Figure/FigureLicenseDialog.js +0 -69
- package/lib/Figure/index.js +0 -49
- package/lib/FileList/File.js +0 -77
- package/lib/FileList/FileList.js +0 -48
- package/lib/FileList/index.js +0 -21
- package/lib/Hero/Hero.js +0 -108
- package/lib/Hero/index.js +0 -55
- package/lib/Image/Image.js +0 -129
- package/lib/Image/ImageLink.js +0 -62
- package/lib/Image/LazyLoadImage.js +0 -61
- package/lib/Image/index.js +0 -38
- package/lib/Image/shapes.js +0 -33
- package/lib/InfoBox/InfoBox.js +0 -29
- package/lib/InfoBox/index.js +0 -15
- package/lib/InfoWidget/InfoWidget.js +0 -93
- package/lib/InfoWidget/index.js +0 -13
- package/lib/Logo/Logo.js +0 -93
- package/lib/Logo/SvgLogo.js +0 -68
- package/lib/Logo/index.js +0 -20
- package/lib/Masthead/Masthead.js +0 -106
- package/lib/Masthead/index.js +0 -30
- package/lib/NoContentBox/NoContentBox.js +0 -53
- package/lib/NoContentBox/index.js +0 -20
- package/lib/Portrait/Portrait.js +0 -55
- package/lib/Portrait/index.js +0 -20
- package/lib/Translation/Translation.js +0 -41
- package/lib/Translation/TranslationBox.js +0 -25
- package/lib/Translation/TranslationLine.js +0 -60
- package/lib/Translation/index.js +0 -31
- package/src/BackgroundImage/BackgroundImage.jsx +0 -39
- package/src/FileList/FileList.jsx +0 -36
- package/src/Hero/Hero.jsx +0 -38
- package/src/Image/LazyLoadImage.jsx +0 -39
- package/src/Image/shapes.js +0 -21
- package/src/InfoBox/InfoBox.jsx +0 -13
- package/src/Translation/TranslationBox.jsx +0 -12
package/lib/types.d.ts
CHANGED
|
@@ -37,6 +37,16 @@ export interface Contributor {
|
|
|
37
37
|
export interface License {
|
|
38
38
|
license: string;
|
|
39
39
|
}
|
|
40
|
+
export interface ImageCrop {
|
|
41
|
+
startX: number;
|
|
42
|
+
startY: number;
|
|
43
|
+
endX: number;
|
|
44
|
+
endY: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ImageFocalPoint {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}
|
|
40
50
|
export interface Copyright {
|
|
41
51
|
license: License;
|
|
42
52
|
creators: Array<Contributor>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "3.2.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/button": "^1.0
|
|
34
|
+
"@ndla/button": "^1.1.0",
|
|
35
35
|
"@ndla/carousel": "^1.0.6",
|
|
36
36
|
"@ndla/core": "^0.7.2",
|
|
37
37
|
"@ndla/hooks": "^1.0.6",
|
|
38
38
|
"@ndla/icons": "^1.3.1",
|
|
39
39
|
"@ndla/licenses": "^1.0.7",
|
|
40
|
-
"@ndla/modal": "^1.1.12
|
|
40
|
+
"@ndla/modal": "^1.1.12",
|
|
41
41
|
"@ndla/safelink": "^1.0.5",
|
|
42
42
|
"@ndla/switch": "^0.0.32",
|
|
43
|
-
"@ndla/tabs": "^1.0.
|
|
44
|
-
"@ndla/tooltip": "^0.2.
|
|
43
|
+
"@ndla/tabs": "^1.0.9",
|
|
44
|
+
"@ndla/tooltip": "^0.2.48",
|
|
45
45
|
"@ndla/util": "^2.0.0",
|
|
46
46
|
"@reach/menu-button": "^0.12.1",
|
|
47
47
|
"@reach/slider": "^0.12.1",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "e2135297c1f57072515a122173674a211b541752"
|
|
96
96
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BEMHelper from 'react-bem-helper';
|
|
3
|
+
|
|
4
|
+
const classes = BEMHelper('c-background-image');
|
|
5
|
+
|
|
6
|
+
type ImageType = 'mobile' | 'tablet' | 'desktop' | 'wide';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
showOverlay?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
images: {
|
|
12
|
+
url: string;
|
|
13
|
+
types: ImageType[];
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const BackgroundImage = ({ images, showOverlay = false }: Props) => (
|
|
18
|
+
<div {...classes('', { showOverlay })}>
|
|
19
|
+
{images &&
|
|
20
|
+
images.map((image) =>
|
|
21
|
+
image.types.map((type) => (
|
|
22
|
+
<div
|
|
23
|
+
key={`${image.url}${type}`}
|
|
24
|
+
{...classes('background', type)}
|
|
25
|
+
style={{ backgroundImage: `url(${image.url})` }}
|
|
26
|
+
/>
|
|
27
|
+
)),
|
|
28
|
+
)}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export default BackgroundImage;
|
|
File without changes
|
|
@@ -6,21 +6,31 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
9
|
+
import React, { ReactNode } from 'react';
|
|
11
10
|
import { uuid } from '@ndla/util';
|
|
12
11
|
|
|
12
|
+
interface Props {
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
speed?: number;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
primaryColor?: string;
|
|
18
|
+
secondaryColor?: string;
|
|
19
|
+
preserveAspectRatio?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
const ContentLoader = ({
|
|
14
24
|
children,
|
|
15
|
-
width,
|
|
16
|
-
height,
|
|
17
|
-
preserveAspectRatio,
|
|
18
|
-
className,
|
|
19
|
-
primaryColor,
|
|
20
|
-
secondaryColor,
|
|
21
|
-
speed,
|
|
25
|
+
width = 400,
|
|
26
|
+
height = 130,
|
|
27
|
+
preserveAspectRatio = 'xMidYMid meet',
|
|
28
|
+
className = '',
|
|
29
|
+
primaryColor = '#f0f0f0',
|
|
30
|
+
secondaryColor = '#e0e0e0',
|
|
31
|
+
speed = 2,
|
|
22
32
|
...rest
|
|
23
|
-
}) => {
|
|
33
|
+
}: Props) => {
|
|
24
34
|
const idClip = uuid();
|
|
25
35
|
const idGradient = uuid();
|
|
26
36
|
|
|
@@ -59,24 +69,4 @@ const ContentLoader = ({
|
|
|
59
69
|
);
|
|
60
70
|
};
|
|
61
71
|
|
|
62
|
-
ContentLoader.propTypes = {
|
|
63
|
-
children: PropTypes.node,
|
|
64
|
-
speed: PropTypes.number,
|
|
65
|
-
width: PropTypes.number,
|
|
66
|
-
height: PropTypes.number,
|
|
67
|
-
primaryColor: PropTypes.string,
|
|
68
|
-
secondaryColor: PropTypes.string,
|
|
69
|
-
preserveAspectRatio: PropTypes.string,
|
|
70
|
-
className: PropTypes.string,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
ContentLoader.defaultProps = {
|
|
74
|
-
speed: 2,
|
|
75
|
-
width: 400,
|
|
76
|
-
height: 130,
|
|
77
|
-
primaryColor: '#f0f0f0',
|
|
78
|
-
secondaryColor: '#e0e0e0',
|
|
79
|
-
preserveAspectRatio: 'xMidYMid meet',
|
|
80
|
-
className: '',
|
|
81
|
-
};
|
|
82
72
|
export default ContentLoader;
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
// N.B These component is used to render static markup serverside
|
|
10
10
|
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
11
|
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
12
|
+
import React, { ReactNode } from 'react';
|
|
14
13
|
import BEMHelper from 'react-bem-helper';
|
|
15
|
-
|
|
14
|
+
//@ts-ignore
|
|
16
15
|
import { createUniversalPortal } from '../utils/createUniversalPortal';
|
|
17
16
|
|
|
18
17
|
const classes = new BEMHelper({
|
|
@@ -20,18 +19,32 @@ const classes = new BEMHelper({
|
|
|
20
19
|
prefix: 'c-',
|
|
21
20
|
});
|
|
22
21
|
|
|
22
|
+
interface Props {
|
|
23
|
+
id: string;
|
|
24
|
+
labelledby?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
messages?: {
|
|
29
|
+
close: string;
|
|
30
|
+
};
|
|
31
|
+
modifier?: string | string[];
|
|
32
|
+
disablePortal?: boolean;
|
|
33
|
+
onClose?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
export const Dialog = ({
|
|
24
37
|
children,
|
|
25
|
-
messages,
|
|
38
|
+
messages = { close: 'Lukk' },
|
|
26
39
|
id,
|
|
27
40
|
labelledby,
|
|
28
41
|
label,
|
|
29
42
|
modifier,
|
|
30
|
-
disablePortal,
|
|
31
|
-
hidden,
|
|
43
|
+
disablePortal = false,
|
|
44
|
+
hidden = true,
|
|
32
45
|
onClose,
|
|
33
46
|
...rest
|
|
34
|
-
}) => {
|
|
47
|
+
}: Props) => {
|
|
35
48
|
const content = (
|
|
36
49
|
<div
|
|
37
50
|
{...classes('', modifier)}
|
|
@@ -64,28 +77,3 @@ export const Dialog = ({
|
|
|
64
77
|
|
|
65
78
|
return createUniversalPortal(content, 'body');
|
|
66
79
|
};
|
|
67
|
-
|
|
68
|
-
Dialog.propTypes = {
|
|
69
|
-
id: PropTypes.string.isRequired,
|
|
70
|
-
labelledby: PropTypes.string,
|
|
71
|
-
label: PropTypes.string,
|
|
72
|
-
hidden: PropTypes.bool,
|
|
73
|
-
children: PropTypes.node,
|
|
74
|
-
messages: PropTypes.shape({
|
|
75
|
-
close: PropTypes.string.isRequired,
|
|
76
|
-
}),
|
|
77
|
-
modifier: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
78
|
-
disablePortal: PropTypes.bool,
|
|
79
|
-
onClose: PropTypes.func,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
Dialog.defaultProps = {
|
|
83
|
-
disablePortal: false,
|
|
84
|
-
labelledby: null,
|
|
85
|
-
label: null,
|
|
86
|
-
hidden: true,
|
|
87
|
-
onClose: null,
|
|
88
|
-
messages: {
|
|
89
|
-
close: 'Lukk',
|
|
90
|
-
},
|
|
91
|
-
};
|
|
File without changes
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
// N.B These component is used to render static markup serverside
|
|
10
10
|
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
11
|
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
12
|
+
import React, { ReactNode } from 'react';
|
|
14
13
|
import BEMHelper from 'react-bem-helper';
|
|
15
14
|
import { isFunction, parseMarkdown } from '@ndla/util';
|
|
16
15
|
import { useTranslation } from 'react-i18next';
|
|
17
16
|
import { Link as LinkIcon } from '@ndla/icons/common';
|
|
18
17
|
import { LicenseByline } from '@ndla/licenses';
|
|
19
18
|
import SafeLink from '@ndla/safelink';
|
|
19
|
+
//@ts-ignore
|
|
20
20
|
import Button from '@ndla/button';
|
|
21
|
+
import { License } from '../types';
|
|
21
22
|
|
|
22
23
|
const classes = new BEMHelper({
|
|
23
24
|
name: 'figure',
|
|
@@ -36,16 +37,16 @@ export const FigureCaption = ({
|
|
|
36
37
|
link,
|
|
37
38
|
hideFigcaption,
|
|
38
39
|
hasLinkedVideo,
|
|
39
|
-
}) => {
|
|
40
|
+
}: FigureCaptionProps) => {
|
|
40
41
|
const { t } = useTranslation();
|
|
41
42
|
return (
|
|
42
|
-
<figcaption {...classes('caption', hideFigcaption
|
|
43
|
+
<figcaption {...classes('caption', hideFigcaption ? 'hidden-caption' : undefined)}>
|
|
43
44
|
{caption ? <div {...classes('info')}>{parseMarkdown(caption)}</div> : null}
|
|
44
45
|
<footer {...classes('byline')}>
|
|
45
46
|
<div {...classes('byline-licenselist')}>
|
|
46
47
|
<LicenseByline licenseRights={licenseRights} locale={locale} marginRight>
|
|
47
48
|
<div {...classes('byline-author-buttons')}>
|
|
48
|
-
<span {...classes('byline-authors')}>{authors
|
|
49
|
+
<span {...classes('byline-authors')}>{authors?.map((author) => author.name).join(', ')}</span>
|
|
49
50
|
<div>
|
|
50
51
|
<Button
|
|
51
52
|
borderShape="rounded"
|
|
@@ -76,8 +77,8 @@ export const FigureCaption = ({
|
|
|
76
77
|
<SafeLink
|
|
77
78
|
to={link.url}
|
|
78
79
|
{...classes('link')}
|
|
79
|
-
target={link.external ? '_blank' :
|
|
80
|
-
rel={link.external ? 'noopener noreferrer' :
|
|
80
|
+
target={link.external ? '_blank' : undefined}
|
|
81
|
+
rel={link.external ? 'noopener noreferrer' : undefined}>
|
|
81
82
|
<span {...classes('link-text')}>{link.text}</span>
|
|
82
83
|
<LinkIcon />
|
|
83
84
|
</SafeLink>
|
|
@@ -90,61 +91,50 @@ export const FigureCaption = ({
|
|
|
90
91
|
);
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
name: PropTypes.string.isRequired,
|
|
103
|
-
}),
|
|
104
|
-
),
|
|
105
|
-
link: PropTypes.shape({
|
|
106
|
-
url: PropTypes.string.isRequired,
|
|
107
|
-
text: PropTypes.string.isRequired,
|
|
108
|
-
description: PropTypes.string,
|
|
109
|
-
external: PropTypes.bool,
|
|
110
|
-
}),
|
|
111
|
-
locale: PropTypes.string,
|
|
112
|
-
hideFigcaption: PropTypes.bool,
|
|
113
|
-
hasLinkedVideo: PropTypes.bool,
|
|
114
|
-
};
|
|
94
|
+
export interface FigureLicense extends License {
|
|
95
|
+
short: string;
|
|
96
|
+
title: string;
|
|
97
|
+
userFriendlyTitle: string;
|
|
98
|
+
description: string;
|
|
99
|
+
rights: string[];
|
|
100
|
+
linkText?: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
}
|
|
115
103
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
interface FigureCaptionProps {
|
|
105
|
+
figureId: string;
|
|
106
|
+
id: string;
|
|
107
|
+
caption?: string;
|
|
108
|
+
reuseLabel: string;
|
|
109
|
+
licenseRights: string[];
|
|
110
|
+
children?: ReactNode;
|
|
111
|
+
authors?: { name: string }[];
|
|
112
|
+
link?: {
|
|
113
|
+
url: string;
|
|
114
|
+
text: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
external?: boolean;
|
|
117
|
+
};
|
|
118
|
+
locale?: string;
|
|
119
|
+
hideFigcaption?: boolean;
|
|
120
|
+
hasLinkedVideo?: boolean;
|
|
121
|
+
}
|
|
119
122
|
|
|
120
|
-
const Figure = ({ children, type, resizeIframe, ...rest }) => {
|
|
123
|
+
const Figure = ({ children, type = 'full', resizeIframe, ...rest }: Props) => {
|
|
121
124
|
const typeClass = type === 'full-column' ? 'c-figure--full-column' : `u-float-${type}`;
|
|
122
125
|
return (
|
|
123
|
-
<figure data-sizetype={type} {...classes('', { resize: resizeIframe }, typeClass)} {...rest}>
|
|
126
|
+
<figure data-sizetype={type} {...classes('', { resize: !!resizeIframe }, typeClass)} {...rest}>
|
|
124
127
|
{isFunction(children) ? children({ typeClass }) : children}
|
|
125
128
|
</figure>
|
|
126
129
|
);
|
|
127
130
|
};
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
id:
|
|
131
|
-
children:
|
|
132
|
-
type:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
'small-left',
|
|
137
|
-
'right',
|
|
138
|
-
'small-right',
|
|
139
|
-
'xsmall-right',
|
|
140
|
-
'xsmall-left',
|
|
141
|
-
]),
|
|
142
|
-
resizeIframe: PropTypes.bool,
|
|
143
|
-
noFigcaption: PropTypes.bool,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
Figure.defaultProps = {
|
|
147
|
-
type: 'full',
|
|
148
|
-
};
|
|
132
|
+
interface Props {
|
|
133
|
+
id: string;
|
|
134
|
+
children: (params: { typeClass: string }) => ReactNode | ReactNode;
|
|
135
|
+
type: 'full' | 'full-column' | 'left' | 'small-left' | 'right' | 'small-right' | 'xsmall-right' | 'xsmall-left';
|
|
136
|
+
resizeIframe?: boolean;
|
|
137
|
+
noFigcaption?: boolean;
|
|
138
|
+
}
|
|
149
139
|
|
|
150
140
|
export default Figure;
|
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
10
|
import { ArrowCollapse } from '@ndla/icons/common';
|
|
12
11
|
import { ExpandTwoArrows } from '@ndla/icons/action';
|
|
13
12
|
|
|
14
|
-
export function FigureExpandButton({
|
|
13
|
+
export function FigureExpandButton({ messages, typeClass }: Props) {
|
|
15
14
|
return (
|
|
16
15
|
<button
|
|
17
16
|
className="c-figure__fullscreen-btn"
|
|
@@ -27,10 +26,10 @@ export function FigureExpandButton({ children, messages, typeClass }) {
|
|
|
27
26
|
);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
messages:
|
|
32
|
-
zoomImageButtonLabel:
|
|
33
|
-
zoomOutImageButtonLabel:
|
|
34
|
-
}
|
|
35
|
-
typeClass:
|
|
36
|
-
}
|
|
29
|
+
interface Props {
|
|
30
|
+
messages: {
|
|
31
|
+
zoomImageButtonLabel: string;
|
|
32
|
+
zoomOutImageButtonLabel: string;
|
|
33
|
+
};
|
|
34
|
+
typeClass: string;
|
|
35
|
+
}
|
|
@@ -9,23 +9,34 @@
|
|
|
9
9
|
// N.B This component is used to render static markup serverside
|
|
10
10
|
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
11
|
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import PropTypes from 'prop-types';
|
|
12
|
+
import React, { ReactNode } from 'react';
|
|
14
13
|
import BEMHelper from 'react-bem-helper';
|
|
15
14
|
import { uuid } from '@ndla/util';
|
|
16
15
|
import { LicenseDescription } from '@ndla/licenses';
|
|
17
|
-
import {
|
|
16
|
+
import { FigureLicense } from './Figure';
|
|
17
|
+
import { Contributor } from '../types';
|
|
18
18
|
|
|
19
19
|
export const classLicenses = new BEMHelper({
|
|
20
20
|
name: 'figure-license',
|
|
21
21
|
prefix: 'c-',
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
|
|
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) => (
|
|
25
36
|
<div {...classLicenses('cta-wrapper')}>
|
|
26
37
|
<ul {...classLicenses('list')}>
|
|
27
38
|
{title && <li {...classLicenses('item')}>{`${messages.title}: ${title}`}</li>}
|
|
28
|
-
{authors
|
|
39
|
+
{authors?.map((author) => (
|
|
29
40
|
<li key={uuid()} {...classLicenses('item')}>{`${author.type}: ${author.name}`}</li>
|
|
30
41
|
))}
|
|
31
42
|
{origin && (
|
|
@@ -45,29 +56,20 @@ export const FigureLicenseCta = ({ children, messages, authors, origin, title })
|
|
|
45
56
|
</div>
|
|
46
57
|
);
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
title: PropTypes.string,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const FigureLicenseByline = ({ messages, license, locale }) => [
|
|
60
|
-
<LicenseDescription key="byline" highlightCC locale={locale} messages={messages} licenseRights={license.rights} />,
|
|
61
|
-
<a key="link" {...classLicenses('link')} target="_blank" rel="noopener noreferrer" href={license.url}>
|
|
62
|
-
{license.linkText}
|
|
63
|
-
</a>,
|
|
64
|
-
];
|
|
59
|
+
interface Props {
|
|
60
|
+
messages: {
|
|
61
|
+
modelPremission?: string;
|
|
62
|
+
learnAboutLicenses: string;
|
|
63
|
+
};
|
|
64
|
+
license: FigureLicense;
|
|
65
|
+
locale: string;
|
|
66
|
+
}
|
|
65
67
|
|
|
66
|
-
FigureLicenseByline
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
);
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
// N.B This component is used to render static markup serverside
|
|
10
10
|
// Any interactivty is added by scripts located in the ndla-article-scripts package
|
|
11
11
|
|
|
12
|
-
import React from 'react';
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import React, { ReactNode } from 'react';
|
|
13
|
+
//@ts-ignore
|
|
15
14
|
import Dialog from '../Dialog';
|
|
16
|
-
import { ContributorShape, LicenseShape } from '../shapes';
|
|
17
15
|
import { classLicenses, FigureLicenseByline, FigureLicenseCta } from './FigureLicense';
|
|
16
|
+
import { FigureLicense } from './Figure';
|
|
17
|
+
import { Contributor } from '../types';
|
|
18
18
|
|
|
19
|
-
export const FigureLicenseDialog = ({ children, messages, id, authors, origin, title, locale, license }) => {
|
|
19
|
+
export const FigureLicenseDialog = ({ children, messages, id, authors, origin, title, locale, license }: Props) => {
|
|
20
20
|
const headingLabelId = `heading-${id}`;
|
|
21
21
|
return (
|
|
22
22
|
<Dialog id={id} labelledby={headingLabelId} messages={messages}>
|
|
@@ -33,20 +33,20 @@ export const FigureLicenseDialog = ({ children, messages, id, authors, origin, t
|
|
|
33
33
|
);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
id:
|
|
38
|
-
children
|
|
39
|
-
origin
|
|
40
|
-
authors
|
|
41
|
-
messages:
|
|
42
|
-
modelPremission
|
|
43
|
-
close:
|
|
44
|
-
rulesForUse:
|
|
45
|
-
source:
|
|
46
|
-
learnAboutLicenses:
|
|
47
|
-
title:
|
|
48
|
-
}
|
|
49
|
-
title
|
|
50
|
-
license:
|
|
51
|
-
locale:
|
|
52
|
-
}
|
|
36
|
+
interface Props {
|
|
37
|
+
id: string;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
origin?: string;
|
|
40
|
+
authors?: Contributor[];
|
|
41
|
+
messages: {
|
|
42
|
+
modelPremission?: string;
|
|
43
|
+
close: string;
|
|
44
|
+
rulesForUse: string;
|
|
45
|
+
source: string;
|
|
46
|
+
learnAboutLicenses: string;
|
|
47
|
+
title: string;
|
|
48
|
+
};
|
|
49
|
+
title?: string;
|
|
50
|
+
license: FigureLicense;
|
|
51
|
+
locale: string;
|
|
52
|
+
}
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import BEMHelper from 'react-bem-helper';
|
|
4
3
|
import { Download } from '@ndla/icons/common';
|
|
5
4
|
import SafeLink from '@ndla/safelink';
|
|
5
|
+
import { FileFormat, FileType } from './FileList';
|
|
6
6
|
|
|
7
7
|
const classes = BEMHelper('c-file-list');
|
|
8
8
|
|
|
9
|
-
const renderFormat = (format, title, isPrimary, id, isDeadLink) => {
|
|
9
|
+
const renderFormat = (format: FileFormat, title: string, isPrimary: boolean, id: string, isDeadLink: boolean) => {
|
|
10
10
|
const titleWithFormat = `${title} (${format.fileType.toUpperCase()})`;
|
|
11
11
|
|
|
12
12
|
const formatId = `${id}_${format.fileType}`;
|
|
@@ -42,7 +42,12 @@ const renderFormat = (format, title, isPrimary, id, isDeadLink) => {
|
|
|
42
42
|
);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
interface Props {
|
|
46
|
+
id: string;
|
|
47
|
+
file: FileType;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const File = ({ file, id }: Props) => {
|
|
46
51
|
const formatLinks = file.formats.map((format, index) =>
|
|
47
52
|
renderFormat(format, file.title, index === 0, id, !file.fileExists),
|
|
48
53
|
);
|
|
@@ -54,19 +59,4 @@ const File = ({ file, id }) => {
|
|
|
54
59
|
);
|
|
55
60
|
};
|
|
56
61
|
|
|
57
|
-
File.propTypes = {
|
|
58
|
-
id: PropTypes.string.isRequired,
|
|
59
|
-
file: PropTypes.shape({
|
|
60
|
-
fileExists: PropTypes.bool,
|
|
61
|
-
title: PropTypes.string.isRequired,
|
|
62
|
-
formats: PropTypes.arrayOf(
|
|
63
|
-
PropTypes.shape({
|
|
64
|
-
url: PropTypes.string.isRequired,
|
|
65
|
-
fileType: PropTypes.string.isRequired,
|
|
66
|
-
tooltip: PropTypes.string.isRequired,
|
|
67
|
-
}),
|
|
68
|
-
).isRequired,
|
|
69
|
-
}),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
62
|
export default File;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BEMHelper from 'react-bem-helper';
|
|
3
|
+
import File from './File';
|
|
4
|
+
|
|
5
|
+
const classes = BEMHelper('c-file-list');
|
|
6
|
+
|
|
7
|
+
export interface FileType {
|
|
8
|
+
title: string;
|
|
9
|
+
formats: FileFormat[];
|
|
10
|
+
fileExists?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FileFormat {
|
|
14
|
+
url: string;
|
|
15
|
+
fileType: string;
|
|
16
|
+
tooltip: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
id: string;
|
|
21
|
+
heading: string;
|
|
22
|
+
files: FileType[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const FileList = ({ files, heading, id }: Props) => (
|
|
26
|
+
<section {...classes()}>
|
|
27
|
+
<h1 {...classes('heading')}>{heading}</h1>
|
|
28
|
+
<ul {...classes('files')}>
|
|
29
|
+
{files.map((file) => (
|
|
30
|
+
<File key={`file-${id}-${file.title}`} file={file} id={id} />
|
|
31
|
+
))}
|
|
32
|
+
</ul>
|
|
33
|
+
</section>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export default FileList;
|
|
File without changes
|