-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Reveal.js
77 lines (63 loc) · 1.76 KB
/
Reveal.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
import cx from 'clsx'
import PropTypes from 'prop-types'
import * as React from 'react'
import {
childrenUtils,
customPropTypes,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'
import RevealContent from './RevealContent'
/**
* A reveal displays additional content in place of previous content when activated.
*/
const Reveal = React.forwardRef(function (props, ref) {
const { active, animated, children, className, content, disabled, instant } = props
const classes = cx(
'ui',
animated,
useKeyOnly(active, 'active'),
useKeyOnly(disabled, 'disabled'),
useKeyOnly(instant, 'instant'),
'reveal',
className,
)
const rest = getUnhandledProps(Reveal, props)
const ElementType = getComponentType(props)
return (
<ElementType {...rest} className={classes} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
})
Reveal.displayName = 'Reveal'
Reveal.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** An active reveal displays its hidden content. */
active: PropTypes.bool,
/** An animation name that will be applied to Reveal. */
animated: PropTypes.oneOf([
'fade',
'small fade',
'move',
'move right',
'move up',
'move down',
'rotate',
'rotate left',
]),
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
/** A disabled reveal will not animate when hovered. */
disabled: PropTypes.bool,
/** An element can show its content without delay. */
instant: PropTypes.bool,
}
Reveal.Content = RevealContent
export default Reveal