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

simple player controls

This commit is contained in:
Fedor Katurov 2019-10-13 18:43:42 +07:00
parent 3fcff3ea0d
commit 69ff9a7652
8 changed files with 128 additions and 25 deletions

View file

@ -1,22 +1,14 @@
import React, { FC } from 'react';
import * as styles from './styles.scss';
import classNames = require('classnames');
import classNames from 'classnames';
type IProps = React.HTMLAttributes<HTMLDivElement> & {
seamless?: boolean;
}
};
const Card: FC<IProps> = ({
className,
children,
seamless,
...props
}) => (
<div
className={classNames(styles.card, className, { seamless })}
{...props}
>
const Card: FC<IProps> = ({ className, children, seamless, ...props }) => (
<div className={classNames(styles.card, className, { seamless })} {...props}>
{children}
</div>
);

View file

@ -1,6 +1,4 @@
import React, {
FC, HTMLAttributes, ReactChild, ReactChildren
} from 'react';
import React, { FC, HTMLAttributes } from 'react';
import * as styles from './styles.scss';
import classNames = require('classnames');
@ -8,14 +6,9 @@ import classNames = require('classnames');
type IProps = HTMLAttributes<HTMLDivElement> & {
children: any;
size: number;
}
};
const CellGrid: FC<IProps> = ({
children,
size,
className,
...props
}) => (
const CellGrid: FC<IProps> = ({ children, size, className, ...props }) => (
<div
className={classNames(styles.grid, className)}
style={{ gridTemplateColumns: `repeat(auto-fit, minmax(${size}px, 1fr))` }}

View file

@ -4,7 +4,7 @@
display: flex;
position: relative;
box-shadow: none;
// box-shadow: $comment_shadow;
min-width: 0;
&:global(.is_empty) {
opacity: 0.5;
@ -18,6 +18,7 @@
.text {
flex: 1;
min-width: 0;
}
.thumb {

View file

@ -5,6 +5,9 @@ import * as PLAYER_ACTIONS from '~/redux/player/actions';
import { IFile } from '~/redux/types';
import { PLAYER_STATES } from '~/redux/player/constants';
import { Player } from '~/utils/player';
import classNames from 'classnames';
import * as styles from './styles.scss';
import { Icon } from '~/components/input/Icon';
const mapStateToProps = state => ({
player: selectPlayer(state),
@ -61,8 +64,16 @@ const AudioPlayerUnconnected = ({
}, [file, current, setPlaying, onProgress]);
return (
<div onClick={onPlay}>
- {file.url} - {progress} - {playing && 'playing'}
<div onClick={onPlay} className={classNames(styles.wrap, { playing })}>
<div className={styles.playpause}>
{playing && status === PLAYER_STATES.PLAYING ? <Icon icon="pause" /> : <Icon icon="play" />}
</div>
<div className={styles.content}>
<div className={styles.progress}>
<div className={styles.bar} style={{ width: `${progress}%` }} />
</div>
<div className={styles.title}>{file.url}</div>
</div>
</div>
);
};

View file

@ -0,0 +1,101 @@
.wrap {
display: flex;
flex-direction: row;
&:global(.playing) {
.progress {
opacity: 1;
pointer-events: all;
touch-action: auto;
}
.title {
top: 15px;
opacity: 1;
font-size: 12px;
padding-right: 140px;
}
}
}
.playpause {
flex: 0 0 $comment_height;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
svg {
width: 32px;
height: 32px;
fill: transparentize($color: white, $amount: 0.5);
stroke: transparentize($color: white, $amount: 0.5);
transition: fill 250ms, stroke 250ms;
}
&:hover {
svg {
fill: white;
stroke: white;
}
}
}
.content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
padding: 0 $gap;
position: relative;
}
.title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
opacity: 0.2;
pointer-events: none;
touch-action: none;
padding: 0 10px;
box-sizing: border-box;
height: 100%;
top: 0;
text-align: left;
transition: all 0.5s;
}
.progress {
height: 20px;
position: relative;
opacity: 0;
pointer-events: none;
touch-action: none;
transition: opacity 0.5s;
left: 0;
&::after {
content: ' ';
position: absolute;
height: 10px;
border-radius: 5px;
background: transparentize(white, 0.95);
width: 100%;
top: 5px;
left: 0;
}
}
.bar {
background: linear-gradient(270deg, $green, $wisegreen);
position: absolute;
height: 10px;
left: 0;
top: 5px;
border-radius: 5px;
min-width: 10px;
}

View file

@ -6,6 +6,7 @@
.comments {
flex: 3 1;
min-width: 0;
}
.panel {

View file

@ -25,6 +25,10 @@ const Sprites: FC<{}> = () => (
<path d="M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18c.62-.39.62-1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82z" />
</g>
<g id="pause">
<path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z" strokeWidth="0" />
</g>
<g id="plus" stroke="none">
<path fill="none" d="M0 0h24v24H0V0z" />
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />