From 6a76c71b7da1618ea6d5a11544e783af925cdc2d Mon Sep 17 00:00:00 2001 From: PKulkoRaccoonGang Date: Sat, 29 Jun 2024 23:43:08 +0300 Subject: [PATCH] refactor: added dist folder --- .gitignore | 4 +- dist/Avatar.js | 43 ++ dist/Avatar.js.map | 1 + dist/DesktopHeader.js | 241 ++++++++++ dist/DesktopHeader.js.map | 1 + dist/Header.js | 125 +++++ dist/Header.js.map | 1 + dist/Header.messages.js | 115 +++++ dist/Header.messages.js.map | 1 + dist/Header.test.jsx | 104 ++++ dist/Icons.js | 52 ++ dist/Icons.js.map | 1 + dist/Logo.js | 41 ++ dist/Logo.js.map | 1 + dist/Menu/Menu.js | 321 +++++++++++++ dist/Menu/Menu.js.map | 1 + dist/Menu/index.js | 3 + dist/Menu/index.js.map | 1 + dist/Menu/menu.scss | 45 ++ dist/MobileHeader.js | 250 ++++++++++ dist/MobileHeader.js.map | 1 + dist/__snapshots__/Header.test.jsx.snap | 445 ++++++++++++++++++ dist/generic/messages.js | 15 + dist/generic/messages.js.map | 1 + dist/i18n/index.js | 2 + dist/i18n/index.js.map | 1 + dist/index.js | 7 + dist/index.js.map | 1 + dist/index.scss | 134 ++++++ dist/learning-header/AnonymousUserMenu.js | 22 + dist/learning-header/AnonymousUserMenu.js.map | 1 + .../AuthenticatedUserDropdown.js | 46 ++ .../AuthenticatedUserDropdown.js.map | 1 + dist/learning-header/LearningHeader.js | 79 ++++ dist/learning-header/LearningHeader.js.map | 1 + dist/learning-header/messages.js | 40 ++ dist/learning-header/messages.js.map | 1 + dist/setupTest.js | 125 +++++ dist/studio-header/BrandNav.js | 21 + dist/studio-header/BrandNav.js.map | 1 + dist/studio-header/CourseLockUp.js | 45 ++ dist/studio-header/CourseLockUp.js.map | 1 + dist/studio-header/HeaderBody.js | 131 ++++++ dist/studio-header/HeaderBody.js.map | 1 + dist/studio-header/MobileHeader.js | 79 ++++ dist/studio-header/MobileHeader.js.map | 1 + dist/studio-header/MobileMenu.js | 45 ++ dist/studio-header/MobileMenu.js.map | 1 + dist/studio-header/NavDropdownMenu.js | 30 ++ dist/studio-header/NavDropdownMenu.js.map | 1 + dist/studio-header/StudioHeader.js | 72 +++ dist/studio-header/StudioHeader.js.map | 1 + dist/studio-header/StudioHeader.scss | 46 ++ dist/studio-header/UserMenu.js | 55 +++ dist/studio-header/UserMenu.js.map | 1 + dist/studio-header/index.js | 3 + dist/studio-header/index.js.map | 1 + dist/studio-header/messages.js | 60 +++ dist/studio-header/messages.js.map | 1 + dist/studio-header/utils.js | 29 ++ dist/studio-header/utils.js.map | 1 + dist/test-utils.js | 26 + dist/test-utils.js.map | 1 + 63 files changed, 2927 insertions(+), 2 deletions(-) create mode 100644 dist/Avatar.js create mode 100644 dist/Avatar.js.map create mode 100644 dist/DesktopHeader.js create mode 100644 dist/DesktopHeader.js.map create mode 100644 dist/Header.js create mode 100644 dist/Header.js.map create mode 100644 dist/Header.messages.js create mode 100644 dist/Header.messages.js.map create mode 100644 dist/Header.test.jsx create mode 100644 dist/Icons.js create mode 100644 dist/Icons.js.map create mode 100644 dist/Logo.js create mode 100644 dist/Logo.js.map create mode 100644 dist/Menu/Menu.js create mode 100644 dist/Menu/Menu.js.map create mode 100644 dist/Menu/index.js create mode 100644 dist/Menu/index.js.map create mode 100644 dist/Menu/menu.scss create mode 100644 dist/MobileHeader.js create mode 100644 dist/MobileHeader.js.map create mode 100644 dist/__snapshots__/Header.test.jsx.snap create mode 100644 dist/generic/messages.js create mode 100644 dist/generic/messages.js.map create mode 100644 dist/i18n/index.js create mode 100644 dist/i18n/index.js.map create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/index.scss create mode 100644 dist/learning-header/AnonymousUserMenu.js create mode 100644 dist/learning-header/AnonymousUserMenu.js.map create mode 100644 dist/learning-header/AuthenticatedUserDropdown.js create mode 100644 dist/learning-header/AuthenticatedUserDropdown.js.map create mode 100644 dist/learning-header/LearningHeader.js create mode 100644 dist/learning-header/LearningHeader.js.map create mode 100644 dist/learning-header/messages.js create mode 100644 dist/learning-header/messages.js.map create mode 100644 dist/setupTest.js create mode 100644 dist/studio-header/BrandNav.js create mode 100644 dist/studio-header/BrandNav.js.map create mode 100644 dist/studio-header/CourseLockUp.js create mode 100644 dist/studio-header/CourseLockUp.js.map create mode 100644 dist/studio-header/HeaderBody.js create mode 100644 dist/studio-header/HeaderBody.js.map create mode 100644 dist/studio-header/MobileHeader.js create mode 100644 dist/studio-header/MobileHeader.js.map create mode 100644 dist/studio-header/MobileMenu.js create mode 100644 dist/studio-header/MobileMenu.js.map create mode 100644 dist/studio-header/NavDropdownMenu.js create mode 100644 dist/studio-header/NavDropdownMenu.js.map create mode 100644 dist/studio-header/StudioHeader.js create mode 100644 dist/studio-header/StudioHeader.js.map create mode 100644 dist/studio-header/StudioHeader.scss create mode 100644 dist/studio-header/UserMenu.js create mode 100644 dist/studio-header/UserMenu.js.map create mode 100644 dist/studio-header/index.js create mode 100644 dist/studio-header/index.js.map create mode 100644 dist/studio-header/messages.js create mode 100644 dist/studio-header/messages.js.map create mode 100644 dist/studio-header/utils.js create mode 100644 dist/studio-header/utils.js.map create mode 100644 dist/test-utils.js create mode 100644 dist/test-utils.js.map diff --git a/.gitignore b/.gitignore index 9e0934673..eab69194a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .cache .DS_Store coverage -dist +# dist node_modules temp src/i18n/transifex_input.json @@ -9,4 +9,4 @@ module.config.js .idea/ .vscode -src/i18n/messages \ No newline at end of file +src/i18n/messages diff --git a/dist/Avatar.js b/dist/Avatar.js new file mode 100644 index 000000000..eecef4191 --- /dev/null +++ b/dist/Avatar.js @@ -0,0 +1,43 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { AvatarIcon } from './Icons'; +var Avatar = function Avatar(_ref) { + var size = _ref.size, + src = _ref.src, + alt = _ref.alt, + className = _ref.className; + var avatar = src ? /*#__PURE__*/React.createElement("img", { + className: "d-block w-100 h-100", + src: src, + alt: alt + }) : /*#__PURE__*/React.createElement(AvatarIcon, { + style: { + width: size, + height: size + }, + role: "img", + "aria-hidden": true, + focusable: "false" + }); + return /*#__PURE__*/React.createElement("span", { + style: { + height: size, + width: size + }, + className: "avatar overflow-hidden d-inline-flex rounded-circle ".concat(className) + }, avatar); +}; +Avatar.propTypes = { + src: PropTypes.string, + size: PropTypes.string, + alt: PropTypes.string, + className: PropTypes.string +}; +Avatar.defaultProps = { + src: null, + size: '2rem', + alt: null, + className: null +}; +export default Avatar; +//# sourceMappingURL=Avatar.js.map \ No newline at end of file diff --git a/dist/Avatar.js.map b/dist/Avatar.js.map new file mode 100644 index 000000000..667a29fa8 --- /dev/null +++ b/dist/Avatar.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Avatar.js","names":["React","PropTypes","AvatarIcon","Avatar","_ref","size","src","alt","className","avatar","createElement","style","width","height","role","focusable","concat","propTypes","string","defaultProps"],"sources":["../src/Avatar.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { AvatarIcon } from './Icons';\n\nconst Avatar = ({\n size,\n src,\n alt,\n className,\n}) => {\n const avatar = src ? (\n {alt}\n ) : (\n \n );\n\n return (\n \n {avatar}\n \n );\n};\n\nAvatar.propTypes = {\n src: PropTypes.string,\n size: PropTypes.string,\n alt: PropTypes.string,\n className: PropTypes.string,\n};\n\nAvatar.defaultProps = {\n src: null,\n size: '2rem',\n alt: null,\n className: null,\n};\n\nexport default Avatar;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,UAAU,QAAQ,SAAS;AAEpC,IAAMC,MAAM,GAAG,SAATA,MAAMA,CAAAC,IAAA,EAKN;EAAA,IAJJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,GAAG,GAAAH,IAAA,CAAHG,GAAG;IACHC,SAAS,GAAAJ,IAAA,CAATI,SAAS;EAET,IAAMC,MAAM,GAAGH,GAAG,gBAChBN,KAAA,CAAAU,aAAA;IAAKF,SAAS,EAAC,qBAAqB;IAACF,GAAG,EAAEA,GAAI;IAACC,GAAG,EAAEA;EAAI,CAAE,CAAC,gBAE3DP,KAAA,CAAAU,aAAA,CAACR,UAAU;IAACS,KAAK,EAAE;MAAEC,KAAK,EAAEP,IAAI;MAAEQ,MAAM,EAAER;IAAK,CAAE;IAACS,IAAI,EAAC,KAAK;IAAC,mBAAW;IAACC,SAAS,EAAC;EAAO,CAAE,CAC7F;EAED,oBACEf,KAAA,CAAAU,aAAA;IACEC,KAAK,EAAE;MAAEE,MAAM,EAAER,IAAI;MAAEO,KAAK,EAAEP;IAAK,CAAE;IACrCG,SAAS,yDAAAQ,MAAA,CAAyDR,SAAS;EAAG,GAE7EC,MACG,CAAC;AAEX,CAAC;AAEDN,MAAM,CAACc,SAAS,GAAG;EACjBX,GAAG,EAAEL,SAAS,CAACiB,MAAM;EACrBb,IAAI,EAAEJ,SAAS,CAACiB,MAAM;EACtBX,GAAG,EAAEN,SAAS,CAACiB,MAAM;EACrBV,SAAS,EAAEP,SAAS,CAACiB;AACvB,CAAC;AAEDf,MAAM,CAACgB,YAAY,GAAG;EACpBb,GAAG,EAAE,IAAI;EACTD,IAAI,EAAE,MAAM;EACZE,GAAG,EAAE,IAAI;EACTC,SAAS,EAAE;AACb,CAAC;AAED,eAAeL,MAAM","ignoreList":[]} \ No newline at end of file diff --git a/dist/DesktopHeader.js b/dist/DesktopHeader.js new file mode 100644 index 000000000..63c67160f --- /dev/null +++ b/dist/DesktopHeader.js @@ -0,0 +1,241 @@ +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +import React from 'react'; +import PropTypes from 'prop-types'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { getConfig } from '@edx/frontend-platform'; + +// Local Components +import { Menu, MenuTrigger, MenuContent } from './Menu'; +import Avatar from './Avatar'; +import { LinkedLogo, Logo } from './Logo'; + +// i18n +import messages from './Header.messages'; + +// Assets +import { CaretIcon } from './Icons'; +var DesktopHeader = /*#__PURE__*/function (_React$Component) { + function DesktopHeader(props) { + _classCallCheck(this, DesktopHeader); + // eslint-disable-line no-useless-constructor + return _callSuper(this, DesktopHeader, [props]); + } + _inherits(DesktopHeader, _React$Component); + return _createClass(DesktopHeader, [{ + key: "renderMenu", + value: function renderMenu(menu) { + // Nodes are accepted as a prop + if (!Array.isArray(menu)) { + return menu; + } + return menu.map(function (menuItem) { + var type = menuItem.type, + href = menuItem.href, + content = menuItem.content, + submenuContent = menuItem.submenuContent, + disabled = menuItem.disabled, + isActive = menuItem.isActive, + onClick = menuItem.onClick; + if (type === 'item') { + return /*#__PURE__*/React.createElement("a", { + key: "".concat(type, "-").concat(content), + className: "nav-link".concat(disabled ? ' disabled' : '').concat(isActive ? ' active' : ''), + href: href, + onClick: onClick || null + }, content); + } + return /*#__PURE__*/React.createElement(Menu, { + key: "".concat(type, "-").concat(content), + tag: "div", + className: "nav-item", + respondToPointerEvents: true + }, /*#__PURE__*/React.createElement(MenuTrigger, { + onClick: onClick || null, + tag: "a", + className: "nav-link d-inline-flex align-items-center", + href: href + }, content, " ", /*#__PURE__*/React.createElement(CaretIcon, { + role: "img", + "aria-hidden": true, + focusable: "false" + })), /*#__PURE__*/React.createElement(MenuContent, { + className: "pin-left pin-right shadow py-2" + }, submenuContent)); + }); + } + }, { + key: "renderMainMenu", + value: function renderMainMenu() { + var mainMenu = this.props.mainMenu; + return this.renderMenu(mainMenu); + } + }, { + key: "renderSecondaryMenu", + value: function renderSecondaryMenu() { + var secondaryMenu = this.props.secondaryMenu; + return this.renderMenu(secondaryMenu); + } + }, { + key: "renderUserMenu", + value: function renderUserMenu() { + var _this$props = this.props, + userMenu = _this$props.userMenu, + avatar = _this$props.avatar, + username = _this$props.username, + intl = _this$props.intl; + return /*#__PURE__*/React.createElement(Menu, { + transitionClassName: "menu-dropdown", + transitionTimeout: 250 + }, /*#__PURE__*/React.createElement(MenuTrigger, { + tag: "button", + "aria-label": intl.formatMessage(messages['header.label.account.menu.for'], { + username: username + }), + className: "btn btn-outline-primary d-inline-flex align-items-center pl-2 pr-3" + }, /*#__PURE__*/React.createElement(Avatar, { + size: "1.5em", + src: avatar, + alt: "", + className: "mr-2" + }), username, " ", /*#__PURE__*/React.createElement(CaretIcon, { + role: "img", + "aria-hidden": true, + focusable: "false" + })), /*#__PURE__*/React.createElement(MenuContent, { + className: "mb-0 dropdown-menu show dropdown-menu-right pin-right shadow py-2" + }, userMenu.map(function (group, index) { + return ( + /*#__PURE__*/ + // eslint-disable-next-line react/jsx-no-comment-textnodes,react/no-array-index-key + React.createElement(React.Fragment, { + key: index + }, group.heading && /*#__PURE__*/React.createElement("div", { + className: "dropdown-header", + role: "heading", + "aria-level": "1" + }, group.heading), group.items.map(function (_ref) { + var type = _ref.type, + content = _ref.content, + href = _ref.href, + disabled = _ref.disabled, + isActive = _ref.isActive, + onClick = _ref.onClick; + return /*#__PURE__*/React.createElement("a", { + className: "dropdown-".concat(type).concat(isActive ? ' active' : '').concat(disabled ? ' disabled' : ''), + key: "".concat(type, "-").concat(content), + href: href, + onClick: onClick || null + }, content); + }), index < userMenu.length - 1 && /*#__PURE__*/React.createElement("div", { + className: "dropdown-divider", + role: "separator" + })) + ); + }))); + } + }, { + key: "renderLoggedOutItems", + value: function renderLoggedOutItems() { + var loggedOutItems = this.props.loggedOutItems; + return loggedOutItems.map(function (item, i, arr) { + return /*#__PURE__*/React.createElement("a", { + key: "".concat(item.type, "-").concat(item.content), + className: i < arr.length - 1 ? 'btn mr-2 btn-link' : 'btn mr-2 btn-outline-primary', + href: item.href + }, item.content); + }); + } + }, { + key: "render", + value: function render() { + var _this$props2 = this.props, + logo = _this$props2.logo, + logoAltText = _this$props2.logoAltText, + logoDestination = _this$props2.logoDestination, + loggedIn = _this$props2.loggedIn, + intl = _this$props2.intl; + var logoProps = { + src: logo, + alt: logoAltText, + href: logoDestination + }; + var logoClasses = getConfig().AUTHN_MINIMAL_HEADER ? 'mw-100' : null; + return /*#__PURE__*/React.createElement("header", { + className: "site-header-desktop" + }, /*#__PURE__*/React.createElement("a", { + className: "nav-skip sr-only sr-only-focusable", + href: "#main" + }, intl.formatMessage(messages['header.label.skip.nav'])), /*#__PURE__*/React.createElement("div", { + className: "container-fluid ".concat(logoClasses) + }, /*#__PURE__*/React.createElement("div", { + className: "nav-container position-relative d-flex align-items-center" + }, logoDestination === null ? /*#__PURE__*/React.createElement(Logo, { + className: "logo", + src: logo, + alt: logoAltText + }) : /*#__PURE__*/React.createElement(LinkedLogo, _extends({ + className: "logo" + }, logoProps)), /*#__PURE__*/React.createElement("nav", { + "aria-label": intl.formatMessage(messages['header.label.main.nav']), + className: "nav main-nav" + }, this.renderMainMenu()), /*#__PURE__*/React.createElement("nav", { + "aria-label": intl.formatMessage(messages['header.label.secondary.nav']), + className: "nav secondary-menu-container align-items-center ml-auto" + }, loggedIn ? /*#__PURE__*/React.createElement(React.Fragment, null, this.renderSecondaryMenu(), this.renderUserMenu()) : this.renderLoggedOutItems())))); + } + }]); +}(React.Component); +DesktopHeader.propTypes = { + mainMenu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + secondaryMenu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + userMenu: PropTypes.arrayOf(PropTypes.shape({ + heading: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.oneOf(['item', 'menu']), + href: PropTypes.string, + content: PropTypes.string, + isActive: PropTypes.bool, + onClick: PropTypes.func + })) + })), + loggedOutItems: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.oneOf(['item', 'menu']), + href: PropTypes.string, + content: PropTypes.string + })), + logo: PropTypes.string, + logoAltText: PropTypes.string, + logoDestination: PropTypes.string, + avatar: PropTypes.string, + username: PropTypes.string, + loggedIn: PropTypes.bool, + // i18n + intl: intlShape.isRequired +}; +DesktopHeader.defaultProps = { + mainMenu: [], + secondaryMenu: [], + userMenu: [], + loggedOutItems: [], + logo: null, + logoAltText: null, + logoDestination: null, + avatar: null, + username: null, + loggedIn: false +}; +export default injectIntl(DesktopHeader); +//# sourceMappingURL=DesktopHeader.js.map \ No newline at end of file diff --git a/dist/DesktopHeader.js.map b/dist/DesktopHeader.js.map new file mode 100644 index 000000000..8d728e965 --- /dev/null +++ b/dist/DesktopHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DesktopHeader.js","names":["React","PropTypes","injectIntl","intlShape","getConfig","Menu","MenuTrigger","MenuContent","Avatar","LinkedLogo","Logo","messages","CaretIcon","DesktopHeader","_React$Component","props","_classCallCheck","_callSuper","_inherits","_createClass","key","value","renderMenu","menu","Array","isArray","map","menuItem","type","href","content","submenuContent","disabled","isActive","onClick","createElement","concat","className","tag","respondToPointerEvents","role","focusable","renderMainMenu","mainMenu","renderSecondaryMenu","secondaryMenu","renderUserMenu","_this$props","userMenu","avatar","username","intl","transitionClassName","transitionTimeout","formatMessage","size","src","alt","group","index","Fragment","heading","items","_ref","length","renderLoggedOutItems","loggedOutItems","item","i","arr","render","_this$props2","logo","logoAltText","logoDestination","loggedIn","logoProps","logoClasses","AUTHN_MINIMAL_HEADER","_extends","Component","propTypes","oneOfType","node","array","arrayOf","shape","string","oneOf","bool","func","isRequired","defaultProps"],"sources":["../src/DesktopHeader.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { getConfig } from '@edx/frontend-platform';\n\n// Local Components\nimport { Menu, MenuTrigger, MenuContent } from './Menu';\nimport Avatar from './Avatar';\nimport { LinkedLogo, Logo } from './Logo';\n\n// i18n\nimport messages from './Header.messages';\n\n// Assets\nimport { CaretIcon } from './Icons';\n\nclass DesktopHeader extends React.Component {\n constructor(props) { // eslint-disable-line no-useless-constructor\n super(props);\n }\n\n renderMenu(menu) {\n // Nodes are accepted as a prop\n if (!Array.isArray(menu)) {\n return menu;\n }\n\n return menu.map((menuItem) => {\n const {\n type,\n href,\n content,\n submenuContent,\n disabled,\n isActive,\n onClick,\n } = menuItem;\n\n if (type === 'item') {\n return (\n \n {content}\n \n );\n }\n\n return (\n \n \n {content} \n \n \n {submenuContent}\n \n \n );\n });\n }\n\n renderMainMenu() {\n const { mainMenu } = this.props;\n return this.renderMenu(mainMenu);\n }\n\n renderSecondaryMenu() {\n const { secondaryMenu } = this.props;\n return this.renderMenu(secondaryMenu);\n }\n\n renderUserMenu() {\n const {\n userMenu,\n avatar,\n username,\n intl,\n } = this.props;\n\n return (\n \n \n \n {username} \n \n \n {userMenu.map((group, index) => (\n // eslint-disable-next-line react/jsx-no-comment-textnodes,react/no-array-index-key\n \n {group.heading &&
{group.heading}
}\n {group.items.map(({\n type, content, href, disabled, isActive, onClick,\n }) => (\n \n {content}\n \n ))}\n {index < userMenu.length - 1 &&
}\n \n ))}\n \n
\n );\n }\n\n renderLoggedOutItems() {\n const { loggedOutItems } = this.props;\n\n return loggedOutItems.map((item, i, arr) => (\n \n {item.content}\n \n ));\n }\n\n render() {\n const {\n logo,\n logoAltText,\n logoDestination,\n loggedIn,\n intl,\n } = this.props;\n const logoProps = { src: logo, alt: logoAltText, href: logoDestination };\n const logoClasses = getConfig().AUTHN_MINIMAL_HEADER ? 'mw-100' : null;\n\n return (\n
\n {intl.formatMessage(messages['header.label.skip.nav'])}\n
\n
\n {logoDestination === null ? : }\n \n {this.renderMainMenu()}\n \n \n {loggedIn\n ? (\n <>\n {this.renderSecondaryMenu()}\n {this.renderUserMenu()}\n \n ) : this.renderLoggedOutItems()}\n \n
\n
\n
\n );\n }\n}\n\nDesktopHeader.propTypes = {\n mainMenu: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n secondaryMenu: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n userMenu: PropTypes.arrayOf(PropTypes.shape({\n heading: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n type: PropTypes.oneOf(['item', 'menu']),\n href: PropTypes.string,\n content: PropTypes.string,\n isActive: PropTypes.bool,\n onClick: PropTypes.func,\n })),\n })),\n loggedOutItems: PropTypes.arrayOf(PropTypes.shape({\n type: PropTypes.oneOf(['item', 'menu']),\n href: PropTypes.string,\n content: PropTypes.string,\n })),\n logo: PropTypes.string,\n logoAltText: PropTypes.string,\n logoDestination: PropTypes.string,\n avatar: PropTypes.string,\n username: PropTypes.string,\n loggedIn: PropTypes.bool,\n\n // i18n\n intl: intlShape.isRequired,\n};\n\nDesktopHeader.defaultProps = {\n mainMenu: [],\n secondaryMenu: [],\n userMenu: [],\n loggedOutItems: [],\n logo: null,\n logoAltText: null,\n logoDestination: null,\n avatar: null,\n username: null,\n loggedIn: false,\n};\n\nexport default injectIntl(DesktopHeader);\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,SAAS,QAAQ,wBAAwB;;AAElD;AACA,SAASC,IAAI,EAAEC,WAAW,EAAEC,WAAW,QAAQ,QAAQ;AACvD,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,UAAU,EAAEC,IAAI,QAAQ,QAAQ;;AAEzC;AACA,OAAOC,QAAQ,MAAM,mBAAmB;;AAExC;AACA,SAASC,SAAS,QAAQ,SAAS;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O,EAAE7B,SAAS,CAACsF;EACrB,CAAC,CAAC,CAAC;EACHf,IAAI,EAAEvE,SAAS,CAACsF,MAAM;EACtBd,WAAW,EAAExE,SAAS,CAACsF,MAAM;EAC7Bb,eAAe,EAAEzE,SAAS,CAACsF,MAAM;EACjCtC,MAAM,EAAEhD,SAAS,CAACsF,MAAM;EACxBrC,QAAQ,EAAEjD,SAAS,CAACsF,MAAM;EAC1BZ,QAAQ,EAAE1E,SAAS,CAACwF,IAAI;EAExB;EACAtC,IAAI,EAAEhD,SAAS,CAACwF;AAClB,CAAC;AAED9E,aAAa,CAAC+E,YAAY,GAAG;EAC3BjD,QAAQ,EAAE,EAAE;EACZE,aAAa,EAAE,EAAE;EACjBG,QAAQ,EAAE,EAAE;EACZkB,cAAc,EAAE,EAAE;EAClBM,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,IAAI;EACjBC,eAAe,EAAE,IAAI;EACrBzB,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAE,IAAI;EACdyB,QAAQ,EAAE;AACZ,CAAC;AAED,eAAezE,UAAU,CAACW,aAAa,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/Header.js b/dist/Header.js new file mode 100644 index 000000000..e6ef09eab --- /dev/null +++ b/dist/Header.js @@ -0,0 +1,125 @@ +function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } +function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +import React, { useContext } from 'react'; +import Responsive from 'react-responsive'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { AppContext } from '@edx/frontend-platform/react'; +import { APP_CONFIG_INITIALIZED, ensureConfig, mergeConfig, getConfig, subscribe } from '@edx/frontend-platform'; +import PropTypes from 'prop-types'; +import DesktopHeader from './DesktopHeader'; +import MobileHeader from './MobileHeader'; +import messages from './Header.messages'; +ensureConfig(['LMS_BASE_URL', 'LOGOUT_URL', 'LOGIN_URL', 'SITE_NAME', 'LOGO_URL', 'ORDER_HISTORY_URL'], 'Header component'); +subscribe(APP_CONFIG_INITIALIZED, function () { + mergeConfig({ + AUTHN_MINIMAL_HEADER: !!process.env.AUTHN_MINIMAL_HEADER + }, 'Header additional config'); +}); + +/** + * Header component for the application. + * Displays a header with the provided main menu, secondary menu, and user menu when the user is authenticated. + * If any of the props (mainMenuItems, secondaryMenuItems, userMenuItems) are not provided, default + * items are displayed. + * For more details on how to use this component, please refer to this document: + * https://github.com/openedx/frontend-component-header/blob/master/docs/using_custom_header.rst + * + * @param {list} mainMenuItems - The list of main menu items to display. + * See the documentation for the structure of main menu item. + * @param {list} secondaryMenuItems - The list of secondary menu items to display. + * See the documentation for the structure of secondary menu item. + * @param {list} userMenuItems - The list of user menu items to display. + * See the documentation for the structure of user menu item. + */ +var Header = function Header(_ref) { + var intl = _ref.intl, + mainMenuItems = _ref.mainMenuItems, + secondaryMenuItems = _ref.secondaryMenuItems, + userMenuItems = _ref.userMenuItems; + var _useContext = useContext(AppContext), + authenticatedUser = _useContext.authenticatedUser, + config = _useContext.config; + var defaultMainMenu = [{ + type: 'item', + href: "".concat(config.LMS_BASE_URL, "/dashboard"), + content: intl.formatMessage(messages['header.links.courses']) + }]; + var defaultUserMenu = authenticatedUser === null ? [] : [{ + heading: '', + items: [{ + type: 'item', + href: "".concat(config.LMS_BASE_URL, "/dashboard"), + content: intl.formatMessage(messages['header.user.menu.dashboard']) + }, { + type: 'item', + href: "".concat(config.ACCOUNT_PROFILE_URL, "/u/").concat(authenticatedUser.username), + content: intl.formatMessage(messages['header.user.menu.profile']) + }, { + type: 'item', + href: config.ACCOUNT_SETTINGS_URL, + content: intl.formatMessage(messages['header.user.menu.account.settings']) + }].concat(_toConsumableArray(config.ORDER_HISTORY_URL ? [{ + type: 'item', + href: config.ORDER_HISTORY_URL, + content: intl.formatMessage(messages['header.user.menu.order.history']) + }] : []), [{ + type: 'item', + href: config.LOGOUT_URL, + content: intl.formatMessage(messages['header.user.menu.logout']) + }]) + }]; + var mainMenu = mainMenuItems || defaultMainMenu; + var secondaryMenu = secondaryMenuItems || []; + var userMenu = authenticatedUser === null ? [] : userMenuItems || defaultUserMenu; + var loggedOutItems = [{ + type: 'item', + href: config.LOGIN_URL, + content: intl.formatMessage(messages['header.user.menu.login']) + }, { + type: 'item', + href: "".concat(config.LMS_BASE_URL, "/register"), + content: intl.formatMessage(messages['header.user.menu.register']) + }]; + var props = { + logo: config.LOGO_URL, + logoAltText: config.SITE_NAME, + logoDestination: "".concat(config.LMS_BASE_URL, "/dashboard"), + loggedIn: authenticatedUser !== null, + username: authenticatedUser !== null ? authenticatedUser.username : null, + avatar: authenticatedUser !== null ? authenticatedUser.avatar : null, + mainMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : mainMenu, + secondaryMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : secondaryMenu, + userMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : userMenu, + loggedOutItems: getConfig().AUTHN_MINIMAL_HEADER ? [] : loggedOutItems + }; + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Responsive, { + maxWidth: 769 + }, /*#__PURE__*/React.createElement(MobileHeader, props)), /*#__PURE__*/React.createElement(Responsive, { + minWidth: 769 + }, /*#__PURE__*/React.createElement(DesktopHeader, props))); +}; +Header.defaultProps = { + mainMenuItems: null, + secondaryMenuItems: null, + userMenuItems: null +}; +Header.propTypes = { + intl: intlShape.isRequired, + mainMenuItems: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + secondaryMenuItems: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + userMenuItems: PropTypes.arrayOf(PropTypes.shape({ + heading: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.oneOf(['item', 'menu']), + href: PropTypes.string, + content: PropTypes.string, + isActive: PropTypes.bool + })) + })) +}; +export default injectIntl(Header); +//# sourceMappingURL=Header.js.map \ No newline at end of file diff --git a/dist/Header.js.map b/dist/Header.js.map new file mode 100644 index 000000000..849ee5ea2 --- /dev/null +++ b/dist/Header.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Header.js","names":["React","useContext","Responsive","injectIntl","intlShape","AppContext","APP_CONFIG_INITIALIZED","ensureConfig","mergeConfig","getConfig","subscribe","PropTypes","DesktopHeader","MobileHeader","messages","AUTHN_MINIMAL_HEADER","process","env","Header","_ref","intl","mainMenuItems","secondaryMenuItems","userMenuItems","_useContext","authenticatedUser","config","defaultMainMenu","type","href","concat","LMS_BASE_URL","content","formatMessage","defaultUserMenu","heading","items","ACCOUNT_PROFILE_URL","username","ACCOUNT_SETTINGS_URL","_toConsumableArray","ORDER_HISTORY_URL","LOGOUT_URL","mainMenu","secondaryMenu","userMenu","loggedOutItems","LOGIN_URL","props","logo","LOGO_URL","logoAltText","SITE_NAME","logoDestination","loggedIn","avatar","createElement","Fragment","maxWidth","minWidth","defaultProps","propTypes","isRequired","oneOfType","node","array","arrayOf","shape","string","oneOf","isActive","bool"],"sources":["../src/Header.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport Responsive from 'react-responsive';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { AppContext } from '@edx/frontend-platform/react';\nimport {\n APP_CONFIG_INITIALIZED,\n ensureConfig,\n mergeConfig,\n getConfig,\n subscribe,\n} from '@edx/frontend-platform';\n\nimport PropTypes from 'prop-types';\nimport DesktopHeader from './DesktopHeader';\nimport MobileHeader from './MobileHeader';\n\nimport messages from './Header.messages';\n\nensureConfig([\n 'LMS_BASE_URL',\n 'LOGOUT_URL',\n 'LOGIN_URL',\n 'SITE_NAME',\n 'LOGO_URL',\n 'ORDER_HISTORY_URL',\n], 'Header component');\n\nsubscribe(APP_CONFIG_INITIALIZED, () => {\n mergeConfig({\n AUTHN_MINIMAL_HEADER: !!process.env.AUTHN_MINIMAL_HEADER,\n }, 'Header additional config');\n});\n\n/**\n * Header component for the application.\n * Displays a header with the provided main menu, secondary menu, and user menu when the user is authenticated.\n * If any of the props (mainMenuItems, secondaryMenuItems, userMenuItems) are not provided, default\n * items are displayed.\n * For more details on how to use this component, please refer to this document:\n * https://github.com/openedx/frontend-component-header/blob/master/docs/using_custom_header.rst\n *\n * @param {list} mainMenuItems - The list of main menu items to display.\n * See the documentation for the structure of main menu item.\n * @param {list} secondaryMenuItems - The list of secondary menu items to display.\n * See the documentation for the structure of secondary menu item.\n * @param {list} userMenuItems - The list of user menu items to display.\n * See the documentation for the structure of user menu item.\n */\nconst Header = ({\n intl, mainMenuItems, secondaryMenuItems, userMenuItems,\n}) => {\n const { authenticatedUser, config } = useContext(AppContext);\n\n const defaultMainMenu = [\n {\n type: 'item',\n href: `${config.LMS_BASE_URL}/dashboard`,\n content: intl.formatMessage(messages['header.links.courses']),\n },\n ];\n const defaultUserMenu = authenticatedUser === null ? [] : [{\n heading: '',\n items: [\n {\n type: 'item',\n href: `${config.LMS_BASE_URL}/dashboard`,\n content: intl.formatMessage(messages['header.user.menu.dashboard']),\n },\n {\n type: 'item',\n href: `${config.ACCOUNT_PROFILE_URL}/u/${authenticatedUser.username}`,\n content: intl.formatMessage(messages['header.user.menu.profile']),\n },\n {\n type: 'item',\n href: config.ACCOUNT_SETTINGS_URL,\n content: intl.formatMessage(messages['header.user.menu.account.settings']),\n },\n // Users should only see Order History if have a ORDER_HISTORY_URL define in the environment.\n ...(config.ORDER_HISTORY_URL ? [{\n type: 'item',\n href: config.ORDER_HISTORY_URL,\n content: intl.formatMessage(messages['header.user.menu.order.history']),\n }] : []),\n {\n type: 'item',\n href: config.LOGOUT_URL,\n content: intl.formatMessage(messages['header.user.menu.logout']),\n },\n ],\n }];\n\n const mainMenu = mainMenuItems || defaultMainMenu;\n const secondaryMenu = secondaryMenuItems || [];\n const userMenu = authenticatedUser === null ? [] : userMenuItems || defaultUserMenu;\n\n const loggedOutItems = [\n {\n type: 'item',\n href: config.LOGIN_URL,\n content: intl.formatMessage(messages['header.user.menu.login']),\n },\n {\n type: 'item',\n href: `${config.LMS_BASE_URL}/register`,\n content: intl.formatMessage(messages['header.user.menu.register']),\n },\n ];\n\n const props = {\n logo: config.LOGO_URL,\n logoAltText: config.SITE_NAME,\n logoDestination: `${config.LMS_BASE_URL}/dashboard`,\n loggedIn: authenticatedUser !== null,\n username: authenticatedUser !== null ? authenticatedUser.username : null,\n avatar: authenticatedUser !== null ? authenticatedUser.avatar : null,\n mainMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : mainMenu,\n secondaryMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : secondaryMenu,\n userMenu: getConfig().AUTHN_MINIMAL_HEADER ? [] : userMenu,\n loggedOutItems: getConfig().AUTHN_MINIMAL_HEADER ? [] : loggedOutItems,\n };\n\n return (\n <>\n \n \n \n \n \n \n \n );\n};\n\nHeader.defaultProps = {\n mainMenuItems: null,\n secondaryMenuItems: null,\n userMenuItems: null,\n};\n\nHeader.propTypes = {\n intl: intlShape.isRequired,\n mainMenuItems: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n secondaryMenuItems: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n userMenuItems: PropTypes.arrayOf(PropTypes.shape({\n heading: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n type: PropTypes.oneOf(['item', 'menu']),\n href: PropTypes.string,\n content: PropTypes.string,\n isActive: PropTypes.bool,\n })),\n })),\n};\n\nexport default injectIntl(Header);\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,UAAU,QAAQ,8BAA8B;AACzD,SACEC,sBAAsB,EACtBC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,SAAS,QACJ,wBAAwB;AAE/B,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,OAAOC,QAAQ,MAAM,mBAAmB;AAExCP,YAAY,CAAC,CACX,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,mBAAmB,CACpB,EAAE,kBAAkB,CAAC;AAEtBG,SAAS,CAACJ,sBAAsB,EAAE,YAAM;EACtCE,WAAW,CAAC;IACVO,oBAAoB,EAAE,CAAC,CAACC,OAAO,CAACC,GAAG,CAACF;EACtC,CAAC,EAAE,0BAA0B,CAAC;AAChC,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMG,MAAM,GAAG,SAATA,MAAMA,CAAAC,IAAA,EAEN;EAAA,IADJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IAAEC,aAAa,GAAAF,IAAA,CAAbE,aAAa;IAAEC,kBAAkB,GAAAH,IAAA,CAAlBG,kBAAkB;IAAEC,aAAa,GAAAJ,IAAA,CAAbI,aAAa;EAEtD,IAAAC,WAAA,GAAsCvB,UAAU,CAACI,UAAU,CAAC;IAApDoB,iBAAiB,GAAAD,WAAA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AM;MACtBpC,OAAO,EAAErB,SAAS,CAACyD,MAAM;MACzBE,QAAQ,EAAE3D,SAAS,CAAC4D;IACtB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC;AAED,eAAepE,UAAU,CAACe,MAAM,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/Header.messages.js b/dist/Header.messages.js new file mode 100644 index 000000000..4aac3e8fd --- /dev/null +++ b/dist/Header.messages.js @@ -0,0 +1,115 @@ +import { defineMessages } from '@edx/frontend-platform/i18n'; +var messages = defineMessages({ + 'header.links.courses': { + id: 'header.links.courses', + defaultMessage: 'Courses', + description: 'Link to the learner course dashboard' + }, + 'header.links.programs': { + id: 'header.links.programs', + defaultMessage: 'Programs', + description: 'Link to the learner program dashboard' + }, + 'header.links.content.search': { + id: 'header.links.content.search', + defaultMessage: 'Discover New', + description: 'Link to the content search page' + }, + 'header.links.schools': { + id: 'header.links.schools', + defaultMessage: 'Schools & Partners', + description: 'Link to the schools and partners landing page' + }, + 'header.user.menu.dashboard': { + id: 'header.user.menu.dashboard', + defaultMessage: 'Dashboard', + description: 'Link to the user dashboard' + }, + 'header.user.menu.profile': { + id: 'header.user.menu.profile', + defaultMessage: 'Profile', + description: 'Link to the user profile' + }, + 'header.user.menu.account.settings': { + id: 'header.user.menu.account.settings', + defaultMessage: 'Account', + description: 'Link to account settings' + }, + 'header.user.menu.order.history': { + id: 'header.user.menu.order.history', + defaultMessage: 'Order History', + description: 'Link to order history' + }, + 'header.user.menu.logout': { + id: 'header.user.menu.logout', + defaultMessage: 'Logout', + description: 'Logout link' + }, + 'header.user.menu.login': { + id: 'header.user.menu.login', + defaultMessage: 'Login', + description: 'Login link' + }, + 'header.user.menu.register': { + id: 'header.user.menu.register', + defaultMessage: 'Sign Up', + description: 'Link to registration' + }, + 'header.user.menu.studio.home': { + id: 'header.user.menu.studio.home', + defaultMessage: 'Studio Home', + description: 'Link to the Studio Home' + }, + 'header.user.menu.studio.maintenance': { + id: 'header.user.menu.studio.maintenance', + defaultMessage: 'Maintenance', + description: 'Link to the Studio Maintenance' + }, + 'header.label.account.nav': { + id: 'header.label.account.nav', + defaultMessage: 'Account', + description: 'The aria label for the account menu nav' + }, + 'header.label.account.menu': { + id: 'header.label.account.menu', + defaultMessage: 'Account Menu', + description: 'The aria label for the account menu trigger' + }, + 'header.label.account.menu.for': { + id: 'header.label.account.menu.for', + defaultMessage: 'Account menu for {username}', + description: 'The aria label for the account menu trigger when the username is displayed in it' + }, + 'header.label.main.nav': { + id: 'header.label.main.nav', + defaultMessage: 'Main', + description: 'The aria label for the main menu nav' + }, + 'header.label.main.menu': { + id: 'header.label.main.menu', + defaultMessage: 'Main Menu', + description: 'The aria label for the main menu trigger' + }, + 'header.label.main.header': { + id: 'header.label.main.header', + defaultMessage: 'Main', + description: 'The aria label for the main header' + }, + 'header.label.secondary.nav': { + id: 'header.label.secondary.nav', + defaultMessage: 'Secondary', + description: 'The aria label for the seconary nav' + }, + 'header.label.skip.nav': { + id: 'header.label.skip.nav', + defaultMessage: 'Skip to main content', + description: 'A link used by screen readers to allow users to skip to the main content of the page.' + }, + 'header.label.app.nav': { + id: 'header.label.app.nav', + defaultMessage: 'App', + description: 'The aria label for the app Nav' + } +}); +export default messages; +//# sourceMappingURL=Header.messages.js.map \ No newline at end of file diff --git a/dist/Header.messages.js.map b/dist/Header.messages.js.map new file mode 100644 index 000000000..1dd150c4c --- /dev/null +++ b/dist/Header.messages.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Header.messages.js","names":["defineMessages","messages","id","defaultMessage","description"],"sources":["../src/Header.messages.jsx"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n 'header.links.courses': {\n id: 'header.links.courses',\n defaultMessage: 'Courses',\n description: 'Link to the learner course dashboard',\n },\n 'header.links.programs': {\n id: 'header.links.programs',\n defaultMessage: 'Programs',\n description: 'Link to the learner program dashboard',\n },\n 'header.links.content.search': {\n id: 'header.links.content.search',\n defaultMessage: 'Discover New',\n description: 'Link to the content search page',\n },\n 'header.links.schools': {\n id: 'header.links.schools',\n defaultMessage: 'Schools & Partners',\n description: 'Link to the schools and partners landing page',\n },\n 'header.user.menu.dashboard': {\n id: 'header.user.menu.dashboard',\n defaultMessage: 'Dashboard',\n description: 'Link to the user dashboard',\n },\n 'header.user.menu.profile': {\n id: 'header.user.menu.profile',\n defaultMessage: 'Profile',\n description: 'Link to the user profile',\n },\n 'header.user.menu.account.settings': {\n id: 'header.user.menu.account.settings',\n defaultMessage: 'Account',\n description: 'Link to account settings',\n },\n 'header.user.menu.order.history': {\n id: 'header.user.menu.order.history',\n defaultMessage: 'Order History',\n description: 'Link to order history',\n },\n 'header.user.menu.logout': {\n id: 'header.user.menu.logout',\n defaultMessage: 'Logout',\n description: 'Logout link',\n },\n 'header.user.menu.login': {\n id: 'header.user.menu.login',\n defaultMessage: 'Login',\n description: 'Login link',\n },\n 'header.user.menu.register': {\n id: 'header.user.menu.register',\n defaultMessage: 'Sign Up',\n description: 'Link to registration',\n },\n 'header.user.menu.studio.home': {\n id: 'header.user.menu.studio.home',\n defaultMessage: 'Studio Home',\n description: 'Link to the Studio Home',\n },\n 'header.user.menu.studio.maintenance': {\n id: 'header.user.menu.studio.maintenance',\n defaultMessage: 'Maintenance',\n description: 'Link to the Studio Maintenance',\n },\n 'header.label.account.nav': {\n id: 'header.label.account.nav',\n defaultMessage: 'Account',\n description: 'The aria label for the account menu nav',\n },\n 'header.label.account.menu': {\n id: 'header.label.account.menu',\n defaultMessage: 'Account Menu',\n description: 'The aria label for the account menu trigger',\n },\n 'header.label.account.menu.for': {\n id: 'header.label.account.menu.for',\n defaultMessage: 'Account menu for {username}',\n description: 'The aria label for the account menu trigger when the username is displayed in it',\n },\n 'header.label.main.nav': {\n id: 'header.label.main.nav',\n defaultMessage: 'Main',\n description: 'The aria label for the main menu nav',\n },\n 'header.label.main.menu': {\n id: 'header.label.main.menu',\n defaultMessage: 'Main Menu',\n description: 'The aria label for the main menu trigger',\n },\n 'header.label.main.header': {\n id: 'header.label.main.header',\n defaultMessage: 'Main',\n description: 'The aria label for the main header',\n },\n 'header.label.secondary.nav': {\n id: 'header.label.secondary.nav',\n defaultMessage: 'Secondary',\n description: 'The aria label for the seconary nav',\n },\n 'header.label.skip.nav': {\n id: 'header.label.skip.nav',\n defaultMessage: 'Skip to main content',\n description: 'A link used by screen readers to allow users to skip to the main content of the page.',\n },\n 'header.label.app.nav': {\n id: 'header.label.app.nav',\n defaultMessage: 'App',\n description: 'The aria label for the app Nav',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,6BAA6B;AAE5D,IAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9B,sBAAsB,EAAE;IACtBE,EAAE,EAAE,sBAAsB;IAC1BC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf,CAAC;EACD,uBAAuB,EAAE;IACvBF,EAAE,EAAE,uBAAuB;IAC3BC,cAAc,EAAE,UAAU;IAC1BC,WAAW,EAAE;EACf,CAAC;EACD,6BAA6B,EAAE;IAC7BF,EAAE,EAAE,6BAA6B;IACjCC,cAAc,EAAE,cAAc;IAC9BC,WAAW,EAAE;EACf,CAAC;EACD,sBAAsB,EAAE;IACtBF,EAAE,EAAE,sBAAsB;IAC1BC,cAAc,EAAE,oBAAoB;IACpCC,WAAW,EAAE;EACf,CAAC;EACD,4BAA4B,EAAE;IAC5BF,EAAE,EAAE,4BAA4B;IAChCC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE;EACf,CAAC;EACD,0BAA0B,EAAE;IAC1BF,EAAE,EAAE,0BAA0B;IAC9BC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf,CAAC;EACD,mCAAmC,EAAE;IACnCF,EAAE,EAAE,mCAAmC;IACvCC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf,CAAC;EACD,gCAAgC,EAAE;IAChCF,EAAE,EAAE,gCAAgC;IACpCC,cAAc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AE,4BAA4B;IAChCC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE;EACf,CAAC;EACD,uBAAuB,EAAE;IACvBF,EAAE,EAAE,uBAAuB;IAC3BC,cAAc,EAAE,sBAAsB;IACtCC,WAAW,EAAE;EACf,CAAC;EACD,sBAAsB,EAAE;IACtBF,EAAE,EAAE,sBAAsB;IAC1BC,cAAc,EAAE,KAAK;IACrBC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeH,QAAQ","ignoreList":[]} \ No newline at end of file diff --git a/dist/Header.test.jsx b/dist/Header.test.jsx new file mode 100644 index 000000000..51fef2089 --- /dev/null +++ b/dist/Header.test.jsx @@ -0,0 +1,104 @@ +/* eslint-disable react/prop-types */ +import React from 'react'; +import { IntlProvider } from '@edx/frontend-platform/i18n'; +import TestRenderer from 'react-test-renderer'; +import { AppContext } from '@edx/frontend-platform/react'; +import { Context as ResponsiveContext } from 'react-responsive'; + +import Header from './index'; + +const HeaderComponent = ({ width, contextValue }) => ( + + + +
+ + + +); + +describe('
', () => { + it('renders correctly for anonymous desktop', () => { + const contextValue = { + authenticatedUser: null, + config: { + LMS_BASE_URL: process.env.LMS_BASE_URL, + SITE_NAME: process.env.SITE_NAME, + LOGIN_URL: process.env.LOGIN_URL, + LOGOUT_URL: process.env.LOGOUT_URL, + LOGO_URL: process.env.LOGO_URL, + }, + }; + const component = ; + + const wrapper = TestRenderer.create(component); + + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + it('renders correctly for authenticated desktop', () => { + const contextValue = { + authenticatedUser: { + userId: 'abc123', + username: 'edX', + roles: [], + administrator: false, + }, + config: { + LMS_BASE_URL: process.env.LMS_BASE_URL, + SITE_NAME: process.env.SITE_NAME, + LOGIN_URL: process.env.LOGIN_URL, + LOGOUT_URL: process.env.LOGOUT_URL, + LOGO_URL: process.env.LOGO_URL, + }, + }; + const component = ; + + const wrapper = TestRenderer.create(component); + + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + it('renders correctly for anonymous mobile', () => { + const contextValue = { + authenticatedUser: null, + config: { + LMS_BASE_URL: process.env.LMS_BASE_URL, + SITE_NAME: process.env.SITE_NAME, + LOGIN_URL: process.env.LOGIN_URL, + LOGOUT_URL: process.env.LOGOUT_URL, + LOGO_URL: process.env.LOGO_URL, + }, + }; + const component = ; + + const wrapper = TestRenderer.create(component); + + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + it('renders correctly for authenticated mobile', () => { + const contextValue = { + authenticatedUser: { + userId: 'abc123', + username: 'edX', + roles: [], + administrator: false, + }, + config: { + LMS_BASE_URL: process.env.LMS_BASE_URL, + SITE_NAME: process.env.SITE_NAME, + LOGIN_URL: process.env.LOGIN_URL, + LOGOUT_URL: process.env.LOGOUT_URL, + LOGO_URL: process.env.LOGO_URL, + }, + }; + const component = ; + + const wrapper = TestRenderer.create(component); + + expect(wrapper.toJSON()).toMatchSnapshot(); + }); +}); diff --git a/dist/Icons.js b/dist/Icons.js new file mode 100644 index 000000000..1c19cb8f9 --- /dev/null +++ b/dist/Icons.js @@ -0,0 +1,52 @@ +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +import React from 'react'; +export var MenuIcon = function MenuIcon(props) { + return /*#__PURE__*/React.createElement("svg", _extends({ + width: "24px", + height: "24px", + viewBox: "0 0 24 24", + version: "1.1" + }, props), /*#__PURE__*/React.createElement("rect", { + fill: "currentColor", + x: "2", + y: "5", + width: "20", + height: "2" + }), /*#__PURE__*/React.createElement("rect", { + fill: "currentColor", + x: "2", + y: "11", + width: "20", + height: "2" + }), /*#__PURE__*/React.createElement("rect", { + fill: "currentColor", + x: "2", + y: "17", + width: "20", + height: "2" + })); +}; +export var AvatarIcon = function AvatarIcon(props) { + return /*#__PURE__*/React.createElement("svg", _extends({ + width: "24px", + height: "24px", + viewBox: "0 0 24 24", + version: "1.1" + }, props), /*#__PURE__*/React.createElement("path", { + d: "M4.10255106,18.1351061 C4.7170266,16.0581859 8.01891846,14.4720277 12,14.4720277 C15.9810815,14.4720277 19.2829734,16.0581859 19.8974489,18.1351061 C21.215206,16.4412566 22,14.3122775 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,14.3122775 2.78479405,16.4412566 4.10255106,18.1351061 Z M12,24 C5.372583,24 0,18.627417 0,12 C0,5.372583 5.372583,0 12,0 C18.627417,0 24,5.372583 24,12 C24,18.627417 18.627417,24 12,24 Z M12,13 C9.790861,13 8,11.209139 8,9 C8,6.790861 9.790861,5 12,5 C14.209139,5 16,6.790861 16,9 C16,11.209139 14.209139,13 12,13 Z", + fill: "currentColor" + })); +}; +export var CaretIcon = function CaretIcon(props) { + return /*#__PURE__*/React.createElement("svg", _extends({ + width: "16px", + height: "16px", + viewBox: "0 0 16 16", + version: "1.1" + }, props), /*#__PURE__*/React.createElement("path", { + d: "M7,4 L7,8 L11,8 L11,10 L5,10 L5,4 L7,4 Z", + fill: "currentColor", + transform: "translate(8.000000, 7.000000) rotate(-45.000000) translate(-8.000000, -7.000000) " + })); +}; +//# sourceMappingURL=Icons.js.map \ No newline at end of file diff --git a/dist/Icons.js.map b/dist/Icons.js.map new file mode 100644 index 000000000..a0c108b12 --- /dev/null +++ b/dist/Icons.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Icons.js","names":["React","MenuIcon","props","createElement","_extends","width","height","viewBox","version","fill","x","y","AvatarIcon","d","CaretIcon","transform"],"sources":["../src/Icons.jsx"],"sourcesContent":["import React from 'react';\n\nexport const MenuIcon = (props) => (\n \n \n \n \n \n);\n\nexport const AvatarIcon = (props) => (\n \n \n \n);\n\nexport const CaretIcon = (props) => (\n \n \n \n);\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,IAAMC,QAAQ,GAAG,SAAXA,QAAQA,CAAIC,KAAK;EAAA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C,EAAC,0CAA0C;IAC5CJ,IAAI,EAAC,cAAc;IACnBM,SAAS,EAAC;EAAmF,CAC9F,CACE,CAAC;AAAA,CACP","ignoreList":[]} \ No newline at end of file diff --git a/dist/Logo.js b/dist/Logo.js new file mode 100644 index 000000000..8b8d820ce --- /dev/null +++ b/dist/Logo.js @@ -0,0 +1,41 @@ +var _excluded = ["src", "alt"], + _excluded2 = ["href", "src", "alt"]; +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } +function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } +import React from 'react'; +import PropTypes from 'prop-types'; +var Logo = function Logo(_ref) { + var src = _ref.src, + alt = _ref.alt, + attributes = _objectWithoutProperties(_ref, _excluded); + return /*#__PURE__*/React.createElement("img", _extends({ + src: src, + alt: alt + }, attributes)); +}; +Logo.propTypes = { + src: PropTypes.string.isRequired, + alt: PropTypes.string.isRequired +}; +var LinkedLogo = function LinkedLogo(_ref2) { + var href = _ref2.href, + src = _ref2.src, + alt = _ref2.alt, + attributes = _objectWithoutProperties(_ref2, _excluded2); + return /*#__PURE__*/React.createElement("a", _extends({ + href: href + }, attributes), /*#__PURE__*/React.createElement("img", { + className: "d-block", + src: src, + alt: alt + })); +}; +LinkedLogo.propTypes = { + href: PropTypes.string.isRequired, + src: PropTypes.string.isRequired, + alt: PropTypes.string.isRequired +}; +export { LinkedLogo, Logo }; +export default Logo; +//# sourceMappingURL=Logo.js.map \ No newline at end of file diff --git a/dist/Logo.js.map b/dist/Logo.js.map new file mode 100644 index 000000000..8ab0a7fc2 --- /dev/null +++ b/dist/Logo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Logo.js","names":["React","PropTypes","Logo","_ref","src","alt","attributes","_objectWithoutProperties","_excluded","createElement","_extends","propTypes","string","isRequired","LinkedLogo","_ref2","href","_excluded2","className"],"sources":["../src/Logo.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst Logo = ({ src, alt, ...attributes }) => (\n {alt}\n);\n\nLogo.propTypes = {\n src: PropTypes.string.isRequired,\n alt: PropTypes.string.isRequired,\n};\n\nconst LinkedLogo = ({\n href,\n src,\n alt,\n ...attributes\n}) => (\n \n {alt}\n \n);\n\nLinkedLogo.propTypes = {\n href: PropTypes.string.isRequired,\n src: PropTypes.string.isRequired,\n alt: PropTypes.string.isRequired,\n};\n\nexport { LinkedLogo, Logo };\nexport default Logo;\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,IAAMC,IAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA;EAAA,IAAMC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAKC,UAAU,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAAA,oBACrCR,KAAA,CAAAS,aAAA,QAAAC,QAAA;IAAKN,GAAG,EAAEA,GAAI;IAACC,GAAG,EAAEA;EAAI,GAAKC,UAAU,CAAG,CAAC;AAAA,CAC5C;AAEDJ,IAAI,CAACS,SAAS,GAAG;EACfP,GAAG,EAAEH,SAAS,CAACW,MAAM,CAACC,UAAU;EAChCR,GAAG,EAAEJ,SAAS,CAACW,MAAM,CAACC;AACxB,CAAC;AAED,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,KAAA;EAAA,IACdC,IAAI,GAAAD,KAAA,CAAJC,IAAI;IACJZ,GAAG,GAAAW,KAAA,CAAHX,GAAG;IACHC,GAAG,GAAAU,KAAA,CAAHV,GAAG;IACAC,UAAU,GAAAC,wBAAA,CAAAQ,KAAA,EAAAE,UAAA;EAAA,oBAEbjB,KAAA,CAAAS,aAAA,MAAAC,QAAA;IAAGM,IAAI,EAAEA;EAAK,GAAKV,UAAU,gBAC3BN,KAAA,CAAAS,aAAA;IAAKS,SAAS,EAAC,SAAS;IAACd,GAAG,EAAEA,GAAI;IAACC,GAAG,EAAEA;EAAI,CAAE,CAC7C,CAAC;AAAA,CACL;AAEDS,UAAU,CAACH,SAAS,GAAG;EACrBK,IAAI,EAAEf,SAAS,CAACW,MAAM,CAACC,UAAU;EACjCT,GAAG,EAAEH,SAAS,CAACW,MAAM,CAACC,UAAU;EAChCR,GAAG,EAAEJ,SAAS,CAACW,MAAM,CAACC;AACxB,CAAC;AAED,SAASC,UAAU,EAAEZ,IAAI;AACzB,eAAeA,IAAI","ignoreList":[]} \ No newline at end of file diff --git a/dist/Menu/Menu.js b/dist/Menu/Menu.js new file mode 100644 index 000000000..ce30608b4 --- /dev/null +++ b/dist/Menu/Menu.js @@ -0,0 +1,321 @@ +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +var _excluded = ["tag", "className"], + _excluded2 = ["tag", "className"]; +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } +function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } +function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } +import React from 'react'; +import { CSSTransition } from 'react-transition-group'; +import PropTypes from 'prop-types'; +var MenuTrigger = function MenuTrigger(_ref) { + var tag = _ref.tag, + className = _ref.className, + attributes = _objectWithoutProperties(_ref, _excluded); + return /*#__PURE__*/React.createElement(tag, _objectSpread({ + className: "menu-trigger ".concat(className) + }, attributes)); +}; +MenuTrigger.propTypes = { + tag: PropTypes.string, + className: PropTypes.string +}; +MenuTrigger.defaultProps = { + tag: 'div', + className: null +}; +var MenuTriggerComp = /*#__PURE__*/React.createElement(MenuTrigger, null); +var MenuTriggerType = MenuTriggerComp.type; +var MenuContent = function MenuContent(_ref2) { + var tag = _ref2.tag, + className = _ref2.className, + attributes = _objectWithoutProperties(_ref2, _excluded2); + return /*#__PURE__*/React.createElement(tag, _objectSpread({ + className: ['menu-content', className].join(' ') + }, attributes)); +}; +MenuContent.propTypes = { + tag: PropTypes.string, + className: PropTypes.string +}; +MenuContent.defaultProps = { + tag: 'div', + className: null +}; +var menuPropTypes = { + tag: PropTypes.string, + onClose: PropTypes.func, + onOpen: PropTypes.func, + closeOnDocumentClick: PropTypes.bool, + respondToPointerEvents: PropTypes.bool, + className: PropTypes.string, + transitionTimeout: PropTypes.number, + transitionClassName: PropTypes.string, + children: PropTypes.arrayOf(PropTypes.node).isRequired +}; +var Menu = /*#__PURE__*/function (_React$Component) { + function Menu(props) { + var _this; + _classCallCheck(this, Menu); + _this = _callSuper(this, Menu, [props]); + _this.menu = /*#__PURE__*/React.createRef(); + _this.state = { + expanded: false + }; + _this.onTriggerClick = _this.onTriggerClick.bind(_this); + _this.onCloseClick = _this.onCloseClick.bind(_this); + _this.onKeyDown = _this.onKeyDown.bind(_this); + _this.onDocumentClick = _this.onDocumentClick.bind(_this); + _this.onMouseEnter = _this.onMouseEnter.bind(_this); + _this.onMouseLeave = _this.onMouseLeave.bind(_this); + return _this; + } + + // Lifecycle Events + _inherits(Menu, _React$Component); + return _createClass(Menu, [{ + key: "componentWillUnmount", + value: function componentWillUnmount() { + document.removeEventListener('touchend', this.onDocumentClick, true); + document.removeEventListener('click', this.onDocumentClick, true); + + // Call onClose callback when unmounting and open + if (this.state.expanded && this.props.onClose) { + this.props.onClose(); + } + } + + // Event handlers + }, { + key: "onDocumentClick", + value: function onDocumentClick(e) { + if (!this.props.closeOnDocumentClick) { + return; + } + var clickIsInMenu = this.menu.current === e.target || this.menu.current.contains(e.target); + if (clickIsInMenu) { + return; + } + this.close(); + } + }, { + key: "onTriggerClick", + value: function onTriggerClick(e) { + // Let the browser follow the link of the trigger if the menu + // is already expanded and the trigger has an href attribute + if (this.state.expanded && e.target.getAttribute('href')) { + return; + } + e.preventDefault(); + this.toggle(); + } + }, { + key: "onCloseClick", + value: function onCloseClick() { + this.getFocusableElements()[0].focus(); + this.close(); + } + }, { + key: "onKeyDown", + value: function onKeyDown(e) { + if (!this.state.expanded) { + return; + } + switch (e.key) { + case 'Escape': + { + e.preventDefault(); + e.stopPropagation(); + this.getFocusableElements()[0].focus(); + this.close(); + break; + } + case 'Enter': + { + // Using focusable elements instead of a ref to the trigger + // because Hyperlink and Button can handle refs as functional components + if (document.activeElement === this.getFocusableElements()[0]) { + e.preventDefault(); + this.toggle(); + } + break; + } + case 'Tab': + { + e.preventDefault(); + if (e.shiftKey) { + this.focusPrevious(); + } else { + this.focusNext(); + } + break; + } + case 'ArrowDown': + { + e.preventDefault(); + this.focusNext(); + break; + } + case 'ArrowUp': + { + e.preventDefault(); + this.focusPrevious(); + break; + } + default: + } + } + }, { + key: "onMouseEnter", + value: function onMouseEnter() { + if (!this.props.respondToPointerEvents) { + return; + } + this.open(); + } + }, { + key: "onMouseLeave", + value: function onMouseLeave() { + if (!this.props.respondToPointerEvents) { + return; + } + this.close(); + } + + // Internal functions + }, { + key: "getFocusableElements", + value: function getFocusableElements() { + return this.menu.current.querySelectorAll('button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])'); + } + }, { + key: "getAttributesFromProps", + value: function getAttributesFromProps() { + var _this2 = this; + // Any extra props are attributes for the menu + var attributes = {}; + Object.keys(this.props).filter(function (property) { + return menuPropTypes[property] === undefined; + }).forEach(function (property) { + attributes[property] = _this2.props[property]; + }); + return attributes; + } + }, { + key: "focusNext", + value: function focusNext() { + var focusableElements = Array.from(this.getFocusableElements()); + var activeIndex = focusableElements.indexOf(document.activeElement); + var nextIndex = (activeIndex + 1) % focusableElements.length; + focusableElements[nextIndex].focus(); + } + }, { + key: "focusPrevious", + value: function focusPrevious() { + var focusableElements = Array.from(this.getFocusableElements()); + var activeIndex = focusableElements.indexOf(document.activeElement); + var previousIndex = (activeIndex || focusableElements.length) - 1; + focusableElements[previousIndex].focus(); + } + }, { + key: "open", + value: function open() { + if (this.props.onOpen) { + this.props.onOpen(); + } + this.setState({ + expanded: true + }); + // Listen to touchend and click events to ensure the menu + // can be closed on mobile, pointer, and mixed input devices + document.addEventListener('touchend', this.onDocumentClick, true); + document.addEventListener('click', this.onDocumentClick, true); + } + }, { + key: "close", + value: function close() { + if (this.props.onClose) { + this.props.onClose(); + } + this.setState({ + expanded: false + }); + document.removeEventListener('touchend', this.onDocumentClick, true); + document.removeEventListener('click', this.onDocumentClick, true); + } + }, { + key: "toggle", + value: function toggle() { + if (this.state.expanded) { + this.close(); + } else { + this.open(); + } + } + }, { + key: "renderTrigger", + value: function renderTrigger(node) { + return /*#__PURE__*/React.cloneElement(node, { + onClick: this.onTriggerClick, + 'aria-haspopup': 'menu', + 'aria-expanded': this.state.expanded + }); + } + }, { + key: "renderMenuContent", + value: function renderMenuContent(node) { + return /*#__PURE__*/React.createElement(CSSTransition, { + "in": this.state.expanded, + timeout: this.props.transitionTimeout, + classNames: this.props.transitionClassName, + unmountOnExit: true + }, node); + } + }, { + key: "render", + value: function render() { + var _this3 = this; + var className = this.props.className; + var wrappedChildren = React.Children.map(this.props.children, function (child) { + if (child.type === MenuTriggerType) { + return _this3.renderTrigger(child); + } + return _this3.renderMenuContent(child); + }); + var rootClassName = this.state.expanded ? 'menu expanded' : 'menu'; + return /*#__PURE__*/React.createElement(this.props.tag, _objectSpread({ + className: "".concat(rootClassName, " ").concat(className), + ref: this.menu, + onKeyDown: this.onKeyDown, + onMouseEnter: this.onMouseEnter, + onMouseLeave: this.onMouseLeave + }, this.getAttributesFromProps()), wrappedChildren); + } + }]); +}(React.Component); +Menu.propTypes = menuPropTypes; +Menu.defaultProps = { + tag: 'div', + className: null, + onClose: null, + onOpen: null, + respondToPointerEvents: false, + closeOnDocumentClick: true, + transitionTimeout: 250, + transitionClassName: 'menu-content' +}; +export { Menu, MenuTrigger, MenuContent }; +//# sourceMappingURL=Menu.js.map \ No newline at end of file diff --git a/dist/Menu/Menu.js.map b/dist/Menu/Menu.js.map new file mode 100644 index 000000000..1f8d151eb --- /dev/null +++ b/dist/Menu/Menu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Menu.js","names":["React","CSSTransition","PropTypes","MenuTrigger","_ref","tag","className","attributes","_objectWithoutProperties","_excluded","createElement","_objectSpread","concat","propTypes","string","defaultProps","MenuTriggerComp","MenuTriggerType","type","MenuContent","_ref2","_excluded2","join","menuPropTypes","onClose","func","onOpen","closeOnDocumentClick","bool","respondToPointerEvents","transitionTimeout","number","transitionClassName","children","arrayOf","node","isRequired","Menu","_React$Component","props","_this","_classCallCheck","_callSuper","menu","createRef","state","expanded","onTriggerClick","bind","onCloseClick","onKeyDown","onDocumentClick","onMouseEnter","onMouseLeave","_inherits","_createClass","key","value","componentWillUnmount","document","removeEventListener","e","clickIsInMenu","current","target","contains","close","getAttribute","preventDefault","toggle","getFocusableElements","focus","stopPropagation","activeElement","shiftKey","focusPrevious","focusNext","open","querySelectorAll","getAttributesFromProps","_this2","Object","keys","filter","property","undefined","forEach","focusableElements","Array","from","activeIndex","indexOf","nextIndex","length","previousIndex","setState","addEventListener","renderTrigger","cloneElement","onClick","renderMenuContent","timeout","classNames","unmountOnExit","render","_this3","wrappedChildren","Children","map","child","rootClassName","ref","Component"],"sources":["../../src/Menu/Menu.jsx"],"sourcesContent":["import React from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport PropTypes from 'prop-types';\n\nconst MenuTrigger = ({ tag, className, ...attributes }) => React.createElement(tag, {\n className: `menu-trigger ${className}`,\n ...attributes,\n});\nMenuTrigger.propTypes = {\n tag: PropTypes.string,\n className: PropTypes.string,\n};\nMenuTrigger.defaultProps = {\n tag: 'div',\n className: null,\n};\nconst MenuTriggerComp = ;\nconst MenuTriggerType = MenuTriggerComp.type;\n\nconst MenuContent = ({ tag, className, ...attributes }) => React.createElement(tag, {\n className: ['menu-content', className].join(' '),\n ...attributes,\n});\nMenuContent.propTypes = {\n tag: PropTypes.string,\n className: PropTypes.string,\n};\nMenuContent.defaultProps = {\n tag: 'div',\n className: null,\n};\n\nconst menuPropTypes = {\n tag: PropTypes.string,\n onClose: PropTypes.func,\n onOpen: PropTypes.func,\n closeOnDocumentClick: PropTypes.bool,\n respondToPointerEvents: PropTypes.bool,\n className: PropTypes.string,\n transitionTimeout: PropTypes.number,\n transitionClassName: PropTypes.string,\n children: PropTypes.arrayOf(PropTypes.node).isRequired,\n};\n\nclass Menu extends React.Component {\n constructor(props) {\n super(props);\n\n this.menu = React.createRef();\n this.state = {\n expanded: false,\n };\n\n this.onTriggerClick = this.onTriggerClick.bind(this);\n this.onCloseClick = this.onCloseClick.bind(this);\n this.onKeyDown = this.onKeyDown.bind(this);\n this.onDocumentClick = this.onDocumentClick.bind(this);\n this.onMouseEnter = this.onMouseEnter.bind(this);\n this.onMouseLeave = this.onMouseLeave.bind(this);\n }\n\n // Lifecycle Events\n componentWillUnmount() {\n document.removeEventListener('touchend', this.onDocumentClick, true);\n document.removeEventListener('click', this.onDocumentClick, true);\n\n // Call onClose callback when unmounting and open\n if (this.state.expanded && this.props.onClose) {\n this.props.onClose();\n }\n }\n\n // Event handlers\n onDocumentClick(e) {\n if (!this.props.closeOnDocumentClick) {\n return;\n }\n\n const clickIsInMenu = this.menu.current === e.target || this.menu.current.contains(e.target);\n if (clickIsInMenu) {\n return;\n }\n\n this.close();\n }\n\n onTriggerClick(e) {\n // Let the browser follow the link of the trigger if the menu\n // is already expanded and the trigger has an href attribute\n if (this.state.expanded && e.target.getAttribute('href')) {\n return;\n }\n\n e.preventDefault();\n this.toggle();\n }\n\n onCloseClick() {\n this.getFocusableElements()[0].focus();\n this.close();\n }\n\n onKeyDown(e) {\n if (!this.state.expanded) {\n return;\n }\n switch (e.key) {\n case 'Escape': {\n e.preventDefault();\n e.stopPropagation();\n this.getFocusableElements()[0].focus();\n this.close();\n break;\n }\n case 'Enter': {\n // Using focusable elements instead of a ref to the trigger\n // because Hyperlink and Button can handle refs as functional components\n if (document.activeElement === this.getFocusableElements()[0]) {\n e.preventDefault();\n this.toggle();\n }\n break;\n }\n case 'Tab': {\n e.preventDefault();\n if (e.shiftKey) {\n this.focusPrevious();\n } else {\n this.focusNext();\n }\n break;\n }\n case 'ArrowDown': {\n e.preventDefault();\n this.focusNext();\n break;\n }\n case 'ArrowUp': {\n e.preventDefault();\n this.focusPrevious();\n break;\n }\n default:\n }\n }\n\n onMouseEnter() {\n if (!this.props.respondToPointerEvents) {\n return;\n }\n this.open();\n }\n\n onMouseLeave() {\n if (!this.props.respondToPointerEvents) {\n return;\n }\n this.close();\n }\n\n // Internal functions\n\n getFocusableElements() {\n return this.menu.current.querySelectorAll('button:not([disabled]), [href]:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])');\n }\n\n getAttributesFromProps() {\n // Any extra props are attributes for the menu\n const attributes = {};\n Object.keys(this.props)\n .filter(property => menuPropTypes[property] === undefined)\n .forEach((property) => {\n attributes[property] = this.props[property];\n });\n return attributes;\n }\n\n focusNext() {\n const focusableElements = Array.from(this.getFocusableElements());\n const activeIndex = focusableElements.indexOf(document.activeElement);\n const nextIndex = (activeIndex + 1) % focusableElements.length;\n focusableElements[nextIndex].focus();\n }\n\n focusPrevious() {\n const focusableElements = Array.from(this.getFocusableElements());\n const activeIndex = focusableElements.indexOf(document.activeElement);\n const previousIndex = (activeIndex || focusableElements.length) - 1;\n focusableElements[previousIndex].focus();\n }\n\n open() {\n if (this.props.onOpen) {\n this.props.onOpen();\n }\n this.setState({ expanded: true });\n // Listen to touchend and click events to ensure the menu\n // can be closed on mobile, pointer, and mixed input devices\n document.addEventListener('touchend', this.onDocumentClick, true);\n document.addEventListener('click', this.onDocumentClick, true);\n }\n\n close() {\n if (this.props.onClose) {\n this.props.onClose();\n }\n this.setState({ expanded: false });\n document.removeEventListener('touchend', this.onDocumentClick, true);\n document.removeEventListener('click', this.onDocumentClick, true);\n }\n\n toggle() {\n if (this.state.expanded) {\n this.close();\n } else {\n this.open();\n }\n }\n\n renderTrigger(node) {\n return React.cloneElement(node, {\n onClick: this.onTriggerClick,\n 'aria-haspopup': 'menu',\n 'aria-expanded': this.state.expanded,\n });\n }\n\n renderMenuContent(node) {\n return (\n \n {node}\n \n );\n }\n\n render() {\n const { className } = this.props;\n\n const wrappedChildren = React.Children.map(this.props.children, (child) => {\n if (child.type === MenuTriggerType) {\n return this.renderTrigger(child);\n }\n return this.renderMenuContent(child);\n });\n\n const rootClassName = this.state.expanded ? 'menu expanded' : 'menu';\n\n return React.createElement(this.props.tag, {\n className: `${rootClassName} ${className}`,\n ref: this.menu,\n onKeyDown: this.onKeyDown,\n onMouseEnter: this.onMouseEnter,\n onMouseLeave: this.onMouseLeave,\n ...this.getAttributesFromProps(),\n }, wrappedChildren);\n }\n}\n\nMenu.propTypes = menuPropTypes;\nMenu.defaultProps = {\n tag: 'div',\n className: null,\n onClose: null,\n onOpen: null,\n respondToPointerEvents: false,\n closeOnDocumentClick: true,\n transitionTimeout: 250,\n transitionClassName: 'menu-content',\n};\n\nexport { Menu, MenuTrigger, MenuContent };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,wBAAwB;AACtD,OAAOC,SAAS,MAAM,YAAY;AAElC,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA;EAAA,IAAMC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAAKC,UAAU,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAAA,oBAAOT,KAAK,CAACU,aAAa,CAACL,GAAG,EAAAM,aAAA;IAChFL,SAAS,kBAAAM,MAAA,CAAkBN,SAAS;EAAE,GACnCC,UAAU,CACd,CAAC;AAAA;AACFJ,WAAW,CAACU,SAAS,GAAG;EACtBR,GAAG,EAAEH,SAAS,CAACY,MAAM;EACrBR,SAAS,EAAEJ,SAAS,CAACY;AACvB,CAAC;AACDX,WAAW,CAACY,YAAY,GAAG;EACzBV,GAAG,E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,aAAa;AAC9Bc,IAAI,CAACtB,YAAY,GAAG;EAClBV,GAAG,EAAE,KAAK;EACVC,SAAS,EAAE,IAAI;EACfkB,OAAO,EAAE,IAAI;EACbE,MAAM,EAAE,IAAI;EACZG,sBAAsB,EAAE,KAAK;EAC7BF,oBAAoB,EAAE,IAAI;EAC1BG,iBAAiB,EAAE,GAAG;EACtBE,mBAAmB,EAAE;AACvB,CAAC;AAED,SAASK,IAAI,EAAElC,WAAW,EAAEgB,WAAW","ignoreList":[]} \ No newline at end of file diff --git a/dist/Menu/index.js b/dist/Menu/index.js new file mode 100644 index 000000000..c2cc885ff --- /dev/null +++ b/dist/Menu/index.js @@ -0,0 +1,3 @@ +import { Menu, MenuTrigger, MenuContent } from './Menu'; +export { Menu, MenuTrigger, MenuContent }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/Menu/index.js.map b/dist/Menu/index.js.map new file mode 100644 index 000000000..e765f2223 --- /dev/null +++ b/dist/Menu/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","names":["Menu","MenuTrigger","MenuContent"],"sources":["../../src/Menu/index.jsx"],"sourcesContent":["import { Menu, MenuTrigger, MenuContent } from './Menu';\n\nexport { Menu, MenuTrigger, MenuContent };\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,WAAW,EAAEC,WAAW,QAAQ,QAAQ;AAEvD,SAASF,IAAI,EAAEC,WAAW,EAAEC,WAAW","ignoreList":[]} \ No newline at end of file diff --git a/dist/Menu/menu.scss b/dist/Menu/menu.scss new file mode 100644 index 000000000..39c57ff06 --- /dev/null +++ b/dist/Menu/menu.scss @@ -0,0 +1,45 @@ +.menu { + position: relative; +} + +.menu-content { + position: absolute; + top: 100%; + z-index: 10; + background: var(--pgn-color-white); + min-width: 10rem; + + &.pin-left { + left: 0; + } + + &.pin-right { + right: 0; + } +} + +.menu-dropdown-enter { + opacity: 0; + transform-origin: 75% 0; + transform: scale3d(0.8, 0.8, 1); +} + +.menu-dropdown-enter-active { + transform-origin: 75% 0; + transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1); + transform: scale3d(1, 1, 1); + opacity: 1; +} + +.menu-dropdown-exit { + transform-origin: 75% 0; + transform: scale3d(1, 1, 1); + opacity: 1; +} + +.menu-dropdown-exit-active { + transform-origin: 75% 0; + transform: scale3d(0.8, 0.8, 1); + transition: all 250ms cubic-bezier(0.8, 0, 0.6, 1); + opacity: 0; +} diff --git a/dist/MobileHeader.js b/dist/MobileHeader.js new file mode 100644 index 000000000..9ca3421f9 --- /dev/null +++ b/dist/MobileHeader.js @@ -0,0 +1,250 @@ +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } +function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } +function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } +function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } +function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } +function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } +function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } +function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } +function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } +import React from 'react'; +import PropTypes from 'prop-types'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { getConfig } from '@edx/frontend-platform'; + +// Local Components +import { Menu, MenuTrigger, MenuContent } from './Menu'; +import Avatar from './Avatar'; +import { LinkedLogo, Logo } from './Logo'; + +// i18n +import messages from './Header.messages'; + +// Assets +import { MenuIcon } from './Icons'; +var MobileHeader = /*#__PURE__*/function (_React$Component) { + function MobileHeader(props) { + _classCallCheck(this, MobileHeader); + // eslint-disable-line no-useless-constructor + return _callSuper(this, MobileHeader, [props]); + } + _inherits(MobileHeader, _React$Component); + return _createClass(MobileHeader, [{ + key: "renderMenu", + value: function renderMenu(menu) { + // Nodes are accepted as a prop + if (!Array.isArray(menu)) { + return menu; + } + return menu.map(function (menuItem) { + var type = menuItem.type, + href = menuItem.href, + content = menuItem.content, + submenuContent = menuItem.submenuContent, + disabled = menuItem.disabled, + isActive = menuItem.isActive, + onClick = menuItem.onClick; + if (type === 'item') { + return /*#__PURE__*/React.createElement("a", { + key: "".concat(type, "-").concat(content), + className: "nav-link".concat(disabled ? ' disabled' : '').concat(isActive ? ' active' : ''), + href: href, + onClick: onClick || null + }, content); + } + return /*#__PURE__*/React.createElement(Menu, { + key: "".concat(type, "-").concat(content), + tag: "div", + className: "nav-item" + }, /*#__PURE__*/React.createElement(MenuTrigger, { + onClick: onClick || null, + tag: "a", + role: "button", + tabIndex: "0", + className: "nav-link" + }, content), /*#__PURE__*/React.createElement(MenuContent, { + className: "position-static pin-left pin-right py-2" + }, submenuContent)); + }); + } + }, { + key: "renderMainMenu", + value: function renderMainMenu() { + var mainMenu = this.props.mainMenu; + return this.renderMenu(mainMenu); + } + }, { + key: "renderSecondaryMenu", + value: function renderSecondaryMenu() { + var secondaryMenu = this.props.secondaryMenu; + return this.renderMenu(secondaryMenu); + } + }, { + key: "renderUserMenuItems", + value: function renderUserMenuItems() { + var userMenu = this.props.userMenu; + return userMenu.map(function (group) { + return group.items.map(function (_ref) { + var type = _ref.type, + content = _ref.content, + href = _ref.href, + disabled = _ref.disabled, + isActive = _ref.isActive, + onClick = _ref.onClick; + return /*#__PURE__*/React.createElement("li", { + className: "nav-item", + key: "".concat(type, "-").concat(content) + }, /*#__PURE__*/React.createElement("a", { + className: "nav-link".concat(isActive ? ' active' : '').concat(disabled ? ' disabled' : ''), + href: href, + onClick: onClick || null + }, content)); + }); + }); + } + }, { + key: "renderLoggedOutItems", + value: function renderLoggedOutItems() { + var loggedOutItems = this.props.loggedOutItems; + return loggedOutItems.map(function (_ref2, i, arr) { + var type = _ref2.type, + href = _ref2.href, + content = _ref2.content; + return /*#__PURE__*/React.createElement("li", { + className: "nav-item px-3 my-2", + key: "".concat(type, "-").concat(content) + }, /*#__PURE__*/React.createElement("a", { + className: i < arr.length - 1 ? 'btn btn-block btn-outline-primary' : 'btn btn-block btn-primary', + href: href + }, content)); + }); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + logo = _this$props.logo, + logoAltText = _this$props.logoAltText, + logoDestination = _this$props.logoDestination, + loggedIn = _this$props.loggedIn, + avatar = _this$props.avatar, + username = _this$props.username, + stickyOnMobile = _this$props.stickyOnMobile, + intl = _this$props.intl, + mainMenu = _this$props.mainMenu, + userMenu = _this$props.userMenu, + loggedOutItems = _this$props.loggedOutItems; + var logoProps = { + src: logo, + alt: logoAltText, + href: logoDestination + }; + var stickyClassName = stickyOnMobile ? 'sticky-top' : ''; + var logoClasses = getConfig().AUTHN_MINIMAL_HEADER ? 'justify-content-left pl-3' : 'justify-content-center'; + return /*#__PURE__*/React.createElement("header", { + "aria-label": intl.formatMessage(messages['header.label.main.header']), + className: "site-header-mobile d-flex justify-content-between align-items-center shadow ".concat(stickyClassName) + }, /*#__PURE__*/React.createElement("a", { + className: "nav-skip sr-only sr-only-focusable", + href: "#main" + }, intl.formatMessage(messages['header.label.skip.nav'])), mainMenu.length > 0 ? /*#__PURE__*/React.createElement("div", { + className: "w-100 d-flex justify-content-start" + }, /*#__PURE__*/React.createElement(Menu, { + className: "position-static" + }, /*#__PURE__*/React.createElement(MenuTrigger, { + tag: "button", + className: "icon-button", + "aria-label": intl.formatMessage(messages['header.label.main.menu']), + title: intl.formatMessage(messages['header.label.main.menu']) + }, /*#__PURE__*/React.createElement(MenuIcon, { + role: "img", + "aria-hidden": true, + focusable: "false", + style: { + width: '1.5rem', + height: '1.5rem' + } + })), /*#__PURE__*/React.createElement(MenuContent, { + tag: "nav", + "aria-label": intl.formatMessage(messages['header.label.main.nav']), + className: "nav flex-column pin-left pin-right border-top shadow py-2" + }, this.renderMainMenu(), this.renderSecondaryMenu()))) : null, /*#__PURE__*/React.createElement("div", { + className: "w-100 d-flex ".concat(logoClasses) + }, logoDestination === null ? /*#__PURE__*/React.createElement(Logo, { + className: "logo", + src: logo, + alt: logoAltText + }) : /*#__PURE__*/React.createElement(LinkedLogo, _extends({ + className: "logo" + }, logoProps, { + itemType: "http://schema.org/Organization" + }))), userMenu.length > 0 || loggedOutItems.length > 0 ? /*#__PURE__*/React.createElement("div", { + className: "w-100 d-flex justify-content-end align-items-center" + }, /*#__PURE__*/React.createElement(Menu, { + tag: "nav", + "aria-label": intl.formatMessage(messages['header.label.secondary.nav']), + className: "position-static" + }, /*#__PURE__*/React.createElement(MenuTrigger, { + tag: "button", + className: "icon-button", + "aria-label": intl.formatMessage(messages['header.label.account.menu']), + title: intl.formatMessage(messages['header.label.account.menu']) + }, /*#__PURE__*/React.createElement(Avatar, { + size: "1.5rem", + src: avatar, + alt: username + })), /*#__PURE__*/React.createElement(MenuContent, { + tag: "ul", + className: "nav flex-column pin-left pin-right border-top shadow py-2" + }, loggedIn ? this.renderUserMenuItems() : this.renderLoggedOutItems()))) : null); + } + }]); +}(React.Component); +MobileHeader.propTypes = { + mainMenu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + secondaryMenu: PropTypes.oneOfType([PropTypes.node, PropTypes.array]), + userMenu: PropTypes.arrayOf(PropTypes.shape({ + heading: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.oneOf(['item', 'menu']), + href: PropTypes.string, + content: PropTypes.string, + isActive: PropTypes.bool, + onClick: PropTypes.func + })) + })), + loggedOutItems: PropTypes.arrayOf(PropTypes.shape({ + type: PropTypes.oneOf(['item', 'menu']), + href: PropTypes.string, + content: PropTypes.string + })), + logo: PropTypes.string, + logoAltText: PropTypes.string, + logoDestination: PropTypes.string, + avatar: PropTypes.string, + username: PropTypes.string, + loggedIn: PropTypes.bool, + stickyOnMobile: PropTypes.bool, + // i18n + intl: intlShape.isRequired +}; +MobileHeader.defaultProps = { + mainMenu: [], + secondaryMenu: [], + userMenu: [], + loggedOutItems: [], + logo: null, + logoAltText: null, + logoDestination: null, + avatar: null, + username: null, + loggedIn: false, + stickyOnMobile: true +}; +export default injectIntl(MobileHeader); +//# sourceMappingURL=MobileHeader.js.map \ No newline at end of file diff --git a/dist/MobileHeader.js.map b/dist/MobileHeader.js.map new file mode 100644 index 000000000..9571b85f0 --- /dev/null +++ b/dist/MobileHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MobileHeader.js","names":["React","PropTypes","injectIntl","intlShape","getConfig","Menu","MenuTrigger","MenuContent","Avatar","LinkedLogo","Logo","messages","MenuIcon","MobileHeader","_React$Component","props","_classCallCheck","_callSuper","_inherits","_createClass","key","value","renderMenu","menu","Array","isArray","map","menuItem","type","href","content","submenuContent","disabled","isActive","onClick","createElement","concat","className","tag","role","tabIndex","renderMainMenu","mainMenu","renderSecondaryMenu","secondaryMenu","renderUserMenuItems","userMenu","group","items","_ref","renderLoggedOutItems","loggedOutItems","_ref2","i","arr","length","render","_this$props","logo","logoAltText","logoDestination","loggedIn","avatar","username","stickyOnMobile","intl","logoProps","src","alt","stickyClassName","logoClasses","AUTHN_MINIMAL_HEADER","formatMessage","title","focusable","style","width","height","_extends","itemType","size","Component","propTypes","oneOfType","node","array","arrayOf","shape","heading","string","oneOf","bool","func","isRequired","defaultProps"],"sources":["../src/MobileHeader.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { getConfig } from '@edx/frontend-platform';\n\n// Local Components\nimport { Menu, MenuTrigger, MenuContent } from './Menu';\nimport Avatar from './Avatar';\nimport { LinkedLogo, Logo } from './Logo';\n\n// i18n\nimport messages from './Header.messages';\n\n// Assets\nimport { MenuIcon } from './Icons';\n\nclass MobileHeader extends React.Component {\n constructor(props) { // eslint-disable-line no-useless-constructor\n super(props);\n }\n\n renderMenu(menu) {\n // Nodes are accepted as a prop\n if (!Array.isArray(menu)) {\n return menu;\n }\n\n return menu.map((menuItem) => {\n const {\n type,\n href,\n content,\n submenuContent,\n disabled,\n isActive,\n onClick,\n } = menuItem;\n\n if (type === 'item') {\n return (\n \n {content}\n \n );\n }\n\n return (\n \n \n {content}\n \n \n {submenuContent}\n \n \n );\n });\n }\n\n renderMainMenu() {\n const { mainMenu } = this.props;\n return this.renderMenu(mainMenu);\n }\n\n renderSecondaryMenu() {\n const { secondaryMenu } = this.props;\n return this.renderMenu(secondaryMenu);\n }\n\n renderUserMenuItems() {\n const { userMenu } = this.props;\n\n return userMenu.map((group) => (\n group.items.map(({\n type, content, href, disabled, isActive, onClick,\n }) => (\n
  • \n \n {content}\n \n
  • \n ))\n ));\n }\n\n renderLoggedOutItems() {\n const { loggedOutItems } = this.props;\n\n return loggedOutItems.map(({ type, href, content }, i, arr) => (\n
  • \n \n {content}\n \n
  • \n ));\n }\n\n render() {\n const {\n logo,\n logoAltText,\n logoDestination,\n loggedIn,\n avatar,\n username,\n stickyOnMobile,\n intl,\n mainMenu,\n userMenu,\n loggedOutItems,\n } = this.props;\n const logoProps = { src: logo, alt: logoAltText, href: logoDestination };\n const stickyClassName = stickyOnMobile ? 'sticky-top' : '';\n const logoClasses = getConfig().AUTHN_MINIMAL_HEADER ? 'justify-content-left pl-3' : 'justify-content-center';\n\n return (\n \n {intl.formatMessage(messages['header.label.skip.nav'])}\n {mainMenu.length > 0 ? (\n
    \n\n \n \n \n \n \n {this.renderMainMenu()}\n {this.renderSecondaryMenu()}\n \n \n
    \n ) : null}\n
    \n { logoDestination === null ? : }\n
    \n {userMenu.length > 0 || loggedOutItems.length > 0 ? (\n
    \n \n \n \n \n \n {loggedIn ? this.renderUserMenuItems() : this.renderLoggedOutItems()}\n \n \n
    \n ) : null}\n
    \n );\n }\n}\n\nMobileHeader.propTypes = {\n mainMenu: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n secondaryMenu: PropTypes.oneOfType([\n PropTypes.node,\n PropTypes.array,\n ]),\n userMenu: PropTypes.arrayOf(PropTypes.shape({\n heading: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n type: PropTypes.oneOf(['item', 'menu']),\n href: PropTypes.string,\n content: PropTypes.string,\n isActive: PropTypes.bool,\n onClick: PropTypes.func,\n })),\n })),\n loggedOutItems: PropTypes.arrayOf(PropTypes.shape({\n type: PropTypes.oneOf(['item', 'menu']),\n href: PropTypes.string,\n content: PropTypes.string,\n })),\n logo: PropTypes.string,\n logoAltText: PropTypes.string,\n logoDestination: PropTypes.string,\n avatar: PropTypes.string,\n username: PropTypes.string,\n loggedIn: PropTypes.bool,\n stickyOnMobile: PropTypes.bool,\n\n // i18n\n intl: intlShape.isRequired,\n};\n\nMobileHeader.defaultProps = {\n mainMenu: [],\n secondaryMenu: [],\n userMenu: [],\n loggedOutItems: [],\n logo: null,\n logoAltText: null,\n logoDestination: null,\n avatar: null,\n username: null,\n loggedIn: false,\n stickyOnMobile: true,\n\n};\n\nexport default injectIntl(MobileHeader);\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,SAAS,QAAQ,wBAAwB;;AAElD;AACA,SAASC,IAAI,EAAEC,WAAW,EAAEC,WAAW,QAAQ,QAAQ;AACvD,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,UAAU,EAAEC,IAAI,QAAQ,QAAQ;;AAEzC;AACA,OAAOC,QAAQ,MAAM,mBAAmB;;AAExC;AACA,SAASC,QAAQ,QAAQ,SAAS;AAAC,IAE7BC,YAAY,0BAAAC,gBAAA;EAChB,SAAAD,aAAYE,KAAK,EAAE;IAAAC,eAAA,OAAAH,YAAA;IAAE;IAAA,OAAAI,UAAA,OAAAJ,YAAA,GACbE,KAAK;EACb;EAACG,SAAA,CAAAL,YAAA,EAAAC,gBAAA;EAAA,OAAAK,YAAA,CAAAN,YAAA;IAAAO,GAAA;IAAAC,KAAA,EAED,SAAAC,WAAWC,IAAI,EAAE;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ACsF,KAAK,CAAC;IAChD3D,IAAI,EAAE3B,SAAS,CAACyF,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC7D,IAAI,EAAE5B,SAAS,CAACwF,MAAM;IACtB3D,OAAO,EAAE7B,SAAS,CAACwF;EACrB,CAAC,CAAC,CAAC;EACH/B,IAAI,EAAEzD,SAAS,CAACwF,MAAM;EACtB9B,WAAW,EAAE1D,SAAS,CAACwF,MAAM;EAC7B7B,eAAe,EAAE3D,SAAS,CAACwF,MAAM;EACjC3B,MAAM,EAAE7D,SAAS,CAACwF,MAAM;EACxB1B,QAAQ,EAAE9D,SAAS,CAACwF,MAAM;EAC1B5B,QAAQ,EAAE5D,SAAS,CAAC0F,IAAI;EACxB3B,cAAc,EAAE/D,SAAS,CAAC0F,IAAI;EAE9B;EACA1B,IAAI,EAAE9D,SAAS,CAAC0F;AAClB,CAAC;AAEDhF,YAAY,CAACiF,YAAY,GAAG;EAC1BpD,QAAQ,EAAE,EAAE;EACZE,aAAa,EAAE,EAAE;EACjBE,QAAQ,EAAE,EAAE;EACZK,cAAc,EAAE,EAAE;EAClBO,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,IAAI;EACjBC,eAAe,EAAE,IAAI;EACrBE,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAE,IAAI;EACdF,QAAQ,EAAE,KAAK;EACfG,cAAc,EAAE;AAElB,CAAC;AAED,eAAe9D,UAAU,CAACW,YAAY,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/__snapshots__/Header.test.jsx.snap b/dist/__snapshots__/Header.test.jsx.snap new file mode 100644 index 000000000..781e7f729 --- /dev/null +++ b/dist/__snapshots__/Header.test.jsx.snap @@ -0,0 +1,445 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`
    renders correctly for anonymous desktop 1`] = ` +
    + + Skip to main content + + +
    +`; + +exports[`
    renders correctly for anonymous mobile 1`] = ` +
    + + Skip to main content + +
    +
    + +
    +
    +
    + + edX + +
    +
    + +
    +
    +`; + +exports[`
    renders correctly for authenticated desktop 1`] = ` +
    + + Skip to main content + +
    +
    + + edX + + + +
    +
    +
    +`; + +exports[`
    renders correctly for authenticated mobile 1`] = ` +
    + + Skip to main content + +
    +
    + +
    +
    +
    + + edX + +
    +
    + +
    +
    +`; diff --git a/dist/generic/messages.js b/dist/generic/messages.js new file mode 100644 index 000000000..c64807d2e --- /dev/null +++ b/dist/generic/messages.js @@ -0,0 +1,15 @@ +import { defineMessages } from '@edx/frontend-platform/i18n'; +var messages = defineMessages({ + registerSentenceCase: { + id: 'general.register.sentenceCase', + defaultMessage: 'Register', + description: 'Text in a button, prompting the user to register.' + }, + signInSentenceCase: { + id: 'general.signIn.sentenceCase', + defaultMessage: 'Sign in', + description: 'Text in a button, prompting the user to log in.' + } +}); +export default messages; +//# sourceMappingURL=messages.js.map \ No newline at end of file diff --git a/dist/generic/messages.js.map b/dist/generic/messages.js.map new file mode 100644 index 000000000..bc5b0340c --- /dev/null +++ b/dist/generic/messages.js.map @@ -0,0 +1 @@ +{"version":3,"file":"messages.js","names":["defineMessages","messages","registerSentenceCase","id","defaultMessage","description","signInSentenceCase"],"sources":["../../src/generic/messages.js"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n registerSentenceCase: {\n id: 'general.register.sentenceCase',\n defaultMessage: 'Register',\n description: 'Text in a button, prompting the user to register.',\n },\n signInSentenceCase: {\n id: 'general.signIn.sentenceCase',\n defaultMessage: 'Sign in',\n description: 'Text in a button, prompting the user to log in.',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,6BAA6B;AAE5D,IAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9BE,oBAAoB,EAAE;IACpBC,EAAE,EAAE,+BAA+B;IACnCC,cAAc,EAAE,UAAU;IAC1BC,WAAW,EAAE;EACf,CAAC;EACDC,kBAAkB,EAAE;IAClBH,EAAE,EAAE,6BAA6B;IACjCC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]} \ No newline at end of file diff --git a/dist/i18n/index.js b/dist/i18n/index.js new file mode 100644 index 000000000..2fe05b263 --- /dev/null +++ b/dist/i18n/index.js @@ -0,0 +1,2 @@ +export default {}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/i18n/index.js.map b/dist/i18n/index.js.map new file mode 100644 index 000000000..e86f6ffbd --- /dev/null +++ b/dist/i18n/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","names":[],"sources":["../../src/i18n/index.js"],"sourcesContent":["export default {};\n"],"mappings":"AAAA,eAAe,CAAC,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 000000000..d392a8f7d --- /dev/null +++ b/dist/index.js @@ -0,0 +1,7 @@ +import Header from './Header'; +import LearningHeader from './learning-header/LearningHeader'; +import messages from './i18n/index'; +import StudioHeader from './studio-header'; +export { LearningHeader, messages, StudioHeader }; +export default Header; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 000000000..5a16ee9f7 --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","names":["Header","LearningHeader","messages","StudioHeader"],"sources":["../src/index.jsx"],"sourcesContent":["import Header from './Header';\nimport LearningHeader from './learning-header/LearningHeader';\nimport messages from './i18n/index';\nimport StudioHeader from './studio-header';\n\nexport { LearningHeader, messages, StudioHeader };\n\nexport default Header;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,cAAc,MAAM,kCAAkC;AAC7D,OAAOC,QAAQ,MAAM,cAAc;AACnC,OAAOC,YAAY,MAAM,iBAAiB;AAE1C,SAASF,cAAc,EAAEC,QAAQ,EAAEC,YAAY;AAE/C,eAAeH,MAAM","ignoreList":[]} \ No newline at end of file diff --git a/dist/index.scss b/dist/index.scss new file mode 100644 index 000000000..f468c8a04 --- /dev/null +++ b/dist/index.scss @@ -0,0 +1,134 @@ +@import './Menu/menu.scss'; +@import './studio-header/StudioHeader.scss'; + +.dropdown-item a { + text-decoration: none; +} + +.icon-button { + display: inline-flex; + line-height: 3rem; + background: transparent; + vertical-align: middle; + text-align: center; + border: none; + height: 3rem; + width: 3rem; + padding: .75rem; + justify-content: center; + align-items:center; + + &:hover, &:focus { + background: rgba(0, 0, 0, .1); + } +} + +.learning-header { + min-width: 0; + + .course-title-lockup { + min-width: 0; + + span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + padding-bottom: calc(var(--pgn-spacing-spacer-base)* 0.1); + } + } + + .user-dropdown .btn { + height: 3rem; + + @media (--max-pgn-size-breakpoint-xs) { + padding: 0 .5rem; + } + } +} + +.site-header-mobile, +.site-header-desktop { + position: relative; + z-index: 1000; +} + +.site-header-mobile { + height: 3rem; + + .nav-link { + text-decoration: none; + cursor: pointer; + } + + img { + height: 1.5rem; + } +} + + +.site-header-desktop { + box-shadow: 0 1px 0 0 rgba(0, 0, 0, .1); + background: var(--pgn-color-white); + + .nav-link { + text-decoration: none; + } + + .logo { + display: block; + box-sizing: content-box; + position: relative; + top: -.05em; + height: 1.75rem; + padding: var(--pgn-spacing-spacer-base) 0; + margin-right: var(--pgn-spacing-spacer-base); + + img { + display: block; + height: 100%; + } + } + .secondary-menu-container { + .nav-link:hover, + .nav-link:focus, + .nav-link.active, + .expanded .nav-link { + background: var(--pgn-color-bg-active); + color: var(--pgn-color-active); + } + } + .main-nav { + .nav-link { + padding: 1.125rem var(--pgn-spacing-spacer-base); + text-decoration: none; + font-weight: 500; + letter-spacing: .01em; + } + + .nav-link:hover, + .nav-link:focus, + .nav-link.active, + .expanded .nav-link { + background: var(--pgn-color-bg-active); + color: var(--pgn-color-active); + } + + .menu { + position: static; + + .menu-content { + border-top: solid 2px var(--pgn-color-bg-active); + left: 0; + right: 0; + box-shadow: var(--pgn-elevation-box-shadow-down-1); + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + padding: var(--pgn-spacing-spacer-base); + } + } + } + + .search-input { + border-radius: var(--pgn-size-rounded-pill); + } +} diff --git a/dist/learning-header/AnonymousUserMenu.js b/dist/learning-header/AnonymousUserMenu.js new file mode 100644 index 000000000..a4a1ad0e1 --- /dev/null +++ b/dist/learning-header/AnonymousUserMenu.js @@ -0,0 +1,22 @@ +import React from 'react'; +import { getConfig } from '@edx/frontend-platform'; +import { getLoginRedirectUrl } from '@edx/frontend-platform/auth'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { Button } from '@openedx/paragon'; +import genericMessages from '../generic/messages'; +var AnonymousUserMenu = function AnonymousUserMenu(_ref) { + var intl = _ref.intl; + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, { + className: "mr-3", + variant: "outline-primary", + href: "".concat(getConfig().LMS_BASE_URL, "/register?next=").concat(encodeURIComponent(global.location.href)) + }, intl.formatMessage(genericMessages.registerSentenceCase)), /*#__PURE__*/React.createElement(Button, { + variant: "primary", + href: "".concat(getLoginRedirectUrl(global.location.href)) + }, intl.formatMessage(genericMessages.signInSentenceCase))); +}; +AnonymousUserMenu.propTypes = { + intl: intlShape.isRequired +}; +export default injectIntl(AnonymousUserMenu); +//# sourceMappingURL=AnonymousUserMenu.js.map \ No newline at end of file diff --git a/dist/learning-header/AnonymousUserMenu.js.map b/dist/learning-header/AnonymousUserMenu.js.map new file mode 100644 index 000000000..4244c916f --- /dev/null +++ b/dist/learning-header/AnonymousUserMenu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AnonymousUserMenu.js","names":["React","getConfig","getLoginRedirectUrl","injectIntl","intlShape","Button","genericMessages","AnonymousUserMenu","_ref","intl","createElement","className","variant","href","concat","LMS_BASE_URL","encodeURIComponent","global","location","formatMessage","registerSentenceCase","signInSentenceCase","propTypes","isRequired"],"sources":["../../src/learning-header/AnonymousUserMenu.jsx"],"sourcesContent":["import React from 'react';\n\nimport { getConfig } from '@edx/frontend-platform';\nimport { getLoginRedirectUrl } from '@edx/frontend-platform/auth';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { Button } from '@openedx/paragon';\n\nimport genericMessages from '../generic/messages';\n\nconst AnonymousUserMenu = ({ intl }) => (\n
    \n \n {intl.formatMessage(genericMessages.registerSentenceCase)}\n \n \n {intl.formatMessage(genericMessages.signInSentenceCase)}\n \n
    \n);\n\nAnonymousUserMenu.propTypes = {\n intl: intlShape.isRequired,\n};\n\nexport default injectIntl(AnonymousUserMenu);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,mBAAmB,QAAQ,6BAA6B;AACjE,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,MAAM,QAAQ,kBAAkB;AAEzC,OAAOC,eAAe,MAAM,qBAAqB;AAEjD,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAAC,IAAA;EAAA,IAAMC,IAAI,GAAAD,IAAA,CAAJC,IAAI;EAAA,oBAC/BT,KAAA,CAAAU,aAAA,2BACEV,KAAA,CAAAU,aAAA,CAACL,MAAM;IACLM,SAAS,EAAC,MAAM;IAChBC,OAAO,EAAC,iBAAiB;IACzBC,IAAI,KAAAC,MAAA,CAAKb,SAAS,CAAC,CAAC,CAACc,YAAY,qBAAAD,MAAA,CAAkBE,kBAAkB,CAACC,MAAM,CAACC,QAAQ,CAACL,IAAI,CAAC;EAAG,GAE7FJ,IAAI,CAACU,aAAa,CAACb,eAAe,CAACc,oBAAoB,CAClD,CAAC,eACTpB,KAAA,CAAAU,aAAA,CAACL,MAAM;IACLO,OAAO,EAAC,SAAS;IACjBC,IAAI,KAAAC,MAAA,CAAKZ,mBAAmB,CAACe,MAAM,CAACC,QAAQ,CAACL,IAAI,CAAC;EAAG,GAEpDJ,IAAI,CAACU,aAAa,CAACb,eAAe,CAACe,kBAAkB,CAChD,CACL,CAAC;AAAA,CACP;AAEDd,iBAAiB,CAACe,SAAS,GAAG;EAC5Bb,IAAI,EAAEL,SAAS,CAACmB;AAClB,CAAC;AAED,eAAepB,UAAU,CAACI,iBAAiB,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/learning-header/AuthenticatedUserDropdown.js b/dist/learning-header/AuthenticatedUserDropdown.js new file mode 100644 index 000000000..a3ab0bc33 --- /dev/null +++ b/dist/learning-header/AuthenticatedUserDropdown.js @@ -0,0 +1,46 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faUserCircle } from '@fortawesome/free-solid-svg-icons'; +import { getConfig } from '@edx/frontend-platform'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { Dropdown } from '@openedx/paragon'; +import messages from './messages'; +var AuthenticatedUserDropdown = function AuthenticatedUserDropdown(_ref) { + var intl = _ref.intl, + username = _ref.username; + var dashboardMenuItem = /*#__PURE__*/React.createElement(Dropdown.Item, { + href: "".concat(getConfig().LMS_BASE_URL, "/dashboard") + }, intl.formatMessage(messages.dashboard)); + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", { + className: "text-gray-700", + href: "".concat(getConfig().SUPPORT_URL) + }, intl.formatMessage(messages.help)), /*#__PURE__*/React.createElement(Dropdown, { + className: "user-dropdown ml-3" + }, /*#__PURE__*/React.createElement(Dropdown.Toggle, { + variant: "outline-primary" + }, /*#__PURE__*/React.createElement(FontAwesomeIcon, { + icon: faUserCircle, + className: "d-md-none", + size: "lg" + }), /*#__PURE__*/React.createElement("span", { + "data-hj-suppress": true, + className: "d-none d-md-inline" + }, username)), /*#__PURE__*/React.createElement(Dropdown.Menu, { + className: "dropdown-menu-right" + }, dashboardMenuItem, /*#__PURE__*/React.createElement(Dropdown.Item, { + href: "".concat(getConfig().ACCOUNT_PROFILE_URL, "/u/").concat(username) + }, intl.formatMessage(messages.profile)), /*#__PURE__*/React.createElement(Dropdown.Item, { + href: getConfig().ACCOUNT_SETTINGS_URL + }, intl.formatMessage(messages.account)), getConfig().ORDER_HISTORY_URL && /*#__PURE__*/React.createElement(Dropdown.Item, { + href: getConfig().ORDER_HISTORY_URL + }, intl.formatMessage(messages.orderHistory)), /*#__PURE__*/React.createElement(Dropdown.Item, { + href: getConfig().LOGOUT_URL + }, intl.formatMessage(messages.signOut))))); +}; +AuthenticatedUserDropdown.propTypes = { + intl: intlShape.isRequired, + username: PropTypes.string.isRequired +}; +export default injectIntl(AuthenticatedUserDropdown); +//# sourceMappingURL=AuthenticatedUserDropdown.js.map \ No newline at end of file diff --git a/dist/learning-header/AuthenticatedUserDropdown.js.map b/dist/learning-header/AuthenticatedUserDropdown.js.map new file mode 100644 index 000000000..905f28157 --- /dev/null +++ b/dist/learning-header/AuthenticatedUserDropdown.js.map @@ -0,0 +1 @@ +{"version":3,"file":"AuthenticatedUserDropdown.js","names":["React","PropTypes","FontAwesomeIcon","faUserCircle","getConfig","injectIntl","intlShape","Dropdown","messages","AuthenticatedUserDropdown","_ref","intl","username","dashboardMenuItem","createElement","Item","href","concat","LMS_BASE_URL","formatMessage","dashboard","Fragment","className","SUPPORT_URL","help","Toggle","variant","icon","size","Menu","ACCOUNT_PROFILE_URL","profile","ACCOUNT_SETTINGS_URL","account","ORDER_HISTORY_URL","orderHistory","LOGOUT_URL","signOut","propTypes","isRequired","string"],"sources":["../../src/learning-header/AuthenticatedUserDropdown.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faUserCircle } from '@fortawesome/free-solid-svg-icons';\nimport { getConfig } from '@edx/frontend-platform';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { Dropdown } from '@openedx/paragon';\n\nimport messages from './messages';\n\nconst AuthenticatedUserDropdown = ({ intl, username }) => {\n const dashboardMenuItem = (\n \n {intl.formatMessage(messages.dashboard)}\n \n );\n\n return (\n <>\n {intl.formatMessage(messages.help)}\n \n \n \n \n {username}\n \n \n \n {dashboardMenuItem}\n \n {intl.formatMessage(messages.profile)}\n \n \n {intl.formatMessage(messages.account)}\n \n { getConfig().ORDER_HISTORY_URL && (\n \n {intl.formatMessage(messages.orderHistory)}\n \n )}\n \n {intl.formatMessage(messages.signOut)}\n \n \n \n \n );\n};\n\nAuthenticatedUserDropdown.propTypes = {\n intl: intlShape.isRequired,\n username: PropTypes.string.isRequired,\n};\n\nexport default injectIntl(AuthenticatedUserDropdown);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,YAAY,QAAQ,mCAAmC;AAChE,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,OAAOC,QAAQ,MAAM,YAAY;AAEjC,IAAMC,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAAC,IAAA,EAA2B;EAAA,IAArBC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EACjD,IAAMC,iBAAiB,gBACrBb,KAAA,CAAAc,aAAA,CAACP,QAAQ,CAACQ,IAAI;IAACC,IAAI,KAAAC,MAAA,CAAKb,SAAS,CAAC,CAAC,CAACc,YAAY;EAAa,GAC1DP,IAAI,CAACQ,aAAa,CAACX,QAAQ,CAACY,SAAS,CACzB,CAChB;EAED,oBACEpB,KAAA,CAAAc,aAAA,CAAAd,KAAA,CAAAqB,QAAA,qBACErB,KAAA,CAAAc,aAAA;IAAGQ,SAAS,EAAC,eAAe;IAACN,IAAI,KAAAC,MAAA,CAAKb,SAAS,CAAC,CAAC,CAACmB,WAAW;EAAG,GAAEZ,IAAI,CAACQ,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B,IAAI,CAACQ,aAAa,CAACX,QAAQ,CAAC6B,OAAO,CACvB,CACF,CACP,CACV,CAAC;AAEP,CAAC;AAED5B,yBAAyB,CAAC6B,SAAS,GAAG;EACpC3B,IAAI,EAAEL,SAAS,CAACiC,UAAU;EAC1B3B,QAAQ,EAAEX,SAAS,CAACuC,MAAM,CAACD;AAC7B,CAAC;AAED,eAAelC,UAAU,CAACI,yBAAyB,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/learning-header/LearningHeader.js b/dist/learning-header/LearningHeader.js new file mode 100644 index 000000000..8335e6861 --- /dev/null +++ b/dist/learning-header/LearningHeader.js @@ -0,0 +1,79 @@ +var _excluded = ["href", "src", "alt"]; +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } +function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } +import React, { useContext } from 'react'; +import PropTypes from 'prop-types'; +import { getConfig } from '@edx/frontend-platform'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { AppContext } from '@edx/frontend-platform/react'; +import AnonymousUserMenu from './AnonymousUserMenu'; +import AuthenticatedUserDropdown from './AuthenticatedUserDropdown'; +import messages from './messages'; +var LinkedLogo = function LinkedLogo(_ref) { + var href = _ref.href, + src = _ref.src, + alt = _ref.alt, + attributes = _objectWithoutProperties(_ref, _excluded); + return /*#__PURE__*/React.createElement("a", _extends({ + href: href + }, attributes), /*#__PURE__*/React.createElement("img", { + className: "d-block", + src: src, + alt: alt + })); +}; +LinkedLogo.propTypes = { + href: PropTypes.string.isRequired, + src: PropTypes.string.isRequired, + alt: PropTypes.string.isRequired +}; +var LearningHeader = function LearningHeader(_ref2) { + var courseOrg = _ref2.courseOrg, + courseNumber = _ref2.courseNumber, + courseTitle = _ref2.courseTitle, + intl = _ref2.intl, + showUserDropdown = _ref2.showUserDropdown; + var _useContext = useContext(AppContext), + authenticatedUser = _useContext.authenticatedUser; + var headerLogo = /*#__PURE__*/React.createElement(LinkedLogo, { + className: "logo", + href: "".concat(getConfig().LMS_BASE_URL, "/dashboard"), + src: getConfig().LOGO_URL, + alt: getConfig().SITE_NAME + }); + return /*#__PURE__*/React.createElement("header", { + className: "learning-header" + }, /*#__PURE__*/React.createElement("a", { + className: "sr-only sr-only-focusable", + href: "#main-content" + }, intl.formatMessage(messages.skipNavLink)), /*#__PURE__*/React.createElement("div", { + className: "container-xl py-2 d-flex align-items-center" + }, headerLogo, /*#__PURE__*/React.createElement("div", { + className: "flex-grow-1 course-title-lockup", + style: { + lineHeight: 1 + } + }, /*#__PURE__*/React.createElement("span", { + className: "d-block small m-0" + }, courseOrg, " ", courseNumber), /*#__PURE__*/React.createElement("span", { + className: "d-block m-0 font-weight-bold course-title" + }, courseTitle)), showUserDropdown && authenticatedUser && /*#__PURE__*/React.createElement(AuthenticatedUserDropdown, { + username: authenticatedUser.username + }), showUserDropdown && !authenticatedUser && /*#__PURE__*/React.createElement(AnonymousUserMenu, null))); +}; +LearningHeader.propTypes = { + courseOrg: PropTypes.string, + courseNumber: PropTypes.string, + courseTitle: PropTypes.string, + intl: intlShape.isRequired, + showUserDropdown: PropTypes.bool +}; +LearningHeader.defaultProps = { + courseOrg: null, + courseNumber: null, + courseTitle: null, + showUserDropdown: true +}; +export default injectIntl(LearningHeader); +//# sourceMappingURL=LearningHeader.js.map \ No newline at end of file diff --git a/dist/learning-header/LearningHeader.js.map b/dist/learning-header/LearningHeader.js.map new file mode 100644 index 000000000..0a59c3b53 --- /dev/null +++ b/dist/learning-header/LearningHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LearningHeader.js","names":["React","useContext","PropTypes","getConfig","injectIntl","intlShape","AppContext","AnonymousUserMenu","AuthenticatedUserDropdown","messages","LinkedLogo","_ref","href","src","alt","attributes","_objectWithoutProperties","_excluded","createElement","_extends","className","propTypes","string","isRequired","LearningHeader","_ref2","courseOrg","courseNumber","courseTitle","intl","showUserDropdown","_useContext","authenticatedUser","headerLogo","concat","LMS_BASE_URL","LOGO_URL","SITE_NAME","formatMessage","skipNavLink","style","lineHeight","username","bool","defaultProps"],"sources":["../../src/learning-header/LearningHeader.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { getConfig } from '@edx/frontend-platform';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport { AppContext } from '@edx/frontend-platform/react';\n\nimport AnonymousUserMenu from './AnonymousUserMenu';\nimport AuthenticatedUserDropdown from './AuthenticatedUserDropdown';\nimport messages from './messages';\n\nconst LinkedLogo = ({\n href,\n src,\n alt,\n ...attributes\n}) => (\n \n {alt}\n \n);\n\nLinkedLogo.propTypes = {\n href: PropTypes.string.isRequired,\n src: PropTypes.string.isRequired,\n alt: PropTypes.string.isRequired,\n};\n\nconst LearningHeader = ({\n courseOrg, courseNumber, courseTitle, intl, showUserDropdown,\n}) => {\n const { authenticatedUser } = useContext(AppContext);\n\n const headerLogo = (\n \n );\n\n return (\n
    \n {intl.formatMessage(messages.skipNavLink)}\n
    \n {headerLogo}\n
    \n {courseOrg} {courseNumber}\n {courseTitle}\n
    \n {showUserDropdown && authenticatedUser && (\n \n )}\n {showUserDropdown && !authenticatedUser && (\n \n )}\n
    \n
    \n );\n};\n\nLearningHeader.propTypes = {\n courseOrg: PropTypes.string,\n courseNumber: PropTypes.string,\n courseTitle: PropTypes.string,\n intl: intlShape.isRequired,\n showUserDropdown: PropTypes.bool,\n};\n\nLearningHeader.defaultProps = {\n courseOrg: null,\n courseNumber: null,\n courseTitle: null,\n showUserDropdown: true,\n};\n\nexport default injectIntl(LearningHeader);\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,wBAAwB;AAClD,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SAASC,UAAU,QAAQ,8BAA8B;AAEzD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,yBAAyB,MAAM,6BAA6B;AACnE,OAAOC,QAAQ,MAAM,YAAY;AAEjC,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA;EAAA,IACdC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,GAAG,GAAAH,IAAA,CAAHG,GAAG;IACAC,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAAA,oBAEbjB,KAAA,CAAAkB,aAAA,MAAAC,QAAA;IAAGP,IAAI,EAAEA;EAAK,GAAKG,UAAU,gBAC3Bf,KAAA,CAAAkB,aAAA;IAAKE,SAAS,EAAC,SAAS;IAACP,GAAG,EAAEA,GAAI;IAACC,GAAG,EAAEA;EAAI,CAAE,CAC7C,CAAC;AAAA,CACL;AAEDJ,UAAU,CAACW,SAAS,GAAG;EACrBT,IAAI,EAAEV,SAAS,CAACoB,MAAM,CAACC,UAAU;EACjCV,GAAG,EAAEX,SAAS,CAACoB,MAAM,CAACC,UAAU;EAChCT,GAAG,EAAEZ,SAAS,CAACoB,MAAM,CAACC;AACxB,CAAC;AAED,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAAC,KAAA,EAEd;EAAA,IADJC,SAAS,GAAAD,KAAA,CAATC,SAAS;IAAEC,YAAY,GAAAF,KAAA,CAAZE,YAAY;IA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AiB,iBACvChC,KAAA,CAAAkB,aAAA,CAACX,iBAAiB,MAAE,CAEjB,CACC,CAAC;AAEb,CAAC;AAEDiB,cAAc,CAACH,SAAS,GAAG;EACzBK,SAAS,EAAExB,SAAS,CAACoB,MAAM;EAC3BK,YAAY,EAAEzB,SAAS,CAACoB,MAAM;EAC9BM,WAAW,EAAE1B,SAAS,CAACoB,MAAM;EAC7BO,IAAI,EAAExB,SAAS,CAACkB,UAAU;EAC1BO,gBAAgB,EAAE5B,SAAS,CAACyC;AAC9B,CAAC;AAEDnB,cAAc,CAACoB,YAAY,GAAG;EAC5BlB,SAAS,EAAE,IAAI;EACfC,YAAY,EAAE,IAAI;EAClBC,WAAW,EAAE,IAAI;EACjBE,gBAAgB,EAAE;AACpB,CAAC;AAED,eAAe1B,UAAU,CAACoB,cAAc,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/learning-header/messages.js b/dist/learning-header/messages.js new file mode 100644 index 000000000..f9b0d5e06 --- /dev/null +++ b/dist/learning-header/messages.js @@ -0,0 +1,40 @@ +import { defineMessages } from '@edx/frontend-platform/i18n'; +var messages = defineMessages({ + dashboard: { + id: 'header.menu.dashboard.label', + defaultMessage: 'Dashboard', + description: 'The text for the user menu Dashboard navigation link.' + }, + help: { + id: 'header.help.label', + defaultMessage: 'Help', + description: 'The text for the link to the Help Center' + }, + profile: { + id: 'header.menu.profile.label', + defaultMessage: 'Profile', + description: 'The text for the user menu Profile navigation link.' + }, + account: { + id: 'header.menu.account.label', + defaultMessage: 'Account', + description: 'The text for the user menu Account navigation link.' + }, + orderHistory: { + id: 'header.menu.orderHistory.label', + defaultMessage: 'Order History', + description: 'The text for the user menu Order History navigation link.' + }, + skipNavLink: { + id: 'header.navigation.skipNavLink', + defaultMessage: 'Skip to main content.', + description: 'A link used by screen readers to allow users to skip to the main content of the page.' + }, + signOut: { + id: 'header.menu.signOut.label', + defaultMessage: 'Sign Out', + description: 'The label for the user menu Sign Out action.' + } +}); +export default messages; +//# sourceMappingURL=messages.js.map \ No newline at end of file diff --git a/dist/learning-header/messages.js.map b/dist/learning-header/messages.js.map new file mode 100644 index 000000000..f10eb72a7 --- /dev/null +++ b/dist/learning-header/messages.js.map @@ -0,0 +1 @@ +{"version":3,"file":"messages.js","names":["defineMessages","messages","dashboard","id","defaultMessage","description","help","profile","account","orderHistory","skipNavLink","signOut"],"sources":["../../src/learning-header/messages.js"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n dashboard: {\n id: 'header.menu.dashboard.label',\n defaultMessage: 'Dashboard',\n description: 'The text for the user menu Dashboard navigation link.',\n },\n help: {\n id: 'header.help.label',\n defaultMessage: 'Help',\n description: 'The text for the link to the Help Center',\n },\n profile: {\n id: 'header.menu.profile.label',\n defaultMessage: 'Profile',\n description: 'The text for the user menu Profile navigation link.',\n },\n account: {\n id: 'header.menu.account.label',\n defaultMessage: 'Account',\n description: 'The text for the user menu Account navigation link.',\n },\n orderHistory: {\n id: 'header.menu.orderHistory.label',\n defaultMessage: 'Order History',\n description: 'The text for the user menu Order History navigation link.',\n },\n skipNavLink: {\n id: 'header.navigation.skipNavLink',\n defaultMessage: 'Skip to main content.',\n description: 'A link used by screen readers to allow users to skip to the main content of the page.',\n },\n signOut: {\n id: 'header.menu.signOut.label',\n defaultMessage: 'Sign Out',\n description: 'The label for the user menu Sign Out action.',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,6BAA6B;AAE5D,IAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9BE,SAAS,EAAE;IACTC,EAAE,EAAE,6BAA6B;IACjCC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE;EACf,CAAC;EACDC,IAAI,EAAE;IACJH,EAAE,EAAE,mBAAmB;IACvBC,cAAc,EAAE,MAAM;IACtBC,WAAW,EAAE;EACf,CAAC;EACDE,OAAO,EAAE;IACPJ,EAAE,EAAE,2BAA2B;IAC/BC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf,CAAC;EACDG,OAAO,EAAE;IACPL,EAAE,EAAE,2BAA2B;IAC/BC,cAAc,EAAE,SAAS;IACzBC,WAAW,EAAE;EACf,CAAC;EACDI,YAAY,EAAE;IACZN,EAAE,EAAE,gCAAgC;IACpCC,cAAc,EAAE,eAAe;IAC/BC,WAAW,EAAE;EACf,CAAC;EACDK,WAAW,EAAE;IACXP,EAAE,EAAE,+BAA+B;IACnCC,cAAc,EAAE,uBAAuB;IACvCC,WAAW,EAAE;EACf,CAAC;EACDM,OAAO,EAAE;IACPR,EAAE,EAAE,2BAA2B;IAC/BC,cAAc,EAAE,UAAU;IAC1BC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeJ,QAAQ","ignoreList":[]} \ No newline at end of file diff --git a/dist/setupTest.js b/dist/setupTest.js new file mode 100644 index 000000000..95e0e5866 --- /dev/null +++ b/dist/setupTest.js @@ -0,0 +1,125 @@ +/* eslint-disable import/no-extraneous-dependencies */ + +import React from 'react'; +import PropTypes from 'prop-types'; +import '@testing-library/jest-dom'; +import '@testing-library/jest-dom/extend-expect'; +import 'babel-polyfill'; +import 'jest-chain'; +import { getConfig, mergeConfig } from '@edx/frontend-platform'; +import { configure as configureLogging } from '@edx/frontend-platform/logging'; +import { configure as configureI18n } from '@edx/frontend-platform/i18n'; +import { configure as configureAuth, MockAuthService } from '@edx/frontend-platform/auth'; +import { render as rtlRender } from '@testing-library/react'; +import { IntlProvider } from 'react-intl'; +import AppProvider from '@edx/frontend-platform/react/AppProvider'; +import appMessages from './i18n'; + +// These configuration values are usually set in webpack's EnvironmentPlugin however +// Jest does not use webpack so we need to set these so for testing +process.env.ACCESS_TOKEN_COOKIE_NAME = 'edx-jwt-cookie-header-payload'; +process.env.ACCOUNT_PROFILE_URL = 'http://localhost:1995'; +process.env.ACCOUNT_SETTINGS_URL = 'http://localhost:1997'; +process.env.BASE_URL = 'localhost:1995'; +process.env.CREDENTIALS_BASE_URL = 'http://localhost:18150'; +process.env.CSRF_TOKEN_API_PATH = '/csrf/api/v1/token'; +process.env.ECOMMERCE_BASE_URL = 'http://localhost:18130'; +process.env.LANGUAGE_PREFERENCE_COOKIE_NAME = 'openedx-language-preference'; +process.env.LMS_BASE_URL = 'http://localhost:18000'; +process.env.LOGIN_URL = 'http://localhost:18000/login'; +process.env.LOGOUT_URL = 'http://localhost:18000/logout'; +process.env.MARKETING_SITE_BASE_URL = 'http://localhost:18000'; +process.env.ORDER_HISTORY_URL = 'localhost:1996/orders'; +process.env.REFRESH_ACCESS_TOKEN_ENDPOINT = 'http://localhost:18000/login_refresh'; +process.env.SEGMENT_KEY = 'segment_whoa'; +process.env.SITE_NAME = 'edX'; +process.env.USER_INFO_COOKIE_NAME = 'edx-user-info'; +process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg'; +process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg'; +process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg'; +process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico'; + +class MockLoggingService { + logInfo = jest.fn(); + + logError = jest.fn(); +} + +export const authenticatedUser = { + userId: 'abc123', + username: 'Mock User', + roles: [], + administrator: false, +}; + +export function initializeMockApp() { + mergeConfig({ + INSIGHTS_BASE_URL: process.env.INSIGHTS_BASE_URL || null, + STUDIO_BASE_URL: process.env.STUDIO_BASE_URL || null, + TWITTER_URL: process.env.TWITTER_URL || null, + BASE_URL: process.env.BASE_URL || null, + LMS_BASE_URL: process.env.LMS_BASE_URL || null, + LOGIN_URL: process.env.LOGIN_URL || null, + LOGOUT_URL: process.env.LOGOUT_URL || null, + REFRESH_ACCESS_TOKEN_ENDPOINT: process.env.REFRESH_ACCESS_TOKEN_ENDPOINT || null, + ACCESS_TOKEN_COOKIE_NAME: process.env.ACCESS_TOKEN_COOKIE_NAME || null, + CSRF_TOKEN_API_PATH: process.env.CSRF_TOKEN_API_PATH || null, + LOGO_URL: process.env.LOGO_URL || null, + SITE_NAME: process.env.SITE_NAME || null, + + authenticatedUser: { + userId: 'abc123', + username: 'Mock User', + roles: [], + administrator: false, + }, + }); + + const loggingService = configureLogging(MockLoggingService, { + config: getConfig(), + }); + const authService = configureAuth(MockAuthService, { + config: getConfig(), + loggingService, + }); + + // i18n doesn't have a service class to return. + configureI18n({ + config: getConfig(), + loggingService, + messages: [appMessages], + }); + + return { loggingService, authService }; +} + +function render( + ui, + { + store = null, + ...renderOptions + } = {}, +) { + const Wrapper = ({ children }) => ( + // eslint-disable-next-line react/jsx-filename-extension + + + {children} + + + ); + + Wrapper.propTypes = { + children: PropTypes.node.isRequired, + }; + + return rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); +} + +// Re-export everything. +export * from '@testing-library/react'; + +// Override `render` method. +export { + render, +}; diff --git a/dist/studio-header/BrandNav.js b/dist/studio-header/BrandNav.js new file mode 100644 index 000000000..14cb1cce6 --- /dev/null +++ b/dist/studio-header/BrandNav.js @@ -0,0 +1,21 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +var BrandNav = function BrandNav(_ref) { + var studioBaseUrl = _ref.studioBaseUrl, + logo = _ref.logo, + logoAltText = _ref.logoAltText; + return /*#__PURE__*/React.createElement("a", { + href: studioBaseUrl + }, /*#__PURE__*/React.createElement("img", { + src: logo, + alt: logoAltText, + className: "d-block logo" + })); +}; +BrandNav.propTypes = { + studioBaseUrl: PropTypes.string.isRequired, + logo: PropTypes.string.isRequired, + logoAltText: PropTypes.string.isRequired +}; +export default BrandNav; +//# sourceMappingURL=BrandNav.js.map \ No newline at end of file diff --git a/dist/studio-header/BrandNav.js.map b/dist/studio-header/BrandNav.js.map new file mode 100644 index 000000000..5a8a21991 --- /dev/null +++ b/dist/studio-header/BrandNav.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BrandNav.js","names":["React","PropTypes","BrandNav","_ref","studioBaseUrl","logo","logoAltText","createElement","href","src","alt","className","propTypes","string","isRequired"],"sources":["../../src/studio-header/BrandNav.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst BrandNav = ({\n studioBaseUrl,\n logo,\n logoAltText,\n}) => (\n \n \n \n);\n\nBrandNav.propTypes = {\n studioBaseUrl: PropTypes.string.isRequired,\n logo: PropTypes.string.isRequired,\n logoAltText: PropTypes.string.isRequired,\n};\n\nexport default BrandNav;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,IAAMC,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,IAAA;EAAA,IACZC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,WAAW,GAAAH,IAAA,CAAXG,WAAW;EAAA,oBAEXN,KAAA,CAAAO,aAAA;IAAGC,IAAI,EAAEJ;EAAc,gBACrBJ,KAAA,CAAAO,aAAA;IACEE,GAAG,EAAEJ,IAAK;IACVK,GAAG,EAAEJ,WAAY;IACjBK,SAAS,EAAC;EAAc,CACzB,CACA,CAAC;AAAA,CACL;AAEDT,QAAQ,CAACU,SAAS,GAAG;EACnBR,aAAa,EAAEH,SAAS,CAACY,MAAM,CAACC,UAAU;EAC1CT,IAAI,EAAEJ,SAAS,CAACY,MAAM,CAACC,UAAU;EACjCR,WAAW,EAAEL,SAAS,CAACY,MAAM,CAACC;AAChC,CAAC;AAED,eAAeZ,QAAQ","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/CourseLockUp.js b/dist/studio-header/CourseLockUp.js new file mode 100644 index 000000000..0cc10f1e3 --- /dev/null +++ b/dist/studio-header/CourseLockUp.js @@ -0,0 +1,45 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { OverlayTrigger, Tooltip } from '@openedx/paragon'; +import messages from './messages'; +var CourseLockUp = function CourseLockUp(_ref) { + var outlineLink = _ref.outlineLink, + org = _ref.org, + number = _ref.number, + title = _ref.title, + intl = _ref.intl; + return /*#__PURE__*/React.createElement(OverlayTrigger, { + placement: "bottom", + overlay: /*#__PURE__*/React.createElement(Tooltip, { + id: "course-lock-up" + }, title) + }, /*#__PURE__*/React.createElement("a", { + className: "course-title-lockup mr-2", + href: outlineLink, + "aria-label": intl.formatMessage(messages['header.label.courseOutline']), + "data-testid": "course-lock-up-block" + }, /*#__PURE__*/React.createElement("span", { + className: "d-block small m-0 text-gray-800", + "data-testid": "course-org-number" + }, org, " ", number), /*#__PURE__*/React.createElement("span", { + className: "d-block m-0 font-weight-bold text-gray-800", + "data-testid": "course-title" + }, title))); +}; +CourseLockUp.propTypes = { + number: PropTypes.string, + org: PropTypes.string, + title: PropTypes.string, + outlineLink: PropTypes.string, + // injected + intl: intlShape.isRequired +}; +CourseLockUp.defaultProps = { + number: null, + org: null, + title: null, + outlineLink: null +}; +export default injectIntl(CourseLockUp); +//# sourceMappingURL=CourseLockUp.js.map \ No newline at end of file diff --git a/dist/studio-header/CourseLockUp.js.map b/dist/studio-header/CourseLockUp.js.map new file mode 100644 index 000000000..114365aca --- /dev/null +++ b/dist/studio-header/CourseLockUp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CourseLockUp.js","names":["React","PropTypes","injectIntl","intlShape","OverlayTrigger","Tooltip","messages","CourseLockUp","_ref","outlineLink","org","number","title","intl","createElement","placement","overlay","id","className","href","formatMessage","propTypes","string","isRequired","defaultProps"],"sources":["../../src/studio-header/CourseLockUp.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport {\n OverlayTrigger,\n Tooltip,\n} from '@openedx/paragon';\nimport messages from './messages';\n\nconst CourseLockUp = ({\n outlineLink,\n org,\n number,\n title,\n // injected\n intl,\n}) => (\n \n {title}\n \n )}\n >\n \n {org} {number}\n {title}\n \n \n);\n\nCourseLockUp.propTypes = {\n number: PropTypes.string,\n org: PropTypes.string,\n title: PropTypes.string,\n outlineLink: PropTypes.string,\n // injected\n intl: intlShape.isRequired,\n};\n\nCourseLockUp.defaultProps = {\n number: null,\n org: null,\n title: null,\n outlineLink: null,\n};\n\nexport default injectIntl(CourseLockUp);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SACEC,cAAc,EACdC,OAAO,QACF,kBAAkB;AACzB,OAAOC,QAAQ,MAAM,YAAY;AAEjC,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA;EAAA,IAChBC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IACHC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAELC,IAAI,GAAAL,IAAA,CAAJK,IAAI;EAAA,oBAEJb,KAAA,CAAAc,aAAA,CAACV,cAAc;IACbW,SAAS,EAAC,QAAQ;IAClBC,OAAO,eACLhB,KAAA,CAAAc,aAAA,CAACT,OAAO;MAACY,EAAE,EAAC;IAAgB,GACzBL,KACM;EACT,gBAEFZ,KAAA,CAAAc,aAAA;IACEI,SAAS,EAAC,0BAA0B;IACpCC,IAAI,EAAEV,WAAY;IAClB,cAAYI,IAAI,CAACO,aAAa,CAACd,QAAQ,CAAC,4BAA4B,CAAC,CAAE;IACvE,eAAY;EAAsB,gBAElCN,KAAA,CAAAc,aAAA;IAAMI,SAAS,EAAC,iCAAiC;IAAC,eAAY;EAAmB,GAAER,GAAG,EAAC,GAAC,EAACC,MAAa,CAAC,eACvGX,KAAA,CAAAc,aAAA;IAAMI,SAAS,EAAC,4CAA4C;IAAC,eAAY;EAAc,GAAEN,KAAY,CACpG,CACW,CAAC;AAAA,CAClB;AAEDL,YAAY,CAACc,SAAS,GAAG;EACvBV,MAAM,EAAEV,SAAS,CAACqB,MAAM;EACxBZ,GAAG,EAAET,SAAS,CAACqB,MAAM;EACrBV,KAAK,EAAEX,SAAS,CAACqB,MAAM;EACvBb,WAAW,EAAER,SAAS,CAACqB,MAAM;EAC7B;EACAT,IAAI,EAAEV,SAAS,CAACoB;AAClB,CAAC;AAEDhB,YAAY,CAACiB,YAAY,GAAG;EAC1Bb,MAAM,EAAE,IAAI;EACZD,GAAG,EAAE,IAAI;EACTE,KAAK,EAAE,IAAI;EACXH,WAAW,EAAE;AACf,CAAC;AAED,eAAeP,UAAU,CAACK,YAAY,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/HeaderBody.js b/dist/studio-header/HeaderBody.js new file mode 100644 index 000000000..0a83bb20c --- /dev/null +++ b/dist/studio-header/HeaderBody.js @@ -0,0 +1,131 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { useIntl } from '@edx/frontend-platform/i18n'; +import { ActionRow, Button, Container, Icon, IconButton, Nav, Row } from '@openedx/paragon'; +import { Close, MenuIcon, Search } from '@openedx/paragon/icons'; +import CourseLockUp from './CourseLockUp'; +import UserMenu from './UserMenu'; +import BrandNav from './BrandNav'; +import NavDropdownMenu from './NavDropdownMenu'; +import messages from './messages'; +var HeaderBody = function HeaderBody(_ref) { + var logo = _ref.logo, + logoAltText = _ref.logoAltText, + number = _ref.number, + org = _ref.org, + title = _ref.title, + username = _ref.username, + isAdmin = _ref.isAdmin, + studioBaseUrl = _ref.studioBaseUrl, + logoutUrl = _ref.logoutUrl, + authenticatedUserAvatar = _ref.authenticatedUserAvatar, + isMobile = _ref.isMobile, + setModalPopupTarget = _ref.setModalPopupTarget, + toggleModalPopup = _ref.toggleModalPopup, + isModalPopupOpen = _ref.isModalPopupOpen, + isHiddenMainMenu = _ref.isHiddenMainMenu, + mainMenuDropdowns = _ref.mainMenuDropdowns, + outlineLink = _ref.outlineLink, + searchButtonAction = _ref.searchButtonAction; + var intl = useIntl(); + var renderBrandNav = /*#__PURE__*/React.createElement(BrandNav, { + studioBaseUrl: studioBaseUrl, + logo: logo, + logoAltText: logoAltText + }); + return /*#__PURE__*/React.createElement(Container, { + size: "xl", + className: "px-2.5" + }, /*#__PURE__*/React.createElement(ActionRow, { + as: "header" + }, isHiddenMainMenu ? /*#__PURE__*/React.createElement(Row, { + className: "flex-nowrap ml-4" + }, renderBrandNav) : /*#__PURE__*/React.createElement(React.Fragment, null, isMobile ? /*#__PURE__*/React.createElement(Button, { + ref: setModalPopupTarget, + className: "d-inline-flex align-items-center", + variant: "tertiary", + onClick: toggleModalPopup, + iconBefore: isModalPopupOpen ? Close : MenuIcon, + "data-testid": "mobile-menu-button" + }, "Menu") : /*#__PURE__*/React.createElement("div", { + className: "w-25" + }, /*#__PURE__*/React.createElement(Row, { + className: "m-0 flex-nowrap" + }, renderBrandNav, /*#__PURE__*/React.createElement(CourseLockUp, { + outlineLink: outlineLink, + number: number, + org: org, + title: title + }))), isMobile ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionRow.Spacer, null), renderBrandNav) : /*#__PURE__*/React.createElement(Nav, { + "data-testid": "desktop-menu", + className: "ml-2" + }, mainMenuDropdowns.map(function (dropdown) { + var id = dropdown.id, + buttonTitle = dropdown.buttonTitle, + items = dropdown.items; + return /*#__PURE__*/React.createElement(NavDropdownMenu, { + key: id, + id: id, + buttonTitle: buttonTitle, + items: items + }); + }))), /*#__PURE__*/React.createElement(ActionRow.Spacer, null), searchButtonAction && /*#__PURE__*/React.createElement(Nav, null, /*#__PURE__*/React.createElement(IconButton, { + src: Search, + iconAs: Icon, + onClick: searchButtonAction, + "aria-label": intl.formatMessage(messages['header.label.search.nav']) + })), /*#__PURE__*/React.createElement(Nav, null, /*#__PURE__*/React.createElement(UserMenu, { + username: username, + studioBaseUrl: studioBaseUrl, + logoutUrl: logoutUrl, + authenticatedUserAvatar: authenticatedUserAvatar, + isAdmin: isAdmin + })))); +}; +HeaderBody.propTypes = { + studioBaseUrl: PropTypes.string.isRequired, + logoutUrl: PropTypes.string.isRequired, + setModalPopupTarget: PropTypes.func, + toggleModalPopup: PropTypes.func, + isModalPopupOpen: PropTypes.bool, + number: PropTypes.string, + org: PropTypes.string, + title: PropTypes.string, + logo: PropTypes.string, + logoAltText: PropTypes.string, + authenticatedUserAvatar: PropTypes.string, + username: PropTypes.string, + isAdmin: PropTypes.bool, + isMobile: PropTypes.bool, + isHiddenMainMenu: PropTypes.bool, + mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + buttonTitle: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + href: PropTypes.string, + title: PropTypes.string + })) + })), + outlineLink: PropTypes.string, + searchButtonAction: PropTypes.func +}; +HeaderBody.defaultProps = { + setModalPopupTarget: null, + toggleModalPopup: null, + isModalPopupOpen: false, + logo: null, + logoAltText: null, + number: '', + org: '', + title: '', + authenticatedUserAvatar: null, + username: null, + isAdmin: false, + isMobile: false, + isHiddenMainMenu: false, + mainMenuDropdowns: [], + outlineLink: null, + searchButtonAction: null +}; +export default HeaderBody; +//# sourceMappingURL=HeaderBody.js.map \ No newline at end of file diff --git a/dist/studio-header/HeaderBody.js.map b/dist/studio-header/HeaderBody.js.map new file mode 100644 index 000000000..266074cfe --- /dev/null +++ b/dist/studio-header/HeaderBody.js.map @@ -0,0 +1 @@ +{"version":3,"file":"HeaderBody.js","names":["React","PropTypes","useIntl","ActionRow","Button","Container","Icon","IconButton","Nav","Row","Close","MenuIcon","Search","CourseLockUp","UserMenu","BrandNav","NavDropdownMenu","messages","HeaderBody","_ref","logo","logoAltText","number","org","title","username","isAdmin","studioBaseUrl","logoutUrl","authenticatedUserAvatar","isMobile","setModalPopupTarget","toggleModalPopup","isModalPopupOpen","isHiddenMainMenu","mainMenuDropdowns","outlineLink","searchButtonAction","intl","renderBrandNav","createElement","size","className","as","Fragment","ref","variant","onClick","iconBefore","Spacer","map","dropdown","id","buttonTitle","items","key","src","iconAs","formatMessage","propTypes","string","isRequired","func","bool","arrayOf","shape","href","defaultProps"],"sources":["../../src/studio-header/HeaderBody.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport {\n ActionRow,\n Button,\n Container,\n Icon,\n IconButton,\n Nav,\n Row,\n} from '@openedx/paragon';\nimport { Close, MenuIcon, Search } from '@openedx/paragon/icons';\n\nimport CourseLockUp from './CourseLockUp';\nimport UserMenu from './UserMenu';\nimport BrandNav from './BrandNav';\nimport NavDropdownMenu from './NavDropdownMenu';\nimport messages from './messages';\n\nconst HeaderBody = ({\n logo,\n logoAltText,\n number,\n org,\n title,\n username,\n isAdmin,\n studioBaseUrl,\n logoutUrl,\n authenticatedUserAvatar,\n isMobile,\n setModalPopupTarget,\n toggleModalPopup,\n isModalPopupOpen,\n isHiddenMainMenu,\n mainMenuDropdowns,\n outlineLink,\n searchButtonAction,\n}) => {\n const intl = useIntl();\n\n const renderBrandNav = (\n \n );\n\n return (\n \n \n {isHiddenMainMenu ? (\n \n {renderBrandNav}\n \n ) : (\n <>\n {isMobile ? (\n \n Menu\n \n ) : (\n
    \n \n {renderBrandNav}\n \n \n
    \n )}\n {isMobile ? (\n <>\n \n {renderBrandNav}\n \n ) : (\n \n )}\n \n )}\n \n {searchButtonAction && (\n \n )}\n \n
    \n
    \n );\n};\n\nHeaderBody.propTypes = {\n studioBaseUrl: PropTypes.string.isRequired,\n logoutUrl: PropTypes.string.isRequired,\n setModalPopupTarget: PropTypes.func,\n toggleModalPopup: PropTypes.func,\n isModalPopupOpen: PropTypes.bool,\n number: PropTypes.string,\n org: PropTypes.string,\n title: PropTypes.string,\n logo: PropTypes.string,\n logoAltText: PropTypes.string,\n authenticatedUserAvatar: PropTypes.string,\n username: PropTypes.string,\n isAdmin: PropTypes.bool,\n isMobile: PropTypes.bool,\n isHiddenMainMenu: PropTypes.bool,\n mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({\n id: PropTypes.string,\n buttonTitle: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n href: PropTypes.string,\n title: PropTypes.string,\n })),\n })),\n outlineLink: PropTypes.string,\n searchButtonAction: PropTypes.func,\n};\n\nHeaderBody.defaultProps = {\n setModalPopupTarget: null,\n toggleModalPopup: null,\n isModalPopupOpen: false,\n logo: null,\n logoAltText: null,\n number: '',\n org: '',\n title: '',\n authenticatedUserAvatar: null,\n username: null,\n isAdmin: false,\n isMobile: false,\n isHiddenMainMenu: false,\n mainMenuDropdowns: [],\n outlineLink: null,\n searchButtonAction: null,\n};\n\nexport default HeaderBody;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,OAAO,QAAQ,6BAA6B;AACrD,SACEC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,UAAU,EACVC,GAAG,EACHC,GAAG,QACE,kBAAkB;AACzB,SAASC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,wBAAwB;AAEhE,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,QAAQ,MAAM,YAAY;AAEjC,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA,EAmBV;EAAA,IAlBJC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;IACHC,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;IACRC,OAAO,GAAAP,IAAA,CAAPO,OAAO;IACPC,aAAa,GAAAR,IAAA,CAAbQ,aAAa;IACbC,SAAS,GAAAT,IAAA,CAATS,SAAS;IACTC,uBAAuB,G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CAAC2D,MAAM;MACtBpC,KAAK,EAAEvB,SAAS,CAAC2D;IACnB,CAAC,CAAC;EACJ,CAAC,CAAC,CAAC;EACHxB,WAAW,EAAEnC,SAAS,CAAC2D,MAAM;EAC7BvB,kBAAkB,EAAEpC,SAAS,CAAC6D;AAChC,CAAC;AAED5C,UAAU,CAACiD,YAAY,GAAG;EACxBpC,mBAAmB,EAAE,IAAI;EACzBC,gBAAgB,EAAE,IAAI;EACtBC,gBAAgB,EAAE,KAAK;EACvBb,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,IAAI;EACjBC,MAAM,EAAE,EAAE;EACVC,GAAG,EAAE,EAAE;EACPC,KAAK,EAAE,EAAE;EACTK,uBAAuB,EAAE,IAAI;EAC7BJ,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAE,KAAK;EACdI,QAAQ,EAAE,KAAK;EACfI,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,EAAE;EACrBC,WAAW,EAAE,IAAI;EACjBC,kBAAkB,EAAE;AACtB,CAAC;AAED,eAAenB,UAAU","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/MobileHeader.js b/dist/studio-header/MobileHeader.js new file mode 100644 index 000000000..7fc50680c --- /dev/null +++ b/dist/studio-header/MobileHeader.js @@ -0,0 +1,79 @@ +var _excluded = ["mainMenuDropdowns"]; +function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } +function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } +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."); } +function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } +function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } +function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } +function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } +function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } +function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import { useToggle, ModalPopup } from '@openedx/paragon'; +import HeaderBody from './HeaderBody'; +import MobileMenu from './MobileMenu'; +var MobileHeader = function MobileHeader(_ref) { + var mainMenuDropdowns = _ref.mainMenuDropdowns, + props = _objectWithoutProperties(_ref, _excluded); + var _useToggle = useToggle(false), + _useToggle2 = _slicedToArray(_useToggle, 4), + isOpen = _useToggle2[0], + close = _useToggle2[2], + toggle = _useToggle2[3]; + var _useState = useState(null), + _useState2 = _slicedToArray(_useState, 2), + target = _useState2[0], + setTarget = _useState2[1]; + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderBody, _extends({}, props, { + isMobile: true, + setModalPopupTarget: setTarget, + toggleModalPopup: toggle, + isModalPopupOpen: isOpen + })), /*#__PURE__*/React.createElement(ModalPopup, { + hasArrow: true, + placement: "bottom", + positionRef: target, + isOpen: isOpen, + onClose: close, + onEscapeKey: close, + className: "mobile-menu-container" + }, /*#__PURE__*/React.createElement(MobileMenu, { + mainMenuDropdowns: mainMenuDropdowns + }))); +}; +MobileHeader.propTypes = { + studioBaseUrl: PropTypes.string.isRequired, + logoutUrl: PropTypes.string.isRequired, + number: PropTypes.string, + org: PropTypes.string, + title: PropTypes.string, + logo: PropTypes.string, + logoAltText: PropTypes.string, + authenticatedUserAvatar: PropTypes.string, + username: PropTypes.string, + isAdmin: PropTypes.bool, + mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + buttonTitle: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + href: PropTypes.string, + title: PropTypes.string + })) + })), + outlineLink: PropTypes.string +}; +MobileHeader.defaultProps = { + logo: null, + logoAltText: null, + number: null, + org: null, + title: null, + authenticatedUserAvatar: null, + username: null, + isAdmin: false, + mainMenuDropdowns: [], + outlineLink: null +}; +export default MobileHeader; +//# sourceMappingURL=MobileHeader.js.map \ No newline at end of file diff --git a/dist/studio-header/MobileHeader.js.map b/dist/studio-header/MobileHeader.js.map new file mode 100644 index 000000000..959d344d0 --- /dev/null +++ b/dist/studio-header/MobileHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MobileHeader.js","names":["React","useState","PropTypes","useToggle","ModalPopup","HeaderBody","MobileMenu","MobileHeader","_ref","mainMenuDropdowns","props","_objectWithoutProperties","_excluded","_useToggle","_useToggle2","_slicedToArray","isOpen","close","toggle","_useState","_useState2","target","setTarget","createElement","Fragment","_extends","isMobile","setModalPopupTarget","toggleModalPopup","isModalPopupOpen","hasArrow","placement","positionRef","onClose","onEscapeKey","className","propTypes","studioBaseUrl","string","isRequired","logoutUrl","number","org","title","logo","logoAltText","authenticatedUserAvatar","username","isAdmin","bool","arrayOf","shape","id","buttonTitle","items","href","outlineLink","defaultProps"],"sources":["../../src/studio-header/MobileHeader.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useToggle, ModalPopup } from '@openedx/paragon';\nimport HeaderBody from './HeaderBody';\nimport MobileMenu from './MobileMenu';\n\nconst MobileHeader = ({\n mainMenuDropdowns,\n ...props\n}) => {\n const [isOpen, , close, toggle] = useToggle(false);\n const [target, setTarget] = useState(null);\n\n return (\n <>\n \n \n \n \n \n );\n};\n\nMobileHeader.propTypes = {\n studioBaseUrl: PropTypes.string.isRequired,\n logoutUrl: PropTypes.string.isRequired,\n number: PropTypes.string,\n org: PropTypes.string,\n title: PropTypes.string,\n logo: PropTypes.string,\n logoAltText: PropTypes.string,\n authenticatedUserAvatar: PropTypes.string,\n username: PropTypes.string,\n isAdmin: PropTypes.bool,\n mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({\n id: PropTypes.string,\n buttonTitle: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n href: PropTypes.string,\n title: PropTypes.string,\n })),\n })),\n outlineLink: PropTypes.string,\n};\n\nMobileHeader.defaultProps = {\n logo: null,\n logoAltText: null,\n number: null,\n org: null,\n title: null,\n authenticatedUserAvatar: null,\n username: null,\n isAdmin: false,\n mainMenuDropdowns: [],\n outlineLink: null,\n};\n\nexport default MobileHeader;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,EAAEC,UAAU,QAAQ,kBAAkB;AACxD,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,UAAU,MAAM,cAAc;AAErC,IAAMC,YAA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I,GAAG,EAAExC,SAAS,CAACoC,MAAM;EACrBK,KAAK,EAAEzC,SAAS,CAACoC,MAAM;EACvBM,IAAI,EAAE1C,SAAS,CAACoC,MAAM;EACtBO,WAAW,EAAE3C,SAAS,CAACoC,MAAM;EAC7BQ,uBAAuB,EAAE5C,SAAS,CAACoC,MAAM;EACzCS,QAAQ,EAAE7C,SAAS,CAACoC,MAAM;EAC1BU,OAAO,EAAE9C,SAAS,CAAC+C,IAAI;EACvBxC,iBAAiB,EAAEP,SAAS,CAACgD,OAAO,CAAChD,SAAS,CAACiD,KAAK,CAAC;IACnDC,EAAE,EAAElD,SAAS,CAACoC,MAAM;IACpBe,WAAW,EAAEnD,SAAS,CAACoC,MAAM;IAC7BgB,KAAK,EAAEpD,SAAS,CAACgD,OAAO,CAAChD,SAAS,CAACiD,KAAK,CAAC;MACvCI,IAAI,EAAErD,SAAS,CAACoC,MAAM;MACtBK,KAAK,EAAEzC,SAAS,CAACoC;IACnB,CAAC,CAAC;EACJ,CAAC,CAAC,CAAC;EACHkB,WAAW,EAAEtD,SAAS,CAACoC;AACzB,CAAC;AAED/B,YAAY,CAACkD,YAAY,GAAG;EAC1Bb,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,IAAI;EACjBJ,MAAM,EAAE,IAAI;EACZC,GAAG,EAAE,IAAI;EACTC,KAAK,EAAE,IAAI;EACXG,uBAAuB,EAAE,IAAI;EAC7BC,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAE,KAAK;EACdvC,iBAAiB,EAAE,EAAE;EACrB+C,WAAW,EAAE;AACf,CAAC;AAED,eAAejD,YAAY","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/MobileMenu.js b/dist/studio-header/MobileMenu.js new file mode 100644 index 000000000..a1f618c13 --- /dev/null +++ b/dist/studio-header/MobileMenu.js @@ -0,0 +1,45 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Collapsible } from '@openedx/paragon'; +var MobileMenu = function MobileMenu(_ref) { + var mainMenuDropdowns = _ref.mainMenuDropdowns; + return /*#__PURE__*/React.createElement("div", { + className: "ml-4 p-2 bg-light-100 border border-gray-200 small rounded", + "data-testid": "mobile-menu" + }, /*#__PURE__*/React.createElement("div", null, mainMenuDropdowns.map(function (dropdown) { + var id = dropdown.id, + buttonTitle = dropdown.buttonTitle, + items = dropdown.items; + return /*#__PURE__*/React.createElement(Collapsible, { + className: "border-light-100", + title: buttonTitle, + key: id + }, /*#__PURE__*/React.createElement("ul", { + className: "p-0", + style: { + listStyleType: 'none' + } + }, items.map(function (item) { + return /*#__PURE__*/React.createElement("li", { + className: "mobile-menu-item" + }, /*#__PURE__*/React.createElement("a", { + href: item.href + }, item.title)); + }))); + }))); +}; +MobileMenu.propTypes = { + mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + buttonTitle: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + href: PropTypes.string, + title: PropTypes.string + })) + })) +}; +MobileMenu.defaultProps = { + mainMenuDropdowns: [] +}; +export default MobileMenu; +//# sourceMappingURL=MobileMenu.js.map \ No newline at end of file diff --git a/dist/studio-header/MobileMenu.js.map b/dist/studio-header/MobileMenu.js.map new file mode 100644 index 000000000..7717a6f0d --- /dev/null +++ b/dist/studio-header/MobileMenu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MobileMenu.js","names":["React","PropTypes","Collapsible","MobileMenu","_ref","mainMenuDropdowns","createElement","className","map","dropdown","id","buttonTitle","items","title","key","style","listStyleType","item","href","propTypes","arrayOf","shape","string","defaultProps"],"sources":["../../src/studio-header/MobileMenu.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Collapsible } from '@openedx/paragon';\n\nconst MobileMenu = ({\n mainMenuDropdowns,\n}) => (\n \n
    \n {mainMenuDropdowns.map(dropdown => {\n const { id, buttonTitle, items } = dropdown;\n return (\n \n \n \n );\n })}\n
    \n \n);\n\nMobileMenu.propTypes = {\n mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({\n id: PropTypes.string,\n buttonTitle: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n href: PropTypes.string,\n title: PropTypes.string,\n })),\n })),\n};\nMobileMenu.defaultProps = {\n mainMenuDropdowns: [],\n};\n\nexport default MobileMenu;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAAC,IAAA;EAAA,IACdC,iBAAiB,GAAAD,IAAA,CAAjBC,iBAAiB;EAAA,oBAEjBL,KAAA,CAAAM,aAAA;IACEC,SAAS,EAAC,4DAA4D;IACtE,eAAY;EAAa,gBAEzBP,KAAA,CAAAM,aAAA,cACGD,iBAAiB,CAACG,GAAG,CAAC,UAAAC,QAAQ,EAAI;IACjC,IAAQC,EAAE,GAAyBD,QAAQ,CAAnCC,EAAE;MAAEC,WAAW,GAAYF,QAAQ,CAA/BE,WAAW;MAAEC,KAAK,GAAKH,QAAQ,CAAlBG,KAAK;IAC9B,oBACEZ,KAAA,CAAAM,aAAA,CAACJ,WAAW;MACVK,SAAS,EAAC,kBAAkB;MAC5BM,KAAK,EAAEF,WAAY;MACnBG,GAAG,EAAEJ;IAAG,gBAERV,KAAA,CAAAM,aAAA;MAAIC,SAAS,EAAC,KAAK;MAACQ,KAAK,EAAE;QAAEC,aAAa,EAAE;MAAO;IAAE,GAClDJ,KAAK,CAACJ,GAAG,CAAC,UAAAS,IAAI;MAAA,oBACbjB,KAAA,CAAAM,aAAA;QAAIC,SAAS,EAAC;MAAkB,gBAC9BP,KAAA,CAAAM,aAAA;QAAGY,IAAI,EAAED,IAAI,CAACC;MAAK,GAChBD,IAAI,CAACJ,KACL,CACD,CAAC;IAAA,CACN,CACC,CACO,CAAC;EAElB,CAAC,CACE,CACF,CAAC;AAAA,CACP;AAEDV,UAAU,CAACgB,SAAS,GAAG;EACrBd,iBAAiB,EAAEJ,SAAS,CAACmB,OAAO,CAACnB,SAAS,CAACoB,KAAK,CAAC;IACnDX,EAAE,EAAET,SAAS,CAACqB,MAAM;IACpBX,WAAW,EAAEV,SAAS,CAACqB,MAAM;IAC7BV,KAAK,EAAEX,SAAS,CAACmB,OAAO,CAACnB,SAAS,CAACoB,KAAK,CAAC;MACvCH,IAAI,EAAEjB,SAAS,CAACqB,MAAM;MACtBT,KAAK,EAAEZ,SAAS,CAACqB;IACnB,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC;AACDnB,UAAU,CAACoB,YAAY,GAAG;EACxBlB,iBAAiB,EAAE;AACrB,CAAC;AAED,eAAeF,UAAU","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/NavDropdownMenu.js b/dist/studio-header/NavDropdownMenu.js new file mode 100644 index 000000000..0367ada5a --- /dev/null +++ b/dist/studio-header/NavDropdownMenu.js @@ -0,0 +1,30 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Dropdown, DropdownButton } from '@openedx/paragon'; +var NavDropdownMenu = function NavDropdownMenu(_ref) { + var id = _ref.id, + buttonTitle = _ref.buttonTitle, + items = _ref.items; + return /*#__PURE__*/React.createElement(DropdownButton, { + id: id, + title: buttonTitle, + variant: "outline-primary", + className: "mr-2" + }, items.map(function (item) { + return /*#__PURE__*/React.createElement(Dropdown.Item, { + key: "".concat(item.title, "-dropdown-item"), + href: item.href, + className: "small" + }, item.title); + })); +}; +NavDropdownMenu.propTypes = { + id: PropTypes.string.isRequired, + buttonTitle: PropTypes.string.isRequired, + items: PropTypes.arrayOf(PropTypes.shape({ + href: PropTypes.string, + title: PropTypes.string + })).isRequired +}; +export default NavDropdownMenu; +//# sourceMappingURL=NavDropdownMenu.js.map \ No newline at end of file diff --git a/dist/studio-header/NavDropdownMenu.js.map b/dist/studio-header/NavDropdownMenu.js.map new file mode 100644 index 000000000..7f6eff489 --- /dev/null +++ b/dist/studio-header/NavDropdownMenu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NavDropdownMenu.js","names":["React","PropTypes","Dropdown","DropdownButton","NavDropdownMenu","_ref","id","buttonTitle","items","createElement","title","variant","className","map","item","Item","key","concat","href","propTypes","string","isRequired","arrayOf","shape"],"sources":["../../src/studio-header/NavDropdownMenu.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {\n Dropdown,\n DropdownButton,\n} from '@openedx/paragon';\n\nconst NavDropdownMenu = ({\n id,\n buttonTitle,\n items,\n}) => (\n \n {items.map(item => (\n \n {item.title}\n \n ))}\n \n);\n\nNavDropdownMenu.propTypes = {\n id: PropTypes.string.isRequired,\n buttonTitle: PropTypes.string.isRequired,\n items: PropTypes.arrayOf(PropTypes.shape({\n href: PropTypes.string,\n title: PropTypes.string,\n })).isRequired,\n};\n\nexport default NavDropdownMenu;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SACEC,QAAQ,EACRC,cAAc,QACT,kBAAkB;AAEzB,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA;EAAA,IACnBC,EAAE,GAAAD,IAAA,CAAFC,EAAE;IACFC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,KAAK,GAAAH,IAAA,CAALG,KAAK;EAAA,oBAELR,KAAA,CAAAS,aAAA,CAACN,cAAc;IACbG,EAAE,EAAEA,EAAG;IACPI,KAAK,EAAEH,WAAY;IACnBI,OAAO,EAAC,iBAAiB;IACzBC,SAAS,EAAC;EAAM,GAEfJ,KAAK,CAACK,GAAG,CAAC,UAAAC,IAAI;IAAA,oBACbd,KAAA,CAAAS,aAAA,CAACP,QAAQ,CAACa,IAAI;MACZC,GAAG,KAAAC,MAAA,CAAKH,IAAI,CAACJ,KAAK,mBAAiB;MACnCQ,IAAI,EAAEJ,IAAI,CAACI,IAAK;MAChBN,SAAS,EAAC;IAAO,GAEhBE,IAAI,CAACJ,KACO,CAAC;EAAA,CACjB,CACa,CAAC;AAAA,CAClB;AAEDN,eAAe,CAACe,SAAS,GAAG;EAC1Bb,EAAE,EAAEL,SAAS,CAACmB,MAAM,CAACC,UAAU;EAC/Bd,WAAW,EAAEN,SAAS,CAACmB,MAAM,CAACC,UAAU;EACxCb,KAAK,EAAEP,SAAS,CAACqB,OAAO,CAACrB,SAAS,CAACsB,KAAK,CAAC;IACvCL,IAAI,EAAEjB,SAAS,CAACmB,MAAM;IACtBV,KAAK,EAAET,SAAS,CAACmB;EACnB,CAAC,CAAC,CAAC,CAACC;AACN,CAAC;AAED,eAAejB,eAAe","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/StudioHeader.js b/dist/studio-header/StudioHeader.js new file mode 100644 index 000000000..57366e66b --- /dev/null +++ b/dist/studio-header/StudioHeader.js @@ -0,0 +1,72 @@ +import React, { useContext } from 'react'; +import PropTypes from 'prop-types'; +import Responsive from 'react-responsive'; +import { AppContext } from '@edx/frontend-platform/react'; +import { ensureConfig } from '@edx/frontend-platform'; +import MobileHeader from './MobileHeader'; +import HeaderBody from './HeaderBody'; +ensureConfig(['STUDIO_BASE_URL', 'SITE_NAME', 'LOGOUT_URL', 'LOGIN_URL', 'LOGO_URL'], 'Studio Header component'); +var StudioHeader = function StudioHeader(_ref) { + var number = _ref.number, + org = _ref.org, + title = _ref.title, + isHiddenMainMenu = _ref.isHiddenMainMenu, + mainMenuDropdowns = _ref.mainMenuDropdowns, + outlineLink = _ref.outlineLink, + searchButtonAction = _ref.searchButtonAction; + var _useContext = useContext(AppContext), + authenticatedUser = _useContext.authenticatedUser, + config = _useContext.config; + var props = { + logo: config.LOGO_URL, + logoAltText: "Studio ".concat(config.SITE_NAME), + number: number, + org: org, + title: title, + username: authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.username, + isAdmin: authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.administrator, + authenticatedUserAvatar: authenticatedUser === null || authenticatedUser === void 0 ? void 0 : authenticatedUser.avatar, + studioBaseUrl: config.STUDIO_BASE_URL, + logoutUrl: config.LOGOUT_URL, + isHiddenMainMenu: isHiddenMainMenu, + mainMenuDropdowns: mainMenuDropdowns, + outlineLink: outlineLink, + searchButtonAction: searchButtonAction + }; + return /*#__PURE__*/React.createElement("div", { + className: "studio-header" + }, /*#__PURE__*/React.createElement("a", { + className: "nav-skip sr-only sr-only-focusable", + href: "#main" + }, "Skip to content"), /*#__PURE__*/React.createElement(Responsive, { + maxWidth: 841 + }, /*#__PURE__*/React.createElement(MobileHeader, props)), /*#__PURE__*/React.createElement(Responsive, { + minWidth: 842 + }, /*#__PURE__*/React.createElement(HeaderBody, props))); +}; +StudioHeader.propTypes = { + number: PropTypes.string, + org: PropTypes.string, + title: PropTypes.string.isRequired, + isHiddenMainMenu: PropTypes.bool, + mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + buttonTitle: PropTypes.string, + items: PropTypes.arrayOf(PropTypes.shape({ + href: PropTypes.string, + title: PropTypes.string + })) + })), + outlineLink: PropTypes.string, + searchButtonAction: PropTypes.func +}; +StudioHeader.defaultProps = { + number: '', + org: '', + isHiddenMainMenu: false, + mainMenuDropdowns: [], + outlineLink: null, + searchButtonAction: null +}; +export default StudioHeader; +//# sourceMappingURL=StudioHeader.js.map \ No newline at end of file diff --git a/dist/studio-header/StudioHeader.js.map b/dist/studio-header/StudioHeader.js.map new file mode 100644 index 000000000..923c99af1 --- /dev/null +++ b/dist/studio-header/StudioHeader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StudioHeader.js","names":["React","useContext","PropTypes","Responsive","AppContext","ensureConfig","MobileHeader","HeaderBody","StudioHeader","_ref","number","org","title","isHiddenMainMenu","mainMenuDropdowns","outlineLink","searchButtonAction","_useContext","authenticatedUser","config","props","logo","LOGO_URL","logoAltText","concat","SITE_NAME","username","isAdmin","administrator","authenticatedUserAvatar","avatar","studioBaseUrl","STUDIO_BASE_URL","logoutUrl","LOGOUT_URL","createElement","className","href","maxWidth","minWidth","propTypes","string","isRequired","bool","arrayOf","shape","id","buttonTitle","items","func","defaultProps"],"sources":["../../src/studio-header/StudioHeader.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport Responsive from 'react-responsive';\nimport { AppContext } from '@edx/frontend-platform/react';\nimport { ensureConfig } from '@edx/frontend-platform';\n\nimport MobileHeader from './MobileHeader';\nimport HeaderBody from './HeaderBody';\n\nensureConfig([\n 'STUDIO_BASE_URL',\n 'SITE_NAME',\n 'LOGOUT_URL',\n 'LOGIN_URL',\n 'LOGO_URL',\n], 'Studio Header component');\n\nconst StudioHeader = ({\n number, org, title, isHiddenMainMenu, mainMenuDropdowns, outlineLink, searchButtonAction,\n}) => {\n const { authenticatedUser, config } = useContext(AppContext);\n const props = {\n logo: config.LOGO_URL,\n logoAltText: `Studio ${config.SITE_NAME}`,\n number,\n org,\n title,\n username: authenticatedUser?.username,\n isAdmin: authenticatedUser?.administrator,\n authenticatedUserAvatar: authenticatedUser?.avatar,\n studioBaseUrl: config.STUDIO_BASE_URL,\n logoutUrl: config.LOGOUT_URL,\n isHiddenMainMenu,\n mainMenuDropdowns,\n outlineLink,\n searchButtonAction,\n };\n\n return (\n
    \n Skip to content\n \n \n \n \n \n \n
    \n );\n};\n\nStudioHeader.propTypes = {\n number: PropTypes.string,\n org: PropTypes.string,\n title: PropTypes.string.isRequired,\n isHiddenMainMenu: PropTypes.bool,\n mainMenuDropdowns: PropTypes.arrayOf(PropTypes.shape({\n id: PropTypes.string,\n buttonTitle: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({\n href: PropTypes.string,\n title: PropTypes.string,\n })),\n })),\n outlineLink: PropTypes.string,\n searchButtonAction: PropTypes.func,\n};\n\nStudioHeader.defaultProps = {\n number: '',\n org: '',\n isHiddenMainMenu: false,\n mainMenuDropdowns: [],\n outlineLink: null,\n searchButtonAction: null,\n};\n\nexport default StudioHeader;\n"],"mappings":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nB,CAAC,CAAC;EACJ,CAAC,CAAC,CAAC;EACH1B,WAAW,EAAEb,SAAS,CAACuC,MAAM;EAC7BzB,kBAAkB,EAAEd,SAAS,CAAC+C;AAChC,CAAC;AAEDzC,YAAY,CAAC0C,YAAY,GAAG;EAC1BxC,MAAM,EAAE,EAAE;EACVC,GAAG,EAAE,EAAE;EACPE,gBAAgB,EAAE,KAAK;EACvBC,iBAAiB,EAAE,EAAE;EACrBC,WAAW,EAAE,IAAI;EACjBC,kBAAkB,EAAE;AACtB,CAAC;AAED,eAAeR,YAAY","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/StudioHeader.scss b/dist/studio-header/StudioHeader.scss new file mode 100644 index 000000000..58b597bfa --- /dev/null +++ b/dist/studio-header/StudioHeader.scss @@ -0,0 +1,46 @@ +.studio-header { + position: relative; + z-index: 1000; + + height: 3.75rem; + box-shadow: 0 1px 0 0 rgb(0 0 0 / .1); + background: var(--pgn-color-white); + + .btn-outline-primary { + border-color: var(--pgn-color-white); + } + + .logo { + display: block; + box-sizing: content-box; + position: relative; + top: -.05em; + height: 1.75rem; + padding: var(--pgn-spacing-spacer-base) 0; + margin-right: var(--pgn-spacing-spacer-base); + + img { + display: block; + height: 100%; + } + } + + .course-title-lockup { + @media only screen and (min-width: 769px) { + padding: .5rem; + padding-right: var(--pgn-spacing-spacer-base); + border-right: 1px solid #E5E5E5; + width: 70%; + } + + overflow: hidden; + + span { + color: var(--pgn-color-gray-800); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + line-height: 1.375rem; + } + } +} diff --git a/dist/studio-header/UserMenu.js b/dist/studio-header/UserMenu.js new file mode 100644 index 000000000..e439b972c --- /dev/null +++ b/dist/studio-header/UserMenu.js @@ -0,0 +1,55 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { Avatar } from '@openedx/paragon'; +import NavDropdownMenu from './NavDropdownMenu'; +import getUserMenuItems from './utils'; +var UserMenu = function UserMenu(_ref) { + var username = _ref.username, + studioBaseUrl = _ref.studioBaseUrl, + logoutUrl = _ref.logoutUrl, + authenticatedUserAvatar = _ref.authenticatedUserAvatar, + isMobile = _ref.isMobile, + isAdmin = _ref.isAdmin, + intl = _ref.intl; + var avatar = authenticatedUserAvatar ? /*#__PURE__*/React.createElement("img", { + className: "d-block w-100 h-100", + src: authenticatedUserAvatar, + alt: username, + "data-testid": "avatar-image" + }) : /*#__PURE__*/React.createElement(Avatar, { + size: "sm", + className: "mr-2", + alt: username, + "data-testid": "avatar-icon" + }); + var title = isMobile ? avatar : /*#__PURE__*/React.createElement(React.Fragment, null, avatar, username); + return /*#__PURE__*/React.createElement(NavDropdownMenu, { + buttonTitle: title, + id: "user-dropdown-menu", + items: getUserMenuItems({ + studioBaseUrl: studioBaseUrl, + logoutUrl: logoutUrl, + intl: intl, + isAdmin: isAdmin + }) + }); +}; +UserMenu.propTypes = { + username: PropTypes.string, + studioBaseUrl: PropTypes.string.isRequired, + logoutUrl: PropTypes.string.isRequired, + authenticatedUserAvatar: PropTypes.string, + isMobile: PropTypes.bool, + isAdmin: PropTypes.bool, + // injected + intl: intlShape.isRequired +}; +UserMenu.defaultProps = { + isMobile: false, + isAdmin: false, + authenticatedUserAvatar: null, + username: null +}; +export default injectIntl(UserMenu); +//# sourceMappingURL=UserMenu.js.map \ No newline at end of file diff --git a/dist/studio-header/UserMenu.js.map b/dist/studio-header/UserMenu.js.map new file mode 100644 index 000000000..3a2b62e0a --- /dev/null +++ b/dist/studio-header/UserMenu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserMenu.js","names":["React","PropTypes","injectIntl","intlShape","Avatar","NavDropdownMenu","getUserMenuItems","UserMenu","_ref","username","studioBaseUrl","logoutUrl","authenticatedUserAvatar","isMobile","isAdmin","intl","avatar","createElement","className","src","alt","size","title","Fragment","buttonTitle","id","items","propTypes","string","isRequired","bool","defaultProps"],"sources":["../../src/studio-header/UserMenu.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { injectIntl, intlShape } from '@edx/frontend-platform/i18n';\nimport {\n Avatar,\n} from '@openedx/paragon';\nimport NavDropdownMenu from './NavDropdownMenu';\nimport getUserMenuItems from './utils';\n\nconst UserMenu = ({\n username,\n studioBaseUrl,\n logoutUrl,\n authenticatedUserAvatar,\n isMobile,\n isAdmin,\n // injected\n intl,\n}) => {\n const avatar = authenticatedUserAvatar ? (\n \n ) : (\n \n );\n const title = isMobile ? avatar : <>{avatar}{username};\n\n return (\n \n );\n};\n\nUserMenu.propTypes = {\n username: PropTypes.string,\n studioBaseUrl: PropTypes.string.isRequired,\n logoutUrl: PropTypes.string.isRequired,\n authenticatedUserAvatar: PropTypes.string,\n isMobile: PropTypes.bool,\n isAdmin: PropTypes.bool,\n // injected\n intl: intlShape.isRequired,\n};\n\nUserMenu.defaultProps = {\n isMobile: false,\n isAdmin: false,\n authenticatedUserAvatar: null,\n username: null,\n};\n\nexport default injectIntl(UserMenu);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,SAAS,QAAQ,6BAA6B;AACnE,SACEC,MAAM,QACD,kBAAkB;AACzB,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,gBAAgB,MAAM,SAAS;AAEtC,IAAMC,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,IAAA,EASR;EAAA,IARJC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,aAAa,GAAAF,IAAA,CAAbE,aAAa;IACbC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,uBAAuB,GAAAJ,IAAA,CAAvBI,uBAAuB;IACvBC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,OAAO,GAAAN,IAAA,CAAPM,OAAO;IAEPC,IAAI,GAAAP,IAAA,CAAJO,IAAI;EAEJ,IAAMC,MAAM,GAAGJ,uBAAuB,gBACpCZ,K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AQ,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/index.js b/dist/studio-header/index.js new file mode 100644 index 000000000..29914496a --- /dev/null +++ b/dist/studio-header/index.js @@ -0,0 +1,3 @@ +import StudioHeader from './StudioHeader'; +export default StudioHeader; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/studio-header/index.js.map b/dist/studio-header/index.js.map new file mode 100644 index 000000000..eaf732fbb --- /dev/null +++ b/dist/studio-header/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","names":["StudioHeader"],"sources":["../../src/studio-header/index.js"],"sourcesContent":["import StudioHeader from './StudioHeader';\n\nexport default StudioHeader;\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,gBAAgB;AAEzC,eAAeA,YAAY","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/messages.js b/dist/studio-header/messages.js new file mode 100644 index 000000000..667f9c10c --- /dev/null +++ b/dist/studio-header/messages.js @@ -0,0 +1,60 @@ +import { defineMessages } from '@edx/frontend-platform/i18n'; +var messages = defineMessages({ + 'header.user.menu.studio': { + id: 'header.user.menu.studio', + defaultMessage: 'Studio Home', + description: 'Link to Studio Home' + }, + 'header.user.menu.maintenance': { + id: 'header.user.menu.maintenance', + defaultMessage: 'Maintenance', + description: 'Link to the Studio maintenance page' + }, + 'header.user.menu.logout': { + id: 'header.user.menu.logout', + defaultMessage: 'Logout', + description: 'Logout link' + }, + 'header.label.account.menu': { + id: 'header.label.account.menu', + defaultMessage: 'Account Menu', + description: 'The aria label for the account menu trigger' + }, + 'header.label.account.menu.for': { + id: 'header.label.account.menu.for', + defaultMessage: 'Account menu for {username}', + description: 'The aria label for the account menu trigger when the username is displayed in it' + }, + 'header.label.main.nav': { + id: 'header.label.main.nav', + defaultMessage: 'Main', + description: 'The aria label for the main menu nav' + }, + 'header.label.main.menu': { + id: 'header.label.main.menu', + defaultMessage: 'Main Menu', + description: 'The aria label for the main menu trigger' + }, + 'header.label.main.header': { + id: 'header.label.main.header', + defaultMessage: 'Main', + description: 'The aria label for the main header' + }, + 'header.label.secondary.nav': { + id: 'header.label.secondary.nav', + defaultMessage: 'Secondary', + description: 'The aria label for the seconary nav' + }, + 'header.label.courseOutline': { + id: 'header.label.courseOutline', + defaultMessage: 'Back to course outline in Studio', + description: 'The aria label for the link back to the Studio Course Outline' + }, + 'header.label.search.nav': { + id: 'header.label.search.nav', + defaultMessage: 'Search content', + description: 'The aria label for the search content button nav' + } +}); +export default messages; +//# sourceMappingURL=messages.js.map \ No newline at end of file diff --git a/dist/studio-header/messages.js.map b/dist/studio-header/messages.js.map new file mode 100644 index 000000000..05f2a0626 --- /dev/null +++ b/dist/studio-header/messages.js.map @@ -0,0 +1 @@ +{"version":3,"file":"messages.js","names":["defineMessages","messages","id","defaultMessage","description"],"sources":["../../src/studio-header/messages.js"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n 'header.user.menu.studio': {\n id: 'header.user.menu.studio',\n defaultMessage: 'Studio Home',\n description: 'Link to Studio Home',\n },\n 'header.user.menu.maintenance': {\n id: 'header.user.menu.maintenance',\n defaultMessage: 'Maintenance',\n description: 'Link to the Studio maintenance page',\n },\n 'header.user.menu.logout': {\n id: 'header.user.menu.logout',\n defaultMessage: 'Logout',\n description: 'Logout link',\n },\n 'header.label.account.menu': {\n id: 'header.label.account.menu',\n defaultMessage: 'Account Menu',\n description: 'The aria label for the account menu trigger',\n },\n 'header.label.account.menu.for': {\n id: 'header.label.account.menu.for',\n defaultMessage: 'Account menu for {username}',\n description: 'The aria label for the account menu trigger when the username is displayed in it',\n },\n 'header.label.main.nav': {\n id: 'header.label.main.nav',\n defaultMessage: 'Main',\n description: 'The aria label for the main menu nav',\n },\n 'header.label.main.menu': {\n id: 'header.label.main.menu',\n defaultMessage: 'Main Menu',\n description: 'The aria label for the main menu trigger',\n },\n 'header.label.main.header': {\n id: 'header.label.main.header',\n defaultMessage: 'Main',\n description: 'The aria label for the main header',\n },\n 'header.label.secondary.nav': {\n id: 'header.label.secondary.nav',\n defaultMessage: 'Secondary',\n description: 'The aria label for the seconary nav',\n },\n 'header.label.courseOutline': {\n id: 'header.label.courseOutline',\n defaultMessage: 'Back to course outline in Studio',\n description: 'The aria label for the link back to the Studio Course Outline',\n },\n 'header.label.search.nav': {\n id: 'header.label.search.nav',\n defaultMessage: 'Search content',\n description: 'The aria label for the search content button nav',\n },\n});\n\nexport default messages;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,6BAA6B;AAE5D,IAAMC,QAAQ,GAAGD,cAAc,CAAC;EAC9B,yBAAyB,EAAE;IACzBE,EAAE,EAAE,yBAAyB;IAC7BC,cAAc,EAAE,aAAa;IAC7BC,WAAW,EAAE;EACf,CAAC;EACD,8BAA8B,EAAE;IAC9BF,EAAE,EAAE,8BAA8B;IAClCC,cAAc,EAAE,aAAa;IAC7BC,WAAW,EAAE;EACf,CAAC;EACD,yBAAyB,EAAE;IACzBF,EAAE,EAAE,yBAAyB;IAC7BC,cAAc,EAAE,QAAQ;IACxBC,WAAW,EAAE;EACf,CAAC;EACD,2BAA2B,EAAE;IAC3BF,EAAE,EAAE,2BAA2B;IAC/BC,cAAc,EAAE,cAAc;IAC9BC,WAAW,EAAE;EACf,CAAC;EACD,+BAA+B,EAAE;IAC/BF,EAAE,EAAE,+BAA+B;IACnCC,cAAc,EAAE,6BAA6B;IAC7CC,WAAW,EAAE;EACf,CAAC;EACD,uBAAuB,EAAE;IACvBF,EAAE,EAAE,uBAAuB;IAC3BC,cAAc,EAAE,MAAM;IACtBC,WAAW,EAAE;EACf,CAAC;EACD,wBAAwB,EAAE;IACxBF,EAAE,EAAE,wBAAwB;IAC5BC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE;EACf,CAAC;EACD,0BAA0B,EAAE;IAC1BF,EAAE,EAAE,0BAA0B;IAC9BC,cAAc,EAAE,MAAM;IACtBC,WAAW,EAAE;EACf,CAAC;EACD,4BAA4B,EAAE;IAC5BF,EAAE,EAAE,4BAA4B;IAChCC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE;EACf,CAAC;EACD,4BAA4B,EAAE;IAC5BF,EAAE,EAAE,4BAA4B;IAChCC,cAAc,EAAE,kCAAkC;IAClDC,WAAW,EAAE;EACf,CAAC;EACD,yBAAyB,EAAE;IACzBF,EAAE,EAAE,yBAAyB;IAC7BC,cAAc,EAAE,gBAAgB;IAChCC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,eAAeH,QAAQ","ignoreList":[]} \ No newline at end of file diff --git a/dist/studio-header/utils.js b/dist/studio-header/utils.js new file mode 100644 index 000000000..1abaf7aba --- /dev/null +++ b/dist/studio-header/utils.js @@ -0,0 +1,29 @@ +import messages from './messages'; +var getUserMenuItems = function getUserMenuItems(_ref) { + var studioBaseUrl = _ref.studioBaseUrl, + logoutUrl = _ref.logoutUrl, + intl = _ref.intl, + isAdmin = _ref.isAdmin; + var items = [{ + href: "".concat(studioBaseUrl), + title: intl.formatMessage(messages['header.user.menu.studio']) + }, { + href: "".concat(logoutUrl), + title: intl.formatMessage(messages['header.user.menu.logout']) + }]; + if (isAdmin) { + items = [{ + href: "".concat(studioBaseUrl), + title: intl.formatMessage(messages['header.user.menu.studio']) + }, { + href: "".concat(studioBaseUrl, "/maintenance"), + title: intl.formatMessage(messages['header.user.menu.maintenance']) + }, { + href: "".concat(logoutUrl), + title: intl.formatMessage(messages['header.user.menu.logout']) + }]; + } + return items; +}; +export default getUserMenuItems; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/studio-header/utils.js.map b/dist/studio-header/utils.js.map new file mode 100644 index 000000000..db2dfd8ee --- /dev/null +++ b/dist/studio-header/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","names":["messages","getUserMenuItems","_ref","studioBaseUrl","logoutUrl","intl","isAdmin","items","href","concat","title","formatMessage"],"sources":["../../src/studio-header/utils.js"],"sourcesContent":["import messages from './messages';\n\nconst getUserMenuItems = ({\n studioBaseUrl,\n logoutUrl,\n intl,\n isAdmin,\n}) => {\n let items = [\n {\n href: `${studioBaseUrl}`,\n title: intl.formatMessage(messages['header.user.menu.studio']),\n }, {\n href: `${logoutUrl}`,\n title: intl.formatMessage(messages['header.user.menu.logout']),\n },\n ];\n if (isAdmin) {\n items = [\n {\n href: `${studioBaseUrl}`,\n title: intl.formatMessage(messages['header.user.menu.studio']),\n }, {\n href: `${studioBaseUrl}/maintenance`,\n title: intl.formatMessage(messages['header.user.menu.maintenance']),\n }, {\n href: `${logoutUrl}`,\n title: intl.formatMessage(messages['header.user.menu.logout']),\n },\n ];\n }\n\n return items;\n};\n\nexport default getUserMenuItems;\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,YAAY;AAEjC,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAAC,IAAA,EAKhB;EAAA,IAJJC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IACJC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;EAEP,IAAIC,KAAK,GAAG,CACV;IACEC,IAAI,KAAAC,MAAA,CAAKN,aAAa,CAAE;IACxBO,KAAK,EAAEL,IAAI,CAACM,aAAa,CAACX,QAAQ,CAAC,yBAAyB,CAAC;EAC/D,CAAC,EAAE;IACDQ,IAAI,KAAAC,MAAA,CAAKL,SAAS,CAAE;IACpBM,KAAK,EAAEL,IAAI,CAACM,aAAa,CAACX,QAAQ,CAAC,yBAAyB,CAAC;EAC/D,CAAC,CACF;EACD,IAAIM,OAAO,EAAE;IACXC,KAAK,GAAG,CACN;MACEC,IAAI,KAAAC,MAAA,CAAKN,aAAa,CAAE;MACxBO,KAAK,EAAEL,IAAI,CAACM,aAAa,CAACX,QAAQ,CAAC,yBAAyB,CAAC;IAC/D,CAAC,EAAE;MACDQ,IAAI,KAAAC,MAAA,CAAKN,aAAa,iBAAc;MACpCO,KAAK,EAAEL,IAAI,CAACM,aAAa,CAACX,QAAQ,CAAC,8BAA8B,CAAC;IACpE,CAAC,EAAE;MACDQ,IAAI,KAAAC,MAAA,CAAKL,SAAS,CAAE;MACpBM,KAAK,EAAEL,IAAI,CAACM,aAAa,CAACX,QAAQ,CAAC,yBAAyB,CAAC;IAC/D,CAAC,CACF;EACH;EAEA,OAAOO,KAAK;AACd,CAAC;AAED,eAAeN,gBAAgB","ignoreList":[]} \ No newline at end of file diff --git a/dist/test-utils.js b/dist/test-utils.js new file mode 100644 index 000000000..a0948f725 --- /dev/null +++ b/dist/test-utils.js @@ -0,0 +1,26 @@ +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } +function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } +function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } +function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } +var executeThunk = /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(thunk, dispatch, getState) { + return _regeneratorRuntime().wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return thunk(dispatch, getState); + case 2: + _context.next = 4; + return new Promise(setImmediate); + case 4: + case "end": + return _context.stop(); + } + }, _callee); + })); + return function executeThunk(_x, _x2, _x3) { + return _ref.apply(this, arguments); + }; +}(); +export default executeThunk; +//# sourceMappingURL=test-utils.js.map \ No newline at end of file diff --git a/dist/test-utils.js.map b/dist/test-utils.js.map new file mode 100644 index 000000000..6de925b6e --- /dev/null +++ b/dist/test-utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-utils.js","names":["_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","_catch","delegateYield","asyncGeneratorStep","_asyncToGenerator","arguments","apply","_next","_throw","executeThunk","_ref","_callee","thunk","dispatch","getState","_callee$","_context","setImmediate","_x","_x2","_x3"],"sources":["../src/test-utils.js"],"sourcesContent":["const executeThunk = async (thunk, dispatch, getState) => {\n await thunk(dispatch, getState);\n await new Promise(setImmediate);\n};\n\nexport default executeThunk;\n"],"mappings":";+CACA,qJAAAA,mBAAA,YAAAA,oBAAA,WAAAC,CAAA,SAAAC,CAAA,EAAAD,CAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,EAAAC,CAAA,GAAAH,CAAA,CAAAI,cAAA,EAAAC,CAAA,GAAAJ,MAAA,CAAAK,cAAA,cAAAP,CAAA,EAAAD,CAAA,EAAAE,CAAA,IAAAD,CAAA,CAAAD,CAAA,IAAAE,CAAA,CAAAO,KAAA,KAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA,kBAAAC,CAAA,GAAAJ,CA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