UNPKG

react-octicon

Version:

A GitHub Octicons icon React component

71 lines (51 loc) 4.76 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _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; }; var _class, _temp; require('../css/Octicon.css'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var iconNames = process.env.NODE_ENV !== 'production' ? 'alert arrow-down arrow-left arrow-right arrow-small-down arrow-small-left arrow-small-right arrow-small-up arrow-up beaker bell bold book bookmark briefcase broadcast browser bug calendar check checklist chevron-down chevron-left chevron-right chevron-up circle-slash circuit-board clippy clock cloud-download cloud-upload code comment-discussion comment credit-card dash dashboard database desktop-download device-camera-video device-camera device-desktop device-mobile diff-added diff-ignored diff-modified diff-removed diff-renamed diff ellipses ellipsis eye file-binary file-code file-directory file-media file-pdf file-submodule file-symlink-directory file-symlink-file file-text file-zip file flame fold gear gift gist-secret gist git-branch git-commit git-compare git-merge git-pull-request globe grabber graph heart history home horizontal-rule hubot inbox info issue-closed issue-opened issue-reopened italic jersey key keyboard law light-bulb link-external link list-ordered list-unordered location lock logo-gist logo-github mail-read mail-reply mail mark-github markdown megaphone mention milestone mirror mortar-board mute no-newline octoface organization package paintcan pencil person pin plug plus-small plus primitive-dot primitive-square pulse question quote radio-tower reply repo-clone repo-force-push repo-forked repo-pull repo-push repo rocket rss ruby search server settings shield sign-in sign-out smiley squirrel star stop sync tag tasklist telescope terminal text-size three-bars thumbsdown thumbsup tools trashcan triangle-down triangle-left triangle-right triangle-up unfold unmute unverified verified versions watch x zap'.split(' ') : []; var Octicon = (_temp = _class = function (_React$Component) { _inherits(Octicon, _React$Component); function Octicon() { _classCallCheck(this, Octicon); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } Octicon.prototype.render = function render() { var _props = this.props, name = _props.name, className = _props.className, mega = _props.mega, spin = _props.spin, props = _objectWithoutProperties(_props, ['name', 'className', 'mega', 'spin']); var classNames = [mega ? 'mega-octicon' : 'octicon', 'octicon-' + name]; if (spin) { classNames.push('spin-octicon'); } if (className) { classNames.push(className); } return _react2.default.createElement('span', _extends({}, props, { className: classNames.join(' ') })); }; return Octicon; }(_react2.default.Component), _class.defaultProps = { mega: false, spin: false }, _temp); exports.default = Octicon; Octicon.propTypes = process.env.NODE_ENV !== "production" ? { name: _propTypes2.default.oneOf(iconNames).isRequired, className: _propTypes2.default.string, mega: _propTypes2.default.bool, spin: _propTypes2.default.bool } : {}; module.exports = exports['default'];