Skip to content

Instantly share code, notes, and snippets.

@wongni
Created January 12, 2018 16:50
Show Gist options
  • Save wongni/34b302425a4ce1a69c30db383b73d8c4 to your computer and use it in GitHub Desktop.
Save wongni/34b302425a4ce1a69c30db383b73d8c4 to your computer and use it in GitHub Desktop.
import React from 'react'
import styles from './Viewer.scss'
import classNames from 'classnames/bind'
import { ChasingDots } from 'better-react-spinkit'
const cx = classNames.bind(styles)
const Viewer = ({ mediaType, url, loading }) => {
if (loading) {
return (
<div className={cx('viewer')}>
<ChasingDots color="white" size={60} />
</div>
)
}
return (
<div className={cx('viewer')}>
{(
mediaType === 'image' ? (
<img onClick={() => window.open(url)} src={url} alt="space" />
) : (
<iframe title="space-video" src={url} frameBorder="0" gesture="media" allow="encrypted-media" allowFullScreen />
)
)}
</div>
)
}
export default Viewer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment