1.5.0 • Published 2 years ago

@whatsnextedu/content-viewer v1.5.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

content-viewer


Contents


About

A package that provides a React component to render standard files and media types for the users to view.


Installation

 npm install https://github.com/whatsnextedu/content-viewer
 # or
 yarn add https://github.com/whatsnextedu/content-viewer

Usage

import { FileRender } from "content-viewer";

const App = () => {
  return <FileRender fileType={fileType} source={source} onError={() => setError()} />;
}

export default App

Styling

Styled Component

import { FileRender } from "content-viewer";
import styled from "styled-components";

const StyledFileRender = styled(FileRender)`
  border: 1px solid red;
`;

const App = () => {
  return <StyledFileRender fileType={fileType} source={source} onError={() => setError()} />;
}

export default App

Current Renderer File Types

Document

ExtensionMIME Type
docapplication/msword
docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
pptapplication/vnd.ms-powerpoint
pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
xlsapplication/vnd.ms-excel
xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
pdfapplication/pdf
rtfapplication/rtf
csvtext/csv
tsvtext/tab-separated-values

Image

ExtensionMIME Type
gifimage/gif
pngimage/png
jpegimage/jpeg
jpgimage/jpg
svgimage/svg+xml
webpimage/webp

Video

ExtensionMIME Type
mp4video/mp4
webmvideo/webm
oggvideo/ogg
movvideo/quicktime

Audio

ExtensionMIME Type
mp3audio/mp3
wavaudio/wav
oggaudio/ogg
m4aaudio/m4a

Custom

ExtensionMIME Type
YouTubecustom/youtube

API

FileRender props

nametype
fileTypestring
sourcestring
onError() => void
size{ height: string, width: string }

License

Licensed under the MIT License.

See LICENSE for more information.