UNPKG

3.06 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6
7var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
9function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
10
11var _react = require('react');
12
13var _react2 = _interopRequireDefault(_react);
14
15/**
16 * A React component for the font-awesome icon library.
17 *
18 *
19 * @param {Boolean} [border=false] Whether or not to show a border radius
20 * @param {String} [className] An extra set of CSS classes to add to the component
21 * @param {Boolean} [fixedWidth=false] Make buttons fixed width
22 * @param {String} [flip=false] Flip the icon's orientation.
23 * @param {Boolean} [inverse=false]Inverse the icon's color
24 * @param {String} name Name of the icon to use
25 * @param {Boolean} [pulse=false] Rotate icon with 8 steps (rather than smoothly)
26 * @param {Number} [rotate] The degress to rotate the icon by
27 * @param {String} [size] The icon scaling size
28 * @param {Boolean} [spin=false] Spin the icon
29 * @param {String} [stack] Stack an icon on top of another
30 * @module FontAwesome
31 * @type {ReactClass}
32 */
33exports['default'] = _react2['default'].createClass({
34
35 displayName: 'FontAwesome',
36
37 propTypes: {
38 border: _react2['default'].PropTypes.bool,
39 className: _react2['default'].PropTypes.string,
40 fixedWidth: _react2['default'].PropTypes.bool,
41 flip: _react2['default'].PropTypes.oneOf(['horizontal', 'vertical']),
42 inverse: _react2['default'].PropTypes.bool,
43 name: _react2['default'].PropTypes.string.isRequired,
44 pulse: _react2['default'].PropTypes.bool,
45 rotate: _react2['default'].PropTypes.oneOf([90, 180, 270]),
46 size: _react2['default'].PropTypes.oneOf(['lg', '2x', '3x', '4x', '5x']),
47 spin: _react2['default'].PropTypes.bool,
48 stack: _react2['default'].PropTypes.oneOf(['1x', '2x'])
49 },
50
51 render: function render() {
52 var className = 'fa fa-' + this.props.name;
53
54 if (this.props.size) {
55 className += ' fa-' + this.props.size;
56 }
57
58 if (this.props.spin) {
59 className += ' fa-spin';
60 }
61
62 if (this.props.pulse) {
63 className += ' fa-pulse';
64 }
65
66 if (this.props.border) {
67 className += ' fa-border';
68 }
69
70 if (this.props.fixedWidth) {
71 className += ' fa-fw';
72 }
73
74 if (this.props.inverse) {
75 className += ' fa-inverse';
76 }
77
78 if (this.props.flip) {
79 className += ' fa-flip-' + this.props.flip;
80 }
81
82 if (this.props.rotate) {
83 className += ' fa-rotate-' + this.props.rotate;
84 }
85
86 if (this.props.stack) {
87 className += ' fa-stack-' + this.props.stack;
88 }
89
90 if (this.props.className) {
91 className += ' ' + this.props.className;
92 }
93
94 return _react2['default'].createElement('span', _extends({}, this.props, {
95 className: className
96 }));
97 }
98});
99module.exports = exports['default'];