73 lines
2.3 KiB
JavaScript
Raw Normal View History

import React from 'react';
import style from './Preview.module.css';
import {Spinner} from 'react-bootstrap';
2020-12-29 19:39:30 +00:00
import {Link} from 'react-router-dom';
import GlobalInfos from '../../utils/GlobalInfos';
import {callAPIPlain} from '../../utils/Api';
2020-05-31 20:24:35 +02:00
/**
* Component for single preview tile
* floating side by side
*/
2020-05-31 20:24:35 +02:00
class Preview extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
previewpicture: null,
name: null
2020-05-31 20:24:35 +02:00
};
}
componentDidMount() {
callAPIPlain('video.php', {action: 'readThumbnail', movieid: this.props.movie_id}, (result) => {
this.setState({
previewpicture: result,
name: this.props.name
});
});
2020-05-31 20:24:35 +02:00
}
render() {
const themeStyle = GlobalInfos.getThemeStyle();
2020-05-31 20:24:35 +02:00
return (
2020-12-29 19:39:30 +00:00
<Link to={'/player/' + this.props.movie_id}>
<div className={style.videopreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}>
<div className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>{this.state.name}</div>
<div className={style.previewpic}>
{this.state.previewpicture !== null ?
<img className={style.previewimage}
src={this.state.previewpicture}
alt='Pic loading.'/> :
<span className={style.loadAnimation}><Spinner animation='border'/></span>}
2020-12-29 19:39:30 +00:00
</div>
<div className={style.previewbottom}>
2020-12-29 19:39:30 +00:00
</div>
</div>
2020-12-29 19:39:30 +00:00
</Link>
2020-12-29 19:39:30 +00:00
);
}
2020-05-31 20:24:35 +02:00
}
/**
* Component for a Tag-name tile (used in category page)
*/
export class TagPreview extends React.Component {
render() {
const themeStyle = GlobalInfos.getThemeStyle();
return (
<div
2020-12-29 19:39:30 +00:00
className={style.videopreview + ' ' + style.tagpreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}>
<div className={style.tagpreviewtitle + ' ' + themeStyle.lighttextcolor}>
{this.props.name}
</div>
</div>
);
}
}
2020-05-31 20:24:35 +02:00
export default Preview;