-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathIconGroup.js
47 lines (36 loc) · 1.17 KB
/
IconGroup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import cx from 'clsx'
import _ from 'lodash'
import PropTypes from 'prop-types'
import React from 'react'
import { childrenUtils, customPropTypes, getElementType, getUnhandledProps, SUI } from '../../lib'
/**
* Several icons can be used together as a group.
*/
const IconGroup = React.forwardRef(function (props, ref) {
const { children, className, content, size } = props
const classes = cx(size, 'icons', className)
const rest = getUnhandledProps(IconGroup, props)
const ElementType = getElementType(IconGroup, props)
return (
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
})
IconGroup.displayName = 'IconGroup'
IconGroup.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
/** Size of the icon group. */
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')),
}
IconGroup.defaultProps = {
as: 'i',
}
export default IconGroup