@instructure/quiz-core 20.11.3-rc.11 → 20.11.3-rc.13

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.
@@ -15,7 +15,7 @@ import debounce from 'lodash/debounce';
15
15
  import PropTypes from 'prop-types';
16
16
  import ImmutablePropTypes from 'react-immutable-proptypes';
17
17
  import partial from 'lodash/partial';
18
- import { IconPlusLine } from '@instructure/ui-icons';
18
+ import { IconMoreSolid, IconPlusLine } from '@instructure/ui-icons';
19
19
  import { BreadcrumbLink } from '@instructure/ui-breadcrumb';
20
20
  import { Button } from '@instructure/ui-buttons';
21
21
  import { Heading } from '@instructure/ui-heading';
@@ -38,6 +38,9 @@ import NavWrapper from "../NavWrapper/index.js";
38
38
  import { ADD_BANK_ENTRY_MODAL, BANKS_BANK_ENTRY_PAGINATION, CAN_EDIT, REMOVED_ACCESS, READ_ONLY } from '@instructure/quiz-common';
39
39
  import generateStyle from "./styles.js";
40
40
  import generateComponentTheme from "./theme.js";
41
+
42
+ var _ref = jsx(IconMoreSolid, null);
43
+
41
44
  export var Bank = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
42
45
  _inherits(Bank, _Component);
43
46
 
@@ -67,7 +70,10 @@ export var Bank = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
67
70
  _this.renderHeaderMenu = function () {
68
71
  if (!_this.props.isCompact) {
69
72
  return jsx(HeaderMenu, {
70
- bank: _this.props.bank
73
+ bank: _this.props.bank,
74
+ iceTopNavBarEnabled: _this.props.iceTopNavBarEnabled,
75
+ id: "BankMenu",
76
+ renderIcon: _ref
71
77
  });
72
78
  }
73
79
  };
@@ -92,7 +98,7 @@ export var Bank = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
92
98
  };
93
99
 
94
100
  _this.unshareBankWithCourse = /*#__PURE__*/function () {
95
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(sharedBank) {
101
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(sharedBank) {
96
102
  var _this$props, updateSharedBankPermission, bankId, getSharedBank, scope;
97
103
 
98
104
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -120,7 +126,7 @@ export var Bank = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
120
126
  }));
121
127
 
122
128
  return function (_x) {
123
- return _ref.apply(this, arguments);
129
+ return _ref2.apply(this, arguments);
124
130
  };
125
131
  }();
126
132
 
@@ -175,8 +181,8 @@ export var Bank = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
175
181
  }, _this.renderNewBankEntryButton());
176
182
  };
177
183
 
178
- _this.announceResults = function (_ref2) {
179
- var totalPages = _ref2.totalPages;
184
+ _this.announceResults = function (_ref3) {
185
+ var totalPages = _ref3.totalPages;
180
186
  var message = t("{\n count, plural,\n =0 {No search results found}\n one {Displaying one page of results}\n other {Displaying # pages of results}\n }", {
181
187
  count: totalPages
182
188
  }); // Audibly announce when search results are ready.
@@ -9,8 +9,11 @@ var _dec, _class, _class2, _temp;
9
9
  import { Component } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import ImmutablePropTypes from 'react-immutable-proptypes';
12
+ import { View } from '@instructure/ui-view';
12
13
  import { Menu } from '@instructure/ui-menu';
13
14
  import { IconButton } from '@instructure/ui-buttons';
15
+ import { TopNavBar } from '@instructure/ui-top-nav-bar';
16
+ import { Drilldown } from '@instructure/ui-drilldown';
14
17
  import { IconMoreSolid, IconImportLine } from '@instructure/ui-icons';
15
18
  import { withStyle, jsx } from '@instructure/emotion';
16
19
  import QTIImportModal from "../../../building/components/QTIImportModal/index.js";
@@ -18,6 +21,11 @@ import { PARENT_TYPE_BANK } from '@instructure/quiz-common';
18
21
  import generateStyle from "./styles.js";
19
22
  import generateComponentTheme from "./theme.js";
20
23
  import t from '@instructure/quiz-i18n/es/format-message';
24
+
25
+ var _ref = jsx(IconImportLine, {
26
+ "data-automation": "sdk-headermenu-import-content"
27
+ });
28
+
21
29
  export var HeaderMenu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
22
30
  _inherits(HeaderMenu, _Component);
23
31
 
@@ -32,6 +40,28 @@ export var HeaderMenu = (_dec = withStyle(generateStyle, generateComponentTheme)
32
40
  _createClass(HeaderMenu, [{
33
41
  key: "renderMenu",
34
42
  value: function renderMenu() {
43
+ if (this.props.iceTopNavBarEnabled) {
44
+ return jsx(TopNavBar.Item, {
45
+ id: this.props.id,
46
+ variant: "icon",
47
+ renderIcon: this.props.renderIcon,
48
+ showSubmenuChevron: false,
49
+ renderSubmenu: jsx(Drilldown, {
50
+ rootPageId: "root"
51
+ }, jsx(Drilldown.Page, {
52
+ id: "root"
53
+ }, jsx(Drilldown.Option, {
54
+ id: "import",
55
+ key: "import",
56
+ disabled: !this.props.bank.canImport(),
57
+ onOptionClick: this.props.openImportModal
58
+ }, _ref, jsx(View, {
59
+ as: "span",
60
+ margin: "0 0 0 x-small"
61
+ }, t('Import Content')))))
62
+ }, t('More Item Banking Actions'));
63
+ }
64
+
35
65
  return jsx(Menu, {
36
66
  trigger: jsx(IconButton, {
37
67
  renderIcon: IconMoreSolid,
@@ -52,7 +82,9 @@ export var HeaderMenu = (_dec = withStyle(generateStyle, generateComponentTheme)
52
82
  key: "render",
53
83
  value: function render() {
54
84
  var bank = this.props.bank;
55
- return jsx("div", null, this.renderMenu(), jsx(QTIImportModal, {
85
+ return jsx("div", {
86
+ css: this.props.styles.container
87
+ }, this.renderMenu(), jsx(QTIImportModal, {
56
88
  parentId: bank.id,
57
89
  parentType: PARENT_TYPE_BANK,
58
90
  qtiImport: bank.getLatestImport(),
@@ -66,7 +98,14 @@ export var HeaderMenu = (_dec = withStyle(generateStyle, generateComponentTheme)
66
98
  }(Component), _class2.propTypes = {
67
99
  openImportModal: PropTypes.func.isRequired,
68
100
  bank: ImmutablePropTypes.record.isRequired,
101
+ iceTopNavBarEnabled: PropTypes.bool,
102
+ id: PropTypes.string,
103
+ renderIcon: PropTypes.element,
69
104
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
70
105
  styles: PropTypes.object
106
+ }, _class2.defaultProps = {
107
+ iceTopNavBarEnabled: false,
108
+ id: 'BankMenu',
109
+ renderIcon: jsx(IconMoreSolid, null)
71
110
  }, _temp)) || _class);
72
111
  export default HeaderMenu;
@@ -4,6 +4,9 @@ var generateStyle = function generateStyle(componentTheme) {
4
4
  verticalAlign: 'middle',
5
5
  marginRight: componentTheme.menuIconMargin,
6
6
  fontSize: componentTheme.menuIconFontSize
7
+ },
8
+ container: {
9
+ height: '100%'
7
10
  }
8
11
  };
9
12
  };
@@ -73,12 +73,15 @@ var NavWrapper = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(
73
73
  if (!closeTray && returnToUrl) {
74
74
  return jsx(ReturnButton, {
75
75
  returnToUrl: returnToUrl,
76
+ id: "ReturnButton",
77
+ key: "ReturnButton",
76
78
  iceTopNavBarEnabled: iceTopNavBarEnabled
77
79
  });
78
80
  } else if (navigateToBuild) {
79
81
  if (iceTopNavBarEnabled) {
80
82
  return jsx(SecondaryNavBarButton, {
81
83
  id: "ReturnButton",
84
+ key: "ReturnButton",
82
85
  variant: "button",
83
86
  onClick: navigateToBuild
84
87
  }, t('Return'));
@@ -105,12 +108,14 @@ var NavWrapper = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(
105
108
  key: "render",
106
109
  value: function render() {
107
110
  if (this.props.iceTopNavBarEnabled) {
111
+ var actionItems = [this.renderReturnButton()];
112
+ !this.props.isCompact && actionItems.push(this.props.renderHeaderMenu());
108
113
  return jsx(NavBar, {
109
114
  menuItems: [{
110
115
  path: this.props.menuItemPath,
111
116
  text: 'Item Banks'
112
117
  }],
113
- actionItems: [this.renderReturnButton()]
118
+ actionItems: actionItems
114
119
  });
115
120
  }
116
121
 
@@ -54,7 +54,7 @@ export var SecondaryNavBarButton = (_dec = withStyle(generateStyle, generateComp
54
54
 
55
55
  SecondaryNavBarButton.displayName = "SecondaryNavBarButton";
56
56
  return SecondaryNavBarButton;
57
- }(Component), _class2.propTypes = {
57
+ }(Component), _class2.displayName = 'TopNavBarItem', _class2.propTypes = {
58
58
  children: PropTypes.string.isRequired,
59
59
  styles: PropTypes.object,
60
60
  makeStyles: PropTypes.func
@@ -1,39 +1,136 @@
1
- import { bindActionCreators } from 'redux';
2
- import partial from 'lodash/partial';
3
- import { connect } from "../../../../common/react-redux.js";
4
- import * as modalActions from "../../../../common/actions/modal.js";
5
- import { set as setUI } from "../../../../common/actions/ui.js";
6
- import { BUILD_TRAY_OPEN, BUILD_TRAY_BUTTON_REF } from '@instructure/quiz-common';
7
- import { generateImportModalId } from "../../ImportModal/index.js";
8
- import { NavBar as NavBarPresenter } from "./presenter.js";
9
- import { getActiveQuiz } from "../../../selectors/quizzes.js";
10
- import { featureOn } from "../../../util/featureCheck.js";
11
- import { startQuizExportJob } from "../../../actions/quizExport.js";
12
- import { addAlert, addInfo } from "../../../actions/alerts.js";
13
- export function mapStateToProps(state) {
14
- var quiz = getActiveQuiz(state);
15
- return {
16
- activeQuizId: quiz.id,
17
- canExport: !state.getIn(['quizExport', "activeQuiz".concat(quiz.id)]),
18
- canImport: quiz.canImport(),
19
- hasQuestions: quiz.hasQuestions(),
20
- isEditing: state.get('editing') && state.get('editing').some(function (elem) {
21
- return elem;
22
- }),
23
- printingEnabled: featureOn('printing')
24
- };
25
- }
26
-
27
- var mapDispatchToProps = function mapDispatchToProps(dispatch) {
28
- return {
29
- addAlert: bindActionCreators(addAlert, dispatch),
30
- addInfo: bindActionCreators(addInfo, dispatch),
31
- openBanksTray: bindActionCreators(setUI.bind(void 0, BUILD_TRAY_OPEN, true), dispatch),
32
- setBanksTrayButtonRef: bindActionCreators(partial(setUI, BUILD_TRAY_BUTTON_REF), dispatch),
33
- startExport: bindActionCreators(startQuizExportJob, dispatch),
34
- openModal: bindActionCreators(modalActions.openModal.bind(modalActions, generateImportModalId('qtiImport')), dispatch)
35
- };
36
- };
37
-
38
- export var NavBar = connect(mapStateToProps, mapDispatchToProps)(NavBarPresenter);
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+
7
+ var _dec, _class, _class2, _temp;
8
+
9
+ /** @jsx jsx */
10
+ import { Component } from 'react';
11
+ import PropTypes from 'prop-types';
12
+ import { TopNavBar } from '@instructure/ui-top-nav-bar';
13
+ import { IconQuizLine } from '@instructure/ui-icons';
14
+ import t from '@instructure/quiz-i18n/es/format-message';
15
+ import { withStyle, jsx } from '@instructure/emotion';
16
+ import generateStyle from "./styles.js";
17
+ import generateComponentTheme from "./theme.js";
18
+
19
+ var _ref = jsx(IconQuizLine, {
20
+ color: "primary",
21
+ size: "small"
22
+ });
23
+
24
+ export var NavBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
25
+ _inherits(NavBar, _Component);
26
+
27
+ var _super = _createSuper(NavBar);
28
+
29
+ function NavBar() {
30
+ var _this;
31
+
32
+ _classCallCheck(this, NavBar);
33
+
34
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
+ args[_key] = arguments[_key];
36
+ }
37
+
38
+ _this = _super.call.apply(_super, [this].concat(args));
39
+
40
+ _this.hiddenActionItemsMenuTriggerLabel = function (hiddenChildrenCount) {
41
+ return t('{hiddenChildrenCount} more actions', {
42
+ hiddenChildrenCount: hiddenChildrenCount
43
+ });
44
+ };
45
+
46
+ _this.hiddenMenuItemsMenuTriggerLabel = function (hiddenChildrenCount) {
47
+ return t('{hiddenChildrenCount} More', {
48
+ hiddenChildrenCount: hiddenChildrenCount
49
+ });
50
+ };
51
+
52
+ _this.renderBrand = function () {
53
+ return jsx(TopNavBar.Brand, {
54
+ screenReaderLabel: t('Quizzes'),
55
+ renderIcon: _ref
56
+ });
57
+ };
58
+
59
+ _this.renderMenuItems = function () {
60
+ return jsx(TopNavBar.MenuItems, {
61
+ listLabel: t('Page navigation'),
62
+ currentPageId: window.location.pathname,
63
+ renderHiddenItemsMenuTriggerLabel: _this.hiddenMenuItemsMenuTriggerLabel
64
+ }, _this.props.menuItems.map(function (menuItem) {
65
+ return _this.renderMenuItem(menuItem);
66
+ }));
67
+ };
68
+
69
+ _this.renderMenuItem = function (menuItem) {
70
+ return jsx(TopNavBar.Item, {
71
+ id: menuItem.path,
72
+ key: menuItem.path,
73
+ onClick: function onClick() {
74
+ return _this.props.handleMenuItemChange(menuItem.path);
75
+ } // eslint-disable-line react/jsx-no-bind
76
+
77
+ }, menuItem.text);
78
+ };
79
+
80
+ _this.renderActionItems = function () {
81
+ return jsx(TopNavBar.ActionItems, {
82
+ listLabel: t('Actions'),
83
+ renderHiddenItemsMenuTriggerLabel: _this.hiddenActionItemsMenuTriggerLabel
84
+ }, _toConsumableArray(_this.props.actionItems));
85
+ };
86
+
87
+ return _this;
88
+ }
89
+
90
+ _createClass(NavBar, [{
91
+ key: "render",
92
+ value: function render() {
93
+ var _this2 = this;
94
+
95
+ return jsx(TopNavBar, {
96
+ breakpoint: this.props.styles.phoneBreakPoint,
97
+ mediaQueryMatch: "element",
98
+ inverseColor: true
99
+ }, function () {
100
+ return jsx(TopNavBar.Layout, {
101
+ themeOverride: {
102
+ desktopBackgroundInverse: _this2.props.styles.backgroundColor,
103
+ smallViewportBackgroundInverse: _this2.props.styles.backgroundColor
104
+ },
105
+ navLabel: t('Quizzes navigation bar'),
106
+ desktopConfig: {
107
+ hideActionsUserSeparator: true
108
+ },
109
+ smallViewportConfig: {
110
+ dropdownMenuToggleButtonLabel: t('Toggle Menu'),
111
+ dropdownMenuLabel: t('Main Menu')
112
+ },
113
+ renderBrand: _this2.renderBrand(),
114
+ renderMenuItems: _this2.renderMenuItems(),
115
+ renderActionItems: _this2.renderActionItems()
116
+ });
117
+ });
118
+ }
119
+ }]);
120
+
121
+ NavBar.displayName = "NavBar";
122
+ return NavBar;
123
+ }(Component), _class2.propTypes = {
124
+ menuItems: PropTypes.arrayOf(PropTypes.shape({
125
+ path: PropTypes.string.isRequired,
126
+ text: PropTypes.string.isRequired
127
+ })),
128
+ handleMenuItemChange: PropTypes.func,
129
+ actionItems: PropTypes.arrayOf(PropTypes.node),
130
+ styles: PropTypes.object
131
+ }, _class2.defaultProps = {
132
+ menuItems: [],
133
+ handleMenuItemChange: function handleMenuItemChange() {},
134
+ actionItems: []
135
+ }, _temp)) || _class);
39
136
  export default NavBar;
@@ -27,7 +27,8 @@ export var ReturnButton = /*#__PURE__*/function (_Component) {
27
27
 
28
28
  if (this.props.iceTopNavBarEnabled) {
29
29
  return /*#__PURE__*/React.createElement(SecondaryNavBarButton, {
30
- id: "ReturnButton",
30
+ id: this.props.id,
31
+ key: this.props.id,
31
32
  variant: "button",
32
33
  "data-automation": "sdk-return-button",
33
34
  href: this.props.returnToUrl,
@@ -49,11 +50,13 @@ export var ReturnButton = /*#__PURE__*/function (_Component) {
49
50
  ReturnButton.propTypes = {
50
51
  returnToUrl: PropTypes.string,
51
52
  text: PropTypes.string,
53
+ id: PropTypes.string,
52
54
  iceTopNavBarEnabled: PropTypes.bool
53
55
  };
54
56
  ReturnButton.defaultProps = {
55
57
  returnToUrl: void 0,
56
58
  text: t('Return'),
59
+ id: 'ReturnButton',
57
60
  iceTopNavBarEnabled: false
58
61
  };
59
62
  export default ReturnButton;
@@ -83,6 +83,8 @@ var _theme = _interopRequireDefault(require("./theme.js"));
83
83
 
84
84
  var _dec, _class, _class2, _temp;
85
85
 
86
+ var _ref = (0, _emotion.jsx)(_uiIcons.IconMoreSolid, null);
87
+
86
88
  var Bank = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
87
89
  (0, _inherits2.default)(Bank, _Component);
88
90
 
@@ -112,7 +114,10 @@ var Bank = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
112
114
  _this.renderHeaderMenu = function () {
113
115
  if (!_this.props.isCompact) {
114
116
  return (0, _emotion.jsx)(_index7.default, {
115
- bank: _this.props.bank
117
+ bank: _this.props.bank,
118
+ iceTopNavBarEnabled: _this.props.iceTopNavBarEnabled,
119
+ id: "BankMenu",
120
+ renderIcon: _ref
116
121
  });
117
122
  }
118
123
  };
@@ -137,7 +142,7 @@ var Bank = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
137
142
  };
138
143
 
139
144
  _this.unshareBankWithCourse = /*#__PURE__*/function () {
140
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(sharedBank) {
145
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(sharedBank) {
141
146
  var _this$props, updateSharedBankPermission, bankId, getSharedBank, scope;
142
147
 
143
148
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -165,7 +170,7 @@ var Bank = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
165
170
  }));
166
171
 
167
172
  return function (_x) {
168
- return _ref.apply(this, arguments);
173
+ return _ref2.apply(this, arguments);
169
174
  };
170
175
  }();
171
176
 
@@ -220,8 +225,8 @@ var Bank = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
220
225
  }, _this.renderNewBankEntryButton());
221
226
  };
222
227
 
223
- _this.announceResults = function (_ref2) {
224
- var totalPages = _ref2.totalPages;
228
+ _this.announceResults = function (_ref3) {
229
+ var totalPages = _ref3.totalPages;
225
230
  var message = (0, _formatMessage.default)("{\n count, plural,\n =0 {No search results found}\n one {Displaying one page of results}\n other {Displaying # pages of results}\n }", {
226
231
  count: totalPages
227
232
  }); // Audibly announce when search results are ready.
@@ -21,10 +21,16 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
21
21
 
22
22
  var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
23
23
 
24
+ var _uiView = require("@instructure/ui-view");
25
+
24
26
  var _uiMenu = require("@instructure/ui-menu");
25
27
 
26
28
  var _uiButtons = require("@instructure/ui-buttons");
27
29
 
30
+ var _uiTopNavBar = require("@instructure/ui-top-nav-bar");
31
+
32
+ var _uiDrilldown = require("@instructure/ui-drilldown");
33
+
28
34
  var _uiIcons = require("@instructure/ui-icons");
29
35
 
30
36
  var _emotion = require("@instructure/emotion");
@@ -41,6 +47,10 @@ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/f
41
47
 
42
48
  var _dec, _class, _class2, _temp;
43
49
 
50
+ var _ref = (0, _emotion.jsx)(_uiIcons.IconImportLine, {
51
+ "data-automation": "sdk-headermenu-import-content"
52
+ });
53
+
44
54
  var HeaderMenu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
45
55
  (0, _inherits2.default)(HeaderMenu, _Component);
46
56
 
@@ -54,6 +64,28 @@ var HeaderMenu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
54
64
  (0, _createClass2.default)(HeaderMenu, [{
55
65
  key: "renderMenu",
56
66
  value: function renderMenu() {
67
+ if (this.props.iceTopNavBarEnabled) {
68
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Item, {
69
+ id: this.props.id,
70
+ variant: "icon",
71
+ renderIcon: this.props.renderIcon,
72
+ showSubmenuChevron: false,
73
+ renderSubmenu: (0, _emotion.jsx)(_uiDrilldown.Drilldown, {
74
+ rootPageId: "root"
75
+ }, (0, _emotion.jsx)(_uiDrilldown.Drilldown.Page, {
76
+ id: "root"
77
+ }, (0, _emotion.jsx)(_uiDrilldown.Drilldown.Option, {
78
+ id: "import",
79
+ key: "import",
80
+ disabled: !this.props.bank.canImport(),
81
+ onOptionClick: this.props.openImportModal
82
+ }, _ref, (0, _emotion.jsx)(_uiView.View, {
83
+ as: "span",
84
+ margin: "0 0 0 x-small"
85
+ }, (0, _formatMessage.default)('Import Content')))))
86
+ }, (0, _formatMessage.default)('More Item Banking Actions'));
87
+ }
88
+
57
89
  return (0, _emotion.jsx)(_uiMenu.Menu, {
58
90
  trigger: (0, _emotion.jsx)(_uiButtons.IconButton, {
59
91
  renderIcon: _uiIcons.IconMoreSolid,
@@ -74,7 +106,9 @@ var HeaderMenu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
74
106
  key: "render",
75
107
  value: function render() {
76
108
  var bank = this.props.bank;
77
- return (0, _emotion.jsx)("div", null, this.renderMenu(), (0, _emotion.jsx)(_index.default, {
109
+ return (0, _emotion.jsx)("div", {
110
+ css: this.props.styles.container
111
+ }, this.renderMenu(), (0, _emotion.jsx)(_index.default, {
78
112
  parentId: bank.id,
79
113
  parentType: _quizCommon.PARENT_TYPE_BANK,
80
114
  qtiImport: bank.getLatestImport(),
@@ -87,8 +121,15 @@ var HeaderMenu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
87
121
  }(_react.Component), _class2.propTypes = {
88
122
  openImportModal: _propTypes.default.func.isRequired,
89
123
  bank: _reactImmutableProptypes.default.record.isRequired,
124
+ iceTopNavBarEnabled: _propTypes.default.bool,
125
+ id: _propTypes.default.string,
126
+ renderIcon: _propTypes.default.element,
90
127
  // eslint-disable-next-line react/require-default-props,react/forbid-prop-types
91
128
  styles: _propTypes.default.object
129
+ }, _class2.defaultProps = {
130
+ iceTopNavBarEnabled: false,
131
+ id: 'BankMenu',
132
+ renderIcon: (0, _emotion.jsx)(_uiIcons.IconMoreSolid, null)
92
133
  }, _temp)) || _class);
93
134
  exports.HeaderMenu = HeaderMenu;
94
135
  var _default = HeaderMenu;
@@ -11,6 +11,9 @@ var generateStyle = function generateStyle(componentTheme) {
11
11
  verticalAlign: 'middle',
12
12
  marginRight: componentTheme.menuIconMargin,
13
13
  fontSize: componentTheme.menuIconFontSize
14
+ },
15
+ container: {
16
+ height: '100%'
14
17
  }
15
18
  };
16
19
  };
@@ -100,12 +100,15 @@ var NavWrapper = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
100
100
  if (!closeTray && returnToUrl) {
101
101
  return (0, _emotion.jsx)(_ReturnButton.ReturnButton, {
102
102
  returnToUrl: returnToUrl,
103
+ id: "ReturnButton",
104
+ key: "ReturnButton",
103
105
  iceTopNavBarEnabled: iceTopNavBarEnabled
104
106
  });
105
107
  } else if (navigateToBuild) {
106
108
  if (iceTopNavBarEnabled) {
107
109
  return (0, _emotion.jsx)(_index2.SecondaryNavBarButton, {
108
110
  id: "ReturnButton",
111
+ key: "ReturnButton",
109
112
  variant: "button",
110
113
  onClick: navigateToBuild
111
114
  }, (0, _formatMessage.default)('Return'));
@@ -132,12 +135,14 @@ var NavWrapper = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
132
135
  key: "render",
133
136
  value: function render() {
134
137
  if (this.props.iceTopNavBarEnabled) {
138
+ var actionItems = [this.renderReturnButton()];
139
+ !this.props.isCompact && actionItems.push(this.props.renderHeaderMenu());
135
140
  return (0, _emotion.jsx)(_index.NavBar, {
136
141
  menuItems: [{
137
142
  path: this.props.menuItemPath,
138
143
  text: 'Item Banks'
139
144
  }],
140
- actionItems: [this.renderReturnButton()]
145
+ actionItems: actionItems
141
146
  });
142
147
  }
143
148
 
@@ -70,7 +70,7 @@ var SecondaryNavBarButton = (_dec = (0, _emotion.withStyle)(_styles.default, _th
70
70
  }]);
71
71
  SecondaryNavBarButton.displayName = "SecondaryNavBarButton";
72
72
  return SecondaryNavBarButton;
73
- }(_react.Component), _class2.propTypes = {
73
+ }(_react.Component), _class2.displayName = 'TopNavBarItem', _class2.propTypes = {
74
74
  children: _propTypes.default.string.isRequired,
75
75
  styles: _propTypes.default.object,
76
76
  makeStyles: _propTypes.default.func
@@ -1,65 +1,156 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
- exports.mapStateToProps = mapStateToProps;
11
8
  exports.default = exports.NavBar = void 0;
12
9
 
13
- var _redux = require("redux");
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
13
 
15
- var _partial = _interopRequireDefault(require("lodash/partial"));
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
16
15
 
17
- var _reactRedux = require("../../../../common/react-redux.js");
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
18
17
 
19
- var modalActions = _interopRequireWildcard(require("../../../../common/actions/modal.js"));
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
20
19
 
21
- var _ui = require("../../../../common/actions/ui.js");
20
+ var _react = require("react");
22
21
 
23
- var _quizCommon = require("@instructure/quiz-common");
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
24
23
 
25
- var _index = require("../../ImportModal/index.js");
24
+ var _uiTopNavBar = require("@instructure/ui-top-nav-bar");
26
25
 
27
- var _presenter = require("./presenter.js");
26
+ var _uiIcons = require("@instructure/ui-icons");
28
27
 
29
- var _quizzes = require("../../../selectors/quizzes.js");
28
+ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
30
29
 
31
- var _featureCheck = require("../../../util/featureCheck.js");
30
+ var _emotion = require("@instructure/emotion");
32
31
 
33
- var _quizExport = require("../../../actions/quizExport.js");
32
+ var _styles = _interopRequireDefault(require("./styles.js"));
34
33
 
35
- var _alerts = require("../../../actions/alerts.js");
34
+ var _theme = _interopRequireDefault(require("./theme.js"));
36
35
 
37
- function mapStateToProps(state) {
38
- var quiz = (0, _quizzes.getActiveQuiz)(state);
39
- return {
40
- activeQuizId: quiz.id,
41
- canExport: !state.getIn(['quizExport', "activeQuiz".concat(quiz.id)]),
42
- canImport: quiz.canImport(),
43
- hasQuestions: quiz.hasQuestions(),
44
- isEditing: state.get('editing') && state.get('editing').some(function (elem) {
45
- return elem;
46
- }),
47
- printingEnabled: (0, _featureCheck.featureOn)('printing')
48
- };
49
- }
36
+ var _dec, _class, _class2, _temp;
50
37
 
51
- var mapDispatchToProps = function mapDispatchToProps(dispatch) {
52
- return {
53
- addAlert: (0, _redux.bindActionCreators)(_alerts.addAlert, dispatch),
54
- addInfo: (0, _redux.bindActionCreators)(_alerts.addInfo, dispatch),
55
- openBanksTray: (0, _redux.bindActionCreators)(_ui.set.bind(void 0, _quizCommon.BUILD_TRAY_OPEN, true), dispatch),
56
- setBanksTrayButtonRef: (0, _redux.bindActionCreators)((0, _partial.default)(_ui.set, _quizCommon.BUILD_TRAY_BUTTON_REF), dispatch),
57
- startExport: (0, _redux.bindActionCreators)(_quizExport.startQuizExportJob, dispatch),
58
- openModal: (0, _redux.bindActionCreators)(modalActions.openModal.bind(modalActions, (0, _index.generateImportModalId)('qtiImport')), dispatch)
59
- };
60
- };
38
+ var _ref = (0, _emotion.jsx)(_uiIcons.IconQuizLine, {
39
+ color: "primary",
40
+ size: "small"
41
+ });
61
42
 
62
- var NavBar = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter.NavBar);
43
+ var NavBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
44
+ (0, _inherits2.default)(NavBar, _Component);
45
+
46
+ var _super = (0, _createSuper2.default)(NavBar);
47
+
48
+ function NavBar() {
49
+ var _this;
50
+
51
+ (0, _classCallCheck2.default)(this, NavBar);
52
+
53
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
+ args[_key] = arguments[_key];
55
+ }
56
+
57
+ _this = _super.call.apply(_super, [this].concat(args));
58
+
59
+ _this.hiddenActionItemsMenuTriggerLabel = function (hiddenChildrenCount) {
60
+ return (0, _formatMessage.default)('{hiddenChildrenCount} more actions', {
61
+ hiddenChildrenCount: hiddenChildrenCount
62
+ });
63
+ };
64
+
65
+ _this.hiddenMenuItemsMenuTriggerLabel = function (hiddenChildrenCount) {
66
+ return (0, _formatMessage.default)('{hiddenChildrenCount} More', {
67
+ hiddenChildrenCount: hiddenChildrenCount
68
+ });
69
+ };
70
+
71
+ _this.renderBrand = function () {
72
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Brand, {
73
+ screenReaderLabel: (0, _formatMessage.default)('Quizzes'),
74
+ renderIcon: _ref
75
+ });
76
+ };
77
+
78
+ _this.renderMenuItems = function () {
79
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.MenuItems, {
80
+ listLabel: (0, _formatMessage.default)('Page navigation'),
81
+ currentPageId: window.location.pathname,
82
+ renderHiddenItemsMenuTriggerLabel: _this.hiddenMenuItemsMenuTriggerLabel
83
+ }, _this.props.menuItems.map(function (menuItem) {
84
+ return _this.renderMenuItem(menuItem);
85
+ }));
86
+ };
87
+
88
+ _this.renderMenuItem = function (menuItem) {
89
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Item, {
90
+ id: menuItem.path,
91
+ key: menuItem.path,
92
+ onClick: function onClick() {
93
+ return _this.props.handleMenuItemChange(menuItem.path);
94
+ } // eslint-disable-line react/jsx-no-bind
95
+
96
+ }, menuItem.text);
97
+ };
98
+
99
+ _this.renderActionItems = function () {
100
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.ActionItems, {
101
+ listLabel: (0, _formatMessage.default)('Actions'),
102
+ renderHiddenItemsMenuTriggerLabel: _this.hiddenActionItemsMenuTriggerLabel
103
+ }, (0, _toConsumableArray2.default)(_this.props.actionItems));
104
+ };
105
+
106
+ return _this;
107
+ }
108
+
109
+ (0, _createClass2.default)(NavBar, [{
110
+ key: "render",
111
+ value: function render() {
112
+ var _this2 = this;
113
+
114
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar, {
115
+ breakpoint: this.props.styles.phoneBreakPoint,
116
+ mediaQueryMatch: "element",
117
+ inverseColor: true
118
+ }, function () {
119
+ return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Layout, {
120
+ themeOverride: {
121
+ desktopBackgroundInverse: _this2.props.styles.backgroundColor,
122
+ smallViewportBackgroundInverse: _this2.props.styles.backgroundColor
123
+ },
124
+ navLabel: (0, _formatMessage.default)('Quizzes navigation bar'),
125
+ desktopConfig: {
126
+ hideActionsUserSeparator: true
127
+ },
128
+ smallViewportConfig: {
129
+ dropdownMenuToggleButtonLabel: (0, _formatMessage.default)('Toggle Menu'),
130
+ dropdownMenuLabel: (0, _formatMessage.default)('Main Menu')
131
+ },
132
+ renderBrand: _this2.renderBrand(),
133
+ renderMenuItems: _this2.renderMenuItems(),
134
+ renderActionItems: _this2.renderActionItems()
135
+ });
136
+ });
137
+ }
138
+ }]);
139
+ NavBar.displayName = "NavBar";
140
+ return NavBar;
141
+ }(_react.Component), _class2.propTypes = {
142
+ menuItems: _propTypes.default.arrayOf(_propTypes.default.shape({
143
+ path: _propTypes.default.string.isRequired,
144
+ text: _propTypes.default.string.isRequired
145
+ })),
146
+ handleMenuItemChange: _propTypes.default.func,
147
+ actionItems: _propTypes.default.arrayOf(_propTypes.default.node),
148
+ styles: _propTypes.default.object
149
+ }, _class2.defaultProps = {
150
+ menuItems: [],
151
+ handleMenuItemChange: function handleMenuItemChange() {},
152
+ actionItems: []
153
+ }, _temp)) || _class);
63
154
  exports.NavBar = NavBar;
64
155
  var _default = NavBar;
65
156
  exports.default = _default;
@@ -46,7 +46,8 @@ var ReturnButton = /*#__PURE__*/function (_Component) {
46
46
 
47
47
  if (this.props.iceTopNavBarEnabled) {
48
48
  return /*#__PURE__*/_react.default.createElement(_index.SecondaryNavBarButton, {
49
- id: "ReturnButton",
49
+ id: this.props.id,
50
+ key: this.props.id,
50
51
  variant: "button",
51
52
  "data-automation": "sdk-return-button",
52
53
  href: this.props.returnToUrl,
@@ -69,11 +70,13 @@ exports.ReturnButton = ReturnButton;
69
70
  ReturnButton.propTypes = {
70
71
  returnToUrl: _propTypes.default.string,
71
72
  text: _propTypes.default.string,
73
+ id: _propTypes.default.string,
72
74
  iceTopNavBarEnabled: _propTypes.default.bool
73
75
  };
74
76
  ReturnButton.defaultProps = {
75
77
  returnToUrl: void 0,
76
78
  text: (0, _formatMessage.default)('Return'),
79
+ id: 'ReturnButton',
77
80
  iceTopNavBarEnabled: false
78
81
  };
79
82
  var _default = ReturnButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.11.3-rc.11+9ba5b2201",
3
+ "version": "20.11.3-rc.13+af44749c7",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -44,11 +44,11 @@
44
44
  "@instructure/emotion": "^8.51.0",
45
45
  "@instructure/grading-utils": "^1.0.0",
46
46
  "@instructure/outcomes-ui": "^3.2.0",
47
- "@instructure/quiz-common": "20.11.3-rc.11+9ba5b2201",
48
- "@instructure/quiz-i18n": "20.11.3-rc.11+9ba5b2201",
49
- "@instructure/quiz-interactions": "20.11.3-rc.11+9ba5b2201",
50
- "@instructure/quiz-number-input": "20.11.3-rc.11+9ba5b2201",
51
- "@instructure/quiz-rce": "20.11.3-rc.11+9ba5b2201",
47
+ "@instructure/quiz-common": "20.11.3-rc.13+af44749c7",
48
+ "@instructure/quiz-i18n": "20.11.3-rc.13+af44749c7",
49
+ "@instructure/quiz-interactions": "20.11.3-rc.13+af44749c7",
50
+ "@instructure/quiz-number-input": "20.11.3-rc.13+af44749c7",
51
+ "@instructure/quiz-rce": "20.11.3-rc.13+af44749c7",
52
52
  "@instructure/ui-a11y-content": "^8.51.0",
53
53
  "@instructure/ui-alerts": "^8.51.0",
54
54
  "@instructure/ui-avatar": "^8.51.0",
@@ -112,7 +112,7 @@
112
112
  "file-saver": "~2.0.5",
113
113
  "humps": "^2.0.0",
114
114
  "immutable": "^3.8.1",
115
- "instructure-validations": "20.11.3-rc.11+9ba5b2201",
115
+ "instructure-validations": "20.11.3-rc.13+af44749c7",
116
116
  "ipaddr.js": "^1.5.4",
117
117
  "isomorphic-fetch": "^2.2.0",
118
118
  "isuuid": "^0.1.0",
@@ -163,7 +163,7 @@
163
163
  "intl": "^1.2.4",
164
164
  "jquery": "^2.2.3",
165
165
  "most-subject": "^5.3.0",
166
- "quiz-presets": "20.11.3-rc.11+9ba5b2201",
166
+ "quiz-presets": "20.11.3-rc.13+af44749c7",
167
167
  "react": "^16.8.6",
168
168
  "react-addons-test-utils": "^15.6.2",
169
169
  "react-dom": "^16.8.6",
@@ -179,5 +179,5 @@
179
179
  "publishConfig": {
180
180
  "access": "public"
181
181
  },
182
- "gitHead": "9ba5b22017f1c5d4255fd022b1c3cfcdcbc137f7"
182
+ "gitHead": "af44749c73185aa77fc58e463f82651aaa1e6e92"
183
183
  }
@@ -1,120 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
-
7
- var _dec, _class, _class2, _temp;
8
-
9
- /** @jsx jsx */
10
- import { Component } from 'react';
11
- import PropTypes from 'prop-types';
12
- import { TopNavBar } from '@instructure/ui-top-nav-bar';
13
- import { IconQuizLine } from '@instructure/ui-icons';
14
- import t from '@instructure/quiz-i18n/es/format-message';
15
- import { withStyle, jsx } from '@instructure/emotion';
16
- import generateStyle from "./styles.js";
17
- import generateComponentTheme from "./theme.js";
18
-
19
- var _ref = jsx(IconQuizLine, {
20
- color: "primary",
21
- size: "small"
22
- });
23
-
24
- export var NavBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
25
- _inherits(NavBar, _Component);
26
-
27
- var _super = _createSuper(NavBar);
28
-
29
- function NavBar() {
30
- var _this;
31
-
32
- _classCallCheck(this, NavBar);
33
-
34
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
- args[_key] = arguments[_key];
36
- }
37
-
38
- _this = _super.call.apply(_super, [this].concat(args));
39
-
40
- _this.hiddenActionItemsMenuTriggerLabel = function (hiddenChildrenCount) {
41
- return t('{hiddenChildrenCount} more actions', {
42
- hiddenChildrenCount: hiddenChildrenCount
43
- });
44
- };
45
-
46
- _this.hiddenMenuItemsMenuTriggerLabel = function (hiddenChildrenCount) {
47
- return t('{hiddenChildrenCount} More', {
48
- hiddenChildrenCount: hiddenChildrenCount
49
- });
50
- };
51
-
52
- return _this;
53
- }
54
-
55
- _createClass(NavBar, [{
56
- key: "render",
57
- value: function render() {
58
- var _this2 = this;
59
-
60
- return jsx(TopNavBar, {
61
- breakpoint: this.props.styles.phoneBreakPoint,
62
- mediaQueryMatch: "element",
63
- inverseColor: true
64
- }, function () {
65
- return jsx(TopNavBar.Layout, {
66
- themeOverride: {
67
- desktopBackgroundInverse: _this2.props.styles.backgroundColor,
68
- smallViewportBackgroundInverse: _this2.props.styles.backgroundColor
69
- },
70
- navLabel: t('Quizzes navigation bar'),
71
- desktopConfig: {
72
- hideActionsUserSeparator: true
73
- },
74
- smallViewportConfig: {
75
- dropdownMenuToggleButtonLabel: t('Toggle Menu'),
76
- dropdownMenuLabel: t('Main Menu')
77
- },
78
- renderBrand: jsx(TopNavBar.Brand, {
79
- screenReaderLabel: t('Quizzes'),
80
- renderIcon: _ref
81
- }),
82
- renderMenuItems: jsx(TopNavBar.MenuItems, {
83
- listLabel: t('Page navigation'),
84
- currentPageId: window.location.pathname,
85
- renderHiddenItemsMenuTriggerLabel: _this2.hiddenMenuItemsMenuTriggerLabel
86
- }, _this2.props.menuItems.map(function (menuItem) {
87
- return jsx(TopNavBar.Item, {
88
- id: menuItem.path,
89
- key: menuItem.path,
90
- onClick: function onClick() {
91
- return _this2.props.handleMenuItemChange(menuItem.path);
92
- } // eslint-disable-line react/jsx-no-bind
93
-
94
- }, menuItem.text);
95
- })),
96
- renderActionItems: jsx(TopNavBar.ActionItems, {
97
- listLabel: t('Actions'),
98
- renderHiddenItemsMenuTriggerLabel: _this2.hiddenActionItemsMenuTriggerLabel
99
- }, _toConsumableArray(_this2.props.actionItems))
100
- });
101
- });
102
- }
103
- }]);
104
-
105
- NavBar.displayName = "NavBar";
106
- return NavBar;
107
- }(Component), _class2.propTypes = {
108
- menuItems: PropTypes.arrayOf(PropTypes.shape({
109
- path: PropTypes.string.isRequired,
110
- text: PropTypes.string.isRequired
111
- })),
112
- handleMenuItemChange: PropTypes.func,
113
- actionItems: PropTypes.arrayOf(PropTypes.node),
114
- styles: PropTypes.object
115
- }, _class2.defaultProps = {
116
- menuItems: [],
117
- handleMenuItemChange: function handleMenuItemChange() {},
118
- actionItems: []
119
- }, _temp)) || _class);
120
- export default NavBar;
@@ -1,140 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.NavBar = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
-
20
- var _react = require("react");
21
-
22
- var _propTypes = _interopRequireDefault(require("prop-types"));
23
-
24
- var _uiTopNavBar = require("@instructure/ui-top-nav-bar");
25
-
26
- var _uiIcons = require("@instructure/ui-icons");
27
-
28
- var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
29
-
30
- var _emotion = require("@instructure/emotion");
31
-
32
- var _styles = _interopRequireDefault(require("./styles.js"));
33
-
34
- var _theme = _interopRequireDefault(require("./theme.js"));
35
-
36
- var _dec, _class, _class2, _temp;
37
-
38
- var _ref = (0, _emotion.jsx)(_uiIcons.IconQuizLine, {
39
- color: "primary",
40
- size: "small"
41
- });
42
-
43
- var NavBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) {
44
- (0, _inherits2.default)(NavBar, _Component);
45
-
46
- var _super = (0, _createSuper2.default)(NavBar);
47
-
48
- function NavBar() {
49
- var _this;
50
-
51
- (0, _classCallCheck2.default)(this, NavBar);
52
-
53
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
- args[_key] = arguments[_key];
55
- }
56
-
57
- _this = _super.call.apply(_super, [this].concat(args));
58
-
59
- _this.hiddenActionItemsMenuTriggerLabel = function (hiddenChildrenCount) {
60
- return (0, _formatMessage.default)('{hiddenChildrenCount} more actions', {
61
- hiddenChildrenCount: hiddenChildrenCount
62
- });
63
- };
64
-
65
- _this.hiddenMenuItemsMenuTriggerLabel = function (hiddenChildrenCount) {
66
- return (0, _formatMessage.default)('{hiddenChildrenCount} More', {
67
- hiddenChildrenCount: hiddenChildrenCount
68
- });
69
- };
70
-
71
- return _this;
72
- }
73
-
74
- (0, _createClass2.default)(NavBar, [{
75
- key: "render",
76
- value: function render() {
77
- var _this2 = this;
78
-
79
- return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar, {
80
- breakpoint: this.props.styles.phoneBreakPoint,
81
- mediaQueryMatch: "element",
82
- inverseColor: true
83
- }, function () {
84
- return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Layout, {
85
- themeOverride: {
86
- desktopBackgroundInverse: _this2.props.styles.backgroundColor,
87
- smallViewportBackgroundInverse: _this2.props.styles.backgroundColor
88
- },
89
- navLabel: (0, _formatMessage.default)('Quizzes navigation bar'),
90
- desktopConfig: {
91
- hideActionsUserSeparator: true
92
- },
93
- smallViewportConfig: {
94
- dropdownMenuToggleButtonLabel: (0, _formatMessage.default)('Toggle Menu'),
95
- dropdownMenuLabel: (0, _formatMessage.default)('Main Menu')
96
- },
97
- renderBrand: (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Brand, {
98
- screenReaderLabel: (0, _formatMessage.default)('Quizzes'),
99
- renderIcon: _ref
100
- }),
101
- renderMenuItems: (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.MenuItems, {
102
- listLabel: (0, _formatMessage.default)('Page navigation'),
103
- currentPageId: window.location.pathname,
104
- renderHiddenItemsMenuTriggerLabel: _this2.hiddenMenuItemsMenuTriggerLabel
105
- }, _this2.props.menuItems.map(function (menuItem) {
106
- return (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.Item, {
107
- id: menuItem.path,
108
- key: menuItem.path,
109
- onClick: function onClick() {
110
- return _this2.props.handleMenuItemChange(menuItem.path);
111
- } // eslint-disable-line react/jsx-no-bind
112
-
113
- }, menuItem.text);
114
- })),
115
- renderActionItems: (0, _emotion.jsx)(_uiTopNavBar.TopNavBar.ActionItems, {
116
- listLabel: (0, _formatMessage.default)('Actions'),
117
- renderHiddenItemsMenuTriggerLabel: _this2.hiddenActionItemsMenuTriggerLabel
118
- }, (0, _toConsumableArray2.default)(_this2.props.actionItems))
119
- });
120
- });
121
- }
122
- }]);
123
- NavBar.displayName = "NavBar";
124
- return NavBar;
125
- }(_react.Component), _class2.propTypes = {
126
- menuItems: _propTypes.default.arrayOf(_propTypes.default.shape({
127
- path: _propTypes.default.string.isRequired,
128
- text: _propTypes.default.string.isRequired
129
- })),
130
- handleMenuItemChange: _propTypes.default.func,
131
- actionItems: _propTypes.default.arrayOf(_propTypes.default.node),
132
- styles: _propTypes.default.object
133
- }, _class2.defaultProps = {
134
- menuItems: [],
135
- handleMenuItemChange: function handleMenuItemChange() {},
136
- actionItems: []
137
- }, _temp)) || _class);
138
- exports.NavBar = NavBar;
139
- var _default = NavBar;
140
- exports.default = _default;