mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-09 08:32:48 +00:00
71 lines
2.0 KiB
TypeScript
71 lines
2.0 KiB
TypeScript
import React from 'react';
|
|
import { SoundListType, SoundType } from '../../model';
|
|
|
|
interface IProps {
|
|
sound: SoundType;
|
|
type: SoundListType;
|
|
hasModPermissions: boolean;
|
|
showFavorite?: boolean;
|
|
onFavorite?: () => void;
|
|
onPlayBrowser: (sound: SoundType) => void;
|
|
onPlayDiscord: (sound: SoundType) => void;
|
|
}
|
|
|
|
export class ClipPlayerControl extends React.Component<IProps, unknown> {
|
|
checkExtension(extension: string) {
|
|
switch (extension) {
|
|
case 'wav':
|
|
return true;
|
|
case 'mp3':
|
|
return true;
|
|
case 'mpeg':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { onPlayBrowser, onPlayDiscord, sound, hasModPermissions, showFavorite, type } = this.props;
|
|
|
|
return (
|
|
this.checkExtension(sound.extension) && (
|
|
<div className="flex flex--center">
|
|
{showFavorite && hasModPermissions && (
|
|
<i
|
|
title="Favorite"
|
|
className={'fa link fa-lg ' + (type === 'favorites' ? 'fa-trash' : 'fa-heart color__red')}
|
|
aria-hidden="true"
|
|
style={{ paddingRight: '5px' }}
|
|
onClick={() => !this.props.onFavorite || this.props.onFavorite()}
|
|
/>
|
|
)}
|
|
<a
|
|
href={`/public/${type.toLowerCase()}/` + sound.name + '.' + sound.extension}
|
|
download
|
|
title="Download"
|
|
className="fa fa-download link"
|
|
aria-hidden="true"
|
|
/>
|
|
<i
|
|
title="Play in browser"
|
|
className="fa fa-play link"
|
|
aria-hidden="true"
|
|
style={{ paddingLeft: '15px' }}
|
|
onClick={() => onPlayBrowser(sound)}
|
|
/>
|
|
{hasModPermissions && (
|
|
<i
|
|
title="Play in discord"
|
|
className="fa fa-play-circle link fa-lg"
|
|
aria-hidden="true"
|
|
style={{ paddingLeft: '10px' }}
|
|
onClick={() => onPlayDiscord(sound)}
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
);
|
|
}
|
|
}
|