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

refactored some common components

This commit is contained in:
Fedor Katurov 2023-11-20 22:29:13 +06:00
parent 5e9c111e0f
commit a9a220273f
67 changed files with 238 additions and 220 deletions

View file

@ -1,6 +1,6 @@
import React, { useCallback, VFC } from 'react';
import { Icon } from '~/components/input/Icon';
import { Icon } from '~/components/common/Icon';
import { PlayerState } from '~/constants/player';
import { IFile } from '~/types';
import { PlayerProgress } from '~/types/player';
@ -33,13 +33,13 @@ const PlayerBar: VFC<Props> = ({
}, [playerPlay, playerPause, status]);
const onSeek = useCallback(
event => {
(event) => {
event.stopPropagation();
const { clientX, target } = event;
const { left, width } = target.getBoundingClientRect();
playerSeek(((clientX - left) / width) * 100);
},
[playerSeek]
[playerSeek],
);
if (status === PlayerState.UNSET) return null;
@ -47,21 +47,29 @@ const PlayerBar: VFC<Props> = ({
const metadata: IFile['metadata'] = path(['metadata'], file);
const title =
metadata &&
(metadata.title || [metadata.id3artist, metadata.id3title].filter(el => !!el).join(' - '));
(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" />}
{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
className={styles.bar}
style={{ width: `${progress.progress}%` }}
/>
</div>
</div>