-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Divider.js
88 lines (72 loc) · 2 KB
/
Divider.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import cx from 'clsx'
import PropTypes from 'prop-types'
import * as React from 'react'
import {
childrenUtils,
customPropTypes,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'
/**
* A divider visually segments content into groups.
*/
const Divider = React.forwardRef(function (props, ref) {
const {
children,
className,
clearing,
content,
fitted,
hidden,
horizontal,
inverted,
section,
vertical,
} = props
const classes = cx(
'ui',
useKeyOnly(clearing, 'clearing'),
useKeyOnly(fitted, 'fitted'),
useKeyOnly(hidden, 'hidden'),
useKeyOnly(horizontal, 'horizontal'),
useKeyOnly(inverted, 'inverted'),
useKeyOnly(section, 'section'),
useKeyOnly(vertical, 'vertical'),
'divider',
className,
)
const rest = getUnhandledProps(Divider, props)
const ElementType = getComponentType(props)
return (
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
})
Divider.displayName = 'Divider'
Divider.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Divider can clear the content above it. */
clearing: PropTypes.bool,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
/** Divider can be fitted without any space above or below it. */
fitted: PropTypes.bool,
/** Divider can divide content without creating a dividing line. */
hidden: PropTypes.bool,
/** Divider can segment content horizontally. */
horizontal: PropTypes.bool,
/** Divider can have its colours inverted. */
inverted: PropTypes.bool,
/** Divider can provide greater margins to divide sections of content. */
section: PropTypes.bool,
/** Divider can segment content vertically. */
vertical: PropTypes.bool,
}
export default Divider