@megafon/ui-shared 4.15.0 → 4.16.0
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 +22 -0
- package/dist/es/components/AudioPlayer/AudioPlayer.js +11 -4
- package/dist/es/components/AudioPlayer/AudioProgress.d.ts +3 -3
- package/dist/es/components/AudioPlayer/AudioProgress.js +12 -21
- package/dist/es/components/AudioPlayer/AudioRange.d.ts +2 -1
- package/dist/es/components/AudioPlayer/AudioRange.js +6 -4
- package/dist/es/components/AudioPlayer/AudioVolume.d.ts +1 -1
- package/dist/es/components/AudioPlayer/AudioVolume.js +5 -2
- package/dist/es/components/AudioPlayer/hooks/useTrackDuration.d.ts +3 -0
- package/dist/es/components/AudioPlayer/hooks/useTrackDuration.js +32 -0
- package/dist/es/components/StoreBanner/StoreBanner.css +42 -0
- package/dist/es/components/StoreBanner/StoreBanner.d.ts +3 -0
- package/dist/es/components/StoreBanner/StoreBanner.js +5 -2
- package/dist/es/components/StoreBanner/doc/img/iphone12Screen.png +0 -0
- package/dist/es/components/StoreBanner/img/iphone12.png +0 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/lib/components/AudioPlayer/AudioPlayer.js +11 -4
- package/dist/lib/components/AudioPlayer/AudioProgress.d.ts +3 -3
- package/dist/lib/components/AudioPlayer/AudioProgress.js +13 -21
- package/dist/lib/components/AudioPlayer/AudioRange.d.ts +2 -1
- package/dist/lib/components/AudioPlayer/AudioRange.js +6 -3
- package/dist/lib/components/AudioPlayer/AudioVolume.d.ts +1 -1
- package/dist/lib/components/AudioPlayer/AudioVolume.js +5 -2
- package/dist/lib/components/AudioPlayer/hooks/useTrackDuration.d.ts +3 -0
- package/dist/lib/components/AudioPlayer/hooks/useTrackDuration.js +44 -0
- package/dist/lib/components/StoreBanner/StoreBanner.css +42 -0
- package/dist/lib/components/StoreBanner/StoreBanner.d.ts +3 -0
- package/dist/lib/components/StoreBanner/StoreBanner.js +5 -2
- package/dist/lib/components/StoreBanner/doc/img/iphone12Screen.png +0 -0
- package/dist/lib/components/StoreBanner/img/iphone12.png +0 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +8 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,28 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [4.16.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.15.1...@megafon/ui-shared@4.16.0) (2023-04-04)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **storebanner:** add new mask for iphone 12 and content left on mobile ([8702938](https://github.com/MegafonWebLab/megafon-ui/commit/8702938d1bf9c0b1bbdc80f045e2bc329da1c99d))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [4.15.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.15.0...@megafon/ui-shared@4.15.1) (2023-03-27)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* **audioplayer:** fix loading of audio metadata ([d3a496d](https://github.com/MegafonWebLab/megafon-ui/commit/d3a496d6b3be86627f41d001376f6e20df0275b5))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
6
28
|
# [4.15.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.14.0...@megafon/ui-shared@4.15.0) (2023-03-20)
|
7
29
|
|
8
30
|
|
@@ -83,13 +83,15 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
83
83
|
className: cn({
|
84
84
|
'full-width': isFullWidth,
|
85
85
|
position: position
|
86
|
-
})
|
86
|
+
}),
|
87
|
+
"data-testid": "AudioPlayer"
|
87
88
|
}, /*#__PURE__*/React.createElement("div", {
|
88
89
|
className: cn('player')
|
89
90
|
}, /*#__PURE__*/React.createElement("audio", {
|
90
91
|
className: cn('audio'),
|
91
92
|
ref: audioRef,
|
92
|
-
controls: false
|
93
|
+
controls: false,
|
94
|
+
"data-testid": "AudioPlayer-audio"
|
93
95
|
}, /*#__PURE__*/React.createElement("source", {
|
94
96
|
src: audioSrc,
|
95
97
|
type: "audio/mpeg"
|
@@ -99,14 +101,19 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
99
101
|
icon: isPlaying ? /*#__PURE__*/React.createElement(IconPause, null) : /*#__PURE__*/React.createElement(IconPlay, null),
|
100
102
|
onClick: playingIconHandleClick,
|
101
103
|
sizeAll: "small",
|
102
|
-
className: cn('button')
|
104
|
+
className: cn('button'),
|
105
|
+
dataAttrs: {
|
106
|
+
root: {
|
107
|
+
'data-testid': 'AudioPlayer-btn'
|
108
|
+
}
|
109
|
+
}
|
103
110
|
})), /*#__PURE__*/React.createElement(AudioProgress, {
|
104
111
|
audioRef: audioRef,
|
105
112
|
audioTitle: audioTitle,
|
106
113
|
isPlaying: isPlaying,
|
107
114
|
isPause: isPause,
|
108
115
|
onChangeAudioCurrentTime: handleChangeAudioCurrentTime,
|
109
|
-
|
116
|
+
onPlay: handlePLay,
|
110
117
|
onSetIsPlaying: setIsPlaying
|
111
118
|
}), /*#__PURE__*/React.createElement(AudioVolume, {
|
112
119
|
onChangeAudioVolume: handleChangeAudioVolume
|
@@ -6,9 +6,9 @@ export interface IAudioProgressProps {
|
|
6
6
|
audioTitle: string;
|
7
7
|
isPlaying: boolean;
|
8
8
|
isPause: boolean;
|
9
|
-
onChangeAudioCurrentTime
|
10
|
-
|
11
|
-
onSetIsPlaying
|
9
|
+
onChangeAudioCurrentTime?: (currentTime: number) => void;
|
10
|
+
onPlay?: () => void;
|
11
|
+
onSetIsPlaying?: (value: boolean) => void;
|
12
12
|
}
|
13
13
|
declare const AudioProgress: React.FC<IAudioProgressProps>;
|
14
14
|
export default AudioProgress;
|
@@ -4,6 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import React from 'react';
|
5
5
|
import { cnCreate } from '@megafon/ui-helpers';
|
6
6
|
import AudioRange from "./AudioRange";
|
7
|
+
import useTrackDuration from "./hooks/useTrackDuration";
|
7
8
|
import timerFormat from "./timerFormatUtil";
|
8
9
|
import "./style/AudioProgress.css";
|
9
10
|
export var INTERVAL_DELAY = 1000;
|
@@ -15,20 +16,16 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
15
16
|
isPlaying = _ref.isPlaying,
|
16
17
|
isPause = _ref.isPause,
|
17
18
|
onChangeAudioCurrentTime = _ref.onChangeAudioCurrentTime,
|
18
|
-
|
19
|
+
onPlay = _ref.onPlay,
|
19
20
|
onSetIsPlaying = _ref.onSetIsPlaying;
|
20
21
|
var intervalId = React.useRef(null);
|
21
22
|
|
22
23
|
var _React$useState = React.useState(0),
|
23
24
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
var _React$useState3 = React.useState(0),
|
28
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
29
|
-
trackProgress = _React$useState4[0],
|
30
|
-
setTrackProgress = _React$useState4[1];
|
25
|
+
trackProgress = _React$useState2[0],
|
26
|
+
setTrackProgress = _React$useState2[1];
|
31
27
|
|
28
|
+
var trackDuration = useTrackDuration(audioRef);
|
32
29
|
var progressColorPercent = React.useMemo(function () {
|
33
30
|
return trackProgress / trackDuration * 100;
|
34
31
|
}, [trackDuration, trackProgress]);
|
@@ -41,7 +38,7 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
41
38
|
var _a, _b, _c;
|
42
39
|
|
43
40
|
if ((_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.ended) {
|
44
|
-
onSetIsPlaying(false);
|
41
|
+
onSetIsPlaying === null || onSetIsPlaying === void 0 ? void 0 : onSetIsPlaying(false);
|
45
42
|
setTrackProgress(Math.floor(((_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.duration) || 0));
|
46
43
|
return;
|
47
44
|
}
|
@@ -53,12 +50,12 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
53
50
|
var handleScrubProgress = function handleScrubProgress(e) {
|
54
51
|
var currentTime = Number(e.target.value);
|
55
52
|
setTrackProgress(currentTime);
|
56
|
-
onChangeAudioCurrentTime(currentTime);
|
53
|
+
onChangeAudioCurrentTime === null || onChangeAudioCurrentTime === void 0 ? void 0 : onChangeAudioCurrentTime(currentTime);
|
57
54
|
};
|
58
55
|
|
59
56
|
var handleScrubEndProgress = function handleScrubEndProgress() {
|
60
57
|
if (!isPlaying) {
|
61
|
-
|
58
|
+
onPlay === null || onPlay === void 0 ? void 0 : onPlay();
|
62
59
|
}
|
63
60
|
|
64
61
|
handleStartTimer();
|
@@ -69,15 +66,6 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
69
66
|
|
70
67
|
setTrackProgress(Math.floor(((_a = audioRef === null || audioRef === void 0 ? void 0 : audioRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) || 0));
|
71
68
|
}, [audioRef]);
|
72
|
-
React.useEffect(function () {
|
73
|
-
var audioNode = audioRef.current;
|
74
|
-
|
75
|
-
if (audioNode) {
|
76
|
-
audioNode.onloadedmetadata = function () {
|
77
|
-
setTrackDuration(Math.round(audioNode.duration));
|
78
|
-
};
|
79
|
-
}
|
80
|
-
}, [audioRef]);
|
81
69
|
React.useEffect(function () {
|
82
70
|
if (isPlaying) {
|
83
71
|
handleStartTimer();
|
@@ -110,7 +98,10 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
110
98
|
colorPercent: progressColorPercent || 0,
|
111
99
|
onChange: handleScrubProgress,
|
112
100
|
onMouseUp: handleScrubEndProgress,
|
113
|
-
onTouchEnd: handleScrubEndProgress
|
101
|
+
onTouchEnd: handleScrubEndProgress,
|
102
|
+
dataAttrs: {
|
103
|
+
'data-testid': 'AudioTimeRange'
|
104
|
+
}
|
114
105
|
})));
|
115
106
|
};
|
116
107
|
|
@@ -6,9 +6,10 @@ export interface IAudioRangeProps {
|
|
6
6
|
value: number;
|
7
7
|
step: string;
|
8
8
|
colorPercent: number;
|
9
|
-
onChange
|
9
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
10
10
|
onMouseUp?: () => void;
|
11
11
|
onTouchEnd?: () => void;
|
12
|
+
dataAttrs?: Record<string, string>;
|
12
13
|
}
|
13
14
|
declare const AudioRange: React.FC<IAudioRangeProps>;
|
14
15
|
export default AudioRange;
|
@@ -1,5 +1,6 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
1
2
|
import React from 'react';
|
2
|
-
import { cnCreate } from '@megafon/ui-helpers';
|
3
|
+
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
|
3
4
|
import "./style/AudioRange.css";
|
4
5
|
var cn = cnCreate('mfui-audio-range');
|
5
6
|
|
@@ -11,8 +12,9 @@ var AudioRange = function AudioRange(_ref) {
|
|
11
12
|
colorPercent = _ref.colorPercent,
|
12
13
|
onChange = _ref.onChange,
|
13
14
|
onMouseUp = _ref.onMouseUp,
|
14
|
-
onTouchEnd = _ref.onTouchEnd
|
15
|
-
|
15
|
+
onTouchEnd = _ref.onTouchEnd,
|
16
|
+
dataAttrs = _ref.dataAttrs;
|
17
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
16
18
|
className: cn([className]),
|
17
19
|
style: {
|
18
20
|
backgroundSize: "".concat(colorPercent, "% 100%")
|
@@ -25,7 +27,7 @@ var AudioRange = function AudioRange(_ref) {
|
|
25
27
|
onChange: onChange,
|
26
28
|
onMouseUp: onMouseUp,
|
27
29
|
onTouchEnd: onTouchEnd
|
28
|
-
});
|
30
|
+
}, filterDataAttrs(dataAttrs)));
|
29
31
|
};
|
30
32
|
|
31
33
|
export default AudioRange;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import './style/AudioVolume.less';
|
3
3
|
export interface IAudioVolumeProps {
|
4
|
-
onChangeAudioVolume
|
4
|
+
onChangeAudioVolume?: (volume: number) => void;
|
5
5
|
}
|
6
6
|
declare const AudioVolume: React.FC<IAudioVolumeProps>;
|
7
7
|
export default AudioVolume;
|
@@ -45,7 +45,7 @@ var AudioVolume = function AudioVolume(_ref) {
|
|
45
45
|
var handleScrubVolume = function handleScrubVolume(e) {
|
46
46
|
var currentVolume = Number(e.target.value);
|
47
47
|
setTrackVolume(currentVolume);
|
48
|
-
onChangeAudioVolume(currentVolume);
|
48
|
+
onChangeAudioVolume === null || onChangeAudioVolume === void 0 ? void 0 : onChangeAudioVolume(currentVolume);
|
49
49
|
};
|
50
50
|
|
51
51
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -76,7 +76,10 @@ var AudioVolume = function AudioVolume(_ref) {
|
|
76
76
|
value: trackVolume,
|
77
77
|
step: "0.01",
|
78
78
|
colorPercent: volumeColorPercent || 0,
|
79
|
-
onChange: handleScrubVolume
|
79
|
+
onChange: handleScrubVolume,
|
80
|
+
dataAttrs: {
|
81
|
+
'data-testid': 'AudioVolumeRange'
|
82
|
+
}
|
80
83
|
})));
|
81
84
|
};
|
82
85
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import React from 'react';
|
3
|
+
|
4
|
+
var useTrackDuration = function useTrackDuration(audioRef) {
|
5
|
+
var _React$useState = React.useState(0),
|
6
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
7
|
+
trackDuration = _React$useState2[0],
|
8
|
+
setTrackDuration = _React$useState2[1];
|
9
|
+
|
10
|
+
React.useEffect(function () {
|
11
|
+
var audioNode = audioRef.current;
|
12
|
+
|
13
|
+
if (!audioNode) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
|
17
|
+
var readyState = audioNode.readyState,
|
18
|
+
duration = audioNode.duration;
|
19
|
+
|
20
|
+
if (readyState > 0) {
|
21
|
+
setTrackDuration(Math.round(duration));
|
22
|
+
} else {
|
23
|
+
audioNode.onloadedmetadata = function (e) {
|
24
|
+
var el = e.target;
|
25
|
+
setTrackDuration(Math.round(el.duration));
|
26
|
+
};
|
27
|
+
}
|
28
|
+
}, [audioRef]);
|
29
|
+
return trackDuration;
|
30
|
+
};
|
31
|
+
|
32
|
+
export default useTrackDuration;
|
@@ -92,6 +92,48 @@ h5 {
|
|
92
92
|
top: 63px;
|
93
93
|
}
|
94
94
|
}
|
95
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__device-mask {
|
96
|
+
position: relative;
|
97
|
+
z-index: 2;
|
98
|
+
background-image: url('./img/iphone12.png');
|
99
|
+
}
|
100
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
101
|
+
top: 16px;
|
102
|
+
z-index: 1;
|
103
|
+
width: 87%;
|
104
|
+
}
|
105
|
+
@media screen and (min-width: 1024px) and (max-width: 1279px) {
|
106
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
107
|
+
top: 18px;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
111
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
112
|
+
top: 13px;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
@media screen and (max-width: 767px) {
|
116
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
117
|
+
top: 35px;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
@media screen and (max-width: 767px) {
|
121
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__content {
|
122
|
+
text-align: left;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
@media screen and (max-width: 767px) {
|
126
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__stores {
|
127
|
+
-webkit-box-pack: start;
|
128
|
+
-ms-flex-pack: start;
|
129
|
+
justify-content: flex-start;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
@media screen and (max-width: 767px) {
|
133
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__button {
|
134
|
+
margin: 0;
|
135
|
+
}
|
136
|
+
}
|
95
137
|
@media screen and (min-width: 1024px) {
|
96
138
|
.mfui-store-banner__container {
|
97
139
|
padding-top: 30px;
|
@@ -13,6 +13,7 @@ export declare const DeviceMask: {
|
|
13
13
|
readonly NEW_IPHONE: "new-iphone";
|
14
14
|
readonly BLACK_IPHONE: "black-iphone";
|
15
15
|
readonly WHITE_IPHONE: "white-iphone";
|
16
|
+
readonly IPHONE_12: "iphone-12";
|
16
17
|
};
|
17
18
|
declare type DeviceMaskType = typeof DeviceMask[keyof typeof DeviceMask];
|
18
19
|
declare type LinkHrefType = StoreButtonPropsType['href'];
|
@@ -48,6 +49,8 @@ export interface IStoreBannerProps {
|
|
48
49
|
deviceMask: DeviceMaskType;
|
49
50
|
/** Изображение на дисплее телефона */
|
50
51
|
imageSrc: string;
|
52
|
+
/** Выравнивание контента слева на мобильном разрешении */
|
53
|
+
isContentLeftMobile?: boolean;
|
51
54
|
/** Дополнительный класс корневого элемента */
|
52
55
|
className?: string;
|
53
56
|
/** Дополнительные классы для корневого и внутренних элементов */
|
@@ -16,7 +16,8 @@ export var DeviceMask = {
|
|
16
16
|
ANDROID: 'android',
|
17
17
|
NEW_IPHONE: 'new-iphone',
|
18
18
|
BLACK_IPHONE: 'black-iphone',
|
19
|
-
WHITE_IPHONE: 'white-iphone'
|
19
|
+
WHITE_IPHONE: 'white-iphone',
|
20
|
+
IPHONE_12: 'iphone-12'
|
20
21
|
};
|
21
22
|
var cn = cnCreate('mfui-store-banner');
|
22
23
|
|
@@ -42,6 +43,7 @@ var StoreBanner = function StoreBanner(_ref) {
|
|
42
43
|
_ref$theme = _ref.theme,
|
43
44
|
theme = _ref$theme === void 0 ? 'default' : _ref$theme,
|
44
45
|
deviceMask = _ref.deviceMask,
|
46
|
+
isContentLeftMobile = _ref.isContentLeftMobile,
|
45
47
|
rootRef = _ref.rootRef,
|
46
48
|
dataAttrs = _ref.dataAttrs,
|
47
49
|
onClickApple = _ref.onClickApple,
|
@@ -50,7 +52,8 @@ var StoreBanner = function StoreBanner(_ref) {
|
|
50
52
|
return /*#__PURE__*/React.createElement("div", _extends({
|
51
53
|
className: cn({
|
52
54
|
theme: theme,
|
53
|
-
mask: deviceMask
|
55
|
+
mask: deviceMask,
|
56
|
+
'content-left-mobile': isContentLeftMobile
|
54
57
|
}, [className, rootClassName]),
|
55
58
|
ref: rootRef
|
56
59
|
}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
|
Binary file
|
Binary file
|
package/dist/es/index.d.ts
CHANGED
@@ -39,5 +39,6 @@ export { default as TextWithIcon } from './components/TextWithIcon/TextWithIcon'
|
|
39
39
|
export { default as TextWithIconItem } from './components/TextWithIcon/TextWithIconItem';
|
40
40
|
export { default as timerFormatUtil } from './components/AudioPlayer/timerFormatUtil';
|
41
41
|
export { default as TitleDescriptionBox } from './components/TitleDescriptionBox/TitleDescriptionBox';
|
42
|
+
export { default as useTrackDuration } from './components/AudioPlayer/hooks/useTrackDuration';
|
42
43
|
export { default as VideoBanner } from './components/VideoBanner/VideoBanner';
|
43
44
|
export { default as VideoBlock } from './components/VideoBlock/VideoBlock';
|
package/dist/es/index.js
CHANGED
@@ -39,5 +39,6 @@ export { default as TextWithIcon } from "./components/TextWithIcon/TextWithIcon"
|
|
39
39
|
export { default as TextWithIconItem } from "./components/TextWithIcon/TextWithIconItem";
|
40
40
|
export { default as timerFormatUtil } from "./components/AudioPlayer/timerFormatUtil";
|
41
41
|
export { default as TitleDescriptionBox } from "./components/TitleDescriptionBox/TitleDescriptionBox";
|
42
|
+
export { default as useTrackDuration } from "./components/AudioPlayer/hooks/useTrackDuration";
|
42
43
|
export { default as VideoBanner } from "./components/VideoBanner/VideoBanner";
|
43
44
|
export { default as VideoBlock } from "./components/VideoBlock/VideoBlock";
|
@@ -99,13 +99,15 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
99
99
|
className: cn({
|
100
100
|
'full-width': isFullWidth,
|
101
101
|
position: position
|
102
|
-
})
|
102
|
+
}),
|
103
|
+
"data-testid": "AudioPlayer"
|
103
104
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
104
105
|
className: cn('player')
|
105
106
|
}, /*#__PURE__*/_react["default"].createElement("audio", {
|
106
107
|
className: cn('audio'),
|
107
108
|
ref: audioRef,
|
108
|
-
controls: false
|
109
|
+
controls: false,
|
110
|
+
"data-testid": "AudioPlayer-audio"
|
109
111
|
}, /*#__PURE__*/_react["default"].createElement("source", {
|
110
112
|
src: audioSrc,
|
111
113
|
type: "audio/mpeg"
|
@@ -115,14 +117,19 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
115
117
|
icon: isPlaying ? /*#__PURE__*/_react["default"].createElement(IconPause, null) : /*#__PURE__*/_react["default"].createElement(IconPlay, null),
|
116
118
|
onClick: playingIconHandleClick,
|
117
119
|
sizeAll: "small",
|
118
|
-
className: cn('button')
|
120
|
+
className: cn('button'),
|
121
|
+
dataAttrs: {
|
122
|
+
root: {
|
123
|
+
'data-testid': 'AudioPlayer-btn'
|
124
|
+
}
|
125
|
+
}
|
119
126
|
})), /*#__PURE__*/_react["default"].createElement(_AudioProgress["default"], {
|
120
127
|
audioRef: audioRef,
|
121
128
|
audioTitle: audioTitle,
|
122
129
|
isPlaying: isPlaying,
|
123
130
|
isPause: isPause,
|
124
131
|
onChangeAudioCurrentTime: handleChangeAudioCurrentTime,
|
125
|
-
|
132
|
+
onPlay: handlePLay,
|
126
133
|
onSetIsPlaying: setIsPlaying
|
127
134
|
}), /*#__PURE__*/_react["default"].createElement(_AudioVolume["default"], {
|
128
135
|
onChangeAudioVolume: handleChangeAudioVolume
|
@@ -6,9 +6,9 @@ export interface IAudioProgressProps {
|
|
6
6
|
audioTitle: string;
|
7
7
|
isPlaying: boolean;
|
8
8
|
isPause: boolean;
|
9
|
-
onChangeAudioCurrentTime
|
10
|
-
|
11
|
-
onSetIsPlaying
|
9
|
+
onChangeAudioCurrentTime?: (currentTime: number) => void;
|
10
|
+
onPlay?: () => void;
|
11
|
+
onSetIsPlaying?: (value: boolean) => void;
|
12
12
|
}
|
13
13
|
declare const AudioProgress: React.FC<IAudioProgressProps>;
|
14
14
|
export default AudioProgress;
|
@@ -17,6 +17,8 @@ var _uiHelpers = require("@megafon/ui-helpers");
|
|
17
17
|
|
18
18
|
var _AudioRange = _interopRequireDefault(require("./AudioRange"));
|
19
19
|
|
20
|
+
var _useTrackDuration = _interopRequireDefault(require("./hooks/useTrackDuration"));
|
21
|
+
|
20
22
|
var _timerFormatUtil = _interopRequireDefault(require("./timerFormatUtil"));
|
21
23
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
@@ -31,20 +33,17 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
31
33
|
isPlaying = _ref.isPlaying,
|
32
34
|
isPause = _ref.isPause,
|
33
35
|
onChangeAudioCurrentTime = _ref.onChangeAudioCurrentTime,
|
34
|
-
|
36
|
+
onPlay = _ref.onPlay,
|
35
37
|
onSetIsPlaying = _ref.onSetIsPlaying;
|
36
38
|
|
37
39
|
var intervalId = _react["default"].useRef(null);
|
38
40
|
|
39
41
|
var _React$useState = _react["default"].useState(0),
|
40
42
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
41
|
-
|
42
|
-
|
43
|
+
trackProgress = _React$useState2[0],
|
44
|
+
setTrackProgress = _React$useState2[1];
|
43
45
|
|
44
|
-
var
|
45
|
-
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
46
|
-
trackProgress = _React$useState4[0],
|
47
|
-
setTrackProgress = _React$useState4[1];
|
46
|
+
var trackDuration = (0, _useTrackDuration["default"])(audioRef);
|
48
47
|
|
49
48
|
var progressColorPercent = _react["default"].useMemo(function () {
|
50
49
|
return trackProgress / trackDuration * 100;
|
@@ -60,7 +59,7 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
60
59
|
var _a, _b, _c;
|
61
60
|
|
62
61
|
if ((_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.ended) {
|
63
|
-
onSetIsPlaying(false);
|
62
|
+
onSetIsPlaying === null || onSetIsPlaying === void 0 ? void 0 : onSetIsPlaying(false);
|
64
63
|
setTrackProgress(Math.floor(((_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.duration) || 0));
|
65
64
|
return;
|
66
65
|
}
|
@@ -72,12 +71,12 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
72
71
|
var handleScrubProgress = function handleScrubProgress(e) {
|
73
72
|
var currentTime = Number(e.target.value);
|
74
73
|
setTrackProgress(currentTime);
|
75
|
-
onChangeAudioCurrentTime(currentTime);
|
74
|
+
onChangeAudioCurrentTime === null || onChangeAudioCurrentTime === void 0 ? void 0 : onChangeAudioCurrentTime(currentTime);
|
76
75
|
};
|
77
76
|
|
78
77
|
var handleScrubEndProgress = function handleScrubEndProgress() {
|
79
78
|
if (!isPlaying) {
|
80
|
-
|
79
|
+
onPlay === null || onPlay === void 0 ? void 0 : onPlay();
|
81
80
|
}
|
82
81
|
|
83
82
|
handleStartTimer();
|
@@ -89,16 +88,6 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
89
88
|
setTrackProgress(Math.floor(((_a = audioRef === null || audioRef === void 0 ? void 0 : audioRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) || 0));
|
90
89
|
}, [audioRef]);
|
91
90
|
|
92
|
-
_react["default"].useEffect(function () {
|
93
|
-
var audioNode = audioRef.current;
|
94
|
-
|
95
|
-
if (audioNode) {
|
96
|
-
audioNode.onloadedmetadata = function () {
|
97
|
-
setTrackDuration(Math.round(audioNode.duration));
|
98
|
-
};
|
99
|
-
}
|
100
|
-
}, [audioRef]);
|
101
|
-
|
102
91
|
_react["default"].useEffect(function () {
|
103
92
|
if (isPlaying) {
|
104
93
|
handleStartTimer();
|
@@ -133,7 +122,10 @@ var AudioProgress = function AudioProgress(_ref) {
|
|
133
122
|
colorPercent: progressColorPercent || 0,
|
134
123
|
onChange: handleScrubProgress,
|
135
124
|
onMouseUp: handleScrubEndProgress,
|
136
|
-
onTouchEnd: handleScrubEndProgress
|
125
|
+
onTouchEnd: handleScrubEndProgress,
|
126
|
+
dataAttrs: {
|
127
|
+
'data-testid': 'AudioTimeRange'
|
128
|
+
}
|
137
129
|
})));
|
138
130
|
};
|
139
131
|
|
@@ -6,9 +6,10 @@ export interface IAudioRangeProps {
|
|
6
6
|
value: number;
|
7
7
|
step: string;
|
8
8
|
colorPercent: number;
|
9
|
-
onChange
|
9
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
10
10
|
onMouseUp?: () => void;
|
11
11
|
onTouchEnd?: () => void;
|
12
|
+
dataAttrs?: Record<string, string>;
|
12
13
|
}
|
13
14
|
declare const AudioRange: React.FC<IAudioRangeProps>;
|
14
15
|
export default AudioRange;
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports["default"] = void 0;
|
7
7
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
+
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
9
11
|
|
10
12
|
var _uiHelpers = require("@megafon/ui-helpers");
|
@@ -21,8 +23,9 @@ var AudioRange = function AudioRange(_ref) {
|
|
21
23
|
colorPercent = _ref.colorPercent,
|
22
24
|
onChange = _ref.onChange,
|
23
25
|
onMouseUp = _ref.onMouseUp,
|
24
|
-
onTouchEnd = _ref.onTouchEnd
|
25
|
-
|
26
|
+
onTouchEnd = _ref.onTouchEnd,
|
27
|
+
dataAttrs = _ref.dataAttrs;
|
28
|
+
return /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({
|
26
29
|
className: cn([className]),
|
27
30
|
style: {
|
28
31
|
backgroundSize: "".concat(colorPercent, "% 100%")
|
@@ -35,7 +38,7 @@ var AudioRange = function AudioRange(_ref) {
|
|
35
38
|
onChange: onChange,
|
36
39
|
onMouseUp: onMouseUp,
|
37
40
|
onTouchEnd: onTouchEnd
|
38
|
-
});
|
41
|
+
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs)));
|
39
42
|
};
|
40
43
|
|
41
44
|
var _default = AudioRange;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import './style/AudioVolume.less';
|
3
3
|
export interface IAudioVolumeProps {
|
4
|
-
onChangeAudioVolume
|
4
|
+
onChangeAudioVolume?: (volume: number) => void;
|
5
5
|
}
|
6
6
|
declare const AudioVolume: React.FC<IAudioVolumeProps>;
|
7
7
|
export default AudioVolume;
|
@@ -60,7 +60,7 @@ var AudioVolume = function AudioVolume(_ref) {
|
|
60
60
|
var handleScrubVolume = function handleScrubVolume(e) {
|
61
61
|
var currentVolume = Number(e.target.value);
|
62
62
|
setTrackVolume(currentVolume);
|
63
|
-
onChangeAudioVolume(currentVolume);
|
63
|
+
onChangeAudioVolume === null || onChangeAudioVolume === void 0 ? void 0 : onChangeAudioVolume(currentVolume);
|
64
64
|
};
|
65
65
|
|
66
66
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
@@ -91,7 +91,10 @@ var AudioVolume = function AudioVolume(_ref) {
|
|
91
91
|
value: trackVolume,
|
92
92
|
step: "0.01",
|
93
93
|
colorPercent: volumeColorPercent || 0,
|
94
|
-
onChange: handleScrubVolume
|
94
|
+
onChange: handleScrubVolume,
|
95
|
+
dataAttrs: {
|
96
|
+
'data-testid': 'AudioVolumeRange'
|
97
|
+
}
|
95
98
|
})));
|
96
99
|
};
|
97
100
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
13
|
+
|
14
|
+
var useTrackDuration = function useTrackDuration(audioRef) {
|
15
|
+
var _React$useState = _react["default"].useState(0),
|
16
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
17
|
+
trackDuration = _React$useState2[0],
|
18
|
+
setTrackDuration = _React$useState2[1];
|
19
|
+
|
20
|
+
_react["default"].useEffect(function () {
|
21
|
+
var audioNode = audioRef.current;
|
22
|
+
|
23
|
+
if (!audioNode) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
var readyState = audioNode.readyState,
|
28
|
+
duration = audioNode.duration;
|
29
|
+
|
30
|
+
if (readyState > 0) {
|
31
|
+
setTrackDuration(Math.round(duration));
|
32
|
+
} else {
|
33
|
+
audioNode.onloadedmetadata = function (e) {
|
34
|
+
var el = e.target;
|
35
|
+
setTrackDuration(Math.round(el.duration));
|
36
|
+
};
|
37
|
+
}
|
38
|
+
}, [audioRef]);
|
39
|
+
|
40
|
+
return trackDuration;
|
41
|
+
};
|
42
|
+
|
43
|
+
var _default = useTrackDuration;
|
44
|
+
exports["default"] = _default;
|
@@ -92,6 +92,48 @@ h5 {
|
|
92
92
|
top: 63px;
|
93
93
|
}
|
94
94
|
}
|
95
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__device-mask {
|
96
|
+
position: relative;
|
97
|
+
z-index: 2;
|
98
|
+
background-image: url('./img/iphone12.png');
|
99
|
+
}
|
100
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
101
|
+
top: 16px;
|
102
|
+
z-index: 1;
|
103
|
+
width: 87%;
|
104
|
+
}
|
105
|
+
@media screen and (min-width: 1024px) and (max-width: 1279px) {
|
106
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
107
|
+
top: 18px;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
111
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
112
|
+
top: 13px;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
@media screen and (max-width: 767px) {
|
116
|
+
.mfui-store-banner_mask_iphone-12 .mfui-store-banner__screen {
|
117
|
+
top: 35px;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
@media screen and (max-width: 767px) {
|
121
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__content {
|
122
|
+
text-align: left;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
@media screen and (max-width: 767px) {
|
126
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__stores {
|
127
|
+
-webkit-box-pack: start;
|
128
|
+
-ms-flex-pack: start;
|
129
|
+
justify-content: flex-start;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
@media screen and (max-width: 767px) {
|
133
|
+
.mfui-store-banner_content-left-mobile .mfui-store-banner__button {
|
134
|
+
margin: 0;
|
135
|
+
}
|
136
|
+
}
|
95
137
|
@media screen and (min-width: 1024px) {
|
96
138
|
.mfui-store-banner__container {
|
97
139
|
padding-top: 30px;
|
@@ -13,6 +13,7 @@ export declare const DeviceMask: {
|
|
13
13
|
readonly NEW_IPHONE: "new-iphone";
|
14
14
|
readonly BLACK_IPHONE: "black-iphone";
|
15
15
|
readonly WHITE_IPHONE: "white-iphone";
|
16
|
+
readonly IPHONE_12: "iphone-12";
|
16
17
|
};
|
17
18
|
declare type DeviceMaskType = typeof DeviceMask[keyof typeof DeviceMask];
|
18
19
|
declare type LinkHrefType = StoreButtonPropsType['href'];
|
@@ -48,6 +49,8 @@ export interface IStoreBannerProps {
|
|
48
49
|
deviceMask: DeviceMaskType;
|
49
50
|
/** Изображение на дисплее телефона */
|
50
51
|
imageSrc: string;
|
52
|
+
/** Выравнивание контента слева на мобильном разрешении */
|
53
|
+
isContentLeftMobile?: boolean;
|
51
54
|
/** Дополнительный класс корневого элемента */
|
52
55
|
className?: string;
|
53
56
|
/** Дополнительные классы для корневого и внутренних элементов */
|
@@ -38,7 +38,8 @@ var DeviceMask = {
|
|
38
38
|
ANDROID: 'android',
|
39
39
|
NEW_IPHONE: 'new-iphone',
|
40
40
|
BLACK_IPHONE: 'black-iphone',
|
41
|
-
WHITE_IPHONE: 'white-iphone'
|
41
|
+
WHITE_IPHONE: 'white-iphone',
|
42
|
+
IPHONE_12: 'iphone-12'
|
42
43
|
};
|
43
44
|
exports.DeviceMask = DeviceMask;
|
44
45
|
var cn = (0, _uiHelpers.cnCreate)('mfui-store-banner');
|
@@ -65,6 +66,7 @@ var StoreBanner = function StoreBanner(_ref) {
|
|
65
66
|
_ref$theme = _ref.theme,
|
66
67
|
theme = _ref$theme === void 0 ? 'default' : _ref$theme,
|
67
68
|
deviceMask = _ref.deviceMask,
|
69
|
+
isContentLeftMobile = _ref.isContentLeftMobile,
|
68
70
|
rootRef = _ref.rootRef,
|
69
71
|
dataAttrs = _ref.dataAttrs,
|
70
72
|
onClickApple = _ref.onClickApple,
|
@@ -73,7 +75,8 @@ var StoreBanner = function StoreBanner(_ref) {
|
|
73
75
|
return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
|
74
76
|
className: cn({
|
75
77
|
theme: theme,
|
76
|
-
mask: deviceMask
|
78
|
+
mask: deviceMask,
|
79
|
+
'content-left-mobile': isContentLeftMobile
|
77
80
|
}, [className, rootClassName]),
|
78
81
|
ref: rootRef
|
79
82
|
}, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
|
Binary file
|
Binary file
|
package/dist/lib/index.d.ts
CHANGED
@@ -39,5 +39,6 @@ export { default as TextWithIcon } from './components/TextWithIcon/TextWithIcon'
|
|
39
39
|
export { default as TextWithIconItem } from './components/TextWithIcon/TextWithIconItem';
|
40
40
|
export { default as timerFormatUtil } from './components/AudioPlayer/timerFormatUtil';
|
41
41
|
export { default as TitleDescriptionBox } from './components/TitleDescriptionBox/TitleDescriptionBox';
|
42
|
+
export { default as useTrackDuration } from './components/AudioPlayer/hooks/useTrackDuration';
|
42
43
|
export { default as VideoBanner } from './components/VideoBanner/VideoBanner';
|
43
44
|
export { default as VideoBlock } from './components/VideoBlock/VideoBlock';
|
package/dist/lib/index.js
CHANGED
@@ -249,6 +249,12 @@ Object.defineProperty(exports, "TitleDescriptionBox", {
|
|
249
249
|
return _TitleDescriptionBox["default"];
|
250
250
|
}
|
251
251
|
});
|
252
|
+
Object.defineProperty(exports, "useTrackDuration", {
|
253
|
+
enumerable: true,
|
254
|
+
get: function get() {
|
255
|
+
return _useTrackDuration["default"];
|
256
|
+
}
|
257
|
+
});
|
252
258
|
Object.defineProperty(exports, "VideoBanner", {
|
253
259
|
enumerable: true,
|
254
260
|
get: function get() {
|
@@ -344,6 +350,8 @@ var _timerFormatUtil = _interopRequireDefault(require("./components/AudioPlayer/
|
|
344
350
|
|
345
351
|
var _TitleDescriptionBox = _interopRequireDefault(require("./components/TitleDescriptionBox/TitleDescriptionBox"));
|
346
352
|
|
353
|
+
var _useTrackDuration = _interopRequireDefault(require("./components/AudioPlayer/hooks/useTrackDuration"));
|
354
|
+
|
347
355
|
var _VideoBanner = _interopRequireDefault(require("./components/VideoBanner/VideoBanner"));
|
348
356
|
|
349
357
|
var _VideoBlock = _interopRequireDefault(require("./components/VideoBlock/VideoBlock"));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@megafon/ui-shared",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.16.0",
|
4
4
|
"files": [
|
5
5
|
"dist"
|
6
6
|
],
|
@@ -52,10 +52,11 @@
|
|
52
52
|
"@babel/preset-env": "^7.8.6",
|
53
53
|
"@babel/preset-react": "^7.8.3",
|
54
54
|
"@babel/preset-typescript": "^7.8.3",
|
55
|
-
"@megafon/ui-icons": "^2.8.
|
55
|
+
"@megafon/ui-icons": "^2.8.1",
|
56
56
|
"@svgr/core": "^2.4.1",
|
57
57
|
"@testing-library/jest-dom": "5.16.2",
|
58
58
|
"@testing-library/react": "12.1.2",
|
59
|
+
"@testing-library/react-hooks": "^8.0.1",
|
59
60
|
"@testing-library/user-event": "13.5.0",
|
60
61
|
"@types/enzyme": "^3.10.5",
|
61
62
|
"@types/enzyme-adapter-react-16": "^1.0.6",
|
@@ -85,7 +86,7 @@
|
|
85
86
|
},
|
86
87
|
"dependencies": {
|
87
88
|
"@babel/runtime": "^7.8.4",
|
88
|
-
"@megafon/ui-core": "^4.
|
89
|
+
"@megafon/ui-core": "^4.15.1",
|
89
90
|
"@megafon/ui-helpers": "^2.4.0",
|
90
91
|
"core-js": "^3.6.4",
|
91
92
|
"htmr": "^0.9.2",
|
@@ -93,5 +94,5 @@
|
|
93
94
|
"prop-types": "^15.7.2",
|
94
95
|
"swiper": "^6.5.6"
|
95
96
|
},
|
96
|
-
"gitHead": "
|
97
|
+
"gitHead": "ff8786e64e8cc9220fc248899a2328d28bd159b0"
|
97
98
|
}
|