Repository: andreypopp/react-fa
Branch: master
Commit: de175f971fa2
Files: 20
Total size: 19.1 KB
Directory structure:
gitextract_2ke5qawr/
├── .babelrc
├── .eslintignore
├── .eslintrc
├── .flowconfig
├── .gitignore
├── .npmignore
├── .prettierrc
├── Makefile
├── README.md
├── example/
│ ├── Makefile
│ ├── index.html
│ ├── index.js
│ └── webpack.config.js
├── package.json
└── src/
├── Icon.js
├── IconStack.js
├── README.md
├── __tests__/
│ ├── Icon-test.js
│ └── IconStack-test.js
└── index.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": [
[
"env",
{
"targets": {
"browsers": [
"> 2%"
]
}
}
],
"stage-1",
"react"
]
}
================================================
FILE: .eslintignore
================================================
src/__tests__/**/*.js
================================================
FILE: .eslintrc
================================================
{
"env": {
"browser": true
},
"extends": "airbnb",
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"react/jsx-filename-extension": "off",
"react/jsx-props-no-spreading": "off",
"react/require-default-props": "warn",
"react/static-property-placement": "off",
"react/prefer-stateless-function": "off"
}
}
================================================
FILE: .flowconfig
================================================
[ignore]
[include]
[libs]
[lints]
[options]
================================================
FILE: .gitignore
================================================
node_modules
example/assets
lib/
================================================
FILE: .npmignore
================================================
src/
npm-debug.log
.babelrc
================================================
FILE: .prettierrc
================================================
{
"printWidth": 90,
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "all",
"jsxBracketSameLine": true
}
================================================
FILE: Makefile
================================================
.DELETE_ON_ERROR:
BABEL_OPTIONS = --stage 0
BIN = ./node_modules/.bin
TESTS = $(shell find src -path '*/__tests__/*-test.js')
SRC = $(filter-out $(TESTS), $(shell find src -name '*.js'))
LIB = $(SRC:src/%.js=lib/%.js) $(SRC:src/%.js=lib/%.js.flow)
NODE = $(BIN)/babel-node $(BABEL_OPTIONS)
build:
@$(MAKE) -j 8 $(LIB)
test::
@$(BIN)/jest
ci::
@$(BIN)/jest --watch
lint::
@$(BIN)/flow
version-major version-minor version-patch: lint test
@npm version $(@:version-%=%)
publish: build
@git push --tags origin HEAD:master
@npm publish
lib/%.js: src/%.js
@echo "Building $(@)"
@mkdir -p $(@D)
@$(BIN)/babel $(BABEL_OPTIONS) -o $@ $<
lib/%.js.flow: src/%.js
@echo "Building $(@)"
@mkdir -p $(@D)
@cp $(<) $(@)
example: build
@(cd example; $(BIN)/webpack --hide-modules)
watch-example: build
@(cd example; $(BIN)/webpack --watch --hide-modules)
publish-example: build
@(cd example;\
rm -rf .git;\
git init .;\
$(BIN)/webpack -p;\
git checkout -b gh-pages;\
git add .;\
git commit -m 'Update';\
git push -f git@github.com:andreypopp/react-fa.git gh-pages;\
)
clean:
@rm -rf lib
================================================
FILE: README.md
================================================
**DEPRECATED:** Use https://github.com/FortAwesome/react-fontawesome instead
# Font Awesome icons as React components
## Installation
React Font Awesome is distributed via [npm][]:
```bash
npm install react react-fa
```
You also need to install [webpack][] which is the only bundler at the moment
capable to bundle not only JavaScript code but also stylesheets and static
assets such as fonts and images:
```bash
npm install webpack
```
You also need a couple of loaders for webpack:
```bash
npm install babel-loader style-loader css-loader url-loader file-loader
npm install extract-text-webpack-plugin
```
## Usage
Just as simple as:
```javascript
import React from 'react'
import ReactDOM from 'react-dom'
import {Icon} from 'react-fa'
ReactDOM.renderComponent(
,
document.getElementById('main')
)
```
### Icon Component API
**Props in `[]` are optional**
|Prop |Type |Default |Description |
|-----------|:------:|:---------:|--------------------------------------------|
|name |`string`|`undefined`|Required: Name of the Font Awesome Icon |
|[className]|`string`|`undefined`|Set a CSS class for extra styles |
|[size] |`string`|`undefined`|Increase size: 'lg', '2x', '3x', '4x', '5x' |
|[rotate] |`string`|`undefined`|Rotate by deg: '45', '90', '135', '180', '225', '270', '315'|
|[flip] |`string`|`undefined`|Flips Icon: 'horizontal', 'vertical' |
|[fixedWidth]|`boolean`|`false`|Set Icon to a fixed width |
|[spin] |`boolean`| `false`|Rotate Icon|
|[pulse] |`boolean`|`false`|Rotate Icon in 8 steps|
|[stack] |`string` |`undefined`|Stack Icons: '1x', '2x'. [More Info][]
|[inverse] |`boolean`|`false`|Inverse the Icon color|
|[Component] |`string/func`|`span`|Alternate DOM element |
### IconStack Component API
|Prop |Type |Default |Description |
|-----------|:------:|:---------:|--------------------------------------------|
|[children] |`node`|`undefined`|Required: Child elements |
|[size] |`string`|`undefined`|Increase size: 'lg', '2x', '3x', '4x', '5x' |
|[className]|`string`|`undefined`|Set a CSS class for extra styles |
## Webpack Setup
Use the following webpack config (put it in `webpack.config.js`):
```javascript
var ExtractTextPlugin = require('extract-text-webpack-plugin')
module.exports = {
entry: './index.js',
output: {
path: 'assets',
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel'
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}
]
},
plugins: [
new ExtractTextPlugin('bundle.css')
]
}
```
which compile everything (js, stylesheets and icon fonts) into `assets/`
directory so you would need this basic HTML file to start your app:
```html
```
Note: If you run into issues with loading the FontAwesome font when *not* using `ExtractTextPlugin`, this might be fixed by making your `publicPath` absolute. See [this StackOverflow question](http://stackoverflow.com/questions/34133808/webpack-ots-parsing-error-loading-fonts/34133809#34133809) for details.
[webpack]: http://webpack.github.io/
[npm]: http://npmjs.org
[More Info]: http://fontawesome.io/examples/ 'Scroll to stacked icons'
================================================
FILE: example/Makefile
================================================
build:
../node_modules/.bin/webpack
================================================
FILE: example/index.html
================================================
================================================
FILE: example/index.js
================================================
/**
* @jsx React.DOM
*/
var React = require('react');
var ReactDOM = require('react-dom')
var ReactFA = require('../src/index');
var Icon = ReactFA.Icon;
var IconStack = ReactFA.IconStack;
var Demo = React.createClass({
render() {
return (