UNPKG

1.69 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9
10import { bsClass, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
11
12var propTypes = {
13 /**
14 * An icon name without "glyphicon-" prefix. See e.g. http://getbootstrap.com/components/#glyphicons
15 */
16 glyph: PropTypes.string.isRequired
17};
18
19var Glyphicon = function (_React$Component) {
20 _inherits(Glyphicon, _React$Component);
21
22 function Glyphicon() {
23 _classCallCheck(this, Glyphicon);
24
25 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
26 }
27
28 Glyphicon.prototype.render = function render() {
29 var _extends2;
30
31 var _props = this.props,
32 glyph = _props.glyph,
33 className = _props.className,
34 props = _objectWithoutProperties(_props, ['glyph', 'className']);
35
36 var _splitBsProps = splitBsProps(props),
37 bsProps = _splitBsProps[0],
38 elementProps = _splitBsProps[1];
39
40 var classes = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[prefix(bsProps, glyph)] = true, _extends2));
41
42 return React.createElement('span', _extends({}, elementProps, { className: classNames(className, classes) }));
43 };
44
45 return Glyphicon;
46}(React.Component);
47
48Glyphicon.propTypes = propTypes;
49
50export default bsClass('glyphicon', Glyphicon);
\No newline at end of file