-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Advertisement.js
85 lines (73 loc) · 1.91 KB
/
Advertisement.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
import cx from 'clsx'
import PropTypes from 'prop-types'
import * as React from 'react'
import {
childrenUtils,
customPropTypes,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'
/**
* An ad displays third-party promotional content.
*/
const Advertisement = React.forwardRef(function (props, ref) {
const { centered, children, className, content, test, unit } = props
const classes = cx(
'ui',
unit,
useKeyOnly(centered, 'centered'),
useKeyOnly(test, 'test'),
'ad',
className,
)
const rest = getUnhandledProps(Advertisement, props)
const ElementType = getComponentType(props)
return (
<ElementType {...rest} className={classes} data-text={test} ref={ref}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
})
Advertisement.displayName = 'Advertisement'
Advertisement.propTypes = {
/** An element type to render as (string or function). */
as: PropTypes.elementType,
/** Center the advertisement. */
centered: PropTypes.bool,
/** Primary content. */
children: PropTypes.node,
/** Additional classes. */
className: PropTypes.string,
/** Shorthand for primary content. */
content: customPropTypes.contentShorthand,
/** Text to be displayed on the advertisement. */
test: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]),
/** Varies the size of the advertisement. */
unit: PropTypes.oneOf([
'medium rectangle',
'large rectangle',
'vertical rectangle',
'small rectangle',
'mobile banner',
'banner',
'vertical banner',
'top banner',
'half banner',
'button',
'square button',
'small button',
'skyscraper',
'wide skyscraper',
'leaderboard',
'large leaderboard',
'mobile leaderboard',
'billboard',
'panorama',
'netboard',
'half page',
'square',
'small square',
]).isRequired,
}
export default Advertisement