@ndla/ui 3.2.1-alpha.14 → 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
|
@@ -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
|
-
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 React from 'react';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
alt: string;
|
|
13
|
+
src: string;
|
|
14
|
+
sizes?: string;
|
|
15
|
+
contentType?: string;
|
|
16
|
+
srcSet?: string;
|
|
17
|
+
lazyLoadSrc?: string;
|
|
18
|
+
}
|
|
19
|
+
// Lazyload image with lazysizes (https://github.com/aFarkas/lazysizes)
|
|
20
|
+
const LazyLoadImage = ({ alt, src, srcSet, lazyLoadSrc, sizes, ...rest }: Props) => (
|
|
21
|
+
<>
|
|
22
|
+
<noscript key="noscript">
|
|
23
|
+
<img alt={alt} src={`${src}`} srcSet={srcSet} sizes={sizes} {...rest} />
|
|
24
|
+
</noscript>
|
|
25
|
+
,
|
|
26
|
+
<img
|
|
27
|
+
alt={alt}
|
|
28
|
+
key="img"
|
|
29
|
+
style={{ width: '100%' }}
|
|
30
|
+
className="lazyload"
|
|
31
|
+
src={lazyLoadSrc}
|
|
32
|
+
data-src={src}
|
|
33
|
+
data-src-set={srcSet}
|
|
34
|
+
data-sizes={sizes}
|
|
35
|
+
{...rest}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export default LazyLoadImage;
|
|
@@ -6,7 +6,7 @@ exports[`Image renderers correctly 1`] = `
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
<div
|
|
9
|
-
className="emotion-0
|
|
9
|
+
className="emotion-0"
|
|
10
10
|
>
|
|
11
11
|
<picture>
|
|
12
12
|
<source
|
|
@@ -27,7 +27,7 @@ exports[`Image with crop and focalpoint props renderers correctly 1`] = `
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
<div
|
|
30
|
-
className="emotion-0
|
|
30
|
+
className="emotion-0"
|
|
31
31
|
>
|
|
32
32
|
<picture>
|
|
33
33
|
<source
|
|
@@ -48,7 +48,7 @@ exports[`Lazyloaded image renderers correctly 1`] = `
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
<div
|
|
51
|
-
className="emotion-0
|
|
51
|
+
className="emotion-0"
|
|
52
52
|
>
|
|
53
53
|
<noscript>
|
|
54
54
|
<img
|
|
@@ -58,6 +58,7 @@ exports[`Lazyloaded image renderers correctly 1`] = `
|
|
|
58
58
|
srcSet="https://example.com/image.png?width=2720 2720w, https://example.com/image.png?width=2080 2080w, https://example.com/image.png?width=1760 1760w, https://example.com/image.png?width=1440 1440w, https://example.com/image.png?width=1120 1120w, https://example.com/image.png?width=1000 1000w, https://example.com/image.png?width=960 960w, https://example.com/image.png?width=800 800w, https://example.com/image.png?width=640 640w, https://example.com/image.png?width=480 480w, https://example.com/image.png?width=320 320w, https://example.com/image.png?width=240 240w, https://example.com/image.png?width=180 180w"
|
|
59
59
|
/>
|
|
60
60
|
</noscript>
|
|
61
|
+
,
|
|
61
62
|
<img
|
|
62
63
|
alt="example"
|
|
63
64
|
className="lazyload"
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import BEMHelper from 'react-bem-helper';
|
|
3
|
+
|
|
4
|
+
const classes = BEMHelper('c-info-box');
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
const InfoBox = ({ children }: Props) => <div {...classes()}>{children}</div>;
|
|
10
|
+
|
|
11
|
+
export default InfoBox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as InfoBox } from './InfoBox';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
3
2
|
import BEMHelper from 'react-bem-helper';
|
|
4
3
|
import { Forward } from '@ndla/icons/common';
|
|
5
4
|
|
|
@@ -9,7 +8,24 @@ import SectionHeading from '../SectionHeading';
|
|
|
9
8
|
|
|
10
9
|
const classes = BEMHelper('c-info-widget');
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
interface Props {
|
|
12
|
+
heading: string;
|
|
13
|
+
description: string;
|
|
14
|
+
mainLink: {
|
|
15
|
+
name: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
};
|
|
19
|
+
iconLinks: {
|
|
20
|
+
name: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
href?: string;
|
|
23
|
+
icon: ReactNode;
|
|
24
|
+
}[];
|
|
25
|
+
center?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const InfoWidget = ({ heading, description, mainLink, iconLinks, center = false }: Props) => (
|
|
13
29
|
<section {...classes('', { center })}>
|
|
14
30
|
<SectionHeading large className={classes('heading').className}>
|
|
15
31
|
{heading}
|
|
@@ -55,27 +71,4 @@ const InfoWidget = ({ heading, description, mainLink, iconLinks, center }) => (
|
|
|
55
71
|
</section>
|
|
56
72
|
);
|
|
57
73
|
|
|
58
|
-
InfoWidget.propTypes = {
|
|
59
|
-
heading: PropTypes.string.isRequired,
|
|
60
|
-
description: PropTypes.string.isRequired,
|
|
61
|
-
mainLink: PropTypes.shape({
|
|
62
|
-
name: PropTypes.string.isRequired,
|
|
63
|
-
url: PropTypes.string,
|
|
64
|
-
href: PropTypes.string,
|
|
65
|
-
}).isRequired,
|
|
66
|
-
iconLinks: PropTypes.arrayOf(
|
|
67
|
-
PropTypes.shape({
|
|
68
|
-
name: PropTypes.string.isRequired,
|
|
69
|
-
url: PropTypes.string,
|
|
70
|
-
href: PropTypes.string,
|
|
71
|
-
icon: PropTypes.node.isRequired,
|
|
72
|
-
}),
|
|
73
|
-
),
|
|
74
|
-
center: PropTypes.bool,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
InfoWidget.defaultProps = {
|
|
78
|
-
center: false,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
74
|
export default InfoWidget;
|
|
File without changes
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/* eslint-disable max-len */
|
|
9
9
|
|
|
10
|
-
import React
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
10
|
+
import React from 'react';
|
|
12
11
|
import BEMHelper from 'react-bem-helper';
|
|
13
12
|
import SafeLink from '@ndla/safelink';
|
|
14
13
|
import SvgLogo from './SvgLogo';
|
|
@@ -18,8 +17,24 @@ export const logoClasses = new BEMHelper({
|
|
|
18
17
|
prefix: 'c-',
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
interface Props {
|
|
21
|
+
to?:
|
|
22
|
+
| string
|
|
23
|
+
| {
|
|
24
|
+
pathname: string;
|
|
25
|
+
search?: string;
|
|
26
|
+
hash?: string;
|
|
27
|
+
};
|
|
28
|
+
label: string;
|
|
29
|
+
locale?: string;
|
|
30
|
+
cssModifier?: string;
|
|
31
|
+
large?: boolean;
|
|
32
|
+
name?: boolean;
|
|
33
|
+
color?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Logo = ({ name = true, to, cssModifier, color, large = false, locale, label }: Props) => {
|
|
37
|
+
const modifiers: Record<string, boolean> = { large };
|
|
23
38
|
|
|
24
39
|
if (cssModifier) {
|
|
25
40
|
modifiers[cssModifier] = true;
|
|
@@ -30,33 +45,11 @@ export const Logo = ({ name, to, cssModifier, color, large, locale, label }) =>
|
|
|
30
45
|
<SvgLogo name={name} color={color} locale={locale} />
|
|
31
46
|
</SafeLink>
|
|
32
47
|
) : (
|
|
33
|
-
|
|
48
|
+
<>
|
|
34
49
|
<SvgLogo name={name} color={color} locale={locale} />
|
|
35
|
-
|
|
50
|
+
</>
|
|
36
51
|
);
|
|
37
52
|
return <div {...logoClasses('', modifiers)}>{logo}</div>;
|
|
38
53
|
};
|
|
39
54
|
|
|
40
|
-
Logo.propTypes = {
|
|
41
|
-
to: PropTypes.oneOfType([
|
|
42
|
-
PropTypes.string,
|
|
43
|
-
PropTypes.shape({
|
|
44
|
-
pathname: PropTypes.string.isRequired,
|
|
45
|
-
search: PropTypes.string,
|
|
46
|
-
hash: PropTypes.string,
|
|
47
|
-
}),
|
|
48
|
-
]),
|
|
49
|
-
label: PropTypes.string.isRequired,
|
|
50
|
-
locale: PropTypes.string,
|
|
51
|
-
cssModifier: PropTypes.string,
|
|
52
|
-
large: PropTypes.bool,
|
|
53
|
-
name: PropTypes.bool,
|
|
54
|
-
color: PropTypes.string,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
Logo.defaultProps = {
|
|
58
|
-
name: true,
|
|
59
|
-
large: false,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
55
|
export default Logo;
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
/* eslint-disable max-len */
|
|
9
9
|
|
|
10
10
|
import React from 'react';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
11
|
import { logoClasses } from './Logo';
|
|
13
12
|
|
|
14
|
-
const LogoText = (locale) => {
|
|
13
|
+
const LogoText = (locale?: string) => {
|
|
15
14
|
if (locale === 'en') {
|
|
16
15
|
return (
|
|
17
16
|
<path
|
|
@@ -26,7 +25,13 @@ const LogoText = (locale) => {
|
|
|
26
25
|
);
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
interface Props {
|
|
29
|
+
name?: boolean;
|
|
30
|
+
color?: string;
|
|
31
|
+
locale?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const SvgLogo = ({ name = true, color = '#000000', locale }: Props) => (
|
|
30
35
|
<svg
|
|
31
36
|
{...logoClasses('graphic')}
|
|
32
37
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -41,15 +46,4 @@ export const SvgLogo = ({ name, color, locale }) => (
|
|
|
41
46
|
</svg>
|
|
42
47
|
);
|
|
43
48
|
|
|
44
|
-
SvgLogo.propTypes = {
|
|
45
|
-
name: PropTypes.bool,
|
|
46
|
-
color: PropTypes.string,
|
|
47
|
-
locale: PropTypes.string,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
SvgLogo.defaultProps = {
|
|
51
|
-
name: true,
|
|
52
|
-
color: '#000000',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
49
|
export default SvgLogo;
|
|
File without changes
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
9
|
+
import React, { ReactNode } from 'react';
|
|
10
|
+
//@ts-ignore
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import BEMHelper from 'react-bem-helper';
|
|
13
|
-
import { withTranslation } from 'react-i18next';
|
|
13
|
+
import { WithTranslation, withTranslation } from 'react-i18next';
|
|
14
14
|
import { DisplayOnPageYOffset } from '../Animation';
|
|
15
15
|
|
|
16
16
|
const classes = new BEMHelper({
|
|
@@ -18,7 +18,13 @@ const classes = new BEMHelper({
|
|
|
18
18
|
prefix: 'c-',
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
interface MastheadItemProps {
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
right?: boolean;
|
|
25
|
+
left?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export const MastheadItem = ({ children, className, left = false, right = false }: MastheadItemProps) => {
|
|
22
28
|
const itemClassNames = classNames(
|
|
23
29
|
{ [classes('left').className]: left },
|
|
24
30
|
{ [classes('right').className]: right },
|
|
@@ -28,37 +34,42 @@ export const MastheadItem = ({ children, className, left, right }) => {
|
|
|
28
34
|
return <div className={itemClassNames}>{children}</div>;
|
|
29
35
|
};
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
children
|
|
33
|
-
|
|
34
|
-
right: PropTypes.bool,
|
|
35
|
-
left: PropTypes.bool,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
MastheadItem.defaultProps = {
|
|
39
|
-
right: false,
|
|
40
|
-
left: false,
|
|
41
|
-
};
|
|
37
|
+
interface MastheadInfoProps {
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
42
40
|
|
|
43
|
-
const MastheadInfo = ({ children }) => (
|
|
41
|
+
const MastheadInfo = ({ children }: MastheadInfoProps) => (
|
|
44
42
|
<div {...classes('info')}>
|
|
45
43
|
<div {...classes('info-content')}>{children}</div>
|
|
46
44
|
</div>
|
|
47
45
|
);
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
children
|
|
51
|
-
|
|
47
|
+
interface Props {
|
|
48
|
+
children?: ReactNode;
|
|
49
|
+
fixed?: boolean;
|
|
50
|
+
showLoaderWhenNeeded?: boolean;
|
|
51
|
+
infoContent?: ReactNode;
|
|
52
|
+
ndlaFilm?: boolean;
|
|
53
|
+
skipToMainContentId?: string;
|
|
54
|
+
}
|
|
52
55
|
|
|
53
|
-
export const Masthead = ({
|
|
56
|
+
export const Masthead = ({
|
|
57
|
+
children,
|
|
58
|
+
fixed,
|
|
59
|
+
infoContent,
|
|
60
|
+
showLoaderWhenNeeded = true,
|
|
61
|
+
ndlaFilm,
|
|
62
|
+
skipToMainContentId,
|
|
63
|
+
t,
|
|
64
|
+
}: Props & WithTranslation) => (
|
|
54
65
|
<>
|
|
55
66
|
{skipToMainContentId && (
|
|
56
67
|
<a tabIndex={0} href={`#${skipToMainContentId}`} {...classes('skip-to-main-content')}>
|
|
57
68
|
{t('masthead.skipToContent')}
|
|
58
69
|
</a>
|
|
59
70
|
)}
|
|
60
|
-
<div {...classes('placeholder', { infoContent })} />
|
|
61
|
-
<div {...classes('', { fixed, infoContent, showLoaderWhenNeeded, ndlaFilm })}>
|
|
71
|
+
<div {...classes('placeholder', { infoContent: !!infoContent })} />
|
|
72
|
+
<div {...classes('', { fixed: !!fixed, infoContent: !!infoContent, showLoaderWhenNeeded, ndlaFilm: !!ndlaFilm })}>
|
|
62
73
|
{infoContent && (
|
|
63
74
|
<DisplayOnPageYOffset yOffsetMin={0} yOffsetMax={90}>
|
|
64
75
|
<MastheadInfo>{infoContent}</MastheadInfo>
|
|
@@ -69,17 +80,4 @@ export const Masthead = ({ children, fixed, infoContent, showLoaderWhenNeeded, n
|
|
|
69
80
|
</>
|
|
70
81
|
);
|
|
71
82
|
|
|
72
|
-
Masthead.propTypes = {
|
|
73
|
-
children: PropTypes.node,
|
|
74
|
-
fixed: PropTypes.bool,
|
|
75
|
-
showLoaderWhenNeeded: PropTypes.bool,
|
|
76
|
-
infoContent: PropTypes.node,
|
|
77
|
-
ndlaFilm: PropTypes.bool,
|
|
78
|
-
skipToMainContentId: PropTypes.string,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
Masthead.defaultProps = {
|
|
82
|
-
showLoaderWhenNeeded: true,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
83
|
export default withTranslation()(Masthead);
|
|
File without changes
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
10
|
import BEMHelper from 'react-bem-helper';
|
|
11
|
+
//@ts-ignore
|
|
12
12
|
import Button from '@ndla/button';
|
|
13
13
|
|
|
14
14
|
const classes = new BEMHelper({
|
|
@@ -16,7 +16,12 @@ const classes = new BEMHelper({
|
|
|
16
16
|
prefix: 'c-',
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface Props {
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
buttonText?: string;
|
|
22
|
+
text: string;
|
|
23
|
+
}
|
|
24
|
+
export const NoContentBox = ({ buttonText, text, onClick }: Props) => (
|
|
20
25
|
<div {...classes('additional-resources-trigger')}>
|
|
21
26
|
<span>
|
|
22
27
|
<div>
|
|
@@ -31,15 +36,4 @@ export const NoContentBox = ({ buttonText, text, onClick }) => (
|
|
|
31
36
|
</div>
|
|
32
37
|
);
|
|
33
38
|
|
|
34
|
-
NoContentBox.propTypes = {
|
|
35
|
-
onClick: PropTypes.func,
|
|
36
|
-
buttonText: PropTypes.string,
|
|
37
|
-
text: PropTypes.string.isRequired,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
NoContentBox.defaultProps = {
|
|
41
|
-
onClick: null,
|
|
42
|
-
buttonText: undefined,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
39
|
export default NoContentBox;
|
|
File without changes
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
10
|
import BEMHelper from 'react-bem-helper';
|
|
12
11
|
|
|
13
12
|
const classes = new BEMHelper({
|
|
@@ -15,22 +14,17 @@ const classes = new BEMHelper({
|
|
|
15
14
|
prefix: 'c-',
|
|
16
15
|
});
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
interface Props {
|
|
18
|
+
src: string;
|
|
19
|
+
alt: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
modifier?: 'small' | 'large';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Portrait = ({ src, alt, modifier, className }: Props) => (
|
|
19
25
|
<div {...classes('', modifier, className)}>
|
|
20
26
|
<span role="img" aria-label={alt} style={{ backgroundImage: `url(${src})` }} />
|
|
21
27
|
</div>
|
|
22
28
|
);
|
|
23
29
|
|
|
24
|
-
Portrait.propTypes = {
|
|
25
|
-
src: PropTypes.string.isRequired,
|
|
26
|
-
alt: PropTypes.string.isRequired,
|
|
27
|
-
className: PropTypes.string,
|
|
28
|
-
modifier: PropTypes.oneOf(['small', 'large']),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
Portrait.defaultProps = {
|
|
32
|
-
className: null,
|
|
33
|
-
modifier: null,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
30
|
export default Portrait;
|
|
File without changes
|
package/src/Topic/Topic.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import { ItemProps } from '../Navigation/NavigationBox';
|
|
|
24
24
|
import { NavigationBox } from '../Navigation';
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
import { makeSrcQueryString } from '../Image';
|
|
27
|
+
import { ImageCrop, ImageFocalPoint } from '../types';
|
|
27
28
|
|
|
28
29
|
type InvertItProps = {
|
|
29
30
|
invertedStyle?: boolean;
|
|
@@ -223,8 +224,8 @@ export type TopicProps = {
|
|
|
223
224
|
image?: {
|
|
224
225
|
url: string;
|
|
225
226
|
alt: string;
|
|
226
|
-
crop?:
|
|
227
|
-
focalPoint?:
|
|
227
|
+
crop?: ImageCrop;
|
|
228
|
+
focalPoint?: ImageFocalPoint;
|
|
228
229
|
};
|
|
229
230
|
visualElement?: VisualElementProps;
|
|
230
231
|
resources?: React.ReactNode;
|