GithubHelp home page GithubHelp logo

automattic / genericons-neue-react Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 1.0 126 KB

React Components for using icons from Genericons Neue

License: GNU General Public License v2.0

JavaScript 100.00%

genericons-neue-react's Introduction

Genericons Neue for React

A library to make it easy to use Genericons Neue within React. You only need to import the icons you use, so no extra overhead.

Usage

Here's an example on using within your React project.

  1. First install the package
$ npm install --save genericons-neue-react
  1. Using inside a Component
import React from 'react';
import CloudUpload from 'genericons-neue-react/icons/cloud-upload';

const MyUploadButton = () => {
    return (
        <button>
            <CloudUpload />
            <span> Upload a new image </span>
        </button>
    )
}

Example

You can also pass down any properties to the SVG, for example:

import React from 'react';
import CloudUpload from 'genericons-neue-react/icons/cloud-upload';

const MyUploadButton = () => {
    return (
        <button>
            <CloudUpload fill="tomato" />
            <span> Upload a new image </span>
        </button>
    )
}

Example with Fill

Building this Package

The following info is for creating this package, if you just want to use the icons in your project, see Usage above.

The source SVG files are from automattic/genericons-neue repository, which gets installed as a dev dependcy.

The convert.js script runs through the SVG files and creates React Components (jsx), using the filename as the component name. Component names are CamelCase so cloud-upload.svg becomes CloudUpload.

This build step can be run using: npm run build and creates the components in src directory.

Next we convert the JSX components in src directory to vanilla javascript using babel and store the results in icons directory.

genericons-neue-react's People

Contributors

beaucollins avatar mkaz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

isabella232

genericons-neue-react's Issues

Publish non-jsx files

This project contains .jsx so requires a babel transform step for any project that uses it. Commonly, tools like webpack are configured to ignore source files in node_modules.

Should we also provide vanilla js versions of the icons in this project?

For instance, usually the webpack loader for babel is configured like this:

{ test: /\.jsx?$/, exclude: /node_modules/, loaders: [ 'babel-loader' ] },

However, if this project is installed as a dependency, the source files will not be transformed from the jsx to a browser compatible version unless the exclude is modified:

{ test: /\.jsx?$/, exclude: /node_modules\/(?!genericons-neue-react)/, loaders: [ 'babel-loader' ] },

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.