npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codesmith-99/react-file-preview

v1.0.36

Published

The url previewer is built using native html elements for previewing url of files of the following type

Downloads

339

Readme

react-file-preview

The url previewer is built using native html elements for previewing url of files of the following type

  • csv files
  • text files
  • pdf files
  • html files
  • image files (supported by the browser)
  • audio files (supported by the browser)
  • video files (supported by the browser)
  • docx, xlsx, pptx files

Also, for unsupported files or when an error occurs, it falls back to using an icon.

Installation

npm i @codesmith-99/react-file-preview

Usage

Currently, the file supports only urls, in the future hopefully it can be extended to files also.

Basic Usage

import React, { useState } from 'react'
import FileViewer from '@codesmith-99/react-file-preview'

export default function Demo() {
  const [file, setFile] = useState<string>('')
  const [mimeType, setMimeType] = useState<string>()
  const [name, setName] = useState<string>('image.jpg')

  return (
    <>
      <div>
        <label>File url</label>
        <br />
        <input type='text' onChange={(e) => setFile(e.target.value)} />
      </div>
      <div>
        <label>File mimeType</label>
        <br />
        <input type='text' onChange={(e) => setMimeType(e.target.value)} value={mimeType} />
      </div>
      <div>
        <label>File name</label>
        <br />
        <input type='text' onChange={(e) => setName(e.target.value)} value={name} />
      </div>
      <div
        style={{
          height: '500px',
          width: '500px',
        }}
      >
        <FileViewer
          loader={undefined}
          mimeType={mimeType}
          src={file}
          onError={(e) => {
            console.log(e)
          }}
          fileName={name}
        />
      </div>
    </>
  )
}

FileViewer Props

| Prop name | Type | Description | |--------------|:---------------------------:|-----------:| | src | string | The url of the file to be previewed | | mimetype | string (optional) | Used to specify the mimetype of the file and determine how to preview the url, alternatively filename can be used | | filename | string (optional) | The file extension is used to specify the mimetype of the file and determine how to preview the url, alternatively mimetype can be used | | loader | ReactNode (optional) | A loader to replace the default loader used by the project | | onError | (e: any) => void (optional) | A callback that can be used to detect if an error has occurred in the loading of the files| | autoPlay | boolean | To autoplay a video or an audio | containerErrorStyle | React.CSSProperties | The style of the container when an error occurs