From 69ff9a7652266425dc4ff081a6c4d605b791be30 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Sun, 13 Oct 2019 18:43:42 +0700 Subject: [PATCH] simple player controls --- src/components/containers/Card/index.tsx | 16 +-- src/components/containers/CellGrid/index.tsx | 13 +-- .../containers/CommentWrapper/styles.scss | 3 +- src/components/media/AudioPlayer/index.tsx | 15 ++- src/components/media/AudioPlayer/styles.sass | 0 src/components/media/AudioPlayer/styles.scss | 101 ++++++++++++++++++ src/containers/node/NodeLayout/styles.scss | 1 + src/sprites/Sprites.tsx | 4 + 8 files changed, 128 insertions(+), 25 deletions(-) delete mode 100644 src/components/media/AudioPlayer/styles.sass create mode 100644 src/components/media/AudioPlayer/styles.scss diff --git a/src/components/containers/Card/index.tsx b/src/components/containers/Card/index.tsx index fdf4d17f..f9c76a45 100644 --- a/src/components/containers/Card/index.tsx +++ b/src/components/containers/Card/index.tsx @@ -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 & { seamless?: boolean; -} +}; -const Card: FC = ({ - className, - children, - seamless, - ...props -}) => ( -
+const Card: FC = ({ className, children, seamless, ...props }) => ( +
{children}
); diff --git a/src/components/containers/CellGrid/index.tsx b/src/components/containers/CellGrid/index.tsx index bce8b6bb..0f9e964e 100644 --- a/src/components/containers/CellGrid/index.tsx +++ b/src/components/containers/CellGrid/index.tsx @@ -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 & { children: any; size: number; -} +}; -const CellGrid: FC = ({ - children, - size, - className, - ...props -}) => ( +const CellGrid: FC = ({ children, size, className, ...props }) => (
({ player: selectPlayer(state), @@ -61,8 +64,16 @@ const AudioPlayerUnconnected = ({ }, [file, current, setPlaying, onProgress]); return ( -
- - {file.url} - {progress} - {playing && 'playing'} +
+
+ {playing && status === PLAYER_STATES.PLAYING ? : } +
+
+
+
+
+
{file.url}
+
); }; diff --git a/src/components/media/AudioPlayer/styles.sass b/src/components/media/AudioPlayer/styles.sass deleted file mode 100644 index e69de29b..00000000 diff --git a/src/components/media/AudioPlayer/styles.scss b/src/components/media/AudioPlayer/styles.scss new file mode 100644 index 00000000..a6bf626e --- /dev/null +++ b/src/components/media/AudioPlayer/styles.scss @@ -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; +} diff --git a/src/containers/node/NodeLayout/styles.scss b/src/containers/node/NodeLayout/styles.scss index 2e5e7f78..ae3fabc4 100644 --- a/src/containers/node/NodeLayout/styles.scss +++ b/src/containers/node/NodeLayout/styles.scss @@ -6,6 +6,7 @@ .comments { flex: 3 1; + min-width: 0; } .panel { diff --git a/src/sprites/Sprites.tsx b/src/sprites/Sprites.tsx index d49ddf09..3ae8944d 100644 --- a/src/sprites/Sprites.tsx +++ b/src/sprites/Sprites.tsx @@ -25,6 +25,10 @@ const Sprites: FC<{}> = () => ( + + + +