@royaloperahouse/chord 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [2.3.1]
2
+ - AuxiliaryNav: accessibility improvements
3
+
1
4
  ## [2.3.0]
2
5
  - New component: VideoWithControls
3
6
  - PromoWithTitle: handle video
@@ -10057,55 +10057,92 @@ var ReadMore = function ReadMore(_ref) {
10057
10057
  }, isFullTextOpen ? "" + hideText : "" + showMoreText)));
10058
10058
  };
10059
10059
 
10060
- var _templateObject$1g, _templateObject2$V, _templateObject3$M, _templateObject4$B;
10061
- var MenuContainer$2 = /*#__PURE__*/styled__default.menu(_templateObject$1g || (_templateObject$1g = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n padding: 0;\n margin: 0;\n"])));
10062
- var MenuList = /*#__PURE__*/styled__default.ul(_templateObject2$V || (_templateObject2$V = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n border-right: 1px solid var(--base-color-", ");\n li {\n margin-left: -5px;\n @media ", " {\n margin-left: 0px;\n }\n }\n @media ", " {\n display: ", ";\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-top: 0;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n }\n"])), exports.Colors.LightGrey, devices.mobile, devices.mobile, function (_ref) {
10063
- var mobileOpen = _ref.mobileOpen;
10064
- return mobileOpen ? "block" : 'none';
10065
- }, exports.Colors.White, exports.Colors.DarkGrey);
10066
- var MenuItem$1 = /*#__PURE__*/styled__default.button(_templateObject3$M || (_templateObject3$M = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 20px 15px 5px;\n border: 0;\n border-radius: 0;\n display: block;\n width: 100%;\n text-align: left;\n background: ", ";\n cursor: pointer;\n &:hover {\n background: var(--base-color-", ");\n }\n @media ", " {\n padding: 16px 20px 15px 20px;\n }\n"])), exports.Colors.Black, function (_ref2) {
10067
- var active = _ref2.active;
10068
- return active ? "var(--base-color-" + exports.Colors.MidGrey + ")" : 'none';
10069
- }, exports.Colors.MidGrey, devices.mobile);
10070
- var MobileButton = /*#__PURE__*/styled__default.button(_templateObject4$B || (_templateObject4$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 46px 14px 20px;\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-radius: 0;\n display: none;\n width: 100%;\n text-align: left;\n cursor: pointer;\n position: relative;\n span {\n width: 25px;\n height: 25px;\n position: absolute;\n top: 50%;\n margin-top: -12px;\n right: 10px;\n }\n @media ", " {\n display: block;\n }\n"])), exports.Colors.Black, exports.Colors.White, exports.Colors.DarkGrey, devices.mobile);
10060
+ var _templateObject$1g, _templateObject2$V, _templateObject3$M, _templateObject4$B, _templateObject5$r;
10061
+ var MenuContainer$2 = /*#__PURE__*/styled__default.nav(_templateObject$1g || (_templateObject$1g = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n padding: 0;\n margin: 0;\n"])));
10062
+ var MenuList = /*#__PURE__*/styled__default.ul(_templateObject2$V || (_templateObject2$V = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n border-right: 1px solid var(--base-color-", ");\n li {\n margin-left: -5px;\n }\n"])), exports.Colors.LightGrey);
10063
+ var MobileButton = /*#__PURE__*/styled__default.button(_templateObject3$M || (_templateObject3$M = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 46px 14px 20px;\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-radius: 0;\n display: block;\n width: 100%;\n text-align: left;\n cursor: pointer;\n position: relative;\n span {\n width: 25px;\n height: 25px;\n position: absolute;\n top: 50%;\n margin-top: -12px;\n right: 10px;\n }\n"])), exports.Colors.Black, exports.Colors.White, exports.Colors.DarkGrey);
10064
+ var MenuItem$1 = /*#__PURE__*/styled__default.a(_templateObject4$B || (_templateObject4$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n text-decoration: none;\n margin: 0;\n padding: 16px 20px 15px 5px;\n display: block;\n background: ", ";\n cursor: pointer;\n &:hover {\n background: var(--base-color-", ");\n }\n"])), exports.Colors.Black, function (_ref) {
10065
+ var isActive = _ref.isActive;
10066
+ return isActive ? "var(--base-color-" + exports.Colors.MidGrey + ")" : 'none';
10067
+ }, exports.Colors.MidGrey);
10068
+ var MobileMenuList = /*#__PURE__*/styled__default.ul(_templateObject5$r || (_templateObject5$r = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n display: ", ";\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-top: 0;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n ", " {\n padding: 16px 20px 15px 20px;\n }\n"])), function (_ref2) {
10069
+ var isOpen = _ref2.isOpen;
10070
+ return isOpen ? 'block' : 'none';
10071
+ }, exports.Colors.White, exports.Colors.DarkGrey, MenuItem$1);
10072
+
10073
+ var NavItem = function NavItem(_ref) {
10074
+ var text = _ref.text,
10075
+ href = _ref.href,
10076
+ onClick = _ref.onClick,
10077
+ isActive = _ref.isActive,
10078
+ isMobile = _ref.isMobile;
10071
10079
 
10072
- /**
10073
- * Vertical menu component uses for navigation
10074
- * inside website chapter. It looks like a vertical
10075
- * list with clickable items on desktop and dropdown
10076
- * list on mobile.
10077
- *
10078
- * ## Menu items
10079
- * Menu items should be passed as `items` prop. This
10080
- * should be an array of objects. Each object should
10081
- * have `text` (text displayed as a menu item) and
10082
- * `onClick` (click handler function)
10083
- *
10084
- * ## Active menu item
10085
- * Active menu item should be passed as component `activeItem`
10086
- * prop. This indicates on which menu item should be highlighted
10087
- * as active one. Should be equal to `text` prop from one of the `items`
10088
- */
10080
+ var clickHandler = function () {
10081
+ if (!onClick) return undefined;
10082
+ return function (e) {
10083
+ e.preventDefault();
10084
+ onClick();
10085
+ };
10086
+ }();
10087
+
10088
+ var ariaCurrent = isMobile ? undefined : isActive;
10089
+ var ariaSelected = isMobile ? isActive : undefined;
10090
+ var role = isMobile ? 'option' : undefined;
10091
+ return /*#__PURE__*/React__default.createElement("li", {
10092
+ "aria-current": ariaCurrent,
10093
+ "aria-selected": ariaSelected,
10094
+ role: role
10095
+ }, /*#__PURE__*/React__default.createElement(MenuItem$1, {
10096
+ onClick: clickHandler,
10097
+ href: href,
10098
+ isActive: isActive,
10099
+ "data-testid": "nav-menu-item" + (isActive ? '-active' : '')
10100
+ }, text));
10101
+ };
10102
+
10103
+ var DesktopNav = function DesktopNav(_ref2) {
10104
+ var items = _ref2.items,
10105
+ activeItem = _ref2.activeItem,
10106
+ ariaLabel = _ref2.ariaLabel;
10107
+ return /*#__PURE__*/React__default.createElement(MenuContainer$2, {
10108
+ "data-testid": "nav-menu-container-desktop",
10109
+ "aria-label": ariaLabel
10110
+ }, /*#__PURE__*/React__default.createElement(MenuList, {
10111
+ "data-testid": "nav-menu-list"
10112
+ }, items.map(function (_ref3, idx) {
10113
+ var text = _ref3.text,
10114
+ href = _ref3.href,
10115
+ onClick = _ref3.onClick;
10116
+ return /*#__PURE__*/React__default.createElement(NavItem, {
10117
+ key: text + "-" + idx,
10118
+ text: text,
10119
+ href: href,
10120
+ onClick: onClick,
10121
+ isActive: text === activeItem
10122
+ });
10123
+ })));
10124
+ };
10089
10125
 
10090
- var AuxiliaryNav = function AuxiliaryNav(_ref) {
10091
- var items = _ref.items,
10092
- activeItem = _ref.activeItem;
10126
+ var MobileNav = function MobileNav(_ref4) {
10127
+ var items = _ref4.items,
10128
+ activeItem = _ref4.activeItem,
10129
+ ariaLabel = _ref4.ariaLabel;
10093
10130
 
10094
10131
  var _useState = React.useState(false),
10095
- mobileOpen = _useState[0],
10096
- setMobileOpen = _useState[1];
10132
+ isOpen = _useState[0],
10133
+ setIsOpen = _useState[1];
10097
10134
 
10098
10135
  var containerRef = React.useRef(null);
10099
10136
 
10100
- var mobileButtonClickHandler = function mobileButtonClickHandler() {
10101
- setMobileOpen(function (prev) {
10137
+ var buttonClickHandler = function buttonClickHandler() {
10138
+ setIsOpen(function (prev) {
10102
10139
  return !prev;
10103
10140
  });
10104
10141
  };
10105
10142
 
10106
10143
  var outsideClickHandler = function outsideClickHandler(event) {
10107
10144
  if (containerRef.current && !containerRef.current.contains(event.target)) {
10108
- setMobileOpen(false);
10145
+ setIsOpen(false);
10109
10146
  }
10110
10147
  };
10111
10148
 
@@ -10117,29 +10154,79 @@ var AuxiliaryNav = function AuxiliaryNav(_ref) {
10117
10154
  }, [containerRef]);
10118
10155
  return /*#__PURE__*/React__default.createElement(MenuContainer$2, {
10119
10156
  ref: containerRef,
10120
- "data-testid": "nav-menu-container"
10157
+ "data-testid": "nav-menu-container-mobile",
10158
+ "aria-label": ariaLabel
10121
10159
  }, /*#__PURE__*/React__default.createElement(MobileButton, {
10122
- mobileOpen: mobileOpen,
10123
- onClick: mobileButtonClickHandler,
10124
- "data-testid": "nav-menu-mobile-button"
10160
+ onClick: buttonClickHandler,
10161
+ "data-testid": "nav-menu-mobile-button",
10162
+ "aria-expanded": isOpen,
10163
+ "aria-controls": "auxiliary-nav-list",
10164
+ "aria-haspopup": "listbox",
10165
+ role: 'combobox'
10125
10166
  }, activeItem, /*#__PURE__*/React__default.createElement(Icon, {
10126
10167
  iconName: "DropdownArrow",
10127
- direction: mobileOpen ? 'left' : 'right'
10128
- })), /*#__PURE__*/React__default.createElement(MenuList, {
10129
- mobileOpen: mobileOpen,
10130
- "data-testid": "nav-menu-list"
10131
- }, items.map(function (item, idx) {
10132
- return /*#__PURE__*/React__default.createElement("li", {
10133
- key: item.text + "-" + idx
10134
- }, /*#__PURE__*/React__default.createElement(MenuItem$1, {
10135
- onClick: item.onClick,
10136
- active: item.text === activeItem,
10137
- "data-testid": "nav-menu-item" + (item.text === activeItem ? '-active' : '')
10138
- }, item.text));
10168
+ direction: isOpen ? 'left' : 'right'
10169
+ })), /*#__PURE__*/React__default.createElement(MobileMenuList, {
10170
+ id: 'auxiliary-nav-list',
10171
+ "data-testid": "nav-menu-list",
10172
+ isOpen: isOpen,
10173
+ "aria-hidden": !isOpen,
10174
+ role: 'listbox'
10175
+ }, items.map(function (_ref5, idx) {
10176
+ var text = _ref5.text,
10177
+ href = _ref5.href,
10178
+ onClick = _ref5.onClick;
10179
+ return /*#__PURE__*/React__default.createElement(NavItem, {
10180
+ key: text + "-" + idx,
10181
+ text: text,
10182
+ href: href,
10183
+ onClick: onClick,
10184
+ isActive: text === activeItem,
10185
+ isMobile: true
10186
+ });
10139
10187
  })));
10140
10188
  };
10189
+ /**
10190
+ * Vertical menu component uses for navigation
10191
+ * inside website chapter. It looks like a vertical
10192
+ * list with clickable items on desktop and dropdown
10193
+ * list on mobile.
10194
+ *
10195
+ * ## Menu items
10196
+ * Menu items should be passed as `items` prop. This
10197
+ * should be an array of objects. Each object should
10198
+ * have `text` (text displayed as a menu item) and
10199
+ * `onClick` (click handler function)
10200
+ *
10201
+ * ## Active menu item
10202
+ * Active menu item should be passed as component `activeItem`
10203
+ * prop. This indicates on which menu item should be highlighted
10204
+ * as active one. Should be equal to `text` prop from one of the `items`
10205
+ */
10206
+
10207
+
10208
+ var AuxiliaryNav = function AuxiliaryNav(_ref6) {
10209
+ var items = _ref6.items,
10210
+ activeItem = _ref6.activeItem,
10211
+ isMobile = _ref6.isMobile,
10212
+ ariaLabel = _ref6.ariaLabel;
10213
+
10214
+ if (isMobile) {
10215
+ return /*#__PURE__*/React__default.createElement(MobileNav, {
10216
+ items: items,
10217
+ activeItem: activeItem,
10218
+ ariaLabel: ariaLabel
10219
+ });
10220
+ }
10221
+
10222
+ return /*#__PURE__*/React__default.createElement(DesktopNav, {
10223
+ items: items,
10224
+ activeItem: activeItem,
10225
+ ariaLabel: ariaLabel
10226
+ });
10227
+ };
10141
10228
 
10142
- var _templateObject$1h, _templateObject2$W, _templateObject3$N, _templateObject4$C, _templateObject5$r, _templateObject6$m;
10229
+ var _templateObject$1h, _templateObject2$W, _templateObject3$N, _templateObject4$C, _templateObject5$s, _templateObject6$m;
10143
10230
  var Container$5 = /*#__PURE__*/styled__default.div(_templateObject$1h || (_templateObject$1h = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 10px;\n"])));
10144
10231
  var Sections = /*#__PURE__*/styled__default.div(_templateObject2$W || (_templateObject2$W = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 8px;\n"])));
10145
10232
  var Section = /*#__PURE__*/styled__default.div(_templateObject3$N || (_templateObject3$N = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: 1;\n height: 2px;\n background-color: ", ";\n"])), function (_ref) {
@@ -10147,7 +10234,7 @@ var Section = /*#__PURE__*/styled__default.div(_templateObject3$N || (_templateO
10147
10234
  return "var(--base-color-" + color + ")";
10148
10235
  });
10149
10236
  var BottomLine = /*#__PURE__*/styled__default.div(_templateObject4$C || (_templateObject4$C = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n gap: 20px;\n"])));
10150
- var Text = /*#__PURE__*/styled__default.div(_templateObject5$r || (_templateObject5$r = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (_ref2) {
10237
+ var Text = /*#__PURE__*/styled__default.div(_templateObject5$s || (_templateObject5$s = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (_ref2) {
10151
10238
  var color = _ref2.color;
10152
10239
  return "var(--base-color-" + color + ")";
10153
10240
  });
@@ -10237,14 +10324,14 @@ var PasswordStrength = function PasswordStrength(_ref) {
10237
10324
  }, strengthLabel))));
10238
10325
  };
10239
10326
 
10240
- var _templateObject$1i, _templateObject2$X, _templateObject3$O, _templateObject4$D, _templateObject5$s, _templateObject6$n, _templateObject7$f, _templateObject8$c, _templateObject9$7, _templateObject10$7;
10327
+ var _templateObject$1i, _templateObject2$X, _templateObject3$O, _templateObject4$D, _templateObject5$t, _templateObject6$n, _templateObject7$f, _templateObject8$c, _templateObject9$7, _templateObject10$7;
10241
10328
  var TableContainer = /*#__PURE__*/styled__default.table(_templateObject$1i || (_templateObject$1i = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-collapse: collapse;\n"])));
10242
10329
  var Container$6 = /*#__PURE__*/styled__default.div(_templateObject2$X || (_templateObject2$X = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n overflow-x: auto;\n"])));
10243
10330
  var Wrapper$7 = /*#__PURE__*/styled__default.div(_templateObject3$O || (_templateObject3$O = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
10244
10331
  var TableHeader = /*#__PURE__*/styled__default.th(_templateObject4$D || (_templateObject4$D = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-subtitle-2);\n font-family: var(--font-family-subtitle);\n font-feature-settings: var(--font-feature-settings-subtitle);\n font-weight: var(--font-weight-subtitle-2);\n letter-spacing: var(--letter-spacing-subtitle-2);\n line-height: var(--line-height-subtitle-2);\n padding: 30px 30px 30px 0;\n text-align: left;\n text-transform: uppercase;\n\n &:last-child {\n white-space: nowrap;\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n @media ", " {\n &:last-child {\n white-space: nowrap;\n }\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n\n &:last-child {\n white-space: normal;\n }\n }\n"])), function (props) {
10245
10332
  return "calc(100% / " + (props.columns - 1) + ")";
10246
10333
  }, devices.tablet, devices.mobile);
10247
- var TableCell = /*#__PURE__*/styled__default.td(_templateObject5$s || (_templateObject5$s = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n font-feature-settings: var(--font-feature-settings-body);\n font-weight: var(--font-weight-body-1);\n letter-spacing: var(--letter-spacing-body-1);\n line-height: var(--line-height-body-1);\n padding: 30px 30px 30px 0;\n text-align: left;\n vertical-align: top;\n\n &:last-child {\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n > span > svg {\n width: 24px;\n height: 24px;\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n }\n"])), function (props) {
10334
+ var TableCell = /*#__PURE__*/styled__default.td(_templateObject5$t || (_templateObject5$t = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n font-feature-settings: var(--font-feature-settings-body);\n font-weight: var(--font-weight-body-1);\n letter-spacing: var(--letter-spacing-body-1);\n line-height: var(--line-height-body-1);\n padding: 30px 30px 30px 0;\n text-align: left;\n vertical-align: top;\n\n &:last-child {\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n > span > svg {\n width: 24px;\n height: 24px;\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n }\n"])), function (props) {
10248
10335
  return "calc(100% / " + (props.columns - 1) + ")";
10249
10336
  }, devices.mobile);
10250
10337
  var LineContainer$1 = /*#__PURE__*/styled__default.div(_templateObject6$n || (_templateObject6$n = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 1px;\n background-color: ", ";\n width: 100%;\n"])), function (props) {