1.0.10 • Published 4 months ago

react-file-widget v1.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

react-file-widget is a highly customizable file viewing component that seamlessly integrates into your application. It supports multiple file formats, allowing you to configure which renderers to include, thereby optimizing your build size. Unused renderers are excluded from your bundle, saving space. Additionally, you can add custom renderers or override existing ones to suit your needs.

Features

  • Multiple File Formats: Supports a wide range of file formats including images, videos, PDFs, and more.
  • Customizable Renderers: Easily configure which renderers to include, optimizing your build size by excluding unused renderers.
  • Custom Renderers: Add or override existing renderers to fit your specific needs.
  • Theming: Supports both light and dark themes for better integration with your application.
  • Responsive Design: Adjust the width, height, and maximum height of the component to fit different screen sizes.
  • Header Customization: Option to hide the header or provide a custom header renderer function.
  • Video Controls: Extensive video properties including autoplay, loop, mute, and more.
  • Image Rendering: Choose between 'cover' and 'best-fit' modes for image rendering.
  • PDF Viewing: Advanced PDF viewing options including pagination, zoom, rotation, and custom page controls.
  • Twitch Integration: Embed Twitch streams with customizable parent domain.
  • Class Names and Styles: Apply custom class names and styles to different slots for better styling control.

Installation

// with npm
npm i  react-file-widget

// with yarn
yarn add react-file-widget

Demo && Documentation

Demo and Documentation

Usage

Properties Table

PropertyPossible ValuesDescription
fileRFW_FileAt least url or file or (data and fileType) is required.
├── urlstringThe URL of the file.
├── fileTypestringThe type of the file (e.g., image/png, application/pdf).
├── datastringThe data of the file, typically in base64 format.
├── languageRFW_LanguagesThe language of the file content, if applicable.
├── titlestringThe title of the file.
├── fileNamestringThe name of the file.
├── fileFileThe file object.
classNamesRFW_SlotsClassNamesCustom class names for different slots.
├── rootstringClass name for the root element.
├── headerstringClass name for the header element.
├── contentstringClass name for the content element.
├── videoContainerstringClass name for the video container element.
├── playButtonstringClass name for the play button element.
├── errorstringClass name for the error element.
├── loadingstringClass name for the loading element.
slotPropsRFW_SlotStylePropsCustom style properties for different slots.
├── rootCSSPropertiesStyle properties for the root element of the slot.
├── headerCSSPropertiesStyle properties for the header element of the slot.
├── contentCSSPropertiesStyle properties for the content element of the slot.
├── videoContainerCSSPropertiesStyle properties for the video container element.
├── playButtonCSSPropertiesStyle properties for the play button element.
├── errorCSSPropertiesStyle properties for the error element.
├── loadingCSSPropertiesStyle properties for the loading element.
renderersRFW_FileRenderer[]Custom renderers for the file.
widthstringWidth of the component.
heightstringHeight of the component.
maxHeightstringMaximum height of the component.
theme'light' | 'dark'Theme of the component.
hideHeaderBooleanWhether to hide the header. (default: false)
customHeader(document: RFW_File, config: ContextProps) => ReactNodeCustom header renderer function.
videoPropsProperties for video.
├── hideControlsBooleanWhether to hide video controls. (default: false)
├── mutedBooleanWhether the video should be muted. (default: false)
├── autoplayBooleanWhether the video should autoplay. (default: false)
├── noCookieBooleanWhether to use no-cookie mode.
├── disableKeyBoardBooleanWhether to disable keyboard controls. (default: false)
├── hideFullScreenBooleanWhether to hide the full-screen button. (default: false)
├── loopBooleanWhether the video should loop. (default: false)
├── disableInlineOnMobileBooleanWhether to disable inline playback on mobile devices. (default: false)
├── startnumberThe start time of the video in seconds.
├── disablePreLoadBooleanWhether to disable preloading of the video. (default: false)
├── posterstringThe URL of the poster image to be used as a thumbnail.
├── posterQuality'low' | 'medium' | 'high'The quality of the poster image when fetched from video sharing sites.
imagePropsProperties for image.
├── pictureMode'cover' | 'best-fit'The mode to use for rendering the image. (default: best-fit)
twitchPropsProperties for Twitch.
├── parentstringThe parent domain for the Twitch embed.
pdfPropsProperties for PDF.
├── currentPagenumberThe current page number. (default: 0)
├── zoomnumberThe zoom level.
├── paginatedBooleanWhether the PDF should be paginated. (default: false)
├── mode'single_page_view'The mode to use for rendering the PDF. (default: single_page_view)
├── rotationnumberThe rotation angle of the PDF.
├── onLoad(totalPages: number) => voidCallback function to be called when the PDF is loaded.
├── hidePageSelectorBooleanWhether to hide the page selector. (default: false)
├── pageSelectorPosition'left' | 'right' | 'bottom' | 'top'The position of the page selector. (default: left)
├── hidePageControlsBooleanWhether to hide the page controls. (default: false)
├── hideZoomControlsBooleanWhether to hide the zoom controls. (default: false)
├── hideRotateControlsBooleanWhether to hide the rotate controls. (default: false)