From cfeafcdc04458bce980d251dad1688888bc811b0 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Fri, 1 Nov 2019 16:47:04 +0700 Subject: [PATCH] dropping audio attaches --- src/components/media/AudioPlayer/index.tsx | 15 +++++++ src/components/media/AudioPlayer/styles.scss | 21 ++++++++++ src/components/node/CommentForm/index.tsx | 42 +++++++++++--------- 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/components/media/AudioPlayer/index.tsx b/src/components/media/AudioPlayer/index.tsx index 5b94e0f8..9ea11463 100644 --- a/src/components/media/AudioPlayer/index.tsx +++ b/src/components/media/AudioPlayer/index.tsx @@ -24,11 +24,13 @@ type Props = ReturnType & typeof mapDispatchToProps & { file: IFile; nonInteractive?: boolean; + onDrop?: (id: IFile['id']) => void; }; const AudioPlayerUnconnected = memo( ({ file, + onDrop, nonInteractive, player: { file: current, status }, playerSetFileAndPlay, @@ -72,6 +74,12 @@ const AudioPlayerUnconnected = memo( [playerSeek] ); + const onDropClick = useCallback(() => { + if (!onDrop) return; + + onDrop(file.id); + }, [file, onDrop]); + useEffect(() => { const active = current && current.id === file.id; setPlaying(current && current.id === file.id); @@ -90,6 +98,12 @@ const AudioPlayerUnconnected = memo( return (
+ {onDrop && ( +
+ +
+ )} +
{playing && status === PLAYER_STATES.PLAYING ? ( @@ -97,6 +111,7 @@ const AudioPlayerUnconnected = memo( )}
+
{title || 'Unknown'}
diff --git a/src/components/media/AudioPlayer/styles.scss b/src/components/media/AudioPlayer/styles.scss index e6225cc6..dae743ff 100644 --- a/src/components/media/AudioPlayer/styles.scss +++ b/src/components/media/AudioPlayer/styles.scss @@ -109,3 +109,24 @@ min-width: 10px; transition: width 0.5s; } + +.drop { + width: 24px; + height: 24px; + background: #222222; + position: absolute; + right: 10px; + top: 10px; + border-radius: 12px; + z-index: 2; + transition: background-color 250ms, opacity 0.25s; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + + svg { + width: 20px; + height: 20px; + } +} diff --git a/src/components/node/CommentForm/index.tsx b/src/components/node/CommentForm/index.tsx index d6f70d43..3b852a70 100644 --- a/src/components/node/CommentForm/index.tsx +++ b/src/components/node/CommentForm/index.tsx @@ -202,26 +202,30 @@ const CommentFormUnconnected: FC = ({ {(!!images.length || !!audios.length) && (
- + {!!images.length && ( + + )} - + {!!audios.length && ( + + )}
)}