@megafon/ui-shared 4.7.0 → 4.8.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 +11 -0
- package/dist/es/components/AudioPlayer/AudioPlayer.d.ts +10 -0
- package/dist/es/components/AudioPlayer/AudioPlayer.js +116 -0
- package/dist/es/components/AudioPlayer/AudioProgress.d.ts +14 -0
- package/dist/es/components/AudioPlayer/AudioProgress.js +117 -0
- package/dist/es/components/AudioPlayer/AudioRange.d.ts +14 -0
- package/dist/es/components/AudioPlayer/AudioRange.js +31 -0
- package/dist/es/components/AudioPlayer/AudioVolume.d.ts +7 -0
- package/dist/es/components/AudioPlayer/AudioVolume.js +83 -0
- package/dist/es/components/AudioPlayer/style/AudioPlayer.css +58 -0
- package/dist/es/components/AudioPlayer/style/AudioProgress.css +35 -0
- package/dist/es/components/AudioPlayer/style/AudioRange.css +68 -0
- package/dist/es/components/AudioPlayer/style/AudioVolume.css +34 -0
- package/dist/es/components/AudioPlayer/timerFormatUtil.d.ts +2 -0
- package/dist/es/components/AudioPlayer/timerFormatUtil.js +33 -0
- package/dist/es/index.d.ts +5 -0
- package/dist/es/index.js +5 -0
- package/dist/lib/components/AudioPlayer/AudioPlayer.d.ts +10 -0
- package/dist/lib/components/AudioPlayer/AudioPlayer.js +133 -0
- package/dist/lib/components/AudioPlayer/AudioProgress.d.ts +14 -0
- package/dist/lib/components/AudioPlayer/AudioProgress.js +141 -0
- package/dist/lib/components/AudioPlayer/AudioRange.d.ts +14 -0
- package/dist/lib/components/AudioPlayer/AudioRange.js +42 -0
- package/dist/lib/components/AudioPlayer/AudioVolume.d.ts +7 -0
- package/dist/lib/components/AudioPlayer/AudioVolume.js +99 -0
- package/dist/lib/components/AudioPlayer/style/AudioPlayer.css +58 -0
- package/dist/lib/components/AudioPlayer/style/AudioProgress.css +35 -0
- package/dist/lib/components/AudioPlayer/style/AudioRange.css +68 -0
- package/dist/lib/components/AudioPlayer/style/AudioVolume.css +34 -0
- package/dist/lib/components/AudioPlayer/timerFormatUtil.d.ts +2 -0
- package/dist/lib/components/AudioPlayer/timerFormatUtil.js +42 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +40 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
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.8.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.7.0...@megafon/ui-shared@4.8.0) (2022-12-19)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **audioplayer:** add new component ([43f3159](https://github.com/MegafonWebLab/megafon-ui/commit/43f3159279568538638397e311ce4756f3727d05))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
6
17
|
# [4.7.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.6.0...@megafon/ui-shared@4.7.0) (2022-12-12)
|
7
18
|
|
8
19
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import './style/AudioPlayer.less';
|
3
|
+
export interface IAudioPlayerProps {
|
4
|
+
audioSrc: string;
|
5
|
+
audioTitle: string;
|
6
|
+
position?: 'left' | 'center' | 'right';
|
7
|
+
isFullWidth?: boolean;
|
8
|
+
}
|
9
|
+
declare const AudioPlayer: React.FC<IAudioPlayerProps>;
|
10
|
+
export default AudioPlayer;
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
|
+
import React from 'react';
|
4
|
+
import { Button } from '@megafon/ui-core';
|
5
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
6
|
+
import AudioProgress from "./AudioProgress";
|
7
|
+
import AudioVolume from "./AudioVolume";
|
8
|
+
import "./style/AudioPlayer.css";
|
9
|
+
|
10
|
+
var IconPause = function IconPause(props) {
|
11
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
12
|
+
viewBox: "0 0 32 32"
|
13
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
14
|
+
d: "M11 10.5v11a.5.5 0 00.5.5h2a.5.5 0 00.5-.5v-11a.5.5 0 00-.5-.5h-2a.5.5 0 00-.5.5zm7 0v11a.5.5 0 00.5.5h2a.5.5 0 00.5-.5v-11a.5.5 0 00-.5-.5h-2a.5.5 0 00-.5.5z"
|
15
|
+
}));
|
16
|
+
};
|
17
|
+
|
18
|
+
var IconPlay = function IconPlay(props) {
|
19
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
20
|
+
viewBox: "0 0 32 32"
|
21
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
22
|
+
d: "M11.5 22.13V9.87a.5.5 0 01.752-.431l10.508 6.13a.5.5 0 010 .863l-10.508 6.13a.5.5 0 01-.752-.433z"
|
23
|
+
}));
|
24
|
+
};
|
25
|
+
|
26
|
+
var cn = cnCreate('mfui-audio-player');
|
27
|
+
|
28
|
+
var AudioPlayer = function AudioPlayer(_ref) {
|
29
|
+
var audioSrc = _ref.audioSrc,
|
30
|
+
audioTitle = _ref.audioTitle,
|
31
|
+
_ref$position = _ref.position,
|
32
|
+
position = _ref$position === void 0 ? 'center' : _ref$position,
|
33
|
+
isFullWidth = _ref.isFullWidth;
|
34
|
+
var audioRef = React.useRef(null);
|
35
|
+
|
36
|
+
var _React$useState = React.useState(false),
|
37
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
38
|
+
isPlaying = _React$useState2[0],
|
39
|
+
setIsPlaying = _React$useState2[1];
|
40
|
+
|
41
|
+
var _React$useState3 = React.useState(false),
|
42
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
43
|
+
isPause = _React$useState4[0],
|
44
|
+
setIsPause = _React$useState4[1];
|
45
|
+
|
46
|
+
var handlePLay = function handlePLay() {
|
47
|
+
var _a;
|
48
|
+
|
49
|
+
setIsPlaying(true);
|
50
|
+
setIsPause(false);
|
51
|
+
(_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
52
|
+
};
|
53
|
+
|
54
|
+
var handlePause = function handlePause() {
|
55
|
+
var _a;
|
56
|
+
|
57
|
+
setIsPlaying(false);
|
58
|
+
setIsPause(true);
|
59
|
+
(_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
60
|
+
};
|
61
|
+
|
62
|
+
var handleChangeAudioCurrentTime = function handleChangeAudioCurrentTime(currentTime) {
|
63
|
+
if (!audioRef || !audioRef.current) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
audioRef.current.currentTime = currentTime;
|
68
|
+
};
|
69
|
+
|
70
|
+
var handleChangeAudioVolume = function handleChangeAudioVolume(volume) {
|
71
|
+
if (!audioRef || !audioRef.current) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
audioRef.current.volume = volume;
|
76
|
+
audioRef.current.muted = !volume;
|
77
|
+
};
|
78
|
+
|
79
|
+
var playingIconHandleClick = React.useMemo(function () {
|
80
|
+
return isPlaying ? handlePause : handlePLay;
|
81
|
+
}, [isPlaying]);
|
82
|
+
return /*#__PURE__*/React.createElement("div", {
|
83
|
+
className: cn({
|
84
|
+
'full-width': isFullWidth,
|
85
|
+
position: position
|
86
|
+
})
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
88
|
+
className: cn('player')
|
89
|
+
}, /*#__PURE__*/React.createElement("audio", {
|
90
|
+
className: cn('audio'),
|
91
|
+
ref: audioRef,
|
92
|
+
controls: false
|
93
|
+
}, /*#__PURE__*/React.createElement("source", {
|
94
|
+
src: audioSrc,
|
95
|
+
type: "audio/mpeg"
|
96
|
+
})), /*#__PURE__*/React.createElement("div", {
|
97
|
+
className: cn('playing-controls')
|
98
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
99
|
+
icon: isPlaying ? /*#__PURE__*/React.createElement(IconPause, null) : /*#__PURE__*/React.createElement(IconPlay, null),
|
100
|
+
onClick: playingIconHandleClick,
|
101
|
+
sizeAll: "small",
|
102
|
+
className: cn('button')
|
103
|
+
})), /*#__PURE__*/React.createElement(AudioProgress, {
|
104
|
+
audioRef: audioRef,
|
105
|
+
audioTitle: audioTitle,
|
106
|
+
isPlaying: isPlaying,
|
107
|
+
isPause: isPause,
|
108
|
+
onChangeAudioCurrentTime: handleChangeAudioCurrentTime,
|
109
|
+
onPLay: handlePLay,
|
110
|
+
onSetIsPlaying: setIsPlaying
|
111
|
+
}), /*#__PURE__*/React.createElement(AudioVolume, {
|
112
|
+
onChangeAudioVolume: handleChangeAudioVolume
|
113
|
+
})));
|
114
|
+
};
|
115
|
+
|
116
|
+
export default AudioPlayer;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import './style/AudioProgress.less';
|
3
|
+
export declare const INTERVAL_DELAY = 1000;
|
4
|
+
export interface IAudioProgressProps {
|
5
|
+
audioRef: React.MutableRefObject<HTMLAudioElement | null>;
|
6
|
+
audioTitle: string;
|
7
|
+
isPlaying: boolean;
|
8
|
+
isPause: boolean;
|
9
|
+
onChangeAudioCurrentTime: (currentTime: number) => void;
|
10
|
+
onPLay: () => void;
|
11
|
+
onSetIsPlaying: (value: boolean) => void;
|
12
|
+
}
|
13
|
+
declare const AudioProgress: React.FC<IAudioProgressProps>;
|
14
|
+
export default AudioProgress;
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import "core-js/modules/es.number.constructor";
|
2
|
+
import "core-js/modules/web.timers";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
import React from 'react';
|
5
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
6
|
+
import AudioRange from "./AudioRange";
|
7
|
+
import timerFormat from "./timerFormatUtil";
|
8
|
+
import "./style/AudioProgress.css";
|
9
|
+
export var INTERVAL_DELAY = 1000;
|
10
|
+
var cn = cnCreate('mfui-audio-progress');
|
11
|
+
|
12
|
+
var AudioProgress = function AudioProgress(_ref) {
|
13
|
+
var audioRef = _ref.audioRef,
|
14
|
+
audioTitle = _ref.audioTitle,
|
15
|
+
isPlaying = _ref.isPlaying,
|
16
|
+
isPause = _ref.isPause,
|
17
|
+
onChangeAudioCurrentTime = _ref.onChangeAudioCurrentTime,
|
18
|
+
onPLay = _ref.onPLay,
|
19
|
+
onSetIsPlaying = _ref.onSetIsPlaying;
|
20
|
+
var intervalId = React.useRef(null);
|
21
|
+
|
22
|
+
var _React$useState = React.useState(0),
|
23
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
24
|
+
trackDuration = _React$useState2[0],
|
25
|
+
setTrackDuration = _React$useState2[1];
|
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];
|
31
|
+
|
32
|
+
var progressColorPercent = React.useMemo(function () {
|
33
|
+
return trackProgress / trackDuration * 100;
|
34
|
+
}, [trackDuration, trackProgress]);
|
35
|
+
var progressValue = React.useMemo(function () {
|
36
|
+
return isPlaying || isPause ? trackProgress : trackDuration;
|
37
|
+
}, [isPause, isPlaying, trackDuration, trackProgress]);
|
38
|
+
var handleStartTimer = React.useCallback(function () {
|
39
|
+
intervalId.current && clearInterval(intervalId.current);
|
40
|
+
intervalId.current = setInterval(function () {
|
41
|
+
var _a, _b, _c;
|
42
|
+
|
43
|
+
if ((_a = audioRef.current) === null || _a === void 0 ? void 0 : _a.ended) {
|
44
|
+
onSetIsPlaying(false);
|
45
|
+
setTrackProgress(Math.floor(((_b = audioRef.current) === null || _b === void 0 ? void 0 : _b.duration) || 0));
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
49
|
+
setTrackProgress(Math.floor(((_c = audioRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) || 0));
|
50
|
+
}, INTERVAL_DELAY);
|
51
|
+
}, [audioRef, onSetIsPlaying]);
|
52
|
+
|
53
|
+
var handleScrubProgress = function handleScrubProgress(e) {
|
54
|
+
var currentTime = Number(e.target.value);
|
55
|
+
setTrackProgress(currentTime);
|
56
|
+
onChangeAudioCurrentTime(currentTime);
|
57
|
+
};
|
58
|
+
|
59
|
+
var handleScrubEndProgress = function handleScrubEndProgress() {
|
60
|
+
if (!isPlaying) {
|
61
|
+
onPLay();
|
62
|
+
}
|
63
|
+
|
64
|
+
handleStartTimer();
|
65
|
+
};
|
66
|
+
|
67
|
+
React.useEffect(function () {
|
68
|
+
var _a;
|
69
|
+
|
70
|
+
setTrackProgress(Math.floor(((_a = audioRef === null || audioRef === void 0 ? void 0 : audioRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) || 0));
|
71
|
+
}, [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
|
+
React.useEffect(function () {
|
82
|
+
if (isPlaying) {
|
83
|
+
handleStartTimer();
|
84
|
+
}
|
85
|
+
|
86
|
+
if (isPause) {
|
87
|
+
intervalId.current && clearInterval(intervalId.current);
|
88
|
+
}
|
89
|
+
}, [handleStartTimer, isPause, isPlaying]);
|
90
|
+
React.useEffect(function () {
|
91
|
+
return function () {
|
92
|
+
intervalId.current && clearInterval(intervalId.current);
|
93
|
+
};
|
94
|
+
}, []);
|
95
|
+
return /*#__PURE__*/React.createElement("div", {
|
96
|
+
className: cn()
|
97
|
+
}, /*#__PURE__*/React.createElement("div", {
|
98
|
+
className: cn('info')
|
99
|
+
}, /*#__PURE__*/React.createElement("span", {
|
100
|
+
className: cn('title')
|
101
|
+
}, audioTitle), /*#__PURE__*/React.createElement("span", {
|
102
|
+
className: cn('value')
|
103
|
+
}, timerFormat(progressValue))), /*#__PURE__*/React.createElement("div", {
|
104
|
+
className: cn('range-wrapper')
|
105
|
+
}, /*#__PURE__*/React.createElement(AudioRange, {
|
106
|
+
className: cn('range'),
|
107
|
+
maxValue: trackDuration,
|
108
|
+
value: trackProgress,
|
109
|
+
step: "1",
|
110
|
+
colorPercent: progressColorPercent || 0,
|
111
|
+
onChange: handleScrubProgress,
|
112
|
+
onMouseUp: handleScrubEndProgress,
|
113
|
+
onTouchEnd: handleScrubEndProgress
|
114
|
+
})));
|
115
|
+
};
|
116
|
+
|
117
|
+
export default AudioProgress;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import './style/AudioRange.less';
|
3
|
+
export interface IAudioRangeProps {
|
4
|
+
className?: string;
|
5
|
+
maxValue: number | string;
|
6
|
+
value: number;
|
7
|
+
step: string;
|
8
|
+
colorPercent: number;
|
9
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
10
|
+
onMouseUp?: () => void;
|
11
|
+
onTouchEnd?: () => void;
|
12
|
+
}
|
13
|
+
declare const AudioRange: React.FC<IAudioRangeProps>;
|
14
|
+
export default AudioRange;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
3
|
+
import "./style/AudioRange.css";
|
4
|
+
var cn = cnCreate('mfui-audio-range');
|
5
|
+
|
6
|
+
var AudioRange = function AudioRange(_ref) {
|
7
|
+
var className = _ref.className,
|
8
|
+
maxValue = _ref.maxValue,
|
9
|
+
value = _ref.value,
|
10
|
+
step = _ref.step,
|
11
|
+
colorPercent = _ref.colorPercent,
|
12
|
+
onChange = _ref.onChange,
|
13
|
+
onMouseUp = _ref.onMouseUp,
|
14
|
+
onTouchEnd = _ref.onTouchEnd;
|
15
|
+
return /*#__PURE__*/React.createElement("input", {
|
16
|
+
className: cn([className]),
|
17
|
+
style: {
|
18
|
+
backgroundSize: "".concat(colorPercent, "% 100%")
|
19
|
+
},
|
20
|
+
type: "range",
|
21
|
+
min: "0",
|
22
|
+
max: maxValue,
|
23
|
+
step: step,
|
24
|
+
value: value,
|
25
|
+
onChange: onChange,
|
26
|
+
onMouseUp: onMouseUp,
|
27
|
+
onTouchEnd: onTouchEnd
|
28
|
+
});
|
29
|
+
};
|
30
|
+
|
31
|
+
export default AudioRange;
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import "core-js/modules/es.number.constructor";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
4
|
+
import React from 'react';
|
5
|
+
import { Tooltip } from '@megafon/ui-core';
|
6
|
+
import { cnCreate } from '@megafon/ui-helpers';
|
7
|
+
import AudioRange from "./AudioRange";
|
8
|
+
import "./style/AudioVolume.css";
|
9
|
+
|
10
|
+
var NoVolumeIcon = function NoVolumeIcon(props) {
|
11
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
12
|
+
viewBox: "0 0 24 24"
|
13
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
14
|
+
d: "M14 20.15c0 .322.299.56.606.467a9.004 9.004 0 004.96-13.493l-1.525 1.34a7.002 7.002 0 01-3.687 10.13.525.525 0 00-.354.488v1.069z"
|
15
|
+
}), /*#__PURE__*/React.createElement("path", {
|
16
|
+
d: "M16.094 10.174c.261.56.406 1.177.406 1.826 0 1.426-.7 2.701-1.8 3.548-.3.23-.7-.004-.7-.382v-3.152l2.094-1.84zm-1.225-1.586L14 9.35v-.517c0-.378.4-.613.7-.382.058.044.114.09.169.136zm1.923-1.69a6.998 6.998 0 00-2.438-1.491.525.525 0 01-.354-.489V3.849c0-.32.299-.559.606-.466a8.994 8.994 0 013.694 2.19l-1.508 1.325zM12 11.108V5.36a.5.5 0 00-.342-.474l-.822-.274a.5.5 0 00-.553.167L7.15 8.807A.5.5 0 016.756 9H3.707a.5.5 0 00-.353.146l-.207.208A.5.5 0 003 9.707v4.586a.5.5 0 00.147.353l.207.208a.5.5 0 00.353.146h3.049a.5.5 0 01.394.193l.082.105L12 11.108zM8.462 16.88l1.82 2.34a.5.5 0 00.554.168l.822-.274A.5.5 0 0012 18.64v-4.87l-3.538 3.11zm-5.488 3.563a.5.5 0 01.046-.705L21.497 3.503a.5.5 0 11.66.751L3.68 20.49a.5.5 0 01-.706-.046z"
|
17
|
+
}));
|
18
|
+
};
|
19
|
+
|
20
|
+
var VolumeIcon = function VolumeIcon(props) {
|
21
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
22
|
+
viewBox: "0 0 24 24"
|
23
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
24
|
+
d: "M14 20.15c0 .322.299.56.606.467a9.004 9.004 0 000-17.234.475.475 0 00-.606.466v1.069c0 .221.146.414.354.489a7.002 7.002 0 010 13.186.525.525 0 00-.354.489v1.069zM3.146 14.646A.5.5 0 013 14.293V9.707a.5.5 0 01.146-.353l.208-.208A.5.5 0 013.707 9h3.048a.5.5 0 00.395-.193l3.133-4.028a.5.5 0 01.553-.167l.822.274A.5.5 0 0112 5.36v13.28a.5.5 0 01-.342.474l-.822.274a.5.5 0 01-.553-.167L7.15 15.193A.5.5 0 006.755 15H3.707a.5.5 0 01-.353-.146l-.208-.208z"
|
25
|
+
}), /*#__PURE__*/React.createElement("path", {
|
26
|
+
d: "M16.5 12c0 1.426-.7 2.701-1.8 3.548-.3.23-.7-.004-.7-.382V8.834c0-.378.4-.613.7-.382 1.1.847 1.8 2.122 1.8 3.548z"
|
27
|
+
}));
|
28
|
+
};
|
29
|
+
|
30
|
+
var cn = cnCreate('mfui-audio-volume');
|
31
|
+
|
32
|
+
var AudioVolume = function AudioVolume(_ref) {
|
33
|
+
var onChangeAudioVolume = _ref.onChangeAudioVolume;
|
34
|
+
var tooltipTrigger = React.useRef(null);
|
35
|
+
|
36
|
+
var _React$useState = React.useState(0.3),
|
37
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
38
|
+
trackVolume = _React$useState2[0],
|
39
|
+
setTrackVolume = _React$useState2[1];
|
40
|
+
|
41
|
+
var volumeColorPercent = React.useMemo(function () {
|
42
|
+
return trackVolume * 100;
|
43
|
+
}, [trackVolume]);
|
44
|
+
|
45
|
+
var handleScrubVolume = function handleScrubVolume(e) {
|
46
|
+
var currentVolume = Number(e.target.value);
|
47
|
+
setTrackVolume(currentVolume);
|
48
|
+
onChangeAudioVolume(currentVolume);
|
49
|
+
};
|
50
|
+
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
52
|
+
className: cn()
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
54
|
+
className: cn('icon-area'),
|
55
|
+
ref: tooltipTrigger
|
56
|
+
}, /*#__PURE__*/React.createElement(VolumeIcon, {
|
57
|
+
className: cn('icon', {
|
58
|
+
visible: !!trackVolume
|
59
|
+
})
|
60
|
+
}), /*#__PURE__*/React.createElement(NoVolumeIcon, {
|
61
|
+
className: cn('icon', {
|
62
|
+
visible: !trackVolume
|
63
|
+
})
|
64
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
65
|
+
classes: {
|
66
|
+
content: "".concat(cn('tooltip-content')),
|
67
|
+
contentShadow: "".concat(cn('tooltip-content-shadow'))
|
68
|
+
},
|
69
|
+
triggerElement: tooltipTrigger,
|
70
|
+
triggerEvent: "click",
|
71
|
+
placement: "top",
|
72
|
+
paddings: "none"
|
73
|
+
}, /*#__PURE__*/React.createElement(AudioRange, {
|
74
|
+
className: cn('range'),
|
75
|
+
maxValue: "1",
|
76
|
+
value: trackVolume,
|
77
|
+
step: "0.01",
|
78
|
+
colorPercent: volumeColorPercent || 0,
|
79
|
+
onChange: handleScrubVolume
|
80
|
+
})));
|
81
|
+
};
|
82
|
+
|
83
|
+
export default AudioVolume;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
h1,
|
2
|
+
h2,
|
3
|
+
h3,
|
4
|
+
h4,
|
5
|
+
h5 {
|
6
|
+
margin: 0;
|
7
|
+
}
|
8
|
+
.mfui-audio-player {
|
9
|
+
margin-top: 32px;
|
10
|
+
}
|
11
|
+
.mfui-audio-player__player {
|
12
|
+
display: -webkit-box;
|
13
|
+
display: -ms-flexbox;
|
14
|
+
display: flex;
|
15
|
+
-webkit-box-align: center;
|
16
|
+
-ms-flex-align: center;
|
17
|
+
align-items: center;
|
18
|
+
-webkit-box-pack: justify;
|
19
|
+
-ms-flex-pack: justify;
|
20
|
+
justify-content: space-between;
|
21
|
+
-webkit-box-sizing: border-box;
|
22
|
+
box-sizing: border-box;
|
23
|
+
padding: 16px;
|
24
|
+
border-radius: 12px;
|
25
|
+
background: var(--spbSky0);
|
26
|
+
}
|
27
|
+
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
28
|
+
.mfui-audio-player__player {
|
29
|
+
max-width: 530px;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
@media screen and (min-width: 1024px) {
|
33
|
+
.mfui-audio-player__player {
|
34
|
+
max-width: 550px;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
.mfui-audio-player__playing-controls {
|
38
|
+
margin-right: 16px;
|
39
|
+
}
|
40
|
+
.mfui-audio-player_position_center .mfui-audio-player__player {
|
41
|
+
margin: 0 auto;
|
42
|
+
}
|
43
|
+
.mfui-audio-player_position_left .mfui-audio-player__player {
|
44
|
+
margin-right: auto;
|
45
|
+
}
|
46
|
+
.mfui-audio-player_position_right .mfui-audio-player__player {
|
47
|
+
margin-left: auto;
|
48
|
+
}
|
49
|
+
@media screen and (min-width: 768px) and (max-width: 1023px) {
|
50
|
+
.mfui-audio-player_full-width .mfui-audio-player__player {
|
51
|
+
max-width: 100%;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
@media screen and (min-width: 1024px) {
|
55
|
+
.mfui-audio-player_full-width .mfui-audio-player__player {
|
56
|
+
max-width: 100%;
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
h1,
|
2
|
+
h2,
|
3
|
+
h3,
|
4
|
+
h4,
|
5
|
+
h5 {
|
6
|
+
margin: 0;
|
7
|
+
}
|
8
|
+
.mfui-audio-progress {
|
9
|
+
width: 100%;
|
10
|
+
margin-right: 16px;
|
11
|
+
}
|
12
|
+
.mfui-audio-progress__info {
|
13
|
+
display: -webkit-box;
|
14
|
+
display: -ms-flexbox;
|
15
|
+
display: flex;
|
16
|
+
-webkit-box-align: center;
|
17
|
+
-ms-flex-align: center;
|
18
|
+
align-items: center;
|
19
|
+
-webkit-box-pack: justify;
|
20
|
+
-ms-flex-pack: justify;
|
21
|
+
justify-content: space-between;
|
22
|
+
}
|
23
|
+
.mfui-audio-progress__value {
|
24
|
+
color: var(-spbSky3);
|
25
|
+
font-size: 12px;
|
26
|
+
line-height: 18px;
|
27
|
+
}
|
28
|
+
.mfui-audio-progress__range-wrapper {
|
29
|
+
margin-top: -2px;
|
30
|
+
}
|
31
|
+
.mfui-audio-progress__title {
|
32
|
+
color: var(--stcBlack);
|
33
|
+
font-size: 12px;
|
34
|
+
line-height: 18px;
|
35
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
h1,
|
2
|
+
h2,
|
3
|
+
h3,
|
4
|
+
h4,
|
5
|
+
h5 {
|
6
|
+
margin: 0;
|
7
|
+
}
|
8
|
+
.mfui-audio-range {
|
9
|
+
width: 100%;
|
10
|
+
height: 4px;
|
11
|
+
border-radius: 2px;
|
12
|
+
background: var(--spbSky2);
|
13
|
+
background-image: -webkit-gradient(linear, left top, left bottom, from(#00B956), to(#00B956));
|
14
|
+
background-image: linear-gradient(#00B956, #00B956);
|
15
|
+
background-repeat: no-repeat;
|
16
|
+
cursor: pointer;
|
17
|
+
-webkit-appearance: none;
|
18
|
+
}
|
19
|
+
.mfui-audio-range:focus {
|
20
|
+
outline: none;
|
21
|
+
}
|
22
|
+
.mfui-audio-range::-webkit-slider-thumb {
|
23
|
+
width: 16px;
|
24
|
+
height: 16px;
|
25
|
+
border: none;
|
26
|
+
border-radius: 50%;
|
27
|
+
background: var(--stcWhite);
|
28
|
+
-webkit-box-shadow: 0 2px 9px rgba(0, 0, 0, 0.15);
|
29
|
+
box-shadow: 0 2px 9px rgba(0, 0, 0, 0.15);
|
30
|
+
-webkit-appearance: none;
|
31
|
+
}
|
32
|
+
.mfui-audio-range::-moz-range-thumb {
|
33
|
+
width: 16px;
|
34
|
+
height: 16px;
|
35
|
+
border: none;
|
36
|
+
border-radius: 50%;
|
37
|
+
background: var(--stcWhite);
|
38
|
+
box-shadow: 0 2px 9px rgba(0, 0, 0, 0.15);
|
39
|
+
-webkit-appearance: none;
|
40
|
+
}
|
41
|
+
.mfui-audio-range::-ms-thumb {
|
42
|
+
width: 16px;
|
43
|
+
height: 16px;
|
44
|
+
border: none;
|
45
|
+
border-radius: 50%;
|
46
|
+
background: var(--stcWhite);
|
47
|
+
box-shadow: 0 2px 9px rgba(0, 0, 0, 0.15);
|
48
|
+
-webkit-appearance: none;
|
49
|
+
}
|
50
|
+
.mfui-audio-range::-webkit-slider-runnable-track {
|
51
|
+
border: none;
|
52
|
+
background: transparent;
|
53
|
+
-webkit-box-shadow: none;
|
54
|
+
box-shadow: none;
|
55
|
+
-webkit-appearance: none;
|
56
|
+
}
|
57
|
+
.mfui-audio-range::-moz-range-track {
|
58
|
+
border: none;
|
59
|
+
background: transparent;
|
60
|
+
box-shadow: none;
|
61
|
+
-webkit-appearance: none;
|
62
|
+
}
|
63
|
+
.mfui-audio-range::-ms-track {
|
64
|
+
border: none;
|
65
|
+
background: transparent;
|
66
|
+
box-shadow: none;
|
67
|
+
-webkit-appearance: none;
|
68
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
h1,
|
2
|
+
h2,
|
3
|
+
h3,
|
4
|
+
h4,
|
5
|
+
h5 {
|
6
|
+
margin: 0;
|
7
|
+
}
|
8
|
+
.mfui-audio-volume {
|
9
|
+
width: 24px;
|
10
|
+
}
|
11
|
+
.mfui-audio-volume__tooltip-content {
|
12
|
+
padding: 7px 16px 14px;
|
13
|
+
border-radius: 12px;
|
14
|
+
}
|
15
|
+
.mfui-audio-volume__tooltip-content-shadow {
|
16
|
+
border-radius: 12px;
|
17
|
+
}
|
18
|
+
.mfui-audio-volume__icon {
|
19
|
+
display: none;
|
20
|
+
width: 24px;
|
21
|
+
min-width: 24px;
|
22
|
+
height: 24px;
|
23
|
+
cursor: pointer;
|
24
|
+
fill: var(--brandGreen);
|
25
|
+
}
|
26
|
+
.mfui-audio-volume__icon_visible {
|
27
|
+
display: block;
|
28
|
+
}
|
29
|
+
.mfui-audio-volume__icon:hover {
|
30
|
+
fill: var(--buttonHoverGreen);
|
31
|
+
}
|
32
|
+
.mfui-audio-volume__range {
|
33
|
+
max-width: 128px;
|
34
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import "core-js/modules/es.array.concat";
|
2
|
+
import "core-js/modules/es.parse-int";
|
3
|
+
|
4
|
+
var getMinutes = function getMinutes(sec) {
|
5
|
+
var min = parseInt("".concat(sec / 60), 10);
|
6
|
+
|
7
|
+
if (min < 10) {
|
8
|
+
return "0".concat(min);
|
9
|
+
}
|
10
|
+
|
11
|
+
return "".concat(min);
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* @param {Number} sec
|
15
|
+
* @returns {String}
|
16
|
+
*/
|
17
|
+
|
18
|
+
|
19
|
+
var getSeconds = function getSeconds(sec) {
|
20
|
+
if (sec < 10) {
|
21
|
+
return "0".concat(sec);
|
22
|
+
}
|
23
|
+
|
24
|
+
return "".concat(sec);
|
25
|
+
};
|
26
|
+
|
27
|
+
var timerFormat = function timerFormat(sec) {
|
28
|
+
var min = getMinutes(sec);
|
29
|
+
var seconds = getSeconds(sec % 60);
|
30
|
+
return "".concat(min, ":").concat(seconds);
|
31
|
+
};
|
32
|
+
|
33
|
+
export default timerFormat;
|
package/dist/es/index.d.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
export { default as AccordionBox } from './components/AccordionBox/AccordionBox';
|
2
|
+
export { default as AudioPlayer } from './components/AudioPlayer/AudioPlayer';
|
3
|
+
export { default as AudioProgress } from './components/AudioPlayer/AudioProgress';
|
4
|
+
export { default as AudioRange } from './components/AudioPlayer/AudioRange';
|
5
|
+
export { default as AudioVolume } from './components/AudioPlayer/AudioVolume';
|
2
6
|
export { default as BannerBox } from './components/BannerBox/BannerBox';
|
3
7
|
export { default as BenefitsIcons } from './components/BenefitsIcons/BenefitsIcons';
|
4
8
|
export { default as BenefitsIconsTile } from './components/BenefitsIcons/BenefitsIconsTile';
|
@@ -33,6 +37,7 @@ export { default as TextBox } from './components/TextBox/TextBox';
|
|
33
37
|
export { default as TextBoxPicture } from './components/TextBox/TextBoxPicture';
|
34
38
|
export { default as TextWithIcon } from './components/TextWithIcon/TextWithIcon';
|
35
39
|
export { default as TextWithIconItem } from './components/TextWithIcon/TextWithIconItem';
|
40
|
+
export { default as timerFormatUtil } from './components/AudioPlayer/timerFormatUtil';
|
36
41
|
export { default as TitleDescriptionBox } from './components/TitleDescriptionBox/TitleDescriptionBox';
|
37
42
|
export { default as VideoBanner } from './components/VideoBanner/VideoBanner';
|
38
43
|
export { default as VideoBlock } from './components/VideoBlock/VideoBlock';
|