@ndla/ui 3.3.9 → 3.3.14

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 (184) hide show
  1. package/es/Article/Article.js +23 -1
  2. package/es/Article/ArticleNotions.js +80 -32
  3. package/es/Breadcrumblist/Breadcrumblist.js +14 -10
  4. package/es/CloseButton/CloseButton.js +62 -0
  5. package/es/CloseButton/index.js +9 -0
  6. package/es/Figure/Figure.js +3 -1
  7. package/es/Frontpage/FrontpageAllSubjects.js +7 -7
  8. package/es/Frontpage/FrontpageProgramMenu.js +10 -10
  9. package/es/Frontpage/FrontpageSearch.js +2 -4
  10. package/es/MediaList/MediaList.js +22 -73
  11. package/es/MessageBox/MessageBox.js +146 -78
  12. package/es/MessageBox/MessageBoxTag.js +37 -0
  13. package/es/MessageBox/index.js +3 -1
  14. package/es/NDLAFilm/AboutNdlaFilm.js +6 -17
  15. package/es/NDLAFilm/AllMoviesAlphabetically.js +11 -11
  16. package/es/NDLAFilm/CategorySelect.js +17 -18
  17. package/es/NDLAFilm/FilmContentCard.js +8 -22
  18. package/es/NDLAFilm/FilmContentCardTags.js +4 -8
  19. package/es/NDLAFilm/FilmMovieList.js +6 -21
  20. package/es/NDLAFilm/FilmMovieSearch.js +18 -26
  21. package/es/NDLAFilm/FilmSlideshow.js +2 -1
  22. package/es/NDLAFilm/MovieGrid.js +10 -19
  23. package/es/NDLAFilm/VisualElement.js +22 -29
  24. package/es/Programme/Programme.js +15 -8
  25. package/es/Search/SearchResultSleeve.js +12 -15
  26. package/es/SearchTypeResult/SearchFieldHeader.js +5 -5
  27. package/es/SearchTypeResult/SearchHeader.js +9 -9
  28. package/es/SearchTypeResult/SearchItem.js +19 -19
  29. package/es/SearchTypeResult/SearchNotionItem.js +12 -12
  30. package/es/SearchTypeResult/SearchNotionsResult.js +9 -14
  31. package/es/TopicIntroductionList/TopicIntroduction.js +14 -33
  32. package/es/TopicIntroductionList/TopicIntroductionList.js +6 -23
  33. package/es/TopicIntroductionList/TopicIntroductionShortcuts.js +71 -110
  34. package/es/TopicIntroductionList/TopicShortcutItem.js +0 -9
  35. package/es/all.css +1 -4
  36. package/es/index-javascript.js +1 -5
  37. package/es/index.js +6 -1
  38. package/es/locale/messages-en.js +10 -0
  39. package/es/locale/messages-nb.js +10 -0
  40. package/es/locale/messages-nn.js +10 -0
  41. package/es/shapes.js +0 -6
  42. package/lib/Article/Article.d.ts +3 -1
  43. package/lib/Article/Article.js +25 -3
  44. package/lib/Article/ArticleNotions.js +79 -30
  45. package/lib/Breadcrumblist/Breadcrumblist.d.ts +2 -1
  46. package/lib/Breadcrumblist/Breadcrumblist.js +15 -10
  47. package/lib/CloseButton/CloseButton.d.ts +6 -0
  48. package/lib/CloseButton/CloseButton.js +69 -0
  49. package/lib/CloseButton/index.d.ts +9 -0
  50. package/lib/CloseButton/index.js +15 -0
  51. package/lib/Figure/Figure.js +3 -1
  52. package/lib/Frontpage/FrontpageAllSubjects.d.ts +1 -1
  53. package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
  54. package/lib/Frontpage/FrontpageProgramMenu.js +10 -10
  55. package/lib/Frontpage/FrontpageSearch.d.ts +3 -5
  56. package/lib/Frontpage/FrontpageSearch.js +2 -4
  57. package/lib/MediaList/MediaList.d.ts +48 -0
  58. package/lib/MediaList/MediaList.js +24 -78
  59. package/lib/MediaList/index.d.ts +8 -0
  60. package/lib/MessageBox/MessageBox.d.ts +22 -6
  61. package/lib/MessageBox/MessageBox.js +146 -77
  62. package/lib/MessageBox/MessageBoxTag.d.ts +12 -0
  63. package/lib/MessageBox/MessageBoxTag.js +44 -0
  64. package/lib/MessageBox/index.d.ts +3 -1
  65. package/lib/MessageBox/index.js +22 -2
  66. package/lib/NDLAFilm/AboutNdlaFilm.d.ts +15 -0
  67. package/lib/NDLAFilm/AboutNdlaFilm.js +6 -18
  68. package/lib/NDLAFilm/AllMoviesAlphabetically.d.ts +2 -2
  69. package/lib/NDLAFilm/AllMoviesAlphabetically.js +11 -11
  70. package/lib/NDLAFilm/CategorySelect.d.ts +11 -0
  71. package/lib/NDLAFilm/CategorySelect.js +20 -19
  72. package/lib/NDLAFilm/FilmContentCard.d.ts +11 -0
  73. package/lib/NDLAFilm/FilmContentCard.js +8 -23
  74. package/lib/NDLAFilm/FilmContentCardTags.d.ts +7 -0
  75. package/lib/NDLAFilm/FilmContentCardTags.js +4 -9
  76. package/lib/NDLAFilm/FilmMovieList.d.ts +19 -0
  77. package/lib/NDLAFilm/FilmMovieList.js +5 -21
  78. package/lib/NDLAFilm/FilmMovieSearch.d.ts +21 -0
  79. package/lib/NDLAFilm/FilmMovieSearch.js +25 -30
  80. package/lib/NDLAFilm/FilmSlideshow.d.ts +5 -5
  81. package/lib/NDLAFilm/MovieGrid.d.ts +13 -0
  82. package/lib/NDLAFilm/MovieGrid.js +9 -21
  83. package/lib/NDLAFilm/SlideshowIndicator.d.ts +2 -2
  84. package/lib/NDLAFilm/VisualElement.d.ts +16 -0
  85. package/lib/NDLAFilm/VisualElement.js +22 -30
  86. package/lib/NDLAFilm/index.d.ts +14 -0
  87. package/lib/NDLAFilm/types.d.ts +6 -4
  88. package/lib/Programme/Programme.d.ts +2 -1
  89. package/lib/Programme/Programme.js +18 -9
  90. package/lib/Search/SearchResultSleeve.d.ts +4 -6
  91. package/lib/Search/SearchResultSleeve.js +10 -11
  92. package/lib/SearchTypeResult/SearchFieldHeader.d.ts +3 -3
  93. package/lib/SearchTypeResult/SearchFieldHeader.js +5 -5
  94. package/lib/SearchTypeResult/SearchHeader.d.ts +3 -3
  95. package/lib/SearchTypeResult/SearchHeader.js +9 -9
  96. package/lib/SearchTypeResult/SearchItem.d.ts +2 -3
  97. package/lib/SearchTypeResult/SearchItem.js +19 -19
  98. package/lib/SearchTypeResult/SearchNotionItem.d.ts +1 -1
  99. package/lib/SearchTypeResult/SearchNotionItem.js +12 -12
  100. package/lib/SearchTypeResult/SearchNotionsResult.js +8 -13
  101. package/lib/SearchTypeResult/index.d.ts +1 -0
  102. package/lib/TopicIntroductionList/TopicIntroduction.d.ts +21 -0
  103. package/lib/TopicIntroductionList/TopicIntroduction.js +16 -36
  104. package/lib/TopicIntroductionList/TopicIntroductionList.d.ts +35 -0
  105. package/lib/TopicIntroductionList/TopicIntroductionList.js +6 -25
  106. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.d.ts +8 -0
  107. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.js +72 -110
  108. package/lib/TopicIntroductionList/TopicShortcutItem.d.ts +6 -0
  109. package/lib/TopicIntroductionList/TopicShortcutItem.js +0 -11
  110. package/lib/TopicIntroductionList/index.d.ts +9 -0
  111. package/lib/all.css +1 -4
  112. package/lib/index-javascript.js +3 -137
  113. package/lib/index.d.ts +6 -1
  114. package/lib/index.js +178 -0
  115. package/lib/locale/messages-en.d.ts +10 -0
  116. package/lib/locale/messages-en.js +10 -0
  117. package/lib/locale/messages-nb.d.ts +10 -0
  118. package/lib/locale/messages-nb.js +10 -0
  119. package/lib/locale/messages-nn.d.ts +10 -0
  120. package/lib/locale/messages-nn.js +10 -0
  121. package/lib/shapes.js +1 -10
  122. package/lib/types.d.ts +2 -2
  123. package/package.json +12 -12
  124. package/src/Article/Article.tsx +17 -0
  125. package/src/Article/ArticleNotions.tsx +10 -7
  126. package/src/Breadcrumblist/Breadcrumblist.tsx +5 -3
  127. package/src/CloseButton/CloseButton.tsx +40 -0
  128. package/src/CloseButton/index.ts +11 -0
  129. package/src/Figure/Figure.tsx +2 -1
  130. package/src/Figure/component.figure.scss +37 -3
  131. package/src/Frontpage/FrontpageAllSubjects.tsx +2 -2
  132. package/src/Frontpage/FrontpageProgramMenu.tsx +1 -0
  133. package/src/Frontpage/FrontpageSearch.tsx +3 -7
  134. package/src/MediaList/MediaList.tsx +158 -0
  135. package/src/MediaList/{index.js → index.ts} +0 -0
  136. package/src/MessageBox/MessageBox.tsx +117 -96
  137. package/src/MessageBox/MessageBoxTag.tsx +35 -0
  138. package/src/MessageBox/index.ts +3 -1
  139. package/src/NDLAFilm/{AboutNdlaFilm.jsx → AboutNdlaFilm.tsx} +19 -18
  140. package/src/NDLAFilm/AllMoviesAlphabetically.tsx +3 -3
  141. package/src/NDLAFilm/{CategorySelect.jsx → CategorySelect.tsx} +23 -20
  142. package/src/NDLAFilm/{FilmContentCard.jsx → FilmContentCard.tsx} +21 -21
  143. package/src/NDLAFilm/{FilmContentCardTags.jsx → FilmContentCardTags.tsx} +7 -7
  144. package/src/NDLAFilm/{FilmMovieList.jsx → FilmMovieList.tsx} +17 -27
  145. package/src/NDLAFilm/FilmMovieSearch.tsx +71 -0
  146. package/src/NDLAFilm/FilmSlideshow.tsx +7 -6
  147. package/src/NDLAFilm/MovieGrid.tsx +76 -0
  148. package/src/NDLAFilm/SlideshowIndicator.tsx +2 -2
  149. package/src/NDLAFilm/VisualElement.tsx +40 -0
  150. package/src/NDLAFilm/{index.js → index.ts} +0 -0
  151. package/src/NDLAFilm/types.ts +7 -4
  152. package/src/Programme/Programme.tsx +7 -3
  153. package/src/Search/SearchResultSleeve.tsx +7 -19
  154. package/src/SearchTypeResult/SearchFieldHeader.tsx +3 -3
  155. package/src/SearchTypeResult/SearchHeader.tsx +3 -3
  156. package/src/SearchTypeResult/SearchItem.tsx +4 -5
  157. package/src/SearchTypeResult/SearchNotionItem.tsx +1 -2
  158. package/src/SearchTypeResult/SearchNotionsResult.tsx +3 -8
  159. package/src/SearchTypeResult/index.ts +2 -0
  160. package/src/TopicIntroductionList/{TopicIntroduction.jsx → TopicIntroduction.tsx} +22 -35
  161. package/src/TopicIntroductionList/{TopicIntroductionList.jsx → TopicIntroductionList.tsx} +32 -26
  162. package/src/TopicIntroductionList/TopicIntroductionShortcuts.tsx +71 -0
  163. package/src/TopicIntroductionList/{TopicShortcutItem.jsx → TopicShortcutItem.tsx} +5 -13
  164. package/src/TopicIntroductionList/{index.js → index.ts} +0 -0
  165. package/src/index-javascript.js +0 -30
  166. package/src/index.ts +33 -1
  167. package/src/locale/messages-en.ts +14 -0
  168. package/src/locale/messages-nb.ts +14 -0
  169. package/src/locale/messages-nn.ts +14 -0
  170. package/src/shapes.js +0 -7
  171. package/src/types.ts +2 -2
  172. package/es/NDLAFilm/interfaces.js +0 -0
  173. package/es/NDLAFilm/shapes.js +0 -15
  174. package/lib/NDLAFilm/interfaces.d.ts +0 -10
  175. package/lib/NDLAFilm/interfaces.js +0 -1
  176. package/lib/NDLAFilm/shapes.d.ts +0 -15
  177. package/lib/NDLAFilm/shapes.js +0 -30
  178. package/src/MediaList/MediaList.jsx +0 -182
  179. package/src/NDLAFilm/FilmMovieSearch.jsx +0 -66
  180. package/src/NDLAFilm/MovieGrid.jsx +0 -75
  181. package/src/NDLAFilm/VisualElement.jsx +0 -48
  182. package/src/NDLAFilm/interfaces.ts +0 -10
  183. package/src/NDLAFilm/shapes.ts +0 -17
  184. package/src/TopicIntroductionList/TopicIntroductionShortcuts.jsx +0 -92
@@ -12,8 +12,8 @@ import { useTranslation } from 'react-i18next';
12
12
 
13
13
  // @ts-ignore
14
14
  import Modal, { ModalHeader, ModalCloseButton, ModalBody } from '@ndla/modal';
15
- import { mq, breakpoints, fonts, colors } from '@ndla/core';
16
- import { Explanation, NotionFlip } from '@ndla/icons/common';
15
+ import { mq, breakpoints } from '@ndla/core';
16
+ import { Explanation } from '@ndla/icons/common';
17
17
  import { Locale } from '../types';
18
18
  import { Notion } from '../Notion';
19
19
  import { NotionProps } from '../Notion/Notion';
@@ -25,6 +25,7 @@ const ArticleNotionsContainer = styled.div`
25
25
  margin-bottom: 0;
26
26
  }
27
27
  `;
28
+ /* Stored for later
28
29
 
29
30
  const NotionsTrigger = styled.div`
30
31
  padding: 0 16px;
@@ -33,7 +34,7 @@ const NotionsTrigger = styled.div`
33
34
  background-color: ${colors.brand.greyLighter};
34
35
  border-radius: 4px;
35
36
  cursor: pointer;
36
-
37
+
37
38
  ${mq.range({ from: breakpoints.tablet })} {
38
39
  position: fixed;
39
40
  border: none;
@@ -81,7 +82,7 @@ const NotionsTrigger = styled.div`
81
82
  }
82
83
  }
83
84
  `;
84
-
85
+ */
85
86
  const ModalHeadingContainer = styled.div`
86
87
  display: flex;
87
88
  align-items: center;
@@ -176,17 +177,19 @@ export const ArticleNotions = ({
176
177
  buttonOffsetRight,
177
178
  }: ArticleNotionsProps) => {
178
179
  const { t } = useTranslation();
179
- const leftOffset = `${buttonOffsetRight - 32}px`;
180
+ //const leftOffset = `${buttonOffsetRight - 32}px`;
180
181
  return (
181
182
  <ArticleNotionsContainer>
182
183
  <Modal
183
- activateButton={
184
+ /* Stored for later
185
+
186
+ activateButton={
184
187
  <NotionsTrigger role="button" aria-label={t('article.notionsPrompt')} style={{ left: leftOffset }}>
185
188
  <NotionFlip />
186
189
  <Explanation />
187
190
  <span>{t('article.notionsPrompt')}</span>
188
191
  </NotionsTrigger>
189
- }
192
+ } */
190
193
  size="large"
191
194
  backgroundColor="white">
192
195
  {(onClose: () => void) => (
@@ -9,7 +9,6 @@
9
9
  import React, { useEffect, useState } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { mq, breakpoints, colors } from '@ndla/core';
12
-
13
12
  import {
14
13
  School as SchoolIcon,
15
14
  MenuBook as MenuBookIcon,
@@ -20,6 +19,7 @@ import {
20
19
  } from '@ndla/icons/action';
21
20
  import SafeLink from '@ndla/safelink';
22
21
  import { useTranslation } from 'react-i18next';
22
+ import MessageBoxTag from '../MessageBox/MessageBoxTag';
23
23
 
24
24
  type WrapperProps = {
25
25
  startOffset?: number;
@@ -51,7 +51,6 @@ const Wrapper = styled.div<WrapperProps>`
51
51
  ${(props) =>
52
52
  props.startOffset &&
53
53
  `
54
- position: absolute;
55
54
  top: calc(${props.startOffset}px + 85px);
56
55
  `}
57
56
  }
@@ -87,7 +86,7 @@ const Heading = styled.div<InvertItProps>`
87
86
  font-size: 12px;
88
87
  line-height: 15px;
89
88
  text-transform: uppercase;
90
- padding: 0 0 18px 10px;
89
+ padding: 0 0 10px 10px;
91
90
  ${(props) =>
92
91
  props.invertedStyle &&
93
92
  `
@@ -214,6 +213,7 @@ type BreadCrumbProps = {
214
213
  leftAlign?: boolean;
215
214
  hideOnNarrow?: boolean;
216
215
  onNav?: (e: React.MouseEvent<HTMLElement>, item: BreadcrumbItemProps) => void;
216
+ messageBoxTagMessage?: string;
217
217
  };
218
218
 
219
219
  const Breadcrumblist = ({
@@ -225,6 +225,7 @@ const Breadcrumblist = ({
225
225
  leftAlign,
226
226
  hideOnNarrow,
227
227
  onNav,
228
+ messageBoxTagMessage,
228
229
  }: BreadCrumbProps) => {
229
230
  const { t } = useTranslation();
230
231
  const [wrapperOffset, setWrapperOffset] = useState(startOffset);
@@ -274,6 +275,7 @@ const Breadcrumblist = ({
274
275
  {items.length > 0 && (
275
276
  <>
276
277
  <Heading invertedStyle={invertedStyle}>{t('breadcrumb.youAreHere')}</Heading>
278
+ {messageBoxTagMessage && <MessageBoxTag tagMessage={messageBoxTagMessage} />}
277
279
  <List data-testid="breadcrumb-list">
278
280
  {items.map((item: BreadcrumbItemProps) => {
279
281
  const { id, label, url, typename, icon, isCurrent = false } = item;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2022-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
+ import React from 'react';
9
+ import styled from '@emotion/styled';
10
+ import { Cross } from '@ndla/icons/action';
11
+ import { useTranslation } from 'react-i18next';
12
+ const CloseButtonWrapper = styled.div`
13
+ position: relative;
14
+ top: 1px;
15
+ right: 1px;
16
+ `;
17
+
18
+ const CloseBut = styled.button`
19
+ background-color: transparent;
20
+ border: none;
21
+ display: flex;
22
+ `;
23
+
24
+ type Props = {
25
+ onClick: () => void;
26
+ color: string;
27
+ };
28
+
29
+ export const CloseButton = ({ onClick, color }: Props) => {
30
+ const { t } = useTranslation();
31
+ return (
32
+ <CloseButtonWrapper aria-label={t('lukk')}>
33
+ <CloseBut onClick={onClick}>
34
+ <Cross style={{ width: '24px', height: '24px', color: color }} />
35
+ </CloseBut>
36
+ </CloseButtonWrapper>
37
+ );
38
+ };
39
+
40
+ export default CloseButton;
@@ -0,0 +1,11 @@
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 CloseButton from './CloseButton';
10
+
11
+ export { CloseButton };
@@ -121,8 +121,9 @@ interface FigureCaptionProps {
121
121
 
122
122
  const Figure = ({ children, type = 'full', resizeIframe, ...rest }: Props) => {
123
123
  const typeClass = type === 'full-column' ? 'c-figure--full-column' : `u-float-${type}`;
124
+ const right = ['small-right', 'xsmall-right'].includes(type);
124
125
  return (
125
- <figure data-sizetype={type} {...classes('', { resize: !!resizeIframe }, typeClass)} {...rest}>
126
+ <figure data-sizetype={type} {...classes('', { resize: !!resizeIframe, right }, typeClass)} {...rest}>
126
127
  {isFunction(children) ? children({ typeClass }) : children}
127
128
  </figure>
128
129
  );
@@ -17,6 +17,25 @@
17
17
  **/
18
18
 
19
19
  /* 1. */
20
+
21
+ @keyframes rightFloatTransition {
22
+ 0% {
23
+ left: 75%;
24
+ }
25
+ 100% {
26
+ left: -16.6%;
27
+ }
28
+ }
29
+
30
+ @keyframes smallRightFloatTransition {
31
+ 0% {
32
+ left: 78.5%;
33
+ }
34
+ 100% {
35
+ left: -16.6%;
36
+ }
37
+ }
38
+
20
39
  .c-figure {
21
40
  img {
22
41
  width: 100%;
@@ -51,6 +70,21 @@
51
70
  padding-bottom: $spacing--large;
52
71
  margin-bottom: 0;
53
72
  }
73
+ &--right {
74
+ &.expanded {
75
+ @include mq($from: desktop) {
76
+ animation-name: rightFloatTransition;
77
+ animation-duration: 0.4s;
78
+ }
79
+
80
+ &[data-sizetype='xsmall-right'] {
81
+ @include mq($from: desktop) {
82
+ animation-name: smallRightFloatTransition;
83
+ animation-duration: 0.4s;
84
+ }
85
+ }
86
+ }
87
+ }
54
88
  &.expanded {
55
89
  .c-figure__caption--hidden-caption {
56
90
  display: block;
@@ -74,7 +108,7 @@
74
108
  background-color: $white;
75
109
  padding: $spacing--small 0;
76
110
  display: block;
77
- border-bottom: 1px solid #D1D6DB;
111
+ border-bottom: 1px solid #d1d6db;
78
112
  }
79
113
 
80
114
  .c-figure__caption--hidden-caption {
@@ -119,7 +153,7 @@
119
153
  margin-bottom: $spacing--small;
120
154
  }
121
155
  p {
122
- margin:0;
156
+ margin: 0;
123
157
  }
124
158
  }
125
159
 
@@ -179,7 +213,7 @@
179
213
  padding: $spacing--small;
180
214
  transition: all 0.3s ease-out;
181
215
  background: rgba($white, 0.2);
182
- border:0;
216
+ border: 0;
183
217
 
184
218
  .expanded-icon {
185
219
  display: none;
@@ -73,7 +73,7 @@ const StyledLetterSpacing = styled.span`
73
73
  type subjectProps = {
74
74
  name: string;
75
75
  url?: string;
76
- path: string;
76
+ path?: string;
77
77
  id?: string;
78
78
  };
79
79
  type categoryProps = {
@@ -160,7 +160,7 @@ const renderList = (
160
160
  onNavigate();
161
161
  }
162
162
  }}
163
- to={subject.url || subject.path}>
163
+ to={subject.url || subject.path || ''}>
164
164
  {subject.name}
165
165
  </SafeLink>
166
166
  <StyledSpacingElement />
@@ -120,6 +120,7 @@ const FrontpageProgramMenu = ({ programItems, subjectCategories, showBetaCursor
120
120
  <Button onClick={() => toggleSubjects(true)} lighter={!showSubjects} size="medium" borderShape="rounded">
121
121
  <StyledMenuItem>{t('frontpageMenu.allsubjects')}</StyledMenuItem>
122
122
  </Button>
123
+
123
124
  {showBetaCursor && (
124
125
  <CursorPlaceholder>
125
126
  <CursorWrapper>
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useRef } from 'react';
2
2
  import { isIE, browserVersion, isMobileSafari } from 'react-device-detect';
3
3
  import styled from '@emotion/styled';
4
- import { History } from 'history';
5
4
  import { colors, spacing, mq, breakpoints, animations } from '@ndla/core';
6
5
  // @ts-ignore
7
6
  import { noScroll } from '@ndla/util';
@@ -54,11 +53,10 @@ type Props = {
54
53
  };
55
54
  onSearch: (event: React.FormEvent) => void;
56
55
  allResultUrl: string;
57
- searchResult: Array<ContentTypeResultType>;
56
+ searchResult?: Array<ContentTypeResultType>;
58
57
  loading: boolean;
59
- history: History;
60
- suggestion: string;
61
- suggestionUrl: string;
58
+ suggestion?: string;
59
+ suggestionUrl?: string;
62
60
  };
63
61
 
64
62
  const FrontpageSearch: React.FunctionComponent<Props> = ({
@@ -73,7 +71,6 @@ const FrontpageSearch: React.FunctionComponent<Props> = ({
73
71
  allResultUrl,
74
72
  searchResult,
75
73
  loading,
76
- history,
77
74
  suggestion,
78
75
  suggestionUrl,
79
76
  }) => {
@@ -190,7 +187,6 @@ const FrontpageSearch: React.FunctionComponent<Props> = ({
190
187
  allResultUrl={allResultUrl}
191
188
  resourceToLinkProps={resourceToLinkProps}
192
189
  infoText={t('welcomePage.searchDisclaimer')}
193
- history={history}
194
190
  suggestion={suggestion}
195
191
  suggestionUrl={suggestionUrl}
196
192
  />
@@ -0,0 +1,158 @@
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 {
11
+ LicenseDescription,
12
+ getLicenseByAbbreviation,
13
+ getResourceTypeNamespace,
14
+ isCreativeCommonsLicense,
15
+ metaTypes,
16
+ } from '@ndla/licenses';
17
+ import BEMHelper from 'react-bem-helper';
18
+ import { uuid } from '@ndla/util';
19
+
20
+ const oClasses = new BEMHelper({
21
+ name: 'media',
22
+ prefix: 'o-',
23
+ });
24
+
25
+ const cClasses = new BEMHelper({
26
+ name: 'medialist',
27
+ prefix: 'c-',
28
+ });
29
+
30
+ interface MediaListProps {
31
+ children: ReactNode;
32
+ }
33
+
34
+ export const MediaList = ({ children }: MediaListProps) => <ul {...cClasses()}>{children}</ul>;
35
+
36
+ interface MediaListItemProps {
37
+ children: ReactNode;
38
+ }
39
+ export const MediaListItem = ({ children }: MediaListItemProps) => (
40
+ <li {...oClasses(undefined, undefined, cClasses('item').className)}>{children}</li>
41
+ );
42
+
43
+ interface MediaListItemImageProps {
44
+ children: ReactNode;
45
+ }
46
+ export const MediaListItemImage = ({ children }: MediaListItemImageProps) => (
47
+ <div {...oClasses('img', undefined, cClasses('img').className)}>
48
+ <div>{children}</div>
49
+ </div>
50
+ );
51
+
52
+ interface MediaListCCLinkProps {
53
+ children: ReactNode;
54
+ url: string;
55
+ }
56
+ export const MediaListCCLink = ({ children, url }: MediaListCCLinkProps) => (
57
+ <a className="c-figure-license__link" target="_blank" rel="noopener noreferrer license" href={url}>
58
+ {children}
59
+ </a>
60
+ );
61
+
62
+ interface MediaListItemBodyProps {
63
+ children: ReactNode;
64
+ license: string;
65
+ locale: string;
66
+ resourceUrl?: string;
67
+ resourceType?: 'video' | 'image' | 'audio' | 'text' | 'h5p';
68
+ messages?: {
69
+ modelPremission?: string;
70
+ };
71
+ title?: string;
72
+ }
73
+
74
+ export const MediaListItemBody = ({
75
+ children,
76
+ license: licenseAbbreviation,
77
+ messages,
78
+ title,
79
+ locale,
80
+ resourceUrl = '', // defaults to current page
81
+ resourceType,
82
+ }: MediaListItemBodyProps) => {
83
+ const license = getLicenseByAbbreviation(licenseAbbreviation, locale);
84
+ const containerProps = isCreativeCommonsLicense(license.rights)
85
+ ? {
86
+ ...oClasses('body', undefined, cClasses('body').className),
87
+ 'xmlns:cc': 'https://creativecommons.org/ns#',
88
+ 'xmlns:dct': 'http://purl.org/dc/terms/',
89
+ about: resourceUrl,
90
+ }
91
+ : {
92
+ ...oClasses('body', undefined, cClasses('body').className),
93
+ };
94
+
95
+ const metaResourceType = getResourceTypeNamespace(resourceType);
96
+
97
+ return (
98
+ <div {...containerProps}>
99
+ {/* @ts-ignore */}
100
+ {metaResourceType && <span rel="dct:type" href={metaResourceType} style={{ display: 'none' }} />}
101
+ {title ? <h3 className="c-medialist__title">{title} </h3> : null}
102
+ <LicenseDescription locale={locale} messages={messages} licenseRights={license.rights} highlightCC />
103
+ <MediaListCCLink url={license.url}>{license.linkText}</MediaListCCLink>
104
+ {children}
105
+ </div>
106
+ );
107
+ };
108
+
109
+ interface MediaListItemActionsProps {
110
+ children: ReactNode;
111
+ }
112
+ export const MediaListItemActions = ({ children }: MediaListItemActionsProps) => (
113
+ <div {...cClasses('actions')}>{children}</div>
114
+ );
115
+
116
+ const isLink = (text: string) => text.startsWith('http') || text.startsWith('https');
117
+
118
+ interface HandleLinkProps {
119
+ text: string;
120
+ children: ReactNode;
121
+ }
122
+
123
+ export const HandleLink = ({ text, children }: HandleLinkProps) => {
124
+ if (isLink(text)) {
125
+ return (
126
+ <a href={text} target="_blank" rel="noopener noreferrer">
127
+ {children}
128
+ </a>
129
+ );
130
+ }
131
+ return <span>{children}</span>;
132
+ };
133
+
134
+ const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
135
+
136
+ interface MediaListItemMetaProps {
137
+ items?: {
138
+ label: string;
139
+ description: string;
140
+ metaType: string;
141
+ }[];
142
+ }
143
+
144
+ export const MediaListItemMeta = ({ items = [] }: MediaListItemMetaProps) => {
145
+ const attributionItems = items.filter((item) => attributionTypes.some((type) => type === item.metaType));
146
+ const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(', ');
147
+
148
+ return (
149
+ //@ts-ignore
150
+ <ul {...cClasses('actions')} property="cc:attributionName" content={attributionMeta}>
151
+ {items.map((item) => (
152
+ <li key={uuid()} className="c-medialist__meta-item">
153
+ {item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
154
+ </li>
155
+ ))}
156
+ </ul>
157
+ );
158
+ };
File without changes