From d41070c7b00fafc974a1a6e7b6d1b42391fa57ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 21 Jul 2017 04:48:52 +0200 Subject: all async paths working --- client/components/UI/AudioPlayerView.jsx | 19 ++++--------------- client/components/UI/Link.jsx | 8 ++++---- 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'client/components/UI') diff --git a/client/components/UI/AudioPlayerView.jsx b/client/components/UI/AudioPlayerView.jsx index d2c9982..e715c27 100644 --- a/client/components/UI/AudioPlayerView.jsx +++ b/client/components/UI/AudioPlayerView.jsx @@ -1,19 +1,21 @@ import { h, Component } from 'preact' - +import { pngpath, mp3path } from '../../vendor/paths' const audio = document.createElement('audio') export default function AudioPlayerView (props) { if (props.file) { document.body.style.backgroundImage = 'url(' + pngpath(props.file) + ')' audio.src = mp3path(props.file) + audio.currentTime = 0 audio.play() return ( -
+
audio.paused ? audio.play() : audio.pause()}> Playing {props.file.name}
) } else { + audio.pause() return (
Not Playing @@ -21,16 +23,3 @@ export default function AudioPlayerView (props) { ) } } - -function filepath (file) { - return '/data/' + file.folder_id + '/' + encodeURIComponent(file.name) -} -function mp3path (file) { - if (file.mime !== 'audio/mp3') { - return filepath(file) + '.mp3' - } - return filepath(file) -} -function pngpath (file) { - return filepath(file) + '.png' -} diff --git a/client/components/UI/Link.jsx b/client/components/UI/Link.jsx index d71582b..b4d2d28 100644 --- a/client/components/UI/Link.jsx +++ b/client/components/UI/Link.jsx @@ -2,15 +2,15 @@ import { h, Component } from 'preact' import React from 'react' // import PropTypes from 'prop-types' -const Link = ({ active, children, onClick, disabled }) => { +const Link = ({ href, active, children, onClick, selected, disabled }) => { if (active) { return {children} } - const className = disabled ? 'disabled' : '' - + const className = disabled ? 'disabled' : + selected ? 'selected' : '' return ( // eslint-disable-next-line - { e.preventDefault() -- cgit v1.2.3-70-g09d2