Giter VIP home page Giter VIP logo

react-file-icon's People

Contributors

corygibbons avatar danielr18 avatar jaapbakker88 avatar jesselcampbell avatar kensnyder avatar lounsbrough avatar mahboubii avatar njuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-file-icon's Issues

Using Defaults

Hi this is a great project @corygibbons !

What do you think about adding a prop like usingDefaultStyles that would use the defaults styles based on the extension?

So instead of:

const extension = getFileExtension(file);
const iconStyles = (defaultStyles as any)[extension] || {}; // Typescript does not like the type of defaultStyles as the key is not string

return <FileIcon extension={suffix} {...iconStyles} />

You could do (which would internally do the same as above):

const extension = getFileExtension(file);

return <FileIcon extension={suffix} usingDefaultStyles={true} />

I assume this is the most common use-case, or?

Mime type support

Hi,

Thanks for a great library. There is a small suggestion: using mime types instead of current map, as they are standardized and much easier to utilize directly.

icon size

How can change the size of the icon ?
thank you

React 18 Support

Could you update the library to support react 18?

$ npm i react-file-icon
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"~18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.2.0" from [email protected]
npm ERR! node_modules/react-file-icon
npm ERR!   react-file-icon@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

`id` must be unique

Add type definitions

Hello,

The package is currently not usable with TypeScript. I added own type definitions, but since I am new to TS, rather than opening pull request I offer them here to be checked / corrected and added to right places.

declare module "react-file-icon" {
  import React from "react";

  export type IconType =
    | "3d"
    | "acrobat"
    | "audio"
    | "binary"
    | "code"
    | "code2"
    | "compressed"
    | "document"
    | "drive"
    | "font"
    | "image"
    | "presentation"
    | "settings"
    | "spreadsheet"
    | "vector"
    | "video";

  export interface FileIconProps {
    color?: string;
    extension: string;
    fold?: boolean;
    foldColor?: string;
    glyphColor?: string;
    gradientColor?: string;
    gradientOpacity?: number;
    labelColor?: string;
    labelTextColor?: string;
    labelTextStyle?: object;
    labelUppercase?: boolean;
    radius?: number;
    size?: number;
    type?: IconType;
  }

  export type DefaultExtensionType =
    | "3dm"
    | "3ds"
    | "3g2"
    | "3gp"
    | "7zip"
    | "aac"
    | "aep"
    | "ai"
    | "aif"
    | "aiff"
    | "asf"
    | "asp"
    | "aspx"
    | "avi"
    | "bin"
    | "bmp"
    | "c"
    | "cpp"
    | "cs"
    | "css"
    | "csv"
    | "cue"
    | "dll"
    | "dmg"
    | "doc"
    | "docx"
    | "dwg"
    | "dxf"
    | "eot"
    | "eps"
    | "exe"
    | "flac"
    | "flv"
    | "fnt"
    | "fodp"
    | "fods"
    | "fodt"
    | "fon"
    | "gif"
    | "gz"
    | "htm"
    | "html"
    | "indd"
    | "ini"
    | "java"
    | "jpeg"
    | "jpg"
    | "js"
    | "json"
    | "jsx"
    | "m4a"
    | "m4v"
    | "max"
    | "md"
    | "mid"
    | "mkv"
    | "mov"
    | "mp3"
    | "mp4"
    | "mpeg"
    | "mpg"
    | "obj"
    | "odp"
    | "ods"
    | "odt"
    | "ogg"
    | "ogv"
    | "otf"
    | "pdf"
    | "php"
    | "pkg"
    | "plist"
    | "png"
    | "ppt"
    | "pptx"
    | "pr"
    | "ps"
    | "psd"
    | "py"
    | "rar"
    | "rb"
    | "rm"
    | "rtf"
    | "scss"
    | "sitx"
    | "svg"
    | "swf"
    | "sys"
    | "tar"
    | "tex"
    | "tif"
    | "tiff"
    | "ts"
    | "ttf"
    | "txt"
    | "wav"
    | "webm"
    | "wmv"
    | "woff"
    | "wpd"
    | "wps"
    | "xlr"
    | "xls"
    | "xlsx"
    | "yml"
    | "zip"
    | "zipx";

  declare const FileIcon: React.FunctionComponent<FileIconProps>;
  export default FileIcon;

  export const defaultStyles: Record<
    DefaultExtensionType,
    Partial<FileIconProps>
  >;
}

Provide more thorough default styles for all file types

image

It's a little bit tedious to specify styles for different type icon. These styles are good enough. Is it possible to use this component like:

files.map(file => {
    return (
        <FileIcon
            size={48}
            extension="{file.extension}"
        />
    );
});

Then represents its default styles.

How to set FileIcon defaultStyle dynamically

sample says
<FileIcon extension="docx" {...defaultStyles.docx} />

But i wish to use this dynamically.

extension property is ok but how to set ...defaultStyle.? based on the extension ?

Ability to Combine multiple default style extension

Please is the possible to have a feature like this

<FileIcon 
    glyphColor={tinycolor(linkColor).lighten(40)}
    labelUppercase
    extension={kycData.idCardfiles?.[0]&& getFileExtension(kycData.idCardfiles?.[0].name)} 
    {...defaultStyles['png'|'jpg']} 
    />
    
 Or
 
 ```js
<FileIcon 
    glyphColor={tinycolor(linkColor).lighten(40)}
    labelUppercase
    extension={kycData.idCardfiles?.[0]&& getFileExtension(kycData.idCardfiles?.[0].name)} 
    {...defaultStyles['image/*']} 
    />

 Thanks
 

Bundle Size

Hi there! I noticed that when I pull this package into our project, the tinycolor2 dependency is a little large (14KB parsed from webpack):

image

It looks like the only reason this package is used is to darken a user-provided color in 3 places. Is there a lighter package that could accomplish this, or could we pull that logic into this code base? Would you be open to a PR if I were to put one up?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.