@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.
Files changed (172) hide show
  1. package/es/Article/ArticleAuthorContent.js +1 -2
  2. package/es/AuthorInfo/AuthorInfo.js +1 -2
  3. package/es/BackgroundImage/BackgroundImage.js +5 -15
  4. package/es/ContentLoader/index.js +14 -27
  5. package/es/Dialog/Dialog.js +10 -28
  6. package/es/FactBox/FactBox.js +7 -11
  7. package/es/Figure/Figure.js +9 -41
  8. package/es/Figure/FigureExpandButton.js +2 -11
  9. package/es/Figure/FigureLicense.js +4 -24
  10. package/es/Figure/FigureLicenseDialog.js +2 -20
  11. package/es/FileList/File.js +0 -13
  12. package/es/FileList/FileList.js +0 -13
  13. package/es/Hero/Hero.js +0 -6
  14. package/es/Image/Image.js +4 -27
  15. package/es/Image/ImageLink.js +3 -12
  16. package/es/Image/LazyLoadImage.js +4 -13
  17. package/es/InfoBox/InfoBox.js +0 -4
  18. package/es/InfoWidget/InfoWidget.js +2 -21
  19. package/es/Logo/Logo.js +6 -22
  20. package/es/Logo/SvgLogo.js +4 -12
  21. package/es/Masthead/Masthead.js +12 -33
  22. package/es/NoContentBox/NoContentBox.js +2 -11
  23. package/es/Portrait/Portrait.js +0 -11
  24. package/es/RelatedArticleList/RelatedArticleList.js +4 -23
  25. package/es/Topic/Topic.js +20 -20
  26. package/es/Translation/Translation.js +0 -5
  27. package/es/Translation/TranslationBox.js +7 -3
  28. package/es/Translation/TranslationLine.js +4 -15
  29. package/es/index-javascript.js +1 -18
  30. package/es/index.js +17 -0
  31. package/es/locale/messages-en.js +4 -0
  32. package/es/locale/messages-nb.js +5 -1
  33. package/es/locale/messages-nn.js +5 -1
  34. package/lib/BackgroundImage/BackgroundImage.d.ts +11 -0
  35. package/lib/BackgroundImage/BackgroundImage.js +5 -17
  36. package/lib/BackgroundImage/index.d.ts +2 -0
  37. package/lib/ContentLoader/index.d.ts +20 -0
  38. package/lib/ContentLoader/index.js +14 -28
  39. package/lib/Dialog/Dialog.d.ts +23 -0
  40. package/lib/Dialog/Dialog.js +9 -29
  41. package/lib/Dialog/index.d.ts +10 -0
  42. package/lib/FactBox/FactBox.d.ts +16 -0
  43. package/lib/FactBox/FactBox.js +5 -11
  44. package/lib/FactBox/index.d.ts +2 -0
  45. package/lib/Figure/Figure.d.ts +50 -0
  46. package/lib/Figure/Figure.js +7 -41
  47. package/lib/Figure/FigureExpandButton.d.ts +16 -0
  48. package/lib/Figure/FigureExpandButton.js +2 -13
  49. package/lib/Figure/FigureLicense.d.ts +33 -0
  50. package/lib/Figure/FigureLicense.js +5 -27
  51. package/lib/Figure/FigureLicenseDialog.d.ts +29 -0
  52. package/lib/Figure/FigureLicenseDialog.js +1 -22
  53. package/lib/Figure/index.d.ts +12 -0
  54. package/lib/FileList/File.d.ts +7 -0
  55. package/lib/FileList/File.js +0 -14
  56. package/lib/FileList/FileList.d.ts +17 -0
  57. package/lib/FileList/FileList.js +0 -14
  58. package/lib/FileList/index.d.ts +3 -0
  59. package/lib/Hero/Hero.d.ts +26 -0
  60. package/lib/Hero/Hero.js +0 -8
  61. package/lib/Hero/index.d.ts +8 -0
  62. package/lib/Image/Image.d.ts +25 -0
  63. package/lib/Image/Image.js +4 -28
  64. package/lib/Image/ImageLink.d.ts +18 -0
  65. package/lib/Image/ImageLink.js +3 -15
  66. package/lib/Image/LazyLoadImage.d.ts +17 -0
  67. package/lib/Image/LazyLoadImage.js +3 -13
  68. package/lib/Image/index.d.ts +11 -0
  69. package/lib/InfoBox/InfoBox.d.ts +6 -0
  70. package/lib/InfoBox/InfoBox.js +0 -5
  71. package/{src/InfoBox/index.js → lib/InfoBox/index.d.ts} +0 -0
  72. package/lib/InfoWidget/InfoWidget.d.ts +19 -0
  73. package/lib/InfoWidget/InfoWidget.js +2 -22
  74. package/lib/InfoWidget/index.d.ts +2 -0
  75. package/lib/Logo/Logo.d.ts +24 -0
  76. package/lib/Logo/Logo.js +6 -29
  77. package/lib/Logo/SvgLogo.d.ts +14 -0
  78. package/lib/Logo/SvgLogo.js +4 -13
  79. package/lib/Logo/index.d.ts +9 -0
  80. package/lib/Masthead/Masthead.d.ts +27 -0
  81. package/lib/Masthead/Masthead.js +10 -34
  82. package/lib/Masthead/index.d.ts +10 -0
  83. package/lib/NoContentBox/NoContentBox.d.ts +14 -0
  84. package/lib/NoContentBox/NoContentBox.js +1 -11
  85. package/lib/NoContentBox/index.d.ts +9 -0
  86. package/lib/Portrait/Portrait.d.ts +15 -0
  87. package/lib/Portrait/Portrait.js +0 -12
  88. package/lib/Portrait/index.d.ts +9 -0
  89. package/lib/RelatedArticleList/RelatedArticleList.d.ts +25 -0
  90. package/lib/RelatedArticleList/RelatedArticleList.js +2 -23
  91. package/lib/RelatedArticleList/index.d.ts +10 -0
  92. package/lib/Topic/Topic.d.ts +3 -2
  93. package/lib/Topic/Topic.js +20 -20
  94. package/lib/Translation/Translation.d.ts +14 -0
  95. package/lib/Translation/Translation.js +0 -6
  96. package/lib/Translation/TranslationBox.d.ts +10 -0
  97. package/lib/Translation/TranslationBox.js +6 -2
  98. package/lib/Translation/TranslationLine.d.ts +16 -0
  99. package/lib/Translation/TranslationLine.js +4 -22
  100. package/{src/Translation/index.js → lib/Translation/index.d.ts} +0 -0
  101. package/lib/index-javascript.js +0 -230
  102. package/lib/index.d.ts +17 -0
  103. package/lib/index.js +263 -0
  104. package/lib/locale/messages-en.d.ts +4 -0
  105. package/lib/locale/messages-en.js +4 -0
  106. package/lib/locale/messages-nb.d.ts +4 -0
  107. package/lib/locale/messages-nb.js +5 -1
  108. package/lib/locale/messages-nn.d.ts +4 -0
  109. package/lib/locale/messages-nn.js +5 -1
  110. package/lib/types.d.ts +10 -0
  111. package/lib/utils/createUniversalPortal.d.ts +9 -0
  112. package/package.json +6 -6
  113. package/src/Article/ArticleAuthorContent.tsx +0 -1
  114. package/src/AuthorInfo/AuthorInfo.tsx +0 -1
  115. package/src/BackgroundImage/BackgroundImage.tsx +32 -0
  116. package/src/BackgroundImage/{index.js → index.ts} +0 -0
  117. package/src/ContentLoader/{index.js → index.tsx} +20 -30
  118. package/src/Dialog/{Dialog.jsx → Dialog.tsx} +20 -32
  119. package/src/Dialog/{index.js → index.ts} +0 -0
  120. package/src/FactBox/{FactBox.jsx → FactBox.tsx} +12 -14
  121. package/src/FactBox/{index.js → index.ts} +0 -0
  122. package/src/Figure/{Figure.js → Figure.tsx} +44 -54
  123. package/src/Figure/{FigureExpandButton.js → FigureExpandButton.tsx} +8 -9
  124. package/src/Figure/{FigureLicense.js → FigureLicense.tsx} +32 -30
  125. package/src/Figure/{FigureLicenseDialog.js → FigureLicenseDialog.tsx} +22 -22
  126. package/src/Figure/{index.js → index.ts} +0 -0
  127. package/src/FileList/{File.jsx → File.tsx} +8 -18
  128. package/src/FileList/FileList.tsx +36 -0
  129. package/src/FileList/{index.js → index.ts} +0 -0
  130. package/src/Hero/Hero.tsx +56 -0
  131. package/src/Hero/{index.js → index.ts} +0 -0
  132. package/src/Image/{Image.jsx → Image.tsx} +30 -30
  133. package/src/Image/{ImageLink.js → ImageLink.tsx} +11 -12
  134. package/src/Image/LazyLoadImage.tsx +40 -0
  135. package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +4 -3
  136. package/src/Image/{index.js → index.ts} +0 -0
  137. package/src/InfoBox/InfoBox.tsx +11 -0
  138. package/src/InfoBox/index.ts +1 -0
  139. package/src/InfoWidget/{InfoWidget.jsx → InfoWidget.tsx} +19 -26
  140. package/src/InfoWidget/{index.js → index.ts} +0 -0
  141. package/src/Logo/{Logo.jsx → Logo.tsx} +21 -28
  142. package/src/Logo/{SvgLogo.jsx → SvgLogo.tsx} +8 -14
  143. package/src/Logo/{index.js → index.ts} +0 -0
  144. package/src/Masthead/{Masthead.jsx → Masthead.tsx} +33 -35
  145. package/src/Masthead/{index.js → index.ts} +0 -0
  146. package/src/NoContentBox/{NoContentBox.jsx → NoContentBox.tsx} +7 -13
  147. package/src/NoContentBox/{index.js → index.ts} +0 -0
  148. package/src/Portrait/{Portrait.jsx → Portrait.tsx} +8 -14
  149. package/src/Portrait/{index.js → index.ts} +0 -0
  150. package/src/RelatedArticleList/{RelatedArticleList.jsx → RelatedArticleList.tsx} +43 -30
  151. package/src/RelatedArticleList/{index.js → index.ts} +0 -0
  152. package/src/Topic/Topic.tsx +3 -2
  153. package/src/Translation/{Translation.jsx → Translation.tsx} +7 -8
  154. package/src/Translation/TranslationBox.tsx +20 -0
  155. package/src/Translation/{TranslationLine.jsx → TranslationLine.tsx} +11 -18
  156. package/src/Translation/index.ts +3 -0
  157. package/src/index-javascript.js +0 -32
  158. package/src/index.ts +41 -0
  159. package/src/locale/messages-en.ts +4 -0
  160. package/src/locale/messages-nb.ts +5 -1
  161. package/src/locale/messages-nn.ts +5 -1
  162. package/src/types.ts +12 -0
  163. package/src/utils/{createUniversalPortal.jsx → createUniversalPortal.tsx} +3 -3
  164. package/es/Image/shapes.js +0 -18
  165. package/lib/Image/shapes.js +0 -33
  166. package/src/BackgroundImage/BackgroundImage.jsx +0 -39
  167. package/src/FileList/FileList.jsx +0 -36
  168. package/src/Hero/Hero.jsx +0 -38
  169. package/src/Image/LazyLoadImage.jsx +0 -39
  170. package/src/Image/shapes.js +0 -21
  171. package/src/InfoBox/InfoBox.jsx +0 -13
  172. package/src/Translation/TranslationBox.jsx +0 -12
@@ -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 emotion-1"
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 emotion-1"
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 emotion-1"
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
- const InfoWidget = ({ heading, description, mainLink, iconLinks, center }) => (
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, { Fragment } from '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
- export const Logo = ({ name, to, cssModifier, color, large, locale, label }) => {
22
- const modifiers = { large };
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
- <Fragment>
48
+ <>
34
49
  <SvgLogo name={name} color={color} locale={locale} />
35
- </Fragment>
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
- export const SvgLogo = ({ name, color, locale }) => (
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
- import PropTypes from 'prop-types';
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
- export const MastheadItem = ({ children, className, left, right }) => {
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
- MastheadItem.propTypes = {
32
- children: PropTypes.node,
33
- className: PropTypes.string,
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
- MastheadInfo.propTypes = {
50
- children: PropTypes.node.isRequired,
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 = ({ children, fixed, infoContent, showLoaderWhenNeeded, ndlaFilm, skipToMainContentId, t }) => (
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
- export const NoContentBox = ({ buttonText, text, onClick }) => (
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
- const Portrait = ({ src, alt, modifier, className }) => (
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
@@ -1,6 +1,6 @@
1
- import React, { cloneElement } from 'react';
2
- import PropTypes from 'prop-types';
1
+ import React, { cloneElement, ReactElement } from 'react';
3
2
  import BEMHelper from 'react-bem-helper';
3
+ //@ts-ignore
4
4
  import Button from '@ndla/button';
5
5
  import SafeLink from '@ndla/safelink';
6
6
  import SectionHeading from '../SectionHeading';
@@ -10,14 +10,32 @@ const classes = new BEMHelper({
10
10
  prefix: 'c-',
11
11
  });
12
12
 
13
- export const RelatedArticle = ({ title, introduction, icon, modifier, to, linkInfo = '', target = '' }) => {
13
+ interface RelatedArticleProps {
14
+ icon: ReactElement;
15
+ title: string;
16
+ modifier?: string;
17
+ introduction: string;
18
+ to: string;
19
+ linkInfo?: string;
20
+ target?: string;
21
+ }
22
+
23
+ export const RelatedArticle = ({
24
+ title,
25
+ introduction,
26
+ icon,
27
+ modifier,
28
+ to,
29
+ linkInfo = '',
30
+ target = '',
31
+ }: RelatedArticleProps) => {
14
32
  const iconWithClass = cloneElement(icon, { className: 'c-icon--medium' });
15
33
  return (
16
34
  <article {...classes('item', modifier)}>
17
35
  <h1 {...classes('title')}>
18
36
  {iconWithClass}
19
37
  <span {...classes('link-wrapper')}>
20
- <SafeLink to={to} {...classes('link')} target={target} rel={linkInfo ? 'noopener noreferrer' : null}>
38
+ <SafeLink to={to} {...classes('link')} target={target} rel={linkInfo ? 'noopener noreferrer' : undefined}>
21
39
  {title}
22
40
  </SafeLink>
23
41
  </span>
@@ -28,24 +46,27 @@ export const RelatedArticle = ({ title, introduction, icon, modifier, to, linkIn
28
46
  );
29
47
  };
30
48
 
31
- RelatedArticle.propTypes = {
32
- icon: PropTypes.node.isRequired,
33
- title: PropTypes.string.isRequired,
34
- modifier: PropTypes.string,
35
- introduction: PropTypes.string.isRequired,
36
- to: PropTypes.string.isRequired,
37
- linkInfo: PropTypes.string,
38
- target: PropTypes.string,
39
- };
40
-
41
- const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetInnerHTML }) => {
42
- const clonedChildren = !dangerouslySetInnerHTML
43
- ? React.Children.map(children, (article, i) =>
44
- React.cloneElement(article, {
45
- modifier: i >= 2 ? `${article.props.modifier} hidden` : article.props.modifier,
46
- }),
47
- )
48
- : null;
49
+ interface Props {
50
+ messages: {
51
+ title: string;
52
+ showMore: string;
53
+ showLess: string;
54
+ };
55
+ children?: ReactElement;
56
+ dangerouslySetInnerHTML?: {
57
+ __html: string;
58
+ };
59
+ articleCount?: number;
60
+ }
61
+ const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetInnerHTML }: Props) => {
62
+ const clonedChildren =
63
+ !dangerouslySetInnerHTML && children
64
+ ? React.Children.map(children, (article, i) =>
65
+ React.cloneElement(article, {
66
+ modifier: i >= 2 ? `${article.props.modifier} hidden` : article.props.modifier,
67
+ }),
68
+ )
69
+ : null;
49
70
  const childrenCount = articleCount || React.Children.count(children);
50
71
 
51
72
  return (
@@ -67,12 +88,4 @@ const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetIn
67
88
  );
68
89
  };
69
90
 
70
- RelatedArticleList.propTypes = {
71
- children: PropTypes.node,
72
- messages: PropTypes.shape({ title: PropTypes.string.isRequired }),
73
- dangerouslySetInnerHTML: PropTypes.shape({
74
- __html: PropTypes.string.isRequired,
75
- }),
76
- articleCount: PropTypes.number,
77
- };
78
91
  export default RelatedArticleList;
File without changes
@@ -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?: object;
227
- focalPoint?: object;
227
+ crop?: ImageCrop;
228
+ focalPoint?: ImageFocalPoint;
228
229
  };
229
230
  visualElement?: VisualElementProps;
230
231
  resources?: React.ReactNode;
@@ -6,8 +6,7 @@
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 BEMHelper from 'react-bem-helper';
12
11
 
13
12
  const classes = new BEMHelper({
@@ -15,16 +14,16 @@ const classes = new BEMHelper({
15
14
  prefix: 'c-',
16
15
  });
17
16
 
18
- const Translation = ({ children, index }) => (
17
+ interface Props {
18
+ children: ReactNode;
19
+ index: number;
20
+ }
21
+
22
+ const Translation = ({ children, index }: Props) => (
19
23
  <div {...classes('')}>
20
24
  <div {...classes('index')}>{index}</div>
21
25
  <dl {...classes('wrapper')}>{children}</dl>
22
26
  </div>
23
27
  );
24
28
 
25
- Translation.propTypes = {
26
- index: PropTypes.number.isRequired,
27
- children: PropTypes.node.isRequired,
28
- };
29
-
30
29
  export default Translation;
@@ -0,0 +1,20 @@
1
+ import React, { ReactNode } from 'react';
2
+ //@ts-ignore
3
+ import { ArticleTabs } from '@ndla/tabs';
4
+
5
+ interface Props {
6
+ tabs: {
7
+ id: string;
8
+ title: string;
9
+ content: () => ReactNode | ReactNode;
10
+ }[];
11
+ }
12
+ const TranslationBox = ({ tabs }: Props) => (
13
+ <div className="c-translation-box">
14
+ <div className="c-bodybox c-bodybox--translation">
15
+ <ArticleTabs tabs={tabs} />
16
+ </div>
17
+ </div>
18
+ );
19
+
20
+ export default TranslationBox;