File tree Expand file tree Collapse file tree
components/stateless/SoundBar Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React , { useRef , useState } from 'react'
2+ import styles from './index.module.less'
3+ import music from '@assets/audio/heart-of-the-sea.mp3'
4+ const SoundBar = ( ) => {
5+ const [ isPlaying , setIsPlaying ] = useState ( false )
6+ const audioRef = useRef ( null )
7+ const togglePlay = ( ) => {
8+ if ( isPlaying ) {
9+ audioRef . current . pause ( )
10+ } else {
11+ audioRef . current . play ( )
12+ }
13+ setIsPlaying ( ! isPlaying )
14+ }
15+
16+ return (
17+ < >
18+ < span className = { styles . audio } onClick = { togglePlay } >
19+ { Array . from ( { length : 5 } , ( ) => ( { id : Math . random ( ) } ) ) . map ( ( item , index ) => (
20+ < span
21+ key = { item . id }
22+ style = { { '--i' : index , '--state' : isPlaying ? 'running' : 'paused' } }
23+ className = { styles . line }
24+ />
25+ ) ) }
26+ </ span >
27+ < audio src = { music } ref = { audioRef } loop >
28+ < track kind = "captions" default />
29+ </ audio >
30+ </ >
31+ )
32+ }
33+
34+ export default SoundBar
Original file line number Diff line number Diff line change 1+ .audio {
2+ --i : 0 ;
3+ --state : paused ;
4+
5+ display : flex ;
6+ flex-direction : row ;
7+ justify-content : center ;
8+ align-items : center ;
9+ width : 100% ;
10+ cursor : pointer ;
11+ z-index : 3 ;
12+ position : relative ;
13+
14+ .line {
15+ background : #00ff7f ;
16+ animation : play 1s ease infinite ;
17+ animation-delay : calc (var (--i ) * 0.1s );
18+ animation-play-state : var (--state );
19+ height : 10px ;
20+ width : 2px ;
21+ margin : 0 1px ;
22+ }
23+ }
24+
25+ @keyframes play {
26+ 0% {
27+ transform : scaleY (1 );
28+ }
29+
30+ 50% {
31+ transform : scaleY (1.5 );
32+ }
33+
34+ 100% {
35+ transform : scaleY (1 );
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import LanguageSwitcher from '@stateless/LanguageSwitcher'
1111// import LightSvg from '@assets/svg/light.svg'
1212// import DarkSvg from '@assets/svg/dark.svg'
1313
14+ import SoundBar from '@stateless/SoundBar'
15+
1416import { useProThemeContext } from '@theme/hooks'
1517
1618import PrimaryNav from '../primaryNav'
@@ -84,6 +86,7 @@ const ProHeader = () => {
8486 </ div >
8587 < div className = { styles . headerRight } >
8688 < Space direction = "horizontal" style = { { cursor : 'pointer' , paddingRight : 8 } } >
89+ < SoundBar />
8790 < Switch
8891 // checkedChildren={<Icon component={LightSvg} />}
8992 // unCheckedChildren={<Icon component={DarkSvg} />}
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ const config = {
199199 ] ,
200200 } ,
201201 {
202- test : / \. ( p n g | j p e ? g | g i f | w e b p | e o t | t t f | w o f f | w o f f 2 | m p 4 | m k v | p d f ) $ / i,
202+ test : / \. ( p n g | j p e ? g | g i f | w e b p | e o t | t t f | w o f f | w o f f 2 | m p 4 | m p 3 | m k v | p d f ) $ / i,
203203 type : 'asset' ,
204204 parser : {
205205 // Conditions for converting to base64
You can’t perform that action at this time.
0 commit comments