@ndla/ui 3.3.11 → 3.3.15

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 (132) hide show
  1. package/es/Figure/Figure.js +3 -1
  2. package/es/Filter/FilterButtons.js +11 -13
  3. package/es/Frontpage/FrontpageAllSubjects.js +7 -7
  4. package/es/Frontpage/FrontpageSearch.js +2 -4
  5. package/es/LearningPaths/LearningPathMenu.js +4 -5
  6. package/es/LearningPaths/LearningPathMobileHeader.js +4 -5
  7. package/es/NDLAFilm/AboutNdlaFilm.js +6 -17
  8. package/es/NDLAFilm/AllMoviesAlphabetically.js +11 -11
  9. package/es/NDLAFilm/CategorySelect.js +17 -18
  10. package/es/NDLAFilm/FilmContentCard.js +8 -22
  11. package/es/NDLAFilm/FilmContentCardTags.js +4 -8
  12. package/es/NDLAFilm/FilmMovieList.js +6 -21
  13. package/es/NDLAFilm/FilmMovieSearch.js +18 -26
  14. package/es/NDLAFilm/MovieGrid.js +10 -19
  15. package/es/NDLAFilm/VisualElement.js +22 -29
  16. package/es/Search/SearchResultSleeve.js +12 -15
  17. package/es/SearchTypeResult/SearchFieldHeader.js +5 -5
  18. package/es/SearchTypeResult/SearchHeader.js +9 -9
  19. package/es/SearchTypeResult/SearchItem.js +19 -19
  20. package/es/SearchTypeResult/SearchNotionItem.js +12 -12
  21. package/es/TopicIntroductionList/TopicIntroduction.js +14 -33
  22. package/es/TopicIntroductionList/TopicIntroductionList.js +6 -23
  23. package/es/TopicIntroductionList/TopicIntroductionShortcuts.js +71 -110
  24. package/es/TopicIntroductionList/TopicShortcutItem.js +0 -9
  25. package/es/all.css +1 -4
  26. package/es/index-javascript.js +1 -5
  27. package/es/index.js +4 -0
  28. package/es/shapes.js +0 -6
  29. package/lib/Figure/Figure.js +3 -1
  30. package/lib/Filter/FilterButtons.js +9 -9
  31. package/lib/Frontpage/FrontpageAllSubjects.d.ts +1 -1
  32. package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
  33. package/lib/Frontpage/FrontpageSearch.d.ts +3 -5
  34. package/lib/Frontpage/FrontpageSearch.js +2 -4
  35. package/lib/LearningPaths/LearningPathMenu.js +3 -3
  36. package/lib/LearningPaths/LearningPathMobileHeader.js +4 -5
  37. package/lib/NDLAFilm/AboutNdlaFilm.d.ts +15 -0
  38. package/lib/NDLAFilm/AboutNdlaFilm.js +6 -18
  39. package/lib/NDLAFilm/AllMoviesAlphabetically.d.ts +2 -2
  40. package/lib/NDLAFilm/AllMoviesAlphabetically.js +11 -11
  41. package/lib/NDLAFilm/CategorySelect.d.ts +11 -0
  42. package/lib/NDLAFilm/CategorySelect.js +20 -19
  43. package/lib/NDLAFilm/FilmContentCard.d.ts +11 -0
  44. package/lib/NDLAFilm/FilmContentCard.js +8 -23
  45. package/lib/NDLAFilm/FilmContentCardTags.d.ts +7 -0
  46. package/lib/NDLAFilm/FilmContentCardTags.js +4 -9
  47. package/lib/NDLAFilm/FilmMovieList.d.ts +19 -0
  48. package/lib/NDLAFilm/FilmMovieList.js +5 -21
  49. package/lib/NDLAFilm/FilmMovieSearch.d.ts +21 -0
  50. package/lib/NDLAFilm/FilmMovieSearch.js +25 -30
  51. package/lib/NDLAFilm/FilmSlideshow.d.ts +5 -5
  52. package/lib/NDLAFilm/MovieGrid.d.ts +13 -0
  53. package/lib/NDLAFilm/MovieGrid.js +9 -21
  54. package/lib/NDLAFilm/SlideshowIndicator.d.ts +2 -2
  55. package/lib/NDLAFilm/VisualElement.d.ts +16 -0
  56. package/lib/NDLAFilm/VisualElement.js +22 -30
  57. package/lib/NDLAFilm/index.d.ts +14 -0
  58. package/lib/NDLAFilm/types.d.ts +6 -4
  59. package/lib/Search/SearchResultSleeve.d.ts +4 -6
  60. package/lib/Search/SearchResultSleeve.js +10 -11
  61. package/lib/SearchTypeResult/SearchFieldHeader.d.ts +3 -3
  62. package/lib/SearchTypeResult/SearchFieldHeader.js +5 -5
  63. package/lib/SearchTypeResult/SearchHeader.d.ts +3 -3
  64. package/lib/SearchTypeResult/SearchHeader.js +9 -9
  65. package/lib/SearchTypeResult/SearchItem.d.ts +2 -3
  66. package/lib/SearchTypeResult/SearchItem.js +19 -19
  67. package/lib/SearchTypeResult/SearchNotionItem.d.ts +1 -1
  68. package/lib/SearchTypeResult/SearchNotionItem.js +12 -12
  69. package/lib/SearchTypeResult/index.d.ts +1 -0
  70. package/lib/TopicIntroductionList/TopicIntroduction.d.ts +21 -0
  71. package/lib/TopicIntroductionList/TopicIntroduction.js +16 -36
  72. package/lib/TopicIntroductionList/TopicIntroductionList.d.ts +35 -0
  73. package/lib/TopicIntroductionList/TopicIntroductionList.js +6 -25
  74. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.d.ts +8 -0
  75. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.js +72 -110
  76. package/lib/TopicIntroductionList/TopicShortcutItem.d.ts +6 -0
  77. package/lib/TopicIntroductionList/TopicShortcutItem.js +0 -11
  78. package/lib/TopicIntroductionList/index.d.ts +9 -0
  79. package/lib/all.css +1 -4
  80. package/lib/index-javascript.js +3 -137
  81. package/lib/index.d.ts +4 -0
  82. package/lib/index.js +155 -0
  83. package/lib/shapes.js +1 -10
  84. package/lib/types.d.ts +2 -2
  85. package/package.json +10 -10
  86. package/src/Figure/Figure.tsx +2 -1
  87. package/src/Figure/component.figure.scss +37 -3
  88. package/src/Filter/FilterButtons.tsx +0 -2
  89. package/src/Frontpage/FrontpageAllSubjects.tsx +2 -2
  90. package/src/Frontpage/FrontpageSearch.tsx +3 -7
  91. package/src/LearningPaths/LearningPathMenu.tsx +0 -1
  92. package/src/LearningPaths/LearningPathMobileHeader.tsx +1 -2
  93. package/src/NDLAFilm/{AboutNdlaFilm.jsx → AboutNdlaFilm.tsx} +19 -18
  94. package/src/NDLAFilm/AllMoviesAlphabetically.tsx +3 -3
  95. package/src/NDLAFilm/{CategorySelect.jsx → CategorySelect.tsx} +23 -20
  96. package/src/NDLAFilm/{FilmContentCard.jsx → FilmContentCard.tsx} +21 -21
  97. package/src/NDLAFilm/{FilmContentCardTags.jsx → FilmContentCardTags.tsx} +7 -7
  98. package/src/NDLAFilm/{FilmMovieList.jsx → FilmMovieList.tsx} +17 -27
  99. package/src/NDLAFilm/FilmMovieSearch.tsx +71 -0
  100. package/src/NDLAFilm/FilmSlideshow.tsx +6 -6
  101. package/src/NDLAFilm/MovieGrid.tsx +76 -0
  102. package/src/NDLAFilm/SlideshowIndicator.tsx +2 -2
  103. package/src/NDLAFilm/VisualElement.tsx +40 -0
  104. package/src/NDLAFilm/{index.js → index.ts} +0 -0
  105. package/src/NDLAFilm/types.ts +7 -4
  106. package/src/Search/SearchResultSleeve.tsx +7 -19
  107. package/src/SearchTypeResult/SearchFieldHeader.tsx +3 -3
  108. package/src/SearchTypeResult/SearchHeader.tsx +3 -3
  109. package/src/SearchTypeResult/SearchItem.tsx +4 -5
  110. package/src/SearchTypeResult/SearchNotionItem.tsx +1 -1
  111. package/src/SearchTypeResult/index.ts +2 -0
  112. package/src/TopicIntroductionList/{TopicIntroduction.jsx → TopicIntroduction.tsx} +22 -35
  113. package/src/TopicIntroductionList/{TopicIntroductionList.jsx → TopicIntroductionList.tsx} +32 -26
  114. package/src/TopicIntroductionList/TopicIntroductionShortcuts.tsx +71 -0
  115. package/src/TopicIntroductionList/{TopicShortcutItem.jsx → TopicShortcutItem.tsx} +5 -13
  116. package/src/TopicIntroductionList/{index.js → index.ts} +0 -0
  117. package/src/index-javascript.js +0 -30
  118. package/src/index.ts +31 -0
  119. package/src/shapes.js +0 -7
  120. package/src/types.ts +2 -2
  121. package/es/NDLAFilm/interfaces.js +0 -0
  122. package/es/NDLAFilm/shapes.js +0 -15
  123. package/lib/NDLAFilm/interfaces.d.ts +0 -10
  124. package/lib/NDLAFilm/interfaces.js +0 -1
  125. package/lib/NDLAFilm/shapes.d.ts +0 -15
  126. package/lib/NDLAFilm/shapes.js +0 -30
  127. package/src/NDLAFilm/FilmMovieSearch.jsx +0 -66
  128. package/src/NDLAFilm/MovieGrid.jsx +0 -75
  129. package/src/NDLAFilm/VisualElement.jsx +0 -48
  130. package/src/NDLAFilm/interfaces.ts +0 -10
  131. package/src/NDLAFilm/shapes.ts +0 -17
  132. package/src/TopicIntroductionList/TopicIntroductionShortcuts.jsx +0 -92
@@ -15,7 +15,7 @@ import { breakpoints, mq, spacing, spacingUnit, colors, fonts, animations } from
15
15
  import SafeLink from '@ndla/safelink';
16
16
  // @ts-ignore
17
17
  import { makeSrcQueryString } from '../Image';
18
- import { movieType } from './types';
18
+ import { MovieType } from './types';
19
19
  import { isLetter } from './isLetter';
20
20
  const IMAGE_WIDTH = 143;
21
21
 
@@ -158,7 +158,7 @@ const StyledSafeLink = styled(SafeLink)<isIEProps>`
158
158
  `;
159
159
 
160
160
  interface Props {
161
- movies: movieType[];
161
+ movies: MovieType[];
162
162
  locale: string;
163
163
  }
164
164
 
@@ -231,7 +231,7 @@ const AllMoviesAlphabetically: React.FunctionComponent<Props> = ({ movies, local
231
231
 
232
232
  return (
233
233
  <StyledWrapper ref={wrapperRef}>
234
- {movies.map((movie: movieType, index: number) => {
234
+ {movies.map((movie: MovieType, index: number) => {
235
235
  const currentLetter = movie.title.substr(0, 1);
236
236
  const isNewLetter = currentLetter.localeCompare(previousLetter, locale) === 1 && isLetter(movie.title);
237
237
  previousLetter = currentLetter;
@@ -1,28 +1,40 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
1
+ import React, { Component } from 'react';
3
2
  import BEMHelper from 'react-bem-helper';
4
3
  import FocusTrapReact from 'focus-trap-react';
5
4
  import { ChevronDown } from '@ndla/icons/common';
6
- import { withTranslation } from 'react-i18next';
5
+ import { WithTranslation, withTranslation } from 'react-i18next';
6
+ import { MovieResourceType } from './types';
7
7
 
8
8
  const classes = new BEMHelper({
9
9
  name: 'film-moviesearch',
10
10
  prefix: 'c-',
11
11
  });
12
12
 
13
- class CategorySelect extends React.Component {
14
- constructor(props) {
13
+ interface Props extends WithTranslation {
14
+ resourceTypes: MovieResourceType[];
15
+ resourceTypeSelected?: MovieResourceType;
16
+ ariaControlId?: string;
17
+ onChangeResourceType: (resourceId?: string) => void;
18
+ }
19
+
20
+ interface State {
21
+ resourceTypesIsOpen: boolean;
22
+ }
23
+ class CategorySelect extends Component<Props, State> {
24
+ references: Record<string, HTMLButtonElement | null>;
25
+ constructor(props: Props) {
15
26
  super(props);
16
27
  this.state = {
17
28
  resourceTypesIsOpen: false,
18
29
  };
30
+ this.references = {};
19
31
  this.createRef = this.createRef.bind(this);
20
32
  this.openSelect = this.openSelect.bind(this);
21
33
  this.onSelect = this.onSelect.bind(this);
22
34
  }
23
35
 
24
- createRef(el, name) {
25
- this[name] = el;
36
+ createRef(el: HTMLButtonElement | null, name: string) {
37
+ this.references[name] = el;
26
38
  }
27
39
 
28
40
  openSelect() {
@@ -32,14 +44,14 @@ class CategorySelect extends React.Component {
32
44
  resourceTypesIsOpen: true,
33
45
  },
34
46
  () => {
35
- if (resourceTypeSelected && this[resourceTypeSelected.id]) {
36
- this[resourceTypeSelected.id].focus();
47
+ if (resourceTypeSelected && this.references[resourceTypeSelected.id]) {
48
+ this.references[resourceTypeSelected.id]?.focus();
37
49
  }
38
50
  },
39
51
  );
40
52
  }
41
53
 
42
- onSelect(val) {
54
+ onSelect(val?: string) {
43
55
  this.props.onChangeResourceType(val);
44
56
  this.setState({
45
57
  resourceTypesIsOpen: false,
@@ -97,7 +109,7 @@ class CategorySelect extends React.Component {
97
109
  ref={(el) => this.createRef(el, resourceType.id)}
98
110
  onClick={() => this.onSelect(resourceType.id)}
99
111
  {...classes('dropdown-button', {
100
- selected: resourceTypeSelected && resourceTypeSelected.id === resourceType.id,
112
+ selected: !!resourceTypeSelected && resourceTypeSelected.id === resourceType.id,
101
113
  })}
102
114
  data-id={resourceType.id}
103
115
  key={resourceType.id}>
@@ -112,13 +124,4 @@ class CategorySelect extends React.Component {
112
124
  }
113
125
  }
114
126
 
115
- CategorySelect.propTypes = {
116
- resourceTypes: PropTypes.arrayOf(PropTypes.object),
117
- resourceTypeSelected: PropTypes.shape({
118
- id: PropTypes.string,
119
- name: PropTypes.string,
120
- }),
121
- ariaControlId: PropTypes.string,
122
- };
123
-
124
127
  export default withTranslation()(CategorySelect);
@@ -1,11 +1,20 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { spacing, colors, fonts, breakpoints } from '@ndla/core';
4
3
  import SafeLink from '@ndla/safelink';
5
4
  import styled from '@emotion/styled';
6
5
  // @ts-ignore
7
6
  import { makeSrcQueryString } from '../Image';
8
7
  import FilmContentCardTags from './FilmContentCardTags';
8
+ import { MovieResourceType, MovieType } from './types';
9
+
10
+ interface Props {
11
+ movie: MovieType;
12
+ columnWidth: number;
13
+ distanceBetweenItems?: number;
14
+ resourceTypes: MovieResourceType[];
15
+ resizeThumbnailImages?: boolean;
16
+ hideTags?: boolean;
17
+ }
9
18
 
10
19
  const FilmContentCard = ({
11
20
  movie: { metaImage, resourceTypes: movieResourceTypes, title, id, path },
@@ -13,8 +22,8 @@ const FilmContentCard = ({
13
22
  distanceBetweenItems,
14
23
  resourceTypes,
15
24
  resizeThumbnailImages,
16
- hideTags,
17
- }) => {
25
+ hideTags = false,
26
+ }: Props) => {
18
27
  let backgroundImage = `${(metaImage && metaImage.url) || ''}`;
19
28
  if (resizeThumbnailImages && metaImage) {
20
29
  backgroundImage += '?width=480';
@@ -55,7 +64,10 @@ const StyledMovieTitle = styled.h2`
55
64
  }
56
65
  `;
57
66
 
58
- const StyledImage = styled.div`
67
+ interface StyledImageProps {
68
+ columnWidth: number;
69
+ }
70
+ const StyledImage = styled.div<StyledImageProps>`
59
71
  height: ${(props) => props.columnWidth * 0.5625}px;
60
72
  background-size: cover;
61
73
  background-color: ${colors.ndlaFilm.filmColorLight};
@@ -78,7 +90,11 @@ const StyledImage = styled.div`
78
90
  }
79
91
  `;
80
92
 
81
- const StyledSlideWrapper = styled.div`
93
+ interface StyledSlideWrapperProps {
94
+ columnWidth: number;
95
+ }
96
+
97
+ const StyledSlideWrapper = styled.div<StyledSlideWrapperProps>`
82
98
  width: ${(props) => props.columnWidth}px;
83
99
  color: #fff;
84
100
  box-shadow: none;
@@ -98,20 +114,4 @@ const StyledSlideWrapper = styled.div`
98
114
  }
99
115
  `;
100
116
 
101
- FilmContentCard.propTypes = {
102
- movie: PropTypes.shape({
103
- id: PropTypes.string,
104
- url: PropTypes.string,
105
- }).isRequired,
106
- columnWidth: PropTypes.number,
107
- distanceBetweenItems: PropTypes.number,
108
- resourceTypes: PropTypes.arrayOf(PropTypes.object),
109
- resizeThumbnailImages: PropTypes.bool,
110
- hideTags: PropTypes.bool,
111
- };
112
-
113
- FilmContentCard.defaultProps = {
114
- hideTags: false,
115
- };
116
-
117
117
  export default FilmContentCard;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { spacing, spacingUnit, colors, fonts, misc } from '@ndla/core';
4
3
  import styled from '@emotion/styled';
4
+ import { MovieResourceType } from './types';
5
5
 
6
6
  const StyledWrapperDiv = styled.div`
7
7
  transition: opacity 200ms ease;
@@ -22,8 +22,12 @@ const StyledMovieTags = styled.span`
22
22
  margin-bottom: ${spacingUnit / 8}px;
23
23
  `;
24
24
 
25
- const FilmContentCardTags = ({ movieResourceTypes, resourceTypes }) => {
26
- const resources = {};
25
+ interface Props {
26
+ movieResourceTypes: MovieResourceType[];
27
+ resourceTypes: MovieResourceType[];
28
+ }
29
+ const FilmContentCardTags = ({ movieResourceTypes, resourceTypes }: Props) => {
30
+ const resources: Record<string, boolean> = {};
27
31
  movieResourceTypes.forEach((movieResourceType) => {
28
32
  const resource = resourceTypes.find((resourceType) => resourceType.id === movieResourceType.id);
29
33
  if (resource) {
@@ -39,8 +43,4 @@ const FilmContentCardTags = ({ movieResourceTypes, resourceTypes }) => {
39
43
  );
40
44
  };
41
45
 
42
- FilmContentCardTags.propTypes = {
43
- resourceTypes: PropTypes.arrayOf(PropTypes.object).isRequired,
44
- };
45
-
46
46
  export default FilmContentCardTags;
@@ -1,5 +1,4 @@
1
- /**
2
- * Copyright (c) 2016-present, NDLA.
1
+ /** * Copyright (c) 2016-present, NDLA.
3
2
  *
4
3
  * This source code is licensed under the GPLv3 license found in the
5
4
  * LICENSE file in the root directory of this source tree.
@@ -7,31 +6,41 @@
7
6
  */
8
7
 
9
8
  import React from 'react';
10
- import PropTypes from 'prop-types';
11
9
  import BEMHelper from 'react-bem-helper';
12
- import { Carousel } from '@ndla/carousel';
10
+ import { Carousel, CalculatedCarouselProps } from '@ndla/carousel';
13
11
  import FilmContentCard from './FilmContentCard';
14
- import { movieShape } from './shapes';
12
+ import { MovieResourceType, MovieType } from './types';
15
13
 
16
14
  const classes = new BEMHelper({
17
15
  name: 'film-movielist',
18
16
  prefix: 'c-',
19
17
  });
20
18
 
19
+ interface Props {
20
+ movies: MovieType[];
21
+ name: string;
22
+ slideBackwardsLabel: string;
23
+ slideForwardsLabel: string;
24
+ resourceTypes: MovieResourceType[];
25
+ autoSizedProps: CalculatedCarouselProps;
26
+ resizeThumbnailImages?: boolean;
27
+ }
28
+
21
29
  const FilmMovieList = ({
22
30
  name,
23
- movies,
31
+ movies = [],
24
32
  slideBackwardsLabel,
25
33
  slideForwardsLabel,
26
- resourceTypes,
34
+ resourceTypes = [],
27
35
  autoSizedProps,
28
36
  resizeThumbnailImages,
29
- }) => (
37
+ }: Props) => (
30
38
  <section {...classes()}>
31
39
  <h1 {...classes('heading')} style={{ marginLeft: `${autoSizedProps.margin}px` }}>
32
40
  {name}
33
41
  </h1>
34
42
  <Carousel
43
+ disableScroll={false}
35
44
  slideBackwardsLabel={slideBackwardsLabel}
36
45
  slideForwardsLabel={slideForwardsLabel}
37
46
  buttonClass="c-film-movielist__carousel-buttons"
@@ -50,23 +59,4 @@ const FilmMovieList = ({
50
59
  </section>
51
60
  );
52
61
 
53
- FilmMovieList.propTypes = {
54
- movies: PropTypes.arrayOf(movieShape),
55
- name: PropTypes.string.isRequired,
56
- slideBackwardsLabel: PropTypes.string.isRequired,
57
- slideForwardsLabel: PropTypes.string.isRequired,
58
- resourceTypes: PropTypes.arrayOf(
59
- PropTypes.shape({
60
- name: PropTypes.string,
61
- id: PropTypes.id,
62
- }),
63
- ),
64
- autoSizedProps: PropTypes.shape({}),
65
- };
66
-
67
- FilmMovieList.defaultProps = {
68
- movies: [],
69
- resourceTypes: [],
70
- };
71
-
72
62
  export default FilmMovieList;
@@ -0,0 +1,71 @@
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 from 'react';
10
+ import BEMHelper from 'react-bem-helper';
11
+ import SafeLink from '@ndla/safelink';
12
+ import { useTranslation } from 'react-i18next';
13
+ import CategorySelect from './CategorySelect';
14
+ import { MovieResourceType } from './types';
15
+ import { OneColumn } from '..';
16
+
17
+ const classes = new BEMHelper({
18
+ name: 'film-moviesearch',
19
+ prefix: 'c-',
20
+ });
21
+
22
+ const classesMovieList = new BEMHelper({
23
+ name: 'film-movielist',
24
+ prefix: 'c-',
25
+ });
26
+
27
+ interface Props {
28
+ topics?: { id: string; path: string; name: string }[];
29
+ onChangeResourceType: (resourceType?: string) => void;
30
+ resourceTypeSelected?: MovieResourceType;
31
+ resourceTypes: MovieResourceType[];
32
+ ariaControlId: string;
33
+ }
34
+
35
+ const FilmMovieSearch = ({
36
+ topics = [],
37
+ onChangeResourceType,
38
+ resourceTypes,
39
+ resourceTypeSelected,
40
+ ariaControlId,
41
+ }: Props) => {
42
+ const { t } = useTranslation();
43
+ return (
44
+ <div {...classes('')}>
45
+ <OneColumn>
46
+ <div {...classes('topic-navigation')}>
47
+ <h2 {...classesMovieList('heading', '', 'u-12/12 u-4/12@tablet')}>{t('ndlaFilm.subjectsInMovies')}:</h2>
48
+ <nav className="u-12/12 u-8/12@tablet">
49
+ <ul>
50
+ {topics.map((topic) => (
51
+ <li key={topic.id}>
52
+ <SafeLink to={topic.path} key={topic.id}>
53
+ <span>{topic.name}</span>
54
+ </SafeLink>
55
+ </li>
56
+ ))}
57
+ </ul>
58
+ </nav>
59
+ </div>
60
+ <CategorySelect
61
+ onChangeResourceType={onChangeResourceType}
62
+ resourceTypes={resourceTypes}
63
+ resourceTypeSelected={resourceTypeSelected}
64
+ ariaControlId={ariaControlId}
65
+ />
66
+ </OneColumn>
67
+ </div>
68
+ );
69
+ };
70
+
71
+ export default FilmMovieSearch;
@@ -13,15 +13,15 @@ import BEMHelper from 'react-bem-helper';
13
13
  import SafeLink from '@ndla/safelink';
14
14
  import { OneColumn } from '../Layout';
15
15
  import Spinner from '../Spinner';
16
- import { NDLAMovie } from './interfaces';
17
16
  import NavigationArrow from './NavigationArrow';
18
17
  import SlideshowIndicator from './SlideshowIndicator';
18
+ import { MovieType } from './types';
19
19
 
20
20
  interface Props {
21
- autoSlide: boolean;
22
- randomStart: boolean;
23
- slideshow: NDLAMovie[];
24
- slideInterval: number;
21
+ autoSlide?: boolean;
22
+ randomStart?: boolean;
23
+ slideshow: MovieType[];
24
+ slideInterval?: number;
25
25
  }
26
26
 
27
27
  const classes = new BEMHelper({
@@ -32,7 +32,7 @@ const classes = new BEMHelper({
32
32
  const defaultTransitionSwipeEnd = 'transform 600ms cubic-bezier(0, 0.76, 0.09, 1)';
33
33
  const defaultTransitionText = 'opacity 600ms ease';
34
34
 
35
- const renderSlideItem = (slide: NDLAMovie) => (
35
+ const renderSlideItem = (slide: MovieType) => (
36
36
  <div
37
37
  {...classes('item')}
38
38
  key={slide.id}
@@ -0,0 +1,76 @@
1
+ import React from 'react';
2
+ import BEMHelper from 'react-bem-helper';
3
+ import { css } from '@emotion/core';
4
+ import { CalculatedCarouselProps } from '@ndla/carousel';
5
+ import { useTranslation } from 'react-i18next';
6
+ import FilmContentCard from './FilmContentCard';
7
+ import { MovieResourceType, MovieType } from './types';
8
+
9
+ const movieListClasses = new BEMHelper({
10
+ name: 'film-movielist',
11
+ prefix: 'c-',
12
+ });
13
+
14
+ interface Props {
15
+ autoSizedProps: CalculatedCarouselProps;
16
+ resourceTypeName?: MovieResourceType;
17
+ fetchingMoviesByType: boolean;
18
+ moviesByType: MovieType[];
19
+ resourceTypes: MovieResourceType[];
20
+ loadingPlaceholderHeight?: string;
21
+ resizeThumbnailImages?: boolean;
22
+ }
23
+
24
+ const MovieGrid = ({
25
+ resourceTypeName,
26
+ fetchingMoviesByType,
27
+ moviesByType,
28
+ resourceTypes,
29
+ loadingPlaceholderHeight,
30
+ autoSizedProps,
31
+ resizeThumbnailImages,
32
+ }: Props) => {
33
+ const { t } = useTranslation();
34
+ return (
35
+ <section>
36
+ <h1
37
+ {...movieListClasses('heading')}
38
+ css={css`
39
+ margin-left: ${autoSizedProps.margin}px;
40
+ `}>
41
+ {resourceTypeName && resourceTypeName.name}
42
+ <small>
43
+ {fetchingMoviesByType
44
+ ? t('ndlaFilm.loadingMovies')
45
+ : `${moviesByType.length} ${t('ndlaFilm.movieMatchInCategory')}`}
46
+ </small>
47
+ </h1>
48
+ <div
49
+ {...movieListClasses('movie-listing')}
50
+ css={css`
51
+ margin-left: ${autoSizedProps.margin}px;
52
+ `}>
53
+ {fetchingMoviesByType && (
54
+ <div
55
+ css={css`
56
+ height: ${loadingPlaceholderHeight};
57
+ `}
58
+ />
59
+ )}
60
+ {!fetchingMoviesByType &&
61
+ moviesByType.map((movie) => (
62
+ <FilmContentCard
63
+ hideTags
64
+ movie={movie}
65
+ columnWidth={autoSizedProps.columnWidth}
66
+ distanceBetweenItems={autoSizedProps.distanceBetweenItems}
67
+ resourceTypes={resourceTypes}
68
+ resizeThumbnailImages={resizeThumbnailImages}
69
+ />
70
+ ))}
71
+ </div>
72
+ </section>
73
+ );
74
+ };
75
+
76
+ export default MovieGrid;
@@ -8,10 +8,10 @@
8
8
 
9
9
  import React from 'react';
10
10
  import BEMHelper from 'react-bem-helper';
11
- import { NDLAMovie } from './interfaces';
11
+ import { MovieType } from './types';
12
12
 
13
13
  interface Props {
14
- slideshow: NDLAMovie[];
14
+ slideshow: MovieType[];
15
15
  activeSlide: number;
16
16
  gotoSlide: (indexTarget: number, useAnimation: boolean) => void;
17
17
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2019-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
+ import styled from '@emotion/styled';
11
+ import Image from '../Image';
12
+
13
+ const StylediFrame = styled.iframe`
14
+ height: 100%;
15
+ width: 100%;
16
+ border: 0;
17
+ margin: 0;
18
+ padding: 0;
19
+ `;
20
+
21
+ interface Props {
22
+ visualElement: {
23
+ alt?: string;
24
+ url: string;
25
+ type: string;
26
+ };
27
+ }
28
+ const VisualElement = ({ visualElement }: Props) => {
29
+ const { type, url, alt } = visualElement;
30
+ if (type === 'image') {
31
+ return <Image src={url} alt={alt ?? ''} />;
32
+ } else if (type === 'brightcove') {
33
+ //@ts-ignore react does not recognize fullscreen properties.
34
+ return <StylediFrame allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" src={url} />;
35
+ } else {
36
+ return null;
37
+ }
38
+ };
39
+
40
+ export default VisualElement;
File without changes
@@ -1,13 +1,16 @@
1
- export interface movieType {
1
+ export interface MovieType {
2
2
  id: string;
3
3
  metaDescription: string;
4
+ resourceTypes: MovieResourceType[];
4
5
  metaImage: {
5
6
  alt: string;
6
7
  url: string;
7
8
  };
8
- movieTypes: {
9
- [key: string]: boolean;
10
- };
11
9
  path: string;
12
10
  title: string;
13
11
  }
12
+
13
+ export interface MovieResourceType {
14
+ id: string;
15
+ name: string;
16
+ }
@@ -7,20 +7,10 @@
7
7
  */
8
8
 
9
9
  import React, { useEffect, useRef, useState } from 'react';
10
- import { History } from 'history';
11
10
  import styled from '@emotion/styled';
12
11
  import { breakpoints, colors, fonts, misc, mq, spacing } from '@ndla/core';
13
- import {
14
- ChevronDown,
15
- ChevronUp,
16
- Esc,
17
- KeyboardReturn,
18
- Search as SearchIcon,
19
- Wrench,
20
- // @ts-ignore
21
- } from '@ndla/icons/common';
12
+ import { ChevronDown, ChevronUp, Esc, KeyboardReturn, Search as SearchIcon, Wrench } from '@ndla/icons/common';
22
13
  import SafeLink from '@ndla/safelink';
23
- // @ts-ignore
24
14
  import { useTranslation } from 'react-i18next';
25
15
  import ContentTypeResult from './ContentTypeResult';
26
16
  import { highlightStyle } from './ContentTypeResultStyles';
@@ -218,14 +208,13 @@ type Props = {
218
208
  to: string;
219
209
  };
220
210
  onNavigate?: VoidFunction;
221
- infoText: string;
222
- ignoreContentTypeBadge: boolean;
211
+ infoText?: string;
212
+ ignoreContentTypeBadge?: boolean;
223
213
  searchString: string;
224
214
  loading: boolean;
225
215
  frontpage?: boolean;
226
- history: History;
227
- suggestion: string;
228
- suggestionUrl: string;
216
+ suggestion?: string;
217
+ suggestionUrl?: string;
229
218
  };
230
219
 
231
220
  const SearchResultSleeve: React.FC<Props> = ({
@@ -238,7 +227,6 @@ const SearchResultSleeve: React.FC<Props> = ({
238
227
  searchString,
239
228
  loading,
240
229
  frontpage,
241
- history,
242
230
  suggestion,
243
231
  suggestionUrl,
244
232
  }) => {
@@ -332,7 +320,7 @@ const SearchResultSleeve: React.FC<Props> = ({
332
320
  <strong ref={searchAllRef}>{searchString}</strong>
333
321
  <small>{t('welcomePage.searchAllInfo')}</small>
334
322
  </StyledSearchLink>
335
- {suggestion && (
323
+ {suggestion && suggestionUrl && (
336
324
  <StyledSearchLink css={keyboardPathNavigation === GO_TO_SUGGESTION && highlightStyle} to={suggestionUrl}>
337
325
  <SearchIcon className="c-icon--22" />
338
326
  <small>{t('searchPage.resultType.searchPhraseSuggestion')}</small>
@@ -342,7 +330,7 @@ const SearchResultSleeve: React.FC<Props> = ({
342
330
  </SearchLinkContainer>
343
331
  {result.map((contentTypeResult: ContentTypeResultType) => (
344
332
  <ContentTypeResult
345
- ignoreContentTypeBadge={ignoreContentTypeBadge}
333
+ ignoreContentTypeBadge={!!ignoreContentTypeBadge}
346
334
  onNavigate={onNavigate}
347
335
  contentTypeResult={contentTypeResult}
348
336
  resourceToLinkProps={resourceToLinkProps}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import React, { useEffect, useRef, useState } from 'react';
9
+ import React, { FormEvent, useEffect, useRef, useState } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { colors, breakpoints, mq } from '@ndla/core';
12
12
  // @ts-ignore
@@ -76,8 +76,8 @@ const SearchInput = styled.input`
76
76
  `;
77
77
 
78
78
  type Props = {
79
- onSubmit: (event: {}) => void;
80
- value: string;
79
+ onSubmit: (event: FormEvent<HTMLFormElement>) => void;
80
+ value?: string;
81
81
  onChange: (value: string) => void;
82
82
  filters?: PopupFilterProps;
83
83
  activeFilters?: {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import React from 'react';
9
+ import React, { FormEvent } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { breakpoints, fonts, mq, spacing } from '@ndla/core';
12
12
 
@@ -75,7 +75,7 @@ type Props = {
75
75
  searchPhrase?: string;
76
76
  searchPhraseSuggestion?: string;
77
77
  searchPhraseSuggestionOnClick?: () => void;
78
- searchValue: string;
78
+ searchValue?: string;
79
79
  filters?: PopupFilterProps;
80
80
  activeFilters?: {
81
81
  filters: FilterProps[];
@@ -83,7 +83,7 @@ type Props = {
83
83
  };
84
84
  competenceGoals?: CompetenceGoalsItemType[];
85
85
  onSearchValueChange: (value: string) => void;
86
- onSubmit: () => void;
86
+ onSubmit: (event: FormEvent<HTMLFormElement>) => void;
87
87
  noResults?: boolean;
88
88
  };
89
89