@royaloperahouse/chord 1.18.0 → 1.18.1-dev-chord-development

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,5 +1,5 @@
1
1
  ## [1.18.0]
2
- - Add Compact PageHeading component
2
+ - Add CompactHeading component
3
3
 
4
4
  ## [1.17.0]
5
5
  - Add Page Heading Panel variant
@@ -16,7 +16,7 @@
16
16
  - Change to pagination component to align page numbers with URL numbers.
17
17
 
18
18
  ## [1.15.0]
19
- - Implemented a new Select component
19
+ - Add Compact PageHeading component
20
20
 
21
21
  ## [1.14.0]
22
22
  - Added standfirst functionality to Accordion/ Accordions component and theme for Schools Platform
@@ -36,21 +36,55 @@
36
36
  ## [1.12.0]
37
37
  - Search: Extend ContentSummary and SearchBar components to support new search results
38
38
 
39
+ ## [1.11.0-a]
40
+ - Pagination: add new component
41
+
39
42
  ## [1.11.0]
40
43
  - Carousels: Rewrite logic that cuts description, to support older browsers
41
44
 
45
+ ## [1.10.0-a]
46
+ - ContentSummary: make image clickable
47
+
42
48
  ## [1.10.0]
43
49
  - PageHeadingImpact: Replace CSS background-image with HTML image element
44
50
 
45
51
  ## [1.9.0]
46
52
  - Card: Add a new prop for the hover line color
53
+ ## [1.9.0-c]
54
+ - ContentSummary: make image clickable
55
+
56
+ ## [1.9.0-b]
57
+ - ContentSummary: change image size
58
+ - SearchBar: Export component
59
+
60
+ ## [1.9.0-a]
61
+ - ContentSummary: change image props
62
+
63
+ ## [1.9.0]
64
+ - Card: Add a new prop for the hover line color
65
+
66
+ ## [1.8.1-h]
67
+ - ContentSummary: add exports
68
+
69
+ ## [1.8.1-g]
70
+ - ContentSummary: refactor
71
+
72
+ ## [1.8.1-f]
73
+ - ContentSummary: update conditional rendering
74
+
75
+ ## [1.8.1-c]
76
+ - ContentSummary: update for Search results
77
+ - ContentSummarySection: remove
78
+
79
+ ## [1.8.1-b]
80
+ - Card: add new prop for the line color on hover
47
81
 
48
82
  ## [1.8.0]
49
83
  - SearchBar: Disable
50
84
 
51
85
  ## [1.7.2]
52
86
  - Add imageAltText to Card component
53
-
87
+
54
88
  ## [1.7.0]
55
89
  - Add new ContentSummary component
56
90
  - Add new ContentSummarySection component
@@ -3499,11 +3499,6 @@ var VolumeControlsWrapper = /*#__PURE__*/styled__default.div(_templateObject7$1
3499
3499
  return volumeHidden ? '40px' : '100px';
3500
3500
  }, trackStyles, trackStyles, trackStyles, trackStyles, trackStyles, thumbStyes, thumbStyes, thumbStyes);
3501
3501
 
3502
- var isIOS = function isIOS() {
3503
- return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) || // iPad on iOS 13 detection
3504
- navigator.userAgent.includes('Mac') && 'ontouchend' in document;
3505
- };
3506
-
3507
3502
  var VideoControls = function VideoControls(_ref) {
3508
3503
  var videoElementId = _ref.videoElementId,
3509
3504
  _ref$defaultMuted = _ref.defaultMuted,
@@ -3525,10 +3520,8 @@ var VideoControls = function VideoControls(_ref) {
3525
3520
 
3526
3521
  var getVideoElement = function getVideoElement() {
3527
3522
  return document.querySelector("#" + videoElementId);
3528
- }; // iOS disables javacript manipulation of video volume so we need to hide the slider and tweak the UI to accomodate
3529
-
3523
+ };
3530
3524
 
3531
- var iOS = isIOS();
3532
3525
  var handlePlay = React.useCallback(function () {
3533
3526
  var video = getVideoElement();
3534
3527
  if (!video) return;
@@ -3580,9 +3573,7 @@ var VideoControls = function VideoControls(_ref) {
3580
3573
  "aria-label": !playing ? 'Play' : 'Pause'
3581
3574
  }, /*#__PURE__*/React__default.createElement(Icon, {
3582
3575
  iconName: !playing ? 'Play' : 'Pause'
3583
- })), /*#__PURE__*/React__default.createElement(VolumeControlsWrapper, {
3584
- volumeHidden: iOS
3585
- }, /*#__PURE__*/React__default.createElement(VideoMute, {
3576
+ })), /*#__PURE__*/React__default.createElement(VolumeControlsWrapper, null, /*#__PURE__*/React__default.createElement(VideoMute, {
3586
3577
  id: "mute",
3587
3578
  className: "video-mute-button",
3588
3579
  "data-testid": "video-mute-button",
@@ -3592,7 +3583,7 @@ var VideoControls = function VideoControls(_ref) {
3592
3583
  "data-testid": "mute-icon",
3593
3584
  iconName: muted ? 'Muted' : 'Volume',
3594
3585
  color: "white"
3595
- })), !iOS && /*#__PURE__*/React__default.createElement(VideoVolume, {
3586
+ })), /*#__PURE__*/React__default.createElement(VideoVolume, {
3596
3587
  id: "vol-control",
3597
3588
  type: "range",
3598
3589
  min: "0",
@@ -3657,12 +3648,12 @@ var _templateObject$t;
3657
3648
  var NavTopContainer$1 = /*#__PURE__*/styled__default.div(_templateObject$t || (_templateObject$t = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n column-gap: 16px;\n justify-content: flex-end;\n height: 26px;\n\n @media ", " {\n column-gap: 8px;\n }\n"])), devices.mobile);
3658
3649
 
3659
3650
  var _templateObject$u, _templateObject2$f, _templateObject3$9, _templateObject4$5;
3660
- var BasketContainer = /*#__PURE__*/styled__default.div(_templateObject$u || (_templateObject$u = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n cursor: pointer;\n border-bottom: 1px solid var(--base-color-transparent);\n\n ", "\n\n :hover {\n border-bottom: 1px solid var(--base-color-", ");\n && a {\n color: var(--base-color-", ");\n }\n && svg path {\n fill: var(--base-color-", ");\n }\n }\n"])), function (_ref) {
3651
+ var BasketContainer = /*#__PURE__*/styled__default.div(_templateObject$u || (_templateObject$u = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n cursor: pointer;\n border-bottom: 1px solid var(--base-color-transparent);\n\n ", "\n\n :hover {\n border-bottom: 1px solid var(--base-color-", ");\n && a {\n color: var(--base-color-", ");\n }\n && svg path {\n fill: var(--base-color-", ");\n }\n }\n\n ", "\n"])), function (_ref) {
3661
3652
  var selected = _ref.selected,
3662
3653
  colorPrimary = _ref.colorPrimary;
3663
3654
 
3664
3655
  if (selected) {
3665
- return "\n border-bottom: 1px solid var(--base-color-" + colorPrimary + ");\n && a {\n color: var(--base-color-" + colorPrimary + ");\n } \n && svg path {\n fill: var(--base-color-" + colorPrimary + ");\n }\n ";
3656
+ return "\n border-bottom: 1px solid var(--base-color-" + colorPrimary + ");\n && a {\n color: var(--base-color-" + colorPrimary + ");\n }\n && svg path {\n fill: var(--base-color-" + colorPrimary + ");\n }\n ";
3666
3657
  }
3667
3658
 
3668
3659
  return '';
@@ -3675,10 +3666,37 @@ var BasketContainer = /*#__PURE__*/styled__default.div(_templateObject$u || (_te
3675
3666
  }, function (_ref4) {
3676
3667
  var colorPrimary = _ref4.colorPrimary;
3677
3668
  return colorPrimary;
3669
+ }, function (_ref5) {
3670
+ var isActive = _ref5.isActive,
3671
+ colorPrimary = _ref5.colorPrimary;
3672
+
3673
+ if (isActive) {
3674
+ return "\n && a {\n color: var(--base-color-" + colorPrimary + ");\n }\n && svg path {\n fill: var(--base-color-" + colorPrimary + ");\n }\n ";
3675
+ }
3676
+
3677
+ return '';
3678
3678
  });
3679
3679
  var SvgContainer = /*#__PURE__*/styled__default.div(_templateObject2$f || (_templateObject2$f = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n\n svg {\n width: var(--navigation-large-gap);\n height: var(--navigation-large-gap);\n }\n"])));
3680
3680
  var NumContainer = /*#__PURE__*/styled__default.div(_templateObject3$9 || (_templateObject3$9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n justify-content: center;\n width: 12px;\n height: 12px;\n position: absolute;\n top: 8px;\n margin-left: 6px;\n\n & .basket-num {\n color: white;\n font-size: 10px;\n font-family: var(--font-family-navigation);\n }\n"])));
3681
- var BasketText = /*#__PURE__*/styled__default.a(_templateObject4$5 || (_templateObject4$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n color: var(--base-color-black);\n margin-left: 6px;\n text-decoration: none;\n\n @media ", " {\n display: none;\n }\n"])), devices.mobile);
3681
+ var BasketText = /*#__PURE__*/styled__default.a(_templateObject4$5 || (_templateObject4$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n color: var(--base-color-black);\n margin-left: 6px;\n text-decoration: none;\n"])));
3682
+
3683
+ var checkTimeRed = function checkTimeRed(seconds) {
3684
+ if (seconds <= 0) {
3685
+ return false;
3686
+ }
3687
+
3688
+ return seconds / 60 <= 5;
3689
+ };
3690
+ var formatTime = function formatTime(seconds) {
3691
+ if (seconds > 60) {
3692
+ return Math.ceil(seconds / 60) + " mins";
3693
+ }
3694
+
3695
+ return seconds + " sec" + (seconds === 1 ? '' : 's');
3696
+ };
3697
+ var initSeconds = function initSeconds(expiryDate) {
3698
+ return expiryDate ? Math.ceil((new Date(expiryDate).getTime() - new Date().getTime()) / 1000) : 0;
3699
+ };
3682
3700
 
3683
3701
  var Basket$1 = function Basket(_ref) {
3684
3702
  var text = _ref.text,
@@ -3689,7 +3707,28 @@ var Basket$1 = function Basket(_ref) {
3689
3707
  numItems = _ref$numItems === void 0 ? 0 : _ref$numItems,
3690
3708
  onClick = _ref.onClick,
3691
3709
  _ref$colorPrimary = _ref.colorPrimary,
3692
- colorPrimary = _ref$colorPrimary === void 0 ? 'primary' : _ref$colorPrimary;
3710
+ colorPrimary = _ref$colorPrimary === void 0 ? 'primary' : _ref$colorPrimary,
3711
+ expiryDate = _ref.expiryDate;
3712
+
3713
+ var _useState = React.useState(numItems),
3714
+ basketItems = _useState[0],
3715
+ setBasketItems = _useState[1];
3716
+
3717
+ var _useState2 = React.useState(initSeconds(expiryDate)),
3718
+ seconds = _useState2[0],
3719
+ setSeconds = _useState2[1];
3720
+
3721
+ var _useState3 = React.useState(formatTime(seconds)),
3722
+ countdownText = _useState3[0],
3723
+ setCountdownText = _useState3[1];
3724
+
3725
+ var _useState4 = React.useState(),
3726
+ timer = _useState4[0],
3727
+ setTimer = _useState4[1];
3728
+
3729
+ var _useState5 = React.useState(checkTimeRed(seconds)),
3730
+ isActive = _useState5[0],
3731
+ setIsActive = _useState5[1];
3693
3732
 
3694
3733
  var onClickHandler = function onClickHandler() {
3695
3734
  if (onClick) {
@@ -3703,12 +3742,42 @@ var Basket$1 = function Basket(_ref) {
3703
3742
  }
3704
3743
  };
3705
3744
 
3706
- var empty = numItems <= 0;
3745
+ React.useEffect(function () {
3746
+ if (timer) {
3747
+ clearInterval(timer); // clears the old timer before setting a new one
3748
+ }
3749
+
3750
+ if (!expiryDate || !numItems) return;
3751
+ var interval = setInterval(function () {
3752
+ setSeconds(function (prev) {
3753
+ return prev - 1;
3754
+ });
3755
+ }, 1000);
3756
+ setTimer(interval);
3757
+ return function () {
3758
+ return clearInterval(interval);
3759
+ };
3760
+ }, [expiryDate]);
3761
+ React.useEffect(function () {
3762
+ if (!timer) return;
3763
+
3764
+ if (seconds > 0) {
3765
+ setCountdownText(formatTime(seconds));
3766
+ setIsActive(checkTimeRed(seconds));
3767
+ } else {
3768
+ clearInterval(timer);
3769
+ setBasketItems(0);
3770
+ setCountdownText('');
3771
+ setIsActive(false);
3772
+ }
3773
+ }, [seconds, timer]);
3774
+ var empty = basketItems <= 0;
3707
3775
  return /*#__PURE__*/React__default.createElement(BasketContainer, {
3708
3776
  selected: selected,
3709
3777
  onClick: onClickHandler,
3710
3778
  onKeyDown: onKeyDownHandler,
3711
3779
  colorPrimary: colorPrimary,
3780
+ isActive: isActive,
3712
3781
  tabIndex: 0
3713
3782
  }, /*#__PURE__*/React__default.createElement(SvgContainer, null, empty ? /*#__PURE__*/React__default.createElement(Icon, {
3714
3783
  iconName: "Basket"
@@ -3716,9 +3785,9 @@ var Basket$1 = function Basket(_ref) {
3716
3785
  iconName: "BasketFull"
3717
3786
  }), /*#__PURE__*/React__default.createElement(NumContainer, null, /*#__PURE__*/React__default.createElement("span", {
3718
3787
  className: "basket-num"
3719
- }, numItems)))), /*#__PURE__*/React__default.createElement("div", null, !empty ? /*#__PURE__*/React__default.createElement(BasketText, {
3788
+ }, basketItems)))), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(BasketText, {
3720
3789
  "data-testid": "baskettext"
3721
- }, text) : ''));
3790
+ }, expiryDate ? countdownText : text)));
3722
3791
  };
3723
3792
 
3724
3793
  var _templateObject$v, _templateObject2$g;