@ndla/ui 3.3.7 → 3.3.8

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.
@@ -35,7 +35,8 @@ var Breadcrumb = function Breadcrumb(_ref) {
35
35
  to: item.to,
36
36
  name: item.name
37
37
  }, i === 0 ? ___EmotionJSX(Home, {
38
- className: "c-icon--20"
38
+ className: "c-icon--20",
39
+ title: item.name
39
40
  }) : item.name);
40
41
  })));
41
42
  };
@@ -1,24 +1,14 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
2
 
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
 
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
6
 
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
8
 
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
10
 
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
12
 
23
13
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
14
 
@@ -29,14 +19,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
29
19
  * LICENSE file in the root directory of this source tree.
30
20
  *
31
21
  */
32
- import React, { Component } from 'react';
33
- import PropTypes from 'prop-types';
34
- import { Swipeable } from 'react-swipeable';
22
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
23
+ import { useSwipeable } from 'react-swipeable';
35
24
  import BEMHelper from 'react-bem-helper';
36
- import { OneColumn } from '@ndla/ui';
37
25
  import SafeLink from '@ndla/safelink';
26
+ import { OneColumn } from '../Layout';
38
27
  import Spinner from '../Spinner';
39
- import { movieShape } from './shapes';
40
28
  import NavigationArrow from './NavigationArrow';
41
29
  import SlideshowIndicator from './SlideshowIndicator';
42
30
  import { jsx as ___EmotionJSX } from "@emotion/core";
@@ -58,253 +46,231 @@ var renderSlideItem = function renderSlideItem(slide) {
58
46
  }));
59
47
  };
60
48
 
61
- var FilmSlideshow = /*#__PURE__*/function (_Component) {
62
- _inherits(FilmSlideshow, _Component);
63
-
64
- var _super = _createSuper(FilmSlideshow);
65
-
66
- function FilmSlideshow(props) {
67
- var _this;
68
-
69
- _classCallCheck(this, FilmSlideshow);
70
-
71
- _this = _super.call(this, props);
72
- var startIndex = _this.props.randomStart ? Math.floor(Math.random() * _this.props.slideshow.length) : 0;
73
- _this.state = {
74
- slideIndex: startIndex,
75
- slideIndexTarget: startIndex,
76
- animationComplete: true
77
- };
78
- _this.swipeDistance = 0;
79
- _this.slideRef = /*#__PURE__*/React.createRef();
80
- _this.slideText = /*#__PURE__*/React.createRef();
81
- _this.onSwipeEnd = _this.onSwipeEnd.bind(_assertThisInitialized(_this));
82
- _this.onSwipe = _this.onSwipe.bind(_assertThisInitialized(_this));
83
- _this.gotoSlide = _this.gotoSlide.bind(_assertThisInitialized(_this));
84
- _this.onChangedSlide = _this.onChangedSlide.bind(_assertThisInitialized(_this));
85
- _this.onTransitionEnd = _this.onTransitionEnd.bind(_assertThisInitialized(_this));
86
- _this.timer = null;
87
- _this.onChangedSlideBlock = false;
88
- return _this;
89
- }
90
-
91
- _createClass(FilmSlideshow, [{
92
- key: "componentDidMount",
93
- value: function componentDidMount() {
94
- this.initTimer();
49
+ var FilmSlideshow = function FilmSlideshow(_ref) {
50
+ var _ref$autoSlide = _ref.autoSlide,
51
+ autoSlide = _ref$autoSlide === void 0 ? false : _ref$autoSlide,
52
+ _ref$slideshow = _ref.slideshow,
53
+ slideshow = _ref$slideshow === void 0 ? [] : _ref$slideshow,
54
+ _ref$slideInterval = _ref.slideInterval,
55
+ slideInterval = _ref$slideInterval === void 0 ? 5000 : _ref$slideInterval;
56
+
57
+ var _useState = useState(0),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ swipeDistance = _useState2[0],
60
+ setSwipeDistance = _useState2[1];
61
+
62
+ var _useState3 = useState(0),
63
+ _useState4 = _slicedToArray(_useState3, 2),
64
+ slideIndex = _useState4[0],
65
+ setSlideIndex = _useState4[1];
66
+
67
+ var _useState5 = useState(0),
68
+ _useState6 = _slicedToArray(_useState5, 2),
69
+ slideIndexTarget = _useState6[0],
70
+ setSlideIndexTarget = _useState6[1];
71
+
72
+ var _useState7 = useState(true),
73
+ _useState8 = _slicedToArray(_useState7, 2),
74
+ animationComplete = _useState8[0],
75
+ setAnimationComplete = _useState8[1];
76
+
77
+ var slideRef = useRef(null);
78
+ var slideText = useRef(null);
79
+ var timer = useRef(null);
80
+ var gotoSlide = useCallback(function (indexTarget) {
81
+ var useAnimation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
82
+ setSwipeDistance(0);
83
+
84
+ if (timer.current) {
85
+ clearTimeout(timer.current);
95
86
  }
96
- }, {
97
- key: "onChangedSlide",
98
- value: function onChangedSlide() {
99
- if (!this.state.animationComplete) {
100
- this.slideRef.current.style.transition = 'none';
101
- this.slideRef.current.style.transform = "translateX(".concat(this.state.slideIndexTarget * 100, "vw))");
102
- this.setState(function (prevState) {
103
- return {
104
- animationComplete: true,
105
- slideIndex: prevState.slideIndexTarget
106
- };
107
- });
108
- } else if (this.state.slideIndexTarget === -1) {
87
+
88
+ setSlideIndexTarget(indexTarget);
89
+ setAnimationComplete(!useAnimation);
90
+ }, []);
91
+
92
+ var onChangedSlide = function onChangedSlide() {
93
+ if (!animationComplete) {
94
+ if (slideRef.current) {
95
+ slideRef.current.style.transition = 'none';
96
+ slideRef.current.style.transform = "translateX(".concat(slideIndexTarget * 100, "vw))");
97
+ }
98
+
99
+ setAnimationComplete(true);
100
+ setSlideIndex(slideIndexTarget);
101
+ } else if (slideIndexTarget === -1) {
102
+ if (slideRef.current) {
109
103
  // Go to last slide for continuous loop
110
- this.slideRef.current.style.transition = 'none';
111
- this.slideRef.current.style.transform = "translateX(".concat(this.props.slideshow.length * 100, "vw))");
112
- this.setState({
113
- slideIndex: this.props.slideshow.length - 1,
114
- slideIndexTarget: this.props.slideshow.length - 1,
115
- animationComplete: true
116
- });
117
- } else if (this.state.slideIndexTarget === this.props.slideshow.length) {
104
+ slideRef.current.style.transition = 'none';
105
+ slideRef.current.style.transform = "translateX(".concat(slideshow.length * 100, "vw))");
106
+ }
107
+
108
+ setSlideIndex(slideshow.length - 1);
109
+ setSlideIndexTarget(slideshow.length - 1);
110
+ setAnimationComplete(true);
111
+ } else if (slideIndexTarget === slideshow.length) {
112
+ if (slideRef.current) {
118
113
  // Go to first slide for continuous loop
119
- this.slideRef.current.style.transition = 'none';
120
- this.slideRef.current.style.transform = "translateX(100vw))";
121
- this.setState({
122
- slideIndex: 0,
123
- slideIndexTarget: 0,
124
- animationComplete: true
125
- });
126
- } else {
127
- this.setState(function (prevState) {
128
- return {
129
- animationComplete: true,
130
- slideIndex: prevState.slideIndexTarget
131
- };
132
- });
114
+ slideRef.current.style.transition = 'none';
115
+ slideRef.current.style.transform = "translateX(100vw))";
133
116
  }
117
+
118
+ setSlideIndex(0);
119
+ setSlideIndexTarget(0);
120
+ setAnimationComplete(true);
121
+ } else {
122
+ setAnimationComplete(true);
123
+ setSlideIndex(slideIndexTarget);
134
124
  }
135
- }, {
136
- key: "onSwipeEnd",
137
- value: function onSwipeEnd() {
138
- var slide;
139
-
140
- if (this.swipeDistance > 40) {
141
- slide = -1;
142
- } else if (this.swipeDistance < -40) {
143
- slide = 1;
144
- } else {
145
- slide = 0;
146
- }
125
+ };
147
126
 
148
- this.slideRef.current.style.transition = defaultTransitionSwipeEnd;
149
- this.slideText.current.style.transition = defaultTransitionText;
150
- this.slideText.current.style.opacity = 1;
151
- this.swipeDistance = 0;
152
- this.initTimer();
153
-
154
- if (slide !== 0) {
155
- this.setState(function (prevState) {
156
- return {
157
- slideIndex: prevState.slideIndex + slide,
158
- slideIndexTarget: prevState.slideIndex + slide
159
- };
160
- });
161
- } else {
162
- // Reset transfrom
163
- this.slideRef.current.style.transform = this.getSlidePosition(this.state.slideIndex + slide);
164
- }
127
+ var onSwipeEnd = function onSwipeEnd() {
128
+ var slide;
129
+
130
+ if (swipeDistance > 40) {
131
+ slide = -1;
132
+ } else if (swipeDistance < -40) {
133
+ slide = 1;
134
+ } else {
135
+ slide = 0;
165
136
  }
166
- }, {
167
- key: "onSwipe",
168
- value: function onSwipe(eventData) {
169
- if (eventData.dir === 'Up' || eventData.dir === 'Down') {
170
- return;
171
- }
172
137
 
173
- clearTimeout(this.timer);
174
- this.swipeDistance = -eventData.deltaX;
175
- this.slideRef.current.style.transition = 'none';
176
- this.slideRef.current.style.transform = this.getSlidePosition(this.state.slideIndexTarget);
177
- var opacityText = 1 - Math.min(100, Math.abs(this.swipeDistance)) / 100;
178
- this.slideText.current.style.transition = 'none';
179
- this.slideText.current.style.opacity = opacityText;
138
+ if (slideRef.current && slideText.current) {
139
+ slideRef.current.style.transition = defaultTransitionSwipeEnd;
140
+ slideText.current.style.transition = defaultTransitionText;
141
+ slideText.current.style.opacity = '1';
180
142
  }
181
- }, {
182
- key: "onTransitionEnd",
183
- value: function onTransitionEnd() {
184
- var slideshowLength = this.props.slideshow.length;
185
-
186
- if (this.state.slideIndex === -1) {
187
- this.slideRef.current.style.transition = 'none';
188
- this.slideRef.current.style.transform = this.getSlidePosition(slideshowLength - 1);
189
- this.setState({
190
- slideIndex: slideshowLength - 1,
191
- slideIndexTarget: slideshowLength - 1
192
- });
193
- } else if (this.state.slideIndex >= slideshowLength) {
194
- this.slideRef.current.style.transition = 'none';
195
- this.slideRef.current.style.transform = this.getSlidePosition(0);
196
- this.setState({
197
- slideIndex: 0,
198
- slideIndexTarget: 0
199
- });
143
+
144
+ setSwipeDistance(0);
145
+ initTimer();
146
+
147
+ if (slide !== 0) {
148
+ setSlideIndex(slideIndex + slide);
149
+ setSlideIndexTarget(slideIndex + slide);
150
+ } else {
151
+ // Reset transfrom
152
+ if (slideRef.current) {
153
+ slideRef.current.style.transform = getSlidePosition(slideIndex + slide);
200
154
  }
201
155
  }
202
- }, {
203
- key: "getSlidePosition",
204
- value: function getSlidePosition(target) {
205
- if (this.swipeDistance !== 0) {
206
- return "translateX(calc(".concat(this.swipeDistance, "px -\n ").concat((target + 1) * 100, "vw))");
207
- }
156
+ };
208
157
 
209
- return "translateX(-".concat((target + 1) * 100, "vw)");
158
+ var onSwipe = function onSwipe(eventData) {
159
+ if (eventData.dir === 'Up' || eventData.dir === 'Down') {
160
+ return;
210
161
  }
211
- }, {
212
- key: "gotoSlide",
213
- value: function gotoSlide(slideIndexTarget, useAnimation) {
214
- this.swipeDistance = 0;
215
- clearTimeout(this.timer);
216
- this.initTimer();
217
- this.setState({
218
- slideIndexTarget: slideIndexTarget,
219
- animationComplete: !useAnimation
220
- });
162
+
163
+ if (timer.current) {
164
+ clearTimeout(timer.current);
221
165
  }
222
- }, {
223
- key: "initTimer",
224
- value: function initTimer() {
225
- var _this2 = this;
226
-
227
- if (this.props.autoSlide) {
228
- this.timer = setTimeout(function () {
229
- _this2.gotoSlide(_this2.state.slideIndex + 1);
230
- }, this.props.slideInterval);
231
- }
166
+
167
+ setSwipeDistance(eventData.deltaX);
168
+
169
+ if (slideRef && slideRef.current) {
170
+ slideRef.current.style.transition = 'none';
171
+ slideRef.current.style.transform = getSlidePosition(slideIndexTarget);
232
172
  }
233
- }, {
234
- key: "render",
235
- value: function render() {
236
- var slideshow = this.props.slideshow;
237
- var _this$state = this.state,
238
- slideIndex = _this$state.slideIndex,
239
- slideIndexTarget = _this$state.slideIndexTarget,
240
- animationComplete = _this$state.animationComplete;
241
-
242
- if (slideshow.length === 0) {
243
- return ___EmotionJSX("div", null, ___EmotionJSX("div", classes('slideshow'), ___EmotionJSX(Spinner, {
244
- inverted: true
245
- })));
246
- }
247
173
 
248
- var slideshowWidth = "".concat((slideshow.length + 2) * 100, "vw");
249
- var activeSlide = slideIndex;
174
+ var opacityText = 1 - Math.min(100, Math.abs(swipeDistance)) / 100;
175
+
176
+ if (slideText && slideText.current) {
177
+ slideText.current.style.transition = 'none';
178
+ slideText.current.style.opacity = opacityText.toString();
179
+ }
180
+ };
181
+
182
+ var onTransitionEnd = function onTransitionEnd() {
183
+ var slideshowLength = slideshow.length;
250
184
 
251
- if (activeSlide < 0) {
252
- activeSlide = slideshow.length - 1;
253
- } else if (activeSlide >= slideshow.length) {
254
- activeSlide = 0;
185
+ if (slideIndex === -1) {
186
+ if (slideRef.current) {
187
+ slideRef.current.style.transition = 'none';
188
+ slideRef.current.style.transform = getSlidePosition(slideshowLength - 1);
255
189
  }
256
190
 
257
- return ___EmotionJSX("section", null, ___EmotionJSX(Swipeable, _extends({}, classes(''), {
258
- onSwiped: this.onSwipeEnd,
259
- onSwiping: this.onSwipe
260
- }), ___EmotionJSX("div", classes('slide-link-wrapper'), ___EmotionJSX(OneColumn, null, ___EmotionJSX(SafeLink, _extends({
261
- to: slideshow[activeSlide].path
262
- }, classes('item-wrapper', 'text', {
263
- out: !animationComplete
264
- })), ___EmotionJSX("div", _extends({}, classes('slide-info'), {
265
- ref: this.slideText
266
- }), ___EmotionJSX("h1", null, slideshow[activeSlide].title), ___EmotionJSX("p", null, slideshow[activeSlide].metaDescription))))), ___EmotionJSX(NavigationArrow, {
267
- slideIndexTarget: slideIndexTarget > 0 ? slideIndexTarget - 1 : slideshow.length - 1,
268
- gotoSlide: this.gotoSlide
269
- }), ___EmotionJSX(NavigationArrow, {
270
- slideIndexTarget: slideIndexTarget < slideshow.length - 1 ? slideIndexTarget + 1 : 0,
271
- gotoSlide: this.gotoSlide,
272
- rightArrow: true
273
- }), !animationComplete && ___EmotionJSX("div", _extends({}, classes('item', 'fade-over'), {
274
- role: "img",
275
- onAnimationEnd: this.onChangedSlide,
276
- style: {
277
- backgroundImage: "url(".concat(slideshow[activeSlide].metaImage && slideshow[activeSlide].metaImage.url || '', ")")
278
- }
279
- })), ___EmotionJSX("div", _extends({
280
- ref: this.slideRef
281
- }, classes('item-wrapper'), {
282
- onTransitionEnd: this.onTransitionEnd,
283
- style: {
284
- width: slideshowWidth,
285
- transform: this.getSlidePosition(slideIndex)
286
- }
287
- }), renderSlideItem(slideshow[slideshow.length - 1], -1), slideshow.map(renderSlideItem), renderSlideItem(slideshow[0], slideshow.length))), ___EmotionJSX(SlideshowIndicator, {
288
- slideshow: slideshow,
289
- activeSlide: activeSlide,
290
- gotoSlide: this.gotoSlide
291
- }));
191
+ setSlideIndex(slideshowLength - 1);
192
+ setSlideIndexTarget(slideshowLength - 1);
193
+ } else if (slideIndex >= slideshowLength) {
194
+ if (slideRef.current) {
195
+ slideRef.current.style.transition = 'none';
196
+ slideRef.current.style.transform = getSlidePosition(0);
197
+ }
198
+
199
+ setSlideIndex(0);
200
+ setSlideIndexTarget(0);
201
+ }
202
+ };
203
+
204
+ var getSlidePosition = function getSlidePosition(target) {
205
+ if (swipeDistance !== 0) {
206
+ return "translateX(calc(".concat(swipeDistance, "px -\n ").concat((target + 1) * 100, "vw))");
292
207
  }
293
- }]);
294
208
 
295
- return FilmSlideshow;
296
- }(Component);
209
+ return "translateX(-".concat((target + 1) * 100, "vw)");
210
+ };
297
211
 
298
- FilmSlideshow.propTypes = {
299
- autoSlide: PropTypes.bool,
300
- randomStart: PropTypes.bool,
301
- slideshow: PropTypes.arrayOf(movieShape),
302
- slideInterval: PropTypes.number
303
- };
304
- FilmSlideshow.defaultProps = {
305
- autoSlide: false,
306
- randomStart: false,
307
- slideshow: [],
308
- slideInterval: 5000
212
+ var initTimer = useCallback(function () {
213
+ if (autoSlide) {
214
+ timer.current = setTimeout(function () {
215
+ gotoSlide(slideIndex + 1);
216
+ }, slideInterval);
217
+ }
218
+ }, [autoSlide, gotoSlide, slideInterval, slideIndex]);
219
+ useEffect(function () {
220
+ initTimer();
221
+ }, [initTimer]);
222
+ var handlers = useSwipeable({
223
+ onSwiped: onSwipeEnd,
224
+ onSwiping: onSwipe
225
+ });
226
+
227
+ if (slideshow.length === 0) {
228
+ return ___EmotionJSX("div", null, ___EmotionJSX("div", classes('slideshow'), ___EmotionJSX(Spinner, {
229
+ inverted: true
230
+ })));
231
+ }
232
+
233
+ var slideshowWidth = "".concat((slideshow.length + 2) * 100, "vw");
234
+ var activeSlide = slideIndex;
235
+
236
+ if (activeSlide < 0) {
237
+ activeSlide = slideshow.length - 1;
238
+ } else if (activeSlide >= slideshow.length) {
239
+ activeSlide = 0;
240
+ }
241
+
242
+ return ___EmotionJSX("section", _extends({}, classes(''), handlers), ___EmotionJSX(React.Fragment, null, ___EmotionJSX("div", classes('slide-link-wrapper'), ___EmotionJSX(OneColumn, null, ___EmotionJSX(SafeLink, _extends({
243
+ to: slideshow[activeSlide].path
244
+ }, classes('item-wrapper', 'text', {
245
+ out: !animationComplete
246
+ })), ___EmotionJSX("div", _extends({}, classes('slide-info'), {
247
+ ref: slideText
248
+ }), ___EmotionJSX("h1", null, slideshow[activeSlide].title), ___EmotionJSX("p", null, slideshow[activeSlide].metaDescription))))), ___EmotionJSX(NavigationArrow, {
249
+ slideIndexTarget: slideIndexTarget > 0 ? slideIndexTarget - 1 : slideshow.length - 1,
250
+ gotoSlide: gotoSlide
251
+ }), ___EmotionJSX(NavigationArrow, {
252
+ slideIndexTarget: slideIndexTarget < slideshow.length - 1 ? slideIndexTarget + 1 : 0,
253
+ gotoSlide: gotoSlide,
254
+ rightArrow: true
255
+ }), !animationComplete && ___EmotionJSX("div", _extends({}, classes('item', 'fade-over'), {
256
+ role: "img",
257
+ onAnimationEnd: onChangedSlide,
258
+ style: {
259
+ backgroundImage: "url(".concat(slideshow[activeSlide].metaImage && slideshow[activeSlide].metaImage.url || '', ")")
260
+ }
261
+ })), ___EmotionJSX("div", _extends({
262
+ ref: slideRef
263
+ }, classes('item-wrapper'), {
264
+ onTransitionEnd: onTransitionEnd,
265
+ style: {
266
+ width: slideshowWidth,
267
+ transform: getSlidePosition(slideIndex)
268
+ }
269
+ }), renderSlideItem(slideshow[slideshow.length - 1]), slideshow.map(renderSlideItem), renderSlideItem(slideshow[0])), ___EmotionJSX(SlideshowIndicator, {
270
+ slideshow: slideshow,
271
+ activeSlide: activeSlide,
272
+ gotoSlide: gotoSlide
273
+ })));
309
274
  };
275
+
310
276
  export default FilmSlideshow;
@@ -1,25 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
-
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
-
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
-
23
1
  /**
24
2
  * Copyright (c) 2016-present, NDLA.
25
3
  *
@@ -27,8 +5,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
27
5
  * LICENSE file in the root directory of this source tree.
28
6
  *
29
7
  */
30
- import React, { Component } from 'react';
31
- import PropTypes from 'prop-types';
8
+ import React from 'react';
32
9
  import BEMHelper from 'react-bem-helper';
33
10
  import { ChevronRight, ChevronLeft } from '@ndla/icons/common';
34
11
  import { jsx as ___EmotionJSX } from "@emotion/core";
@@ -37,42 +14,18 @@ var classes = new BEMHelper({
37
14
  prefix: 'c-'
38
15
  });
39
16
 
40
- var NavigationArrow = /*#__PURE__*/function (_Component) {
41
- _inherits(NavigationArrow, _Component);
42
-
43
- var _super = _createSuper(NavigationArrow);
44
-
45
- function NavigationArrow() {
46
- _classCallCheck(this, NavigationArrow);
47
-
48
- return _super.apply(this, arguments);
49
- }
50
-
51
- _createClass(NavigationArrow, [{
52
- key: "render",
53
- value: function render() {
54
- var _this$props = this.props,
55
- slideIndexTarget = _this$props.slideIndexTarget,
56
- gotoSlide = _this$props.gotoSlide,
57
- rightArrow = _this$props.rightArrow;
58
- var Chevron = rightArrow ? ChevronRight : ChevronLeft;
59
- return ___EmotionJSX("div", classes('navigation-arrows', rightArrow ? 'right' : ''), ___EmotionJSX("button", {
60
- type: "button",
61
- tabIndex: -1,
62
- onClick: function onClick() {
63
- gotoSlide(slideIndexTarget, true);
64
- }
65
- }, ___EmotionJSX(Chevron, null)));
17
+ var NavigationArrow = function NavigationArrow(_ref) {
18
+ var slideIndexTarget = _ref.slideIndexTarget,
19
+ gotoSlide = _ref.gotoSlide,
20
+ rightArrow = _ref.rightArrow;
21
+ var Chevron = rightArrow ? ChevronRight : ChevronLeft;
22
+ return ___EmotionJSX("div", classes('navigation-arrows', rightArrow ? 'right' : ''), ___EmotionJSX("button", {
23
+ type: "button",
24
+ tabIndex: -1,
25
+ onClick: function onClick() {
26
+ gotoSlide(slideIndexTarget, true);
66
27
  }
67
- }]);
68
-
69
- return NavigationArrow;
70
- }(Component);
71
-
72
- NavigationArrow.propTypes = {
73
- slideIndexTarget: PropTypes.number,
74
- slideshowLength: PropTypes.number,
75
- gotoSlide: PropTypes.func,
76
- rightArrow: PropTypes.bool
28
+ }, ___EmotionJSX(Chevron, null)));
77
29
  };
30
+
78
31
  export default NavigationArrow;