@ndla/ui 3.3.13 → 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.
- package/es/Figure/Figure.js +3 -1
- package/es/NDLAFilm/AboutNdlaFilm.js +6 -17
- package/es/NDLAFilm/AllMoviesAlphabetically.js +11 -11
- package/es/NDLAFilm/CategorySelect.js +17 -18
- package/es/NDLAFilm/FilmContentCard.js +8 -22
- package/es/NDLAFilm/FilmContentCardTags.js +4 -8
- package/es/NDLAFilm/FilmMovieList.js +6 -21
- package/es/NDLAFilm/FilmMovieSearch.js +18 -26
- package/es/NDLAFilm/MovieGrid.js +10 -19
- package/es/NDLAFilm/VisualElement.js +22 -29
- package/es/TopicIntroductionList/TopicIntroduction.js +14 -33
- package/es/TopicIntroductionList/TopicIntroductionList.js +6 -23
- package/es/TopicIntroductionList/TopicIntroductionShortcuts.js +71 -110
- package/es/TopicIntroductionList/TopicShortcutItem.js +0 -9
- package/es/all.css +1 -4
- package/es/index-javascript.js +1 -5
- package/es/index.js +4 -0
- package/es/shapes.js +0 -6
- package/lib/Figure/Figure.js +3 -1
- package/lib/NDLAFilm/AboutNdlaFilm.d.ts +15 -0
- package/lib/NDLAFilm/AboutNdlaFilm.js +6 -18
- package/lib/NDLAFilm/AllMoviesAlphabetically.d.ts +2 -2
- package/lib/NDLAFilm/AllMoviesAlphabetically.js +11 -11
- package/lib/NDLAFilm/CategorySelect.d.ts +11 -0
- package/lib/NDLAFilm/CategorySelect.js +20 -19
- package/lib/NDLAFilm/FilmContentCard.d.ts +11 -0
- package/lib/NDLAFilm/FilmContentCard.js +8 -23
- package/lib/NDLAFilm/FilmContentCardTags.d.ts +7 -0
- package/lib/NDLAFilm/FilmContentCardTags.js +4 -9
- package/lib/NDLAFilm/FilmMovieList.d.ts +19 -0
- package/lib/NDLAFilm/FilmMovieList.js +5 -21
- package/lib/NDLAFilm/FilmMovieSearch.d.ts +21 -0
- package/lib/NDLAFilm/FilmMovieSearch.js +25 -30
- package/lib/NDLAFilm/FilmSlideshow.d.ts +5 -5
- package/lib/NDLAFilm/MovieGrid.d.ts +13 -0
- package/lib/NDLAFilm/MovieGrid.js +9 -21
- package/lib/NDLAFilm/SlideshowIndicator.d.ts +2 -2
- package/lib/NDLAFilm/VisualElement.d.ts +16 -0
- package/lib/NDLAFilm/VisualElement.js +22 -30
- package/lib/NDLAFilm/index.d.ts +14 -0
- package/lib/NDLAFilm/types.d.ts +6 -4
- package/lib/TopicIntroductionList/TopicIntroduction.d.ts +21 -0
- package/lib/TopicIntroductionList/TopicIntroduction.js +16 -36
- package/lib/TopicIntroductionList/TopicIntroductionList.d.ts +35 -0
- package/lib/TopicIntroductionList/TopicIntroductionList.js +6 -25
- package/lib/TopicIntroductionList/TopicIntroductionShortcuts.d.ts +8 -0
- package/lib/TopicIntroductionList/TopicIntroductionShortcuts.js +72 -110
- package/lib/TopicIntroductionList/TopicShortcutItem.d.ts +6 -0
- package/lib/TopicIntroductionList/TopicShortcutItem.js +0 -11
- package/lib/TopicIntroductionList/index.d.ts +9 -0
- package/lib/all.css +1 -4
- package/lib/index-javascript.js +3 -137
- package/lib/index.d.ts +4 -0
- package/lib/index.js +155 -0
- package/lib/shapes.js +1 -10
- package/package.json +10 -10
- package/src/Figure/Figure.tsx +2 -1
- package/src/Figure/component.figure.scss +37 -3
- package/src/NDLAFilm/{AboutNdlaFilm.jsx → AboutNdlaFilm.tsx} +19 -18
- package/src/NDLAFilm/AllMoviesAlphabetically.tsx +3 -3
- package/src/NDLAFilm/{CategorySelect.jsx → CategorySelect.tsx} +23 -20
- package/src/NDLAFilm/{FilmContentCard.jsx → FilmContentCard.tsx} +21 -21
- package/src/NDLAFilm/{FilmContentCardTags.jsx → FilmContentCardTags.tsx} +7 -7
- package/src/NDLAFilm/{FilmMovieList.jsx → FilmMovieList.tsx} +17 -27
- package/src/NDLAFilm/FilmMovieSearch.tsx +71 -0
- package/src/NDLAFilm/FilmSlideshow.tsx +6 -6
- package/src/NDLAFilm/MovieGrid.tsx +76 -0
- package/src/NDLAFilm/SlideshowIndicator.tsx +2 -2
- package/src/NDLAFilm/VisualElement.tsx +40 -0
- package/src/NDLAFilm/{index.js → index.ts} +0 -0
- package/src/NDLAFilm/types.ts +7 -4
- package/src/TopicIntroductionList/{TopicIntroduction.jsx → TopicIntroduction.tsx} +22 -35
- package/src/TopicIntroductionList/{TopicIntroductionList.jsx → TopicIntroductionList.tsx} +32 -26
- package/src/TopicIntroductionList/TopicIntroductionShortcuts.tsx +71 -0
- package/src/TopicIntroductionList/{TopicShortcutItem.jsx → TopicShortcutItem.tsx} +5 -13
- package/src/TopicIntroductionList/{index.js → index.ts} +0 -0
- package/src/index-javascript.js +0 -30
- package/src/index.ts +31 -0
- package/src/shapes.js +0 -7
- package/es/NDLAFilm/interfaces.js +0 -0
- package/es/NDLAFilm/shapes.js +0 -15
- package/lib/NDLAFilm/interfaces.d.ts +0 -10
- package/lib/NDLAFilm/interfaces.js +0 -1
- package/lib/NDLAFilm/shapes.d.ts +0 -15
- package/lib/NDLAFilm/shapes.js +0 -30
- package/src/NDLAFilm/FilmMovieSearch.jsx +0 -66
- package/src/NDLAFilm/MovieGrid.jsx +0 -75
- package/src/NDLAFilm/VisualElement.jsx +0 -48
- package/src/NDLAFilm/interfaces.ts +0 -10
- package/src/NDLAFilm/shapes.ts +0 -17
- package/src/TopicIntroductionList/TopicIntroductionShortcuts.jsx +0 -92
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
9
|
import BEMHelper from 'react-bem-helper';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { Additional, Core } from '@ndla/icons/common';
|
|
12
12
|
import Tooltip from '@ndla/tooltip';
|
|
13
13
|
import SafeLink from '@ndla/safelink';
|
|
14
|
-
import { TopicShape, ShortcutShape } from '../shapes';
|
|
15
14
|
import TopicIntroductionShortcuts from './TopicIntroductionShortcuts';
|
|
16
15
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
17
16
|
var topicClasses = new BEMHelper({
|
|
@@ -24,15 +23,20 @@ export var TopicIntroduction = function TopicIntroduction(_ref) {
|
|
|
24
23
|
topic = _ref.topic,
|
|
25
24
|
subjectPage = _ref.subjectPage,
|
|
26
25
|
shortcuts = _ref.shortcuts,
|
|
27
|
-
messages = _ref.messages,
|
|
28
26
|
shortcutAlwaysExpanded = _ref.shortcutAlwaysExpanded,
|
|
29
|
-
additional = _ref.additional,
|
|
30
|
-
|
|
27
|
+
_ref$additional = _ref.additional,
|
|
28
|
+
additional = _ref$additional === void 0 ? false : _ref$additional,
|
|
29
|
+
_ref$showAdditionalCo = _ref.showAdditionalCores,
|
|
30
|
+
showAdditionalCores = _ref$showAdditionalCo === void 0 ? false : _ref$showAdditionalCo,
|
|
31
31
|
id = _ref.id;
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
var _useTranslation = useTranslation(),
|
|
34
|
+
t = _useTranslation.t;
|
|
35
|
+
|
|
36
|
+
var contentTypeDescription = t(additional ? 'resource.tooltipAdditionalTopic' : 'resource.tooltipCoreTopic');
|
|
33
37
|
return ___EmotionJSX("li", {
|
|
34
38
|
className: topicClasses('item', {
|
|
35
|
-
subjectPage: subjectPage,
|
|
39
|
+
subjectPage: !!subjectPage,
|
|
36
40
|
additional: additional,
|
|
37
41
|
showAdditionalCores: showAdditionalCores
|
|
38
42
|
})
|
|
@@ -49,12 +53,12 @@ export var TopicIntroduction = function TopicIntroduction(_ref) {
|
|
|
49
53
|
id: id,
|
|
50
54
|
hidden: true
|
|
51
55
|
}, contentTypeDescription), additional && ___EmotionJSX(Tooltip, {
|
|
52
|
-
tooltip:
|
|
56
|
+
tooltip: t('resource.tooltipAdditionalTopic'),
|
|
53
57
|
align: "left"
|
|
54
58
|
}, ___EmotionJSX(Additional, {
|
|
55
59
|
className: "c-icon--20 u-margin-left-tiny"
|
|
56
60
|
})), !additional && showAdditionalCores && ___EmotionJSX(Tooltip, {
|
|
57
|
-
tooltip:
|
|
61
|
+
tooltip: t('resource.tooltipCoreTopic'),
|
|
58
62
|
align: "left"
|
|
59
63
|
}, ___EmotionJSX(Core, {
|
|
60
64
|
className: "c-icon--20 u-margin-left-tiny"
|
|
@@ -67,32 +71,9 @@ export var TopicIntroduction = function TopicIntroduction(_ref) {
|
|
|
67
71
|
}), shortcuts && ___EmotionJSX(TopicIntroductionShortcuts, {
|
|
68
72
|
alwaysExpanded: shortcutAlwaysExpanded,
|
|
69
73
|
id: "".concat(topic.id, "_shortcuts"),
|
|
70
|
-
shortcuts: shortcuts
|
|
71
|
-
messages: {
|
|
72
|
-
toggleButtonText: messages.shortcutButtonText
|
|
73
|
-
}
|
|
74
|
+
shortcuts: shortcuts
|
|
74
75
|
})), topic.metaImage && ___EmotionJSX("div", null, ___EmotionJSX("img", {
|
|
75
76
|
src: topic.metaImage.url,
|
|
76
77
|
alt: topic.metaImage.alt
|
|
77
78
|
})))));
|
|
78
|
-
};
|
|
79
|
-
TopicIntroduction.propTypes = {
|
|
80
|
-
additional: PropTypes.bool,
|
|
81
|
-
showAdditionalCores: PropTypes.bool,
|
|
82
|
-
messages: PropTypes.shape({
|
|
83
|
-
shortcutButtonText: PropTypes.string.isRequired,
|
|
84
|
-
tooltipAdditionalTopic: PropTypes.string,
|
|
85
|
-
tooltipCoreTopic: PropTypes.string
|
|
86
|
-
}),
|
|
87
|
-
topic: TopicShape.isRequired,
|
|
88
|
-
toTopic: PropTypes.func.isRequired,
|
|
89
|
-
subjectPage: PropTypes.bool,
|
|
90
|
-
shortcuts: PropTypes.arrayOf(ShortcutShape),
|
|
91
|
-
twoColumns: PropTypes.bool,
|
|
92
|
-
shortcutAlwaysExpanded: PropTypes.bool,
|
|
93
|
-
id: PropTypes.string.isRequired
|
|
94
|
-
};
|
|
95
|
-
TopicIntroduction.defaultProps = {
|
|
96
|
-
showAdditionalCores: false,
|
|
97
|
-
additional: false
|
|
98
79
|
};
|
|
@@ -12,11 +12,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import PropTypes from 'prop-types';
|
|
16
15
|
import BEMHelper from 'react-bem-helper';
|
|
17
16
|
import { useTranslation } from 'react-i18next';
|
|
18
17
|
import NoContentBox from '../NoContentBox';
|
|
19
|
-
import { TopicShape } from '../shapes';
|
|
20
18
|
import { TopicIntroduction } from './TopicIntroduction';
|
|
21
19
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
22
20
|
var topicClasses = new BEMHelper({
|
|
@@ -27,9 +25,12 @@ var topicClasses = new BEMHelper({
|
|
|
27
25
|
|
|
28
26
|
var TopicIntroductionList = function TopicIntroductionList(_ref) {
|
|
29
27
|
var topics = _ref.topics,
|
|
30
|
-
twoColumns = _ref.twoColumns,
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
_ref$twoColumns = _ref.twoColumns,
|
|
29
|
+
twoColumns = _ref$twoColumns === void 0 ? false : _ref$twoColumns,
|
|
30
|
+
_ref$shortcutAlwaysEx = _ref.shortcutAlwaysExpanded,
|
|
31
|
+
shortcutAlwaysExpanded = _ref$shortcutAlwaysEx === void 0 ? false : _ref$shortcutAlwaysEx,
|
|
32
|
+
_ref$showAdditionalCo = _ref.showAdditionalCores,
|
|
33
|
+
showAdditionalCores = _ref$showAdditionalCo === void 0 ? false : _ref$showAdditionalCo,
|
|
33
34
|
toggleAdditionalCores = _ref.toggleAdditionalCores,
|
|
34
35
|
rest = _objectWithoutProperties(_ref, ["topics", "twoColumns", "shortcutAlwaysExpanded", "showAdditionalCores", "toggleAdditionalCores"]);
|
|
35
36
|
|
|
@@ -56,11 +57,6 @@ var TopicIntroductionList = function TopicIntroductionList(_ref) {
|
|
|
56
57
|
additional: additional,
|
|
57
58
|
showAdditionalCores: showAdditionalCores,
|
|
58
59
|
shortcutAlwaysExpanded: shortcutAlwaysExpanded,
|
|
59
|
-
messages: {
|
|
60
|
-
shortcutButtonText: t('resource.label'),
|
|
61
|
-
tooltipAdditionalTopic: t('resource.tooltipAdditionalTopic'),
|
|
62
|
-
tooltipCoreTopic: t('resource.tooltipCoreTopic')
|
|
63
|
-
},
|
|
64
60
|
id: "".concat(topic.id, "_").concat(index)
|
|
65
61
|
}));
|
|
66
62
|
}), renderAdditionalTopicsTrigger && ___EmotionJSX("li", null, ___EmotionJSX(NoContentBox, {
|
|
@@ -70,17 +66,4 @@ var TopicIntroductionList = function TopicIntroductionList(_ref) {
|
|
|
70
66
|
})));
|
|
71
67
|
};
|
|
72
68
|
|
|
73
|
-
TopicIntroductionList.propTypes = {
|
|
74
|
-
toTopic: PropTypes.func.isRequired,
|
|
75
|
-
topics: PropTypes.arrayOf(TopicShape).isRequired,
|
|
76
|
-
twoColumns: PropTypes.bool,
|
|
77
|
-
shortcutAlwaysExpanded: PropTypes.bool,
|
|
78
|
-
showAdditionalCores: PropTypes.bool,
|
|
79
|
-
toggleAdditionalCores: PropTypes.func.isRequired
|
|
80
|
-
};
|
|
81
|
-
TopicIntroductionList.defaultProps = {
|
|
82
|
-
twoColumns: false,
|
|
83
|
-
shortcutAlwaysExpanded: false,
|
|
84
|
-
showAdditionalCores: false
|
|
85
|
-
};
|
|
86
69
|
export default TopicIntroductionList;
|
|
@@ -1,134 +1,95 @@
|
|
|
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
1
|
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); }
|
|
4
2
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
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); } }
|
|
8
|
-
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
10
|
-
|
|
11
|
-
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); }
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
4
|
|
|
13
|
-
function
|
|
5
|
+
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."); }
|
|
14
6
|
|
|
15
|
-
function
|
|
7
|
+
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); }
|
|
16
8
|
|
|
17
|
-
function
|
|
9
|
+
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; }
|
|
18
10
|
|
|
19
|
-
function
|
|
11
|
+
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; }
|
|
20
12
|
|
|
21
|
-
function
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import React, { Component } from 'react';
|
|
26
|
-
import PropTypes from 'prop-types';
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
import { useTranslation } from 'react-i18next';
|
|
27
17
|
import BEMHelper from 'react-bem-helper';
|
|
28
18
|
import { Forward } from '@ndla/icons/common';
|
|
29
19
|
import ShortcutItem from './TopicShortcutItem';
|
|
30
|
-
import { ShortcutShape } from '../shapes';
|
|
31
20
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
32
21
|
var classes = new BEMHelper({
|
|
33
22
|
name: 'topic-shortcuts',
|
|
34
23
|
prefix: 'c-'
|
|
35
24
|
});
|
|
36
25
|
|
|
37
|
-
var TopicIntroductionShortcuts =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
var TopicIntroductionShortcuts = function TopicIntroductionShortcuts(_ref) {
|
|
27
|
+
var id = _ref.id,
|
|
28
|
+
_ref$alwaysExpanded = _ref.alwaysExpanded,
|
|
29
|
+
alwaysExpanded = _ref$alwaysExpanded === void 0 ? false : _ref$alwaysExpanded,
|
|
30
|
+
shortcuts = _ref.shortcuts;
|
|
31
|
+
|
|
32
|
+
var _useTranslation = useTranslation(),
|
|
33
|
+
t = _useTranslation.t;
|
|
34
|
+
|
|
35
|
+
var _useState = useState(alwaysExpanded),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
open = _useState2[0],
|
|
38
|
+
setOpen = _useState2[1];
|
|
39
|
+
|
|
40
|
+
var _useState3 = useState(false),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
returned = _useState4[0],
|
|
43
|
+
setReturned = _useState4[1];
|
|
44
|
+
|
|
45
|
+
var _useState5 = useState(true),
|
|
46
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
47
|
+
showButtonText = _useState6[0],
|
|
48
|
+
setShowButtonText = _useState6[1];
|
|
49
|
+
|
|
50
|
+
var handleOnToggle = function handleOnToggle(newOpen) {
|
|
51
|
+
setOpen(newOpen);
|
|
52
|
+
setShowButtonText(!newOpen);
|
|
53
|
+
setReturned(!newOpen);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var onMouseEnter = undefined;
|
|
57
|
+
var onMouseLeave = undefined;
|
|
58
|
+
var buttonView = null;
|
|
59
|
+
|
|
60
|
+
if (!alwaysExpanded) {
|
|
61
|
+
onMouseEnter = function onMouseEnter() {
|
|
62
|
+
return handleOnToggle(true);
|
|
63
|
+
};
|
|
46
64
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
open: props.alwaysExpanded,
|
|
50
|
-
returned: false,
|
|
51
|
-
showButtonText: true
|
|
65
|
+
onMouseLeave = function onMouseLeave() {
|
|
66
|
+
return handleOnToggle(false);
|
|
52
67
|
};
|
|
53
|
-
_this.handleOnToggle = _this.handleOnToggle.bind(_assertThisInitialized(_this));
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: "render",
|
|
68
|
-
value: function render() {
|
|
69
|
-
var _this2 = this;
|
|
70
|
-
|
|
71
|
-
var _this$props = this.props,
|
|
72
|
-
shortcuts = _this$props.shortcuts,
|
|
73
|
-
messages = _this$props.messages,
|
|
74
|
-
id = _this$props.id,
|
|
75
|
-
alwaysExpanded = _this$props.alwaysExpanded;
|
|
76
|
-
var _this$state = this.state,
|
|
77
|
-
open = _this$state.open,
|
|
78
|
-
returned = _this$state.returned,
|
|
79
|
-
showButtonText = _this$state.showButtonText;
|
|
80
|
-
var onMouseEnter = null;
|
|
81
|
-
var onMouseLeave = null;
|
|
82
|
-
var buttonView = null;
|
|
83
|
-
|
|
84
|
-
if (!alwaysExpanded) {
|
|
85
|
-
onMouseEnter = function onMouseEnter() {
|
|
86
|
-
return _this2.handleOnToggle(true);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
onMouseLeave = function onMouseLeave() {
|
|
90
|
-
return _this2.handleOnToggle(false);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
buttonView = ___EmotionJSX("button", _extends({
|
|
94
|
-
type: "button",
|
|
95
|
-
"aria-expanded": this.state.open,
|
|
96
|
-
"aria-label": messages.toggleButtonText,
|
|
97
|
-
"aria-controls": id
|
|
98
|
-
}, classes('button', returned ? 're-enter' : ''), {
|
|
99
|
-
onClick: function onClick() {
|
|
100
|
-
_this2.handleOnToggle(!open);
|
|
101
|
-
}
|
|
102
|
-
}), ___EmotionJSX(Forward, null), showButtonText && ___EmotionJSX("span", classes('label'), messages.toggleButtonText));
|
|
69
|
+
buttonView = ___EmotionJSX("button", _extends({
|
|
70
|
+
type: "button",
|
|
71
|
+
"aria-expanded": open,
|
|
72
|
+
"aria-label": t('resource.label'),
|
|
73
|
+
"aria-controls": id
|
|
74
|
+
}, classes('button', returned ? 're-enter' : ''), {
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return handleOnToggle(!open);
|
|
103
77
|
}
|
|
78
|
+
}), ___EmotionJSX(Forward, null), showButtonText && ___EmotionJSX("span", classes('label'), t('resource.label')));
|
|
79
|
+
}
|
|
104
80
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
}]);
|
|
119
|
-
|
|
120
|
-
return TopicIntroductionShortcuts;
|
|
121
|
-
}(Component);
|
|
122
|
-
|
|
123
|
-
TopicIntroductionShortcuts.propTypes = {
|
|
124
|
-
id: PropTypes.string.isRequired,
|
|
125
|
-
alwaysExpanded: PropTypes.bool,
|
|
126
|
-
messages: PropTypes.shape({
|
|
127
|
-
toggleButtonText: PropTypes.string.isRequired
|
|
128
|
-
}),
|
|
129
|
-
shortcuts: PropTypes.arrayOf(ShortcutShape).isRequired
|
|
130
|
-
};
|
|
131
|
-
TopicIntroductionShortcuts.defaultProps = {
|
|
132
|
-
alwaysExpanded: false
|
|
81
|
+
return ___EmotionJSX("div", _extends({
|
|
82
|
+
onMouseEnter: onMouseEnter,
|
|
83
|
+
onMouseLeave: onMouseLeave
|
|
84
|
+
}, classes()), buttonView, open && ___EmotionJSX("ul", {
|
|
85
|
+
className: classes('list', open ? 'visible' : '').className
|
|
86
|
+
}, shortcuts.map(function (shortcut) {
|
|
87
|
+
return ___EmotionJSX("li", _extends({}, classes('item'), {
|
|
88
|
+
key: shortcut.id
|
|
89
|
+
}), ___EmotionJSX(ShortcutItem, {
|
|
90
|
+
shortcut: shortcut
|
|
91
|
+
}));
|
|
92
|
+
})));
|
|
133
93
|
};
|
|
94
|
+
|
|
134
95
|
export default TopicIntroductionShortcuts;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import BEMHelper from 'react-bem-helper';
|
|
6
5
|
import Tooltip from '@ndla/tooltip';
|
|
7
6
|
import SafeLink from '@ndla/safelink';
|
|
8
7
|
import { useTranslation } from 'react-i18next';
|
|
9
8
|
import ContentTypeBadge from '../ContentTypeBadge';
|
|
10
|
-
import { ShortcutShape } from '../shapes';
|
|
11
9
|
import { jsx as ___EmotionJSX } from "@emotion/core";
|
|
12
10
|
var classes = new BEMHelper({
|
|
13
11
|
name: 'topic-shortcuts',
|
|
@@ -42,11 +40,4 @@ var ShortcutItem = function ShortcutItem(_ref) {
|
|
|
42
40
|
}), ___EmotionJSX("span", classes('count'), count)));
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
ShortcutItem.propTypes = {
|
|
46
|
-
shortcut: ShortcutShape.isRequired,
|
|
47
|
-
disableToolTip: PropTypes.bool
|
|
48
|
-
};
|
|
49
|
-
ShortcutItem.defaultProps = {
|
|
50
|
-
disableToolTip: false
|
|
51
|
-
};
|
|
52
43
|
export default ShortcutItem;
|