@royaloperahouse/chord 2.11.0-b-development → 2.11.1-a-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/README.md +4 -0
- package/dist/chord.cjs.development.js +48 -40
- package/dist/chord.cjs.development.js.map +1 -1
- package/dist/chord.cjs.production.min.js +1 -1
- package/dist/chord.cjs.production.min.js.map +1 -1
- package/dist/chord.esm.js +48 -40
- package/dist/chord.esm.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -59,6 +59,10 @@ You can quickly build and serve the contents of `/storybook-static` from your lo
|
|
|
59
59
|
```bash
|
|
60
60
|
yarn storybook
|
|
61
61
|
```
|
|
62
|
+
Try to use this script if you have issues running it locally
|
|
63
|
+
```bash
|
|
64
|
+
NODE_OPTIONS=--openssl-legacy-provider yarn storybook
|
|
65
|
+
```
|
|
62
66
|
|
|
63
67
|
By default the storybook will be accessible at
|
|
64
68
|
[http://localhost:6006/](http://localhost:6006/)
|
|
@@ -8,7 +8,7 @@ var React = require('react');
|
|
|
8
8
|
var React__default = _interopDefault(React);
|
|
9
9
|
var styled = require('styled-components');
|
|
10
10
|
var styled__default = _interopDefault(styled);
|
|
11
|
-
var
|
|
11
|
+
var dateFns = require('date-fns');
|
|
12
12
|
var server = require('react-dom/server');
|
|
13
13
|
var Select$1 = require('react-select');
|
|
14
14
|
var Select$1__default = _interopDefault(Select$1);
|
|
@@ -4660,6 +4660,23 @@ var TimerValueSeparator = /*#__PURE__*/styled__default.div(_templateObject6$3 ||
|
|
|
4660
4660
|
var TimerValueWrapper = /*#__PURE__*/styled__default.div(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
4661
4661
|
var TimerValue = /*#__PURE__*/styled__default.div(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
4662
4662
|
|
|
4663
|
+
var pad = function pad(num) {
|
|
4664
|
+
return String(num || 0).padStart(2, '0');
|
|
4665
|
+
};
|
|
4666
|
+
|
|
4667
|
+
var renderTimerValue = function renderTimerValue(value, title, separator) {
|
|
4668
|
+
if (separator === void 0) {
|
|
4669
|
+
separator = true;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TimerValueWrapper, null, /*#__PURE__*/React__default.createElement(TimerValue, {
|
|
4673
|
+
className: 'chord-timer-value',
|
|
4674
|
+
"data-testid": title
|
|
4675
|
+
}, value), /*#__PURE__*/React__default.createElement(TimerLabel, {
|
|
4676
|
+
className: 'chord-timer-label'
|
|
4677
|
+
}, title)), separator && /*#__PURE__*/React__default.createElement(TimerValueSeparator, null, ":"));
|
|
4678
|
+
};
|
|
4679
|
+
|
|
4663
4680
|
var Timer = function Timer(_ref) {
|
|
4664
4681
|
var endDate = _ref.endDate,
|
|
4665
4682
|
title = _ref.title,
|
|
@@ -4669,39 +4686,27 @@ var Timer = function Timer(_ref) {
|
|
|
4669
4686
|
_ref$color = _ref.color,
|
|
4670
4687
|
color = _ref$color === void 0 ? exports.Colors.Black : _ref$color;
|
|
4671
4688
|
|
|
4672
|
-
var
|
|
4673
|
-
seconds =
|
|
4674
|
-
setSeconds =
|
|
4675
|
-
|
|
4676
|
-
var _React$useState2 = React__default.useState('00'),
|
|
4677
|
-
minutes = _React$useState2[0],
|
|
4678
|
-
setMinutes = _React$useState2[1];
|
|
4689
|
+
var _useState = React.useState('00'),
|
|
4690
|
+
seconds = _useState[0],
|
|
4691
|
+
setSeconds = _useState[1];
|
|
4679
4692
|
|
|
4680
|
-
var
|
|
4681
|
-
|
|
4682
|
-
|
|
4693
|
+
var _useState2 = React.useState('00'),
|
|
4694
|
+
minutes = _useState2[0],
|
|
4695
|
+
setMinutes = _useState2[1];
|
|
4683
4696
|
|
|
4684
|
-
var
|
|
4685
|
-
|
|
4686
|
-
|
|
4697
|
+
var _useState3 = React.useState('00'),
|
|
4698
|
+
hours = _useState3[0],
|
|
4699
|
+
setHours = _useState3[1];
|
|
4687
4700
|
|
|
4688
|
-
var
|
|
4689
|
-
|
|
4690
|
-
|
|
4701
|
+
var _useState4 = React.useState('00'),
|
|
4702
|
+
days = _useState4[0],
|
|
4703
|
+
setDays = _useState4[1];
|
|
4691
4704
|
|
|
4692
|
-
var
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
}
|
|
4696
|
-
|
|
4697
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TimerValueWrapper, null, /*#__PURE__*/React__default.createElement(TimerValue, {
|
|
4698
|
-
className: 'chord-timer-value'
|
|
4699
|
-
}, value), /*#__PURE__*/React__default.createElement(TimerLabel, {
|
|
4700
|
-
className: 'chord-timer-label'
|
|
4701
|
-
}, title)), separator && /*#__PURE__*/React__default.createElement(TimerValueSeparator, null, ":"));
|
|
4702
|
-
};
|
|
4705
|
+
var _useState5 = React.useState(false),
|
|
4706
|
+
isEndDateReached = _useState5[0],
|
|
4707
|
+
setIsEndDateReached = _useState5[1];
|
|
4703
4708
|
|
|
4704
|
-
|
|
4709
|
+
React.useEffect(function () {
|
|
4705
4710
|
if (isEndDateReached) return; // We use this to set values for the timer immediately
|
|
4706
4711
|
|
|
4707
4712
|
var setIntervalAndExecute = function setIntervalAndExecute(fn, delay) {
|
|
@@ -4710,20 +4715,23 @@ var Timer = function Timer(_ref) {
|
|
|
4710
4715
|
};
|
|
4711
4716
|
|
|
4712
4717
|
var updateValues = function updateValues() {
|
|
4713
|
-
var futureDate =
|
|
4714
|
-
|
|
4715
|
-
var
|
|
4716
|
-
var
|
|
4718
|
+
var futureDate = new Date(endDate); // Date.now() is explicitly passed here just to satisfy Jest time mocking.
|
|
4719
|
+
|
|
4720
|
+
var nowDate = new Date(Date.now());
|
|
4721
|
+
var diffInMs = futureDate.getTime() - nowDate.getTime();
|
|
4717
4722
|
|
|
4718
|
-
if (
|
|
4723
|
+
if (diffInMs < 0) {
|
|
4719
4724
|
setIsEndDateReached(true);
|
|
4720
4725
|
if (endDateHandler) endDateHandler();
|
|
4721
4726
|
} else {
|
|
4722
|
-
var
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
var
|
|
4727
|
+
var duration = dateFns.intervalToDuration({
|
|
4728
|
+
start: nowDate,
|
|
4729
|
+
end: futureDate
|
|
4730
|
+
});
|
|
4731
|
+
var daysDiff = pad(dateFns.differenceInDays(futureDate, nowDate));
|
|
4732
|
+
var hoursDiff = pad(duration.hours);
|
|
4733
|
+
var minutesDiff = pad(duration.minutes);
|
|
4734
|
+
var secondsDiff = pad(duration.seconds);
|
|
4727
4735
|
setDays(daysDiff);
|
|
4728
4736
|
setHours(hoursDiff);
|
|
4729
4737
|
setMinutes(minutesDiff);
|
|
@@ -4736,7 +4744,7 @@ var Timer = function Timer(_ref) {
|
|
|
4736
4744
|
clearInterval(interval);
|
|
4737
4745
|
};
|
|
4738
4746
|
});
|
|
4739
|
-
var hideTimer =
|
|
4747
|
+
var hideTimer = dateFns.isPast(new Date(endDate));
|
|
4740
4748
|
if (hideTimer) return null;
|
|
4741
4749
|
return /*#__PURE__*/React__default.createElement(TimerWrapper, {
|
|
4742
4750
|
color: color
|