lbry-desktop/ui/component/viewers/comicBookViewer.jsx

35 lines
787 B
React
Raw Normal View History

2019-05-09 00:47:39 +02:00
// @flow
import * as React from 'react';
2019-05-16 08:32:53 +02:00
import Villain from 'villain';
import 'villain/dist/style.css';
2019-05-09 00:47:39 +02:00
type Props = {
source: {
fileType: string,
2019-05-16 08:32:53 +02:00
downloadPath: string,
2019-05-09 00:47:39 +02:00
},
};
2019-06-04 20:32:42 +02:00
let workerPath = 'webworkers/worker-bundle.js';
if (process.env.NODE_ENV !== 'production') {
// Don't add a leading slash in production because electron treats it as an absolute path
workerPath = `/${workerPath}`;
}
2019-05-16 08:32:53 +02:00
const opts = {
2019-06-04 20:32:42 +02:00
workerPath,
2019-05-23 07:35:48 +02:00
allowFullScreen: false,
autoHideControls: true,
2019-05-16 08:32:53 +02:00
};
2019-05-09 00:47:39 +02:00
2019-05-16 08:32:53 +02:00
class ComicBookViewer extends React.PureComponent<Props> {
2019-05-09 00:47:39 +02:00
render() {
2019-05-16 08:32:53 +02:00
const { downloadPath } = this.props.source || {};
const file = `file://${downloadPath}`;
return <Villain file={file} width={'100%'} height={'100%'} options={opts} />;
2019-05-09 00:47:39 +02:00
}
}
export default ComicBookViewer;