1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

remove bars components

This commit is contained in:
Fedor Katurov 2023-11-19 17:07:58 +06:00
parent 92efb1e97e
commit 8ec77986bf
7 changed files with 13 additions and 3 deletions

View file

@ -0,0 +1,77 @@
import React, { useCallback, VFC } from 'react';
import { Icon } from '~/components/input/Icon';
import { PlayerState } from '~/constants/player';
import { IFile } from '~/types';
import { PlayerProgress } from '~/types/player';
import { path } from '~/utils/ramda';
import styles from './styles.module.scss';
interface Props {
progress: PlayerProgress;
status: PlayerState;
file?: IFile;
playerPlay: () => void;
playerPause: () => void;
playerSeek: (pos: number) => void;
playerStop: () => void;
}
const PlayerBar: VFC<Props> = ({
status,
playerPlay,
playerPause,
playerSeek,
playerStop,
progress,
file,
}) => {
const onClick = useCallback(() => {
if (status === PlayerState.PLAYING) return playerPause();
return playerPlay();
}, [playerPlay, playerPause, status]);
const onSeek = useCallback(
event => {
event.stopPropagation();
const { clientX, target } = event;
const { left, width } = target.getBoundingClientRect();
playerSeek(((clientX - left) / width) * 100);
},
[playerSeek]
);
if (status === PlayerState.UNSET) return null;
const metadata: IFile['metadata'] = path(['metadata'], file);
const title =
metadata &&
(metadata.title || [metadata.id3artist, metadata.id3title].filter(el => !!el).join(' - '));
return (
<div className={styles.place}>
<div className={styles.wrap}>
<div className={styles.status}>
<div className={styles.playpause} onClick={onClick}>
{status === PlayerState.PLAYING ? <Icon icon="pause" /> : <Icon icon="play" />}
</div>
<div className={styles.info}>
<div className={styles.title}>{title}</div>
<div className={styles.progress} onClick={onSeek}>
<div className={styles.bar} style={{ width: `${progress.progress}%` }} />
</div>
</div>
<div className={styles.close} onClick={playerStop}>
<Icon icon="close" />
</div>
</div>
</div>
</div>
);
};
export { PlayerBar };