@ndla/ui 3.3.7 → 3.3.12

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 (115) hide show
  1. package/es/Article/Article.js +23 -1
  2. package/es/Article/ArticleNotions.js +80 -32
  3. package/es/Breadcrumb/Breadcrumb.js +2 -1
  4. package/es/Breadcrumblist/Breadcrumblist.js +14 -10
  5. package/es/CloseButton/CloseButton.js +62 -0
  6. package/es/CloseButton/index.js +9 -0
  7. package/es/Frontpage/FrontpageAllSubjects.js +7 -7
  8. package/es/Frontpage/FrontpageProgramMenu.js +10 -10
  9. package/es/MediaList/MediaList.js +22 -73
  10. package/es/MessageBox/MessageBox.js +146 -78
  11. package/es/MessageBox/MessageBoxTag.js +37 -0
  12. package/es/MessageBox/index.js +3 -1
  13. package/es/NDLAFilm/FilmSlideshow.js +214 -247
  14. package/es/NDLAFilm/NavigationArrow.js +13 -60
  15. package/es/NDLAFilm/SlideshowIndicator.js +16 -63
  16. package/es/NDLAFilm/interfaces.js +0 -0
  17. package/es/Programme/Programme.js +15 -8
  18. package/es/SearchTypeResult/SearchFieldHeader.js +5 -5
  19. package/es/SearchTypeResult/SearchHeader.js +9 -9
  20. package/es/SearchTypeResult/SearchItem.js +19 -19
  21. package/es/SearchTypeResult/SearchNotionItem.js +12 -12
  22. package/es/SearchTypeResult/SearchNotionsResult.js +9 -14
  23. package/es/Spinner/Spinner.js +3 -3
  24. package/es/index.js +2 -1
  25. package/es/locale/messages-en.js +10 -0
  26. package/es/locale/messages-nb.js +10 -0
  27. package/es/locale/messages-nn.js +10 -0
  28. package/lib/Article/Article.d.ts +3 -1
  29. package/lib/Article/Article.js +25 -3
  30. package/lib/Article/ArticleNotions.js +79 -30
  31. package/lib/Breadcrumb/Breadcrumb.js +2 -1
  32. package/lib/Breadcrumblist/Breadcrumblist.d.ts +2 -1
  33. package/lib/Breadcrumblist/Breadcrumblist.js +15 -10
  34. package/lib/CloseButton/CloseButton.d.ts +6 -0
  35. package/lib/CloseButton/CloseButton.js +69 -0
  36. package/lib/CloseButton/index.d.ts +9 -0
  37. package/lib/CloseButton/index.js +15 -0
  38. package/lib/Frontpage/FrontpageAllSubjects.d.ts +1 -1
  39. package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
  40. package/lib/Frontpage/FrontpageProgramMenu.js +10 -10
  41. package/lib/MediaList/MediaList.d.ts +48 -0
  42. package/lib/MediaList/MediaList.js +24 -78
  43. package/lib/MediaList/index.d.ts +8 -0
  44. package/lib/MessageBox/MessageBox.d.ts +22 -6
  45. package/lib/MessageBox/MessageBox.js +146 -77
  46. package/lib/MessageBox/MessageBoxTag.d.ts +12 -0
  47. package/lib/MessageBox/MessageBoxTag.js +44 -0
  48. package/lib/MessageBox/index.d.ts +3 -1
  49. package/lib/MessageBox/index.js +22 -2
  50. package/lib/NDLAFilm/FilmSlideshow.d.ts +16 -0
  51. package/lib/NDLAFilm/FilmSlideshow.js +214 -248
  52. package/lib/NDLAFilm/NavigationArrow.d.ts +15 -0
  53. package/lib/NDLAFilm/NavigationArrow.js +20 -65
  54. package/lib/NDLAFilm/SlideshowIndicator.d.ts +15 -0
  55. package/lib/NDLAFilm/SlideshowIndicator.js +16 -69
  56. package/lib/NDLAFilm/interfaces.d.ts +10 -0
  57. package/lib/NDLAFilm/interfaces.js +1 -0
  58. package/lib/NDLAFilm/shapes.d.ts +15 -0
  59. package/lib/Programme/Programme.d.ts +2 -1
  60. package/lib/Programme/Programme.js +18 -9
  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/SearchNotionsResult.js +8 -13
  70. package/lib/SearchTypeResult/index.d.ts +1 -0
  71. package/lib/Spinner/Spinner.d.ts +3 -3
  72. package/lib/Spinner/Spinner.js +2 -2
  73. package/lib/index.d.ts +2 -1
  74. package/lib/index.js +23 -0
  75. package/lib/locale/messages-en.d.ts +10 -0
  76. package/lib/locale/messages-en.js +10 -0
  77. package/lib/locale/messages-nb.d.ts +10 -0
  78. package/lib/locale/messages-nb.js +10 -0
  79. package/lib/locale/messages-nn.d.ts +10 -0
  80. package/lib/locale/messages-nn.js +10 -0
  81. package/package.json +10 -10
  82. package/src/Article/Article.tsx +17 -0
  83. package/src/Article/ArticleNotions.tsx +10 -7
  84. package/src/Breadcrumb/Breadcrumb.tsx +1 -1
  85. package/src/Breadcrumblist/Breadcrumblist.tsx +5 -3
  86. package/src/CloseButton/CloseButton.tsx +40 -0
  87. package/src/CloseButton/index.ts +11 -0
  88. package/src/Frontpage/FrontpageAllSubjects.tsx +2 -2
  89. package/src/Frontpage/FrontpageProgramMenu.tsx +1 -0
  90. package/src/MediaList/MediaList.tsx +158 -0
  91. package/src/MediaList/{index.js → index.ts} +0 -0
  92. package/src/MessageBox/MessageBox.tsx +117 -96
  93. package/src/MessageBox/MessageBoxTag.tsx +35 -0
  94. package/src/MessageBox/index.ts +3 -1
  95. package/src/NDLAFilm/FilmSlideshow.tsx +265 -0
  96. package/src/NDLAFilm/NavigationArrow.tsx +42 -0
  97. package/src/NDLAFilm/SlideshowIndicator.tsx +40 -0
  98. package/src/NDLAFilm/interfaces.ts +10 -0
  99. package/src/NDLAFilm/{shapes.js → shapes.ts} +0 -0
  100. package/src/Programme/Programme.tsx +7 -3
  101. package/src/SearchTypeResult/SearchFieldHeader.tsx +3 -3
  102. package/src/SearchTypeResult/SearchHeader.tsx +3 -3
  103. package/src/SearchTypeResult/SearchItem.tsx +4 -5
  104. package/src/SearchTypeResult/SearchNotionItem.tsx +1 -2
  105. package/src/SearchTypeResult/SearchNotionsResult.tsx +3 -8
  106. package/src/SearchTypeResult/index.ts +2 -0
  107. package/src/Spinner/Spinner.tsx +9 -5
  108. package/src/index.ts +2 -1
  109. package/src/locale/messages-en.ts +14 -0
  110. package/src/locale/messages-nb.ts +14 -0
  111. package/src/locale/messages-nn.ts +14 -0
  112. package/src/MediaList/MediaList.jsx +0 -182
  113. package/src/NDLAFilm/FilmSlideshow.jsx +0 -277
  114. package/src/NDLAFilm/NavigationArrow.jsx +0 -46
  115. package/src/NDLAFilm/SlideshowIndicator.jsx +0 -43
@@ -1,182 +0,0 @@
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 PropTypes from 'prop-types';
11
- import {
12
- LicenseDescription,
13
- getLicenseByAbbreviation,
14
- resourceTypes,
15
- getResourceTypeNamespace,
16
- isCreativeCommonsLicense,
17
- metaTypes,
18
- } from '@ndla/licenses';
19
- import BEMHelper from 'react-bem-helper';
20
- import { uuid } from '@ndla/util';
21
-
22
- const oClasses = new BEMHelper({
23
- name: 'media',
24
- prefix: 'o-',
25
- });
26
-
27
- const cClasses = new BEMHelper({
28
- name: 'medialist',
29
- prefix: 'c-',
30
- });
31
-
32
- export const MediaList = ({ children }) => <ul {...cClasses()}>{children}</ul>;
33
-
34
- MediaList.propTypes = {
35
- children: PropTypes.node.isRequired,
36
- };
37
-
38
- export const MediaListItem = ({ children }) => (
39
- <li {...oClasses(null, null, cClasses('item').className)}>{children}</li>
40
- );
41
-
42
- MediaListItem.propTypes = {
43
- children: PropTypes.node.isRequired,
44
- };
45
-
46
- export const MediaListItemImage = ({ children }) => (
47
- <div {...oClasses('img', null, cClasses('img').className)}>
48
- <div>{children}</div>
49
- </div>
50
- );
51
-
52
- MediaListItemImage.propTypes = {
53
- children: PropTypes.node.isRequired,
54
- };
55
-
56
- export const MediaListCCLink = ({ children, url }) => (
57
- <a className="c-figure-license__link" target="_blank" rel="noopener noreferrer license" href={url}>
58
- {children}
59
- </a>
60
- );
61
-
62
- MediaListCCLink.propTypes = {
63
- children: PropTypes.node.isRequired,
64
- url: PropTypes.string.isRequired,
65
- };
66
-
67
- MediaListCCLink.defaultProps = {
68
- language: 'no',
69
- };
70
-
71
- export const MediaListItemBody = ({
72
- children,
73
- license: licenseAbbreviation,
74
- messages,
75
- title,
76
- locale,
77
- resourceUrl,
78
- resourceType,
79
- }) => {
80
- const license = getLicenseByAbbreviation(licenseAbbreviation, locale);
81
- const containerProps = isCreativeCommonsLicense(license.rights)
82
- ? {
83
- ...oClasses('body', null, cClasses('body').className),
84
- 'xmlns:cc': 'https://creativecommons.org/ns#',
85
- 'xmlns:dct': 'http://purl.org/dc/terms/',
86
- about: resourceUrl,
87
- }
88
- : {
89
- ...oClasses('body', null, cClasses('body').className),
90
- };
91
-
92
- const metaResourceType = getResourceTypeNamespace(resourceType);
93
-
94
- return (
95
- <div {...containerProps}>
96
- {metaResourceType && <span rel="dct:type" href={metaResourceType} style={{ display: 'none' }} />}
97
- {title ? <h3 className="c-medialist__title">{title} </h3> : null}
98
- <LicenseDescription
99
- withDescription
100
- locale={locale}
101
- messages={messages}
102
- licenseRights={license.rights}
103
- highlightCC
104
- />
105
- <MediaListCCLink url={license.url}>{license.linkText}</MediaListCCLink>
106
- {children}
107
- </div>
108
- );
109
- };
110
-
111
- MediaListItemBody.propTypes = {
112
- children: PropTypes.node.isRequired,
113
- license: PropTypes.string.isRequired,
114
- locale: PropTypes.string.isRequired,
115
- resourceUrl: PropTypes.string,
116
- resourceType: PropTypes.oneOf(Object.keys(resourceTypes).map((key) => resourceTypes[key])),
117
- messages: PropTypes.shape({
118
- modelPremission: PropTypes.string,
119
- }),
120
- title: PropTypes.string,
121
- };
122
-
123
- MediaListItemBody.defaultProps = {
124
- resourceUrl: '', // defaults to current page
125
- };
126
-
127
- export const MediaListItemActions = ({ children }) => <div {...cClasses('actions')}>{children}</div>;
128
-
129
- MediaListItemActions.propTypes = {
130
- children: PropTypes.node.isRequired,
131
- };
132
-
133
- const isLink = (text) => text.startsWith('http') || text.startsWith('https');
134
-
135
- export const HandleLink = ({ text, children }) => {
136
- if (isLink(text)) {
137
- return (
138
- <a href={text} target="_blank" rel="noopener noreferrer">
139
- {children}
140
- </a>
141
- );
142
- }
143
- return <span>{children}</span>;
144
- };
145
-
146
- HandleLink.propTypes = {
147
- text: PropTypes.string.isRequired,
148
- children: PropTypes.node.isRequired,
149
- };
150
-
151
- const attributionTypes = [metaTypes.author, metaTypes.copyrightHolder, metaTypes.contributor];
152
-
153
- export const MediaListItemMeta = ({ items }) => {
154
- const attributionItems = items.filter((item) => attributionTypes.some((type) => type === item.metaType));
155
- const attributionMeta = attributionItems.map((item) => `${item.label}: ${item.description}`).join(', ');
156
-
157
- return (
158
- <ul {...cClasses('actions')} property="cc:attributionName" content={attributionMeta}>
159
- {items.map((item) => (
160
- <li key={uuid()} className="c-medialist__meta-item">
161
- {item.label}: <HandleLink text={item.description}>{item.description}</HandleLink>
162
- </li>
163
- ))}
164
- </ul>
165
- );
166
- };
167
-
168
- const mediaListItemShape = PropTypes.arrayOf(
169
- PropTypes.shape({
170
- label: PropTypes.string.isRequired,
171
- description: PropTypes.string.isRequired,
172
- metaType: PropTypes.oneOf(Object.keys(metaTypes).map((key) => metaTypes[key])).isRequired,
173
- }),
174
- );
175
-
176
- MediaListItemMeta.propTypes = {
177
- items: mediaListItemShape,
178
- };
179
-
180
- MediaListItemMeta.defaultProps = {
181
- items: [],
182
- };
@@ -1,277 +0,0 @@
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, { Component } from 'react';
10
- import PropTypes from 'prop-types';
11
- import { Swipeable } from 'react-swipeable';
12
- import BEMHelper from 'react-bem-helper';
13
- import { OneColumn } from '@ndla/ui';
14
- import SafeLink from '@ndla/safelink';
15
- import Spinner from '../Spinner';
16
- import { movieShape } from './shapes';
17
- import NavigationArrow from './NavigationArrow';
18
- import SlideshowIndicator from './SlideshowIndicator';
19
-
20
- const classes = new BEMHelper({
21
- name: 'film-slideshow',
22
- prefix: 'c-',
23
- });
24
-
25
- const defaultTransitionSwipeEnd = 'transform 600ms cubic-bezier(0, 0.76, 0.09, 1)';
26
- const defaultTransitionText = 'opacity 600ms ease';
27
-
28
- const renderSlideItem = (slide) => (
29
- <div
30
- {...classes('item')}
31
- key={slide.id}
32
- role="img"
33
- aria-label={(slide.metaImage && slide.metaImage.alt) || ''}
34
- style={{
35
- backgroundImage: `url(${(slide.metaImage && slide.metaImage.url) || ''})`,
36
- }}
37
- />
38
- );
39
-
40
- class FilmSlideshow extends Component {
41
- constructor(props) {
42
- super(props);
43
- const startIndex = this.props.randomStart ? Math.floor(Math.random() * this.props.slideshow.length) : 0;
44
- this.state = {
45
- slideIndex: startIndex,
46
- slideIndexTarget: startIndex,
47
- animationComplete: true,
48
- };
49
- this.swipeDistance = 0;
50
- this.slideRef = React.createRef();
51
- this.slideText = React.createRef();
52
- this.onSwipeEnd = this.onSwipeEnd.bind(this);
53
- this.onSwipe = this.onSwipe.bind(this);
54
- this.gotoSlide = this.gotoSlide.bind(this);
55
- this.onChangedSlide = this.onChangedSlide.bind(this);
56
- this.onTransitionEnd = this.onTransitionEnd.bind(this);
57
-
58
- this.timer = null;
59
- this.onChangedSlideBlock = false;
60
- }
61
-
62
- componentDidMount() {
63
- this.initTimer();
64
- }
65
-
66
- onChangedSlide() {
67
- if (!this.state.animationComplete) {
68
- this.slideRef.current.style.transition = 'none';
69
- this.slideRef.current.style.transform = `translateX(${this.state.slideIndexTarget * 100}vw))`;
70
- this.setState((prevState) => ({
71
- animationComplete: true,
72
- slideIndex: prevState.slideIndexTarget,
73
- }));
74
- } else if (this.state.slideIndexTarget === -1) {
75
- // Go to last slide for continuous loop
76
- this.slideRef.current.style.transition = 'none';
77
- this.slideRef.current.style.transform = `translateX(${this.props.slideshow.length * 100}vw))`;
78
- this.setState({
79
- slideIndex: this.props.slideshow.length - 1,
80
- slideIndexTarget: this.props.slideshow.length - 1,
81
- animationComplete: true,
82
- });
83
- } else if (this.state.slideIndexTarget === this.props.slideshow.length) {
84
- // Go to first slide for continuous loop
85
- this.slideRef.current.style.transition = 'none';
86
- this.slideRef.current.style.transform = `translateX(100vw))`;
87
- this.setState({
88
- slideIndex: 0,
89
- slideIndexTarget: 0,
90
- animationComplete: true,
91
- });
92
- } else {
93
- this.setState((prevState) => ({
94
- animationComplete: true,
95
- slideIndex: prevState.slideIndexTarget,
96
- }));
97
- }
98
- }
99
-
100
- onSwipeEnd() {
101
- let slide;
102
- if (this.swipeDistance > 40) {
103
- slide = -1;
104
- } else if (this.swipeDistance < -40) {
105
- slide = 1;
106
- } else {
107
- slide = 0;
108
- }
109
- this.slideRef.current.style.transition = defaultTransitionSwipeEnd;
110
- this.slideText.current.style.transition = defaultTransitionText;
111
- this.slideText.current.style.opacity = 1;
112
- this.swipeDistance = 0;
113
- this.initTimer();
114
- if (slide !== 0) {
115
- this.setState((prevState) => {
116
- return {
117
- slideIndex: prevState.slideIndex + slide,
118
- slideIndexTarget: prevState.slideIndex + slide,
119
- };
120
- });
121
- } else {
122
- // Reset transfrom
123
- this.slideRef.current.style.transform = this.getSlidePosition(this.state.slideIndex + slide);
124
- }
125
- }
126
-
127
- onSwipe(eventData) {
128
- if (eventData.dir === 'Up' || eventData.dir === 'Down') {
129
- return;
130
- }
131
- clearTimeout(this.timer);
132
- this.swipeDistance = -eventData.deltaX;
133
- this.slideRef.current.style.transition = 'none';
134
- this.slideRef.current.style.transform = this.getSlidePosition(this.state.slideIndexTarget);
135
- const opacityText = 1 - Math.min(100, Math.abs(this.swipeDistance)) / 100;
136
- this.slideText.current.style.transition = 'none';
137
- this.slideText.current.style.opacity = opacityText;
138
- }
139
-
140
- onTransitionEnd() {
141
- const slideshowLength = this.props.slideshow.length;
142
- if (this.state.slideIndex === -1) {
143
- this.slideRef.current.style.transition = 'none';
144
- this.slideRef.current.style.transform = this.getSlidePosition(slideshowLength - 1);
145
- this.setState({
146
- slideIndex: slideshowLength - 1,
147
- slideIndexTarget: slideshowLength - 1,
148
- });
149
- } else if (this.state.slideIndex >= slideshowLength) {
150
- this.slideRef.current.style.transition = 'none';
151
- this.slideRef.current.style.transform = this.getSlidePosition(0);
152
- this.setState({
153
- slideIndex: 0,
154
- slideIndexTarget: 0,
155
- });
156
- }
157
- }
158
-
159
- getSlidePosition(target) {
160
- if (this.swipeDistance !== 0) {
161
- return `translateX(calc(${this.swipeDistance}px -
162
- ${(target + 1) * 100}vw))`;
163
- }
164
- return `translateX(-${(target + 1) * 100}vw)`;
165
- }
166
-
167
- gotoSlide(slideIndexTarget, useAnimation) {
168
- this.swipeDistance = 0;
169
- clearTimeout(this.timer);
170
- this.initTimer();
171
- this.setState({
172
- slideIndexTarget,
173
- animationComplete: !useAnimation,
174
- });
175
- }
176
-
177
- initTimer() {
178
- if (this.props.autoSlide) {
179
- this.timer = setTimeout(() => {
180
- this.gotoSlide(this.state.slideIndex + 1);
181
- }, this.props.slideInterval);
182
- }
183
- }
184
-
185
- render() {
186
- const { slideshow } = this.props;
187
- const { slideIndex, slideIndexTarget, animationComplete } = this.state;
188
-
189
- if (slideshow.length === 0) {
190
- return (
191
- <div>
192
- <div {...classes('slideshow')}>
193
- <Spinner inverted />
194
- </div>
195
- </div>
196
- );
197
- }
198
- const slideshowWidth = `${(slideshow.length + 2) * 100}vw`;
199
- let activeSlide = slideIndex;
200
- if (activeSlide < 0) {
201
- activeSlide = slideshow.length - 1;
202
- } else if (activeSlide >= slideshow.length) {
203
- activeSlide = 0;
204
- }
205
-
206
- return (
207
- <section>
208
- <Swipeable {...classes('')} onSwiped={this.onSwipeEnd} onSwiping={this.onSwipe}>
209
- <div {...classes('slide-link-wrapper')}>
210
- <OneColumn>
211
- <SafeLink
212
- to={slideshow[activeSlide].path}
213
- {...classes('item-wrapper', 'text', {
214
- out: !animationComplete,
215
- })}>
216
- <div {...classes('slide-info')} ref={this.slideText}>
217
- <h1>{slideshow[activeSlide].title}</h1>
218
- <p>{slideshow[activeSlide].metaDescription}</p>
219
- </div>
220
- </SafeLink>
221
- </OneColumn>
222
- </div>
223
- <NavigationArrow
224
- slideIndexTarget={slideIndexTarget > 0 ? slideIndexTarget - 1 : slideshow.length - 1}
225
- gotoSlide={this.gotoSlide}
226
- />
227
- <NavigationArrow
228
- slideIndexTarget={slideIndexTarget < slideshow.length - 1 ? slideIndexTarget + 1 : 0}
229
- gotoSlide={this.gotoSlide}
230
- rightArrow
231
- />
232
- {!animationComplete && (
233
- <div
234
- {...classes('item', 'fade-over')}
235
- role="img"
236
- onAnimationEnd={this.onChangedSlide}
237
- style={{
238
- backgroundImage: `url(${
239
- (slideshow[activeSlide].metaImage && slideshow[activeSlide].metaImage.url) || ''
240
- })`,
241
- }}
242
- />
243
- )}
244
- <div
245
- ref={this.slideRef}
246
- {...classes('item-wrapper')}
247
- onTransitionEnd={this.onTransitionEnd}
248
- style={{
249
- width: slideshowWidth,
250
- transform: this.getSlidePosition(slideIndex),
251
- }}>
252
- {renderSlideItem(slideshow[slideshow.length - 1], -1)}
253
- {slideshow.map(renderSlideItem)}
254
- {renderSlideItem(slideshow[0], slideshow.length)}
255
- </div>
256
- </Swipeable>
257
- <SlideshowIndicator slideshow={slideshow} activeSlide={activeSlide} gotoSlide={this.gotoSlide} />
258
- </section>
259
- );
260
- }
261
- }
262
-
263
- FilmSlideshow.propTypes = {
264
- autoSlide: PropTypes.bool,
265
- randomStart: PropTypes.bool,
266
- slideshow: PropTypes.arrayOf(movieShape),
267
- slideInterval: PropTypes.number,
268
- };
269
-
270
- FilmSlideshow.defaultProps = {
271
- autoSlide: false,
272
- randomStart: false,
273
- slideshow: [],
274
- slideInterval: 5000,
275
- };
276
-
277
- export default FilmSlideshow;
@@ -1,46 +0,0 @@
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, { Component } from 'react';
10
- import PropTypes from 'prop-types';
11
- import BEMHelper from 'react-bem-helper';
12
- import { ChevronRight, ChevronLeft } from '@ndla/icons/common';
13
-
14
- const classes = new BEMHelper({
15
- name: 'film-slideshow',
16
- prefix: 'c-',
17
- });
18
-
19
- class NavigationArrow extends Component {
20
- render() {
21
- const { slideIndexTarget, gotoSlide, rightArrow } = this.props;
22
- const Chevron = rightArrow ? ChevronRight : ChevronLeft;
23
-
24
- return (
25
- <div {...classes('navigation-arrows', rightArrow ? 'right' : '')}>
26
- <button
27
- type="button"
28
- tabIndex={-1}
29
- onClick={() => {
30
- gotoSlide(slideIndexTarget, true);
31
- }}>
32
- <Chevron />
33
- </button>
34
- </div>
35
- );
36
- }
37
- }
38
-
39
- NavigationArrow.propTypes = {
40
- slideIndexTarget: PropTypes.number,
41
- slideshowLength: PropTypes.number,
42
- gotoSlide: PropTypes.func,
43
- rightArrow: PropTypes.bool,
44
- };
45
-
46
- export default NavigationArrow;
@@ -1,43 +0,0 @@
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, { Component } from 'react';
10
- import PropTypes from 'prop-types';
11
- import BEMHelper from 'react-bem-helper';
12
- import { movieShape } from './shapes';
13
-
14
- const classes = new BEMHelper({
15
- name: 'film-slideshow',
16
- prefix: 'c-',
17
- });
18
-
19
- class SlideshowIndicator extends Component {
20
- render() {
21
- const { slideshow, activeSlide, gotoSlide } = this.props;
22
- return (
23
- <div {...classes('indicator-wrapper')}>
24
- {slideshow.map((slide, index) => (
25
- <button
26
- key={`indicator_${index}`} // eslint-disable-line react/no-array-index-key
27
- type="button"
28
- {...classes('indicator-dot', index === activeSlide ? 'active' : '')}
29
- onClick={() => gotoSlide(index, true)}>
30
- <span />
31
- </button>
32
- ))}
33
- </div>
34
- );
35
- }
36
- }
37
-
38
- SlideshowIndicator.propTypes = {
39
- slideshow: PropTypes.arrayOf(movieShape),
40
- activeSlide: PropTypes.number,
41
- };
42
-
43
- export default SlideshowIndicator;