@ndla/ui 3.2.1-alpha.3 → 3.2.2
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/ArticleAuthorContent.js +1 -2
- package/es/AuthorInfo/AuthorInfo.js +1 -2
- package/es/BackgroundImage/BackgroundImage.js +5 -15
- package/es/ContentLoader/index.js +14 -27
- package/es/Dialog/Dialog.js +10 -28
- package/es/FactBox/FactBox.js +7 -11
- package/es/Figure/Figure.js +9 -41
- package/es/Figure/FigureExpandButton.js +2 -11
- package/es/Figure/FigureLicense.js +4 -24
- package/es/Figure/FigureLicenseDialog.js +2 -20
- package/es/FileList/File.js +0 -13
- package/es/FileList/FileList.js +0 -13
- package/es/Hero/Hero.js +0 -6
- package/es/Image/Image.js +4 -27
- package/es/Image/ImageLink.js +3 -12
- package/es/Image/LazyLoadImage.js +4 -13
- package/es/InfoBox/InfoBox.js +0 -4
- package/es/InfoWidget/InfoWidget.js +2 -21
- package/es/Logo/Logo.js +6 -22
- package/es/Logo/SvgLogo.js +4 -12
- package/es/Masthead/Masthead.js +12 -33
- package/es/NoContentBox/NoContentBox.js +2 -11
- package/es/Portrait/Portrait.js +0 -11
- package/es/RelatedArticleList/RelatedArticleList.js +4 -23
- package/es/Topic/Topic.js +20 -20
- package/es/Translation/Translation.js +0 -5
- package/es/Translation/TranslationBox.js +7 -3
- package/es/Translation/TranslationLine.js +4 -15
- package/es/index-javascript.js +1 -18
- package/es/index.js +17 -0
- package/es/locale/messages-en.js +4 -0
- package/es/locale/messages-nb.js +5 -1
- package/es/locale/messages-nn.js +5 -1
- package/lib/BackgroundImage/BackgroundImage.d.ts +11 -0
- package/lib/BackgroundImage/BackgroundImage.js +5 -17
- package/lib/BackgroundImage/index.d.ts +2 -0
- package/lib/ContentLoader/index.d.ts +20 -0
- package/lib/ContentLoader/index.js +14 -28
- package/lib/Dialog/Dialog.d.ts +23 -0
- package/lib/Dialog/Dialog.js +9 -29
- package/lib/Dialog/index.d.ts +10 -0
- package/lib/FactBox/FactBox.d.ts +16 -0
- package/lib/FactBox/FactBox.js +5 -11
- package/lib/FactBox/index.d.ts +2 -0
- package/lib/Figure/Figure.d.ts +50 -0
- package/lib/Figure/Figure.js +7 -41
- package/lib/Figure/FigureExpandButton.d.ts +16 -0
- package/lib/Figure/FigureExpandButton.js +2 -13
- package/lib/Figure/FigureLicense.d.ts +33 -0
- package/lib/Figure/FigureLicense.js +5 -27
- package/lib/Figure/FigureLicenseDialog.d.ts +29 -0
- package/lib/Figure/FigureLicenseDialog.js +1 -22
- package/lib/Figure/index.d.ts +12 -0
- package/lib/FileList/File.d.ts +7 -0
- package/lib/FileList/File.js +0 -14
- package/lib/FileList/FileList.d.ts +17 -0
- package/lib/FileList/FileList.js +0 -14
- package/lib/FileList/index.d.ts +3 -0
- package/lib/Hero/Hero.d.ts +26 -0
- package/lib/Hero/Hero.js +0 -8
- package/lib/Hero/index.d.ts +8 -0
- package/lib/Image/Image.d.ts +25 -0
- package/lib/Image/Image.js +4 -28
- package/lib/Image/ImageLink.d.ts +18 -0
- package/lib/Image/ImageLink.js +3 -15
- package/lib/Image/LazyLoadImage.d.ts +17 -0
- package/lib/Image/LazyLoadImage.js +3 -13
- package/lib/Image/index.d.ts +11 -0
- package/lib/InfoBox/InfoBox.d.ts +6 -0
- package/lib/InfoBox/InfoBox.js +0 -5
- package/{src/InfoBox/index.js → lib/InfoBox/index.d.ts} +0 -0
- package/lib/InfoWidget/InfoWidget.d.ts +19 -0
- package/lib/InfoWidget/InfoWidget.js +2 -22
- package/lib/InfoWidget/index.d.ts +2 -0
- package/lib/Logo/Logo.d.ts +24 -0
- package/lib/Logo/Logo.js +6 -29
- package/lib/Logo/SvgLogo.d.ts +14 -0
- package/lib/Logo/SvgLogo.js +4 -13
- package/lib/Logo/index.d.ts +9 -0
- package/lib/Masthead/Masthead.d.ts +27 -0
- package/lib/Masthead/Masthead.js +10 -34
- package/lib/Masthead/index.d.ts +10 -0
- package/lib/NoContentBox/NoContentBox.d.ts +14 -0
- package/lib/NoContentBox/NoContentBox.js +1 -11
- package/lib/NoContentBox/index.d.ts +9 -0
- package/lib/Portrait/Portrait.d.ts +15 -0
- package/lib/Portrait/Portrait.js +0 -12
- package/lib/Portrait/index.d.ts +9 -0
- package/lib/RelatedArticleList/RelatedArticleList.d.ts +25 -0
- package/lib/RelatedArticleList/RelatedArticleList.js +2 -23
- package/lib/RelatedArticleList/index.d.ts +10 -0
- package/lib/Topic/Topic.d.ts +3 -2
- package/lib/Topic/Topic.js +20 -20
- package/lib/Translation/Translation.d.ts +14 -0
- package/lib/Translation/Translation.js +0 -6
- package/lib/Translation/TranslationBox.d.ts +10 -0
- package/lib/Translation/TranslationBox.js +6 -2
- package/lib/Translation/TranslationLine.d.ts +16 -0
- package/lib/Translation/TranslationLine.js +4 -22
- package/{src/Translation/index.js → lib/Translation/index.d.ts} +0 -0
- package/lib/index-javascript.js +0 -230
- package/lib/index.d.ts +17 -0
- package/lib/index.js +263 -0
- package/lib/locale/messages-en.d.ts +4 -0
- package/lib/locale/messages-en.js +4 -0
- package/lib/locale/messages-nb.d.ts +4 -0
- package/lib/locale/messages-nb.js +5 -1
- package/lib/locale/messages-nn.d.ts +4 -0
- package/lib/locale/messages-nn.js +5 -1
- package/lib/types.d.ts +10 -0
- package/lib/utils/createUniversalPortal.d.ts +9 -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/FactBox/{FactBox.jsx → FactBox.tsx} +12 -14
- package/src/FactBox/{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/RelatedArticleList/{RelatedArticleList.jsx → RelatedArticleList.tsx} +43 -30
- package/src/RelatedArticleList/{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/src/Translation/index.ts +3 -0
- package/src/index-javascript.js +0 -32
- package/src/index.ts +41 -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/src/utils/{createUniversalPortal.jsx → createUniversalPortal.tsx} +3 -3
- package/es/Image/shapes.js +0 -18
- package/lib/Image/shapes.js +0 -33
- 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
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
9
|
+
import React, { ReactNode, MouseEvent } from 'react';
|
|
11
10
|
import BEMHelper from 'react-bem-helper';
|
|
11
|
+
//@ts-ignore
|
|
12
12
|
import Button from '@ndla/button';
|
|
13
13
|
|
|
14
|
-
const toggleFactBox = (event) => {
|
|
15
|
-
const button = event.
|
|
16
|
-
const aside = button
|
|
17
|
-
aside
|
|
14
|
+
const toggleFactBox = (event: MouseEvent<HTMLButtonElement>) => {
|
|
15
|
+
const button = event.currentTarget;
|
|
16
|
+
const aside = button?.previousSibling?.parentElement;
|
|
17
|
+
aside?.classList?.toggle('expanded');
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const classes = new BEMHelper({
|
|
@@ -22,7 +22,12 @@ const classes = new BEMHelper({
|
|
|
22
22
|
prefix: 'c-',
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
interface Props {
|
|
26
|
+
dangerouslySetInnerHTML?: { __html: string };
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const FactBox = ({ children, dangerouslySetInnerHTML }: Props) => (
|
|
26
31
|
<aside {...classes()}>
|
|
27
32
|
<div {...classes('content')} dangerouslySetInnerHTML={dangerouslySetInnerHTML}>
|
|
28
33
|
{children}
|
|
@@ -31,11 +36,4 @@ const FactBox = ({ children, dangerouslySetInnerHTML }) => (
|
|
|
31
36
|
</aside>
|
|
32
37
|
);
|
|
33
38
|
|
|
34
|
-
FactBox.propTypes = {
|
|
35
|
-
dangerouslySetInnerHTML: PropTypes.shape({
|
|
36
|
-
__html: PropTypes.string.isRequired,
|
|
37
|
-
}),
|
|
38
|
-
children: PropTypes.node,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
39
|
export default FactBox;
|
|
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
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-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, { ReactNode } from 'react';
|
|
10
|
+
import BEMHelper from 'react-bem-helper';
|
|
11
|
+
|
|
12
|
+
import * as contentTypes from '../model/ContentType';
|
|
13
|
+
|
|
14
|
+
const classes = new BEMHelper({
|
|
15
|
+
name: 'hero',
|
|
16
|
+
prefix: 'c-',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
interface HeroProps {
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
contentType:
|
|
22
|
+
| 'subject-material'
|
|
23
|
+
| 'tasks-and-activities'
|
|
24
|
+
| 'assessment-resources'
|
|
25
|
+
| 'subject'
|
|
26
|
+
| 'external-learning-resources'
|
|
27
|
+
| 'source-material'
|
|
28
|
+
| 'learning-path'
|
|
29
|
+
| 'topic'
|
|
30
|
+
| 'beta'
|
|
31
|
+
| 'ndla-film'
|
|
32
|
+
| 'ndla-film has-image';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Hero = ({ children, contentType }: HeroProps) => (
|
|
36
|
+
<div {...classes('', contentType)}>{children || null}</div>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
interface Props {
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export const SubjectMaterialHero = (props: Props) => <Hero contentType={contentTypes.SUBJECT_MATERIAL} {...props} />;
|
|
43
|
+
export const TasksAndActivitiesHero = (props: Props) => (
|
|
44
|
+
<Hero contentType={contentTypes.TASKS_AND_ACTIVITIES} {...props} />
|
|
45
|
+
);
|
|
46
|
+
export const AssessmentResourcesHero = (props: Props) => (
|
|
47
|
+
<Hero contentType={contentTypes.ASSESSMENT_RESOURCES} {...props} />
|
|
48
|
+
);
|
|
49
|
+
export const SubjectHero = (props: Props) => <Hero contentType={contentTypes.SUBJECT} {...props} />;
|
|
50
|
+
export const ExternalLearningResourcesHero = (props: Props) => (
|
|
51
|
+
<Hero contentType={contentTypes.EXTERNAL_LEARNING_RESOURCES} {...props} />
|
|
52
|
+
);
|
|
53
|
+
export const SourceMaterialHero = (props: Props) => <Hero contentType={contentTypes.SOURCE_MATERIAL} {...props} />;
|
|
54
|
+
export const NdlaFilmHero = ({ hasImage, ...rest }: Props & { hasImage?: boolean }) => (
|
|
55
|
+
<Hero {...rest} contentType={hasImage ? 'ndla-film has-image' : 'ndla-film'} />
|
|
56
|
+
);
|
|
File without changes
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
9
|
+
import React, { ReactNode } from 'react';
|
|
10
10
|
import defined from 'defined';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
11
|
import styled from '@emotion/styled';
|
|
13
12
|
import LazyLoadImage from './LazyLoadImage';
|
|
13
|
+
import { ImageCrop, ImageFocalPoint } from '../types';
|
|
14
14
|
|
|
15
|
-
export const makeSrcQueryString = (width, crop, focalPoint) => {
|
|
15
|
+
export const makeSrcQueryString = (width: number | undefined, crop?: ImageCrop, focalPoint?: ImageFocalPoint) => {
|
|
16
16
|
const widthParams = width && `width=${width}`;
|
|
17
17
|
const cropParams =
|
|
18
18
|
crop && `cropStartX=${crop.startX}&cropEndX=${crop.endX}&cropStartY=${crop.startY}&cropEndY=${crop.endY}`;
|
|
@@ -22,7 +22,7 @@ export const makeSrcQueryString = (width, crop, focalPoint) => {
|
|
|
22
22
|
return params;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getSrcSet = (src, crop, focalPoint) => {
|
|
25
|
+
const getSrcSet = (src: string, crop: ImageCrop | undefined, focalPoint: ImageFocalPoint | undefined) => {
|
|
26
26
|
const widths = [2720, 2080, 1760, 1440, 1120, 1000, 960, 800, 640, 480, 320, 240, 180];
|
|
27
27
|
return widths.map((width) => `${src}?${makeSrcQueryString(width, crop, focalPoint)} ${width}w`).join(', ');
|
|
28
28
|
};
|
|
@@ -31,7 +31,32 @@ const StyledImageWrapper = styled.div`
|
|
|
31
31
|
position: relative;
|
|
32
32
|
`;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
interface Props {
|
|
35
|
+
alt: string;
|
|
36
|
+
src: string;
|
|
37
|
+
sizes?: string;
|
|
38
|
+
fallbackWidth?: number;
|
|
39
|
+
contentType?: string;
|
|
40
|
+
srcSet?: string;
|
|
41
|
+
lazyLoad?: boolean;
|
|
42
|
+
lazyLoadSrc?: string;
|
|
43
|
+
expandButton?: ReactNode;
|
|
44
|
+
crop?: ImageCrop;
|
|
45
|
+
focalPoint?: ImageFocalPoint;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Image = ({
|
|
49
|
+
alt,
|
|
50
|
+
src,
|
|
51
|
+
lazyLoad,
|
|
52
|
+
lazyLoadSrc,
|
|
53
|
+
crop,
|
|
54
|
+
focalPoint,
|
|
55
|
+
contentType,
|
|
56
|
+
sizes = '(min-width: 1024px) 1024px, 100vw',
|
|
57
|
+
expandButton,
|
|
58
|
+
...rest
|
|
59
|
+
}: Props) => {
|
|
35
60
|
const srcSet = defined(rest.srcSet, getSrcSet(src, crop, focalPoint));
|
|
36
61
|
const fallbackWidth = defined(rest.fallbackWidth, 1024);
|
|
37
62
|
const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
|
|
@@ -69,29 +94,4 @@ const Image = ({ alt, src, lazyLoad, lazyLoadSrc, crop, focalPoint, contentType,
|
|
|
69
94
|
);
|
|
70
95
|
};
|
|
71
96
|
|
|
72
|
-
Image.propTypes = {
|
|
73
|
-
alt: PropTypes.string.isRequired,
|
|
74
|
-
src: PropTypes.string.isRequired,
|
|
75
|
-
sizes: PropTypes.string,
|
|
76
|
-
fallbackWidth: PropTypes.number,
|
|
77
|
-
contentType: PropTypes.string,
|
|
78
|
-
srcSet: PropTypes.string,
|
|
79
|
-
lazyLoad: PropTypes.bool,
|
|
80
|
-
lazyLoadSrc: PropTypes.string,
|
|
81
|
-
crop: PropTypes.shape({
|
|
82
|
-
startX: PropTypes.number.isRequired,
|
|
83
|
-
startY: PropTypes.number.isRequired,
|
|
84
|
-
endX: PropTypes.number.isRequired,
|
|
85
|
-
endY: PropTypes.number.isRequired,
|
|
86
|
-
}),
|
|
87
|
-
focalPoint: PropTypes.shape({
|
|
88
|
-
x: PropTypes.number.isRequired,
|
|
89
|
-
y: PropTypes.number.isRequired,
|
|
90
|
-
}),
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
Image.defaultProps = {
|
|
94
|
-
sizes: '(min-width: 1024px) 1024px, 100vw',
|
|
95
|
-
};
|
|
96
|
-
|
|
97
97
|
export default Image;
|
|
@@ -6,17 +6,24 @@
|
|
|
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 styled from '@emotion/styled';
|
|
12
11
|
import { makeSrcQueryString } from './Image';
|
|
13
|
-
import {
|
|
12
|
+
import { ImageCrop, ImageFocalPoint } from '../types';
|
|
14
13
|
|
|
15
14
|
const StyledLink = styled.a`
|
|
16
15
|
box-shadow: inset 0 0;
|
|
17
16
|
`;
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
interface Props {
|
|
19
|
+
src: string;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
sizes?: string;
|
|
22
|
+
crop?: ImageCrop;
|
|
23
|
+
focalPoint?: ImageFocalPoint;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ImageLink({ src, crop, children, ...rest }: Props) {
|
|
20
27
|
return (
|
|
21
28
|
<StyledLink
|
|
22
29
|
target="_blank"
|
|
@@ -27,11 +34,3 @@ export function ImageLink({ src, crop, children, ...rest }) {
|
|
|
27
34
|
</StyledLink>
|
|
28
35
|
);
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
ImageLink.propTypes = {
|
|
32
|
-
src: PropTypes.string.isRequired,
|
|
33
|
-
children: PropTypes.node.isRequired,
|
|
34
|
-
sizes: PropTypes.string,
|
|
35
|
-
crop: CropShape,
|
|
36
|
-
focalPoint: FocalPointShape,
|
|
37
|
-
};
|