-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathLabeledItem.js
92 lines (79 loc) · 2.16 KB
/
LabeledItem.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
89
90
91
92
/**
* Exports the {@link moonstone/LabeledItem.LabeledItem} component.
*
* @module moonstone/LabeledItem
*/
import kind from '@enact/core/kind';
import React from 'react';
import PropTypes from 'prop-types';
import Pure from '@enact/ui/internal/Pure';
import Spottable from '@enact/spotlight/Spottable';
import Icon from '../Icon';
import {ItemBase} from '../Item';
import Skinnable from '../Skinnable';
import {MarqueeController, MarqueeText} from '../Marquee';
const Controller = MarqueeController({marqueeOnFocus: true}, Spottable(ItemBase));
import css from './LabeledItem.less';
/**
* {@link moonstone/LabeledItem.LabeledItemBase} is a focusable Moonstone-styled component
* that combines marquee-able text content with a synchronized marquee-able text label.
*
* @class LabeledItemBase
* @memberof moonstone/LabeledItem
* @ui
* @public
*/
const LabeledItemBase = kind({
name: 'LabeledItem',
propTypes: /** @lends moonstone/LabeledItem.LabeledItemBase.prototype */ {
/**
* The node to be displayed as the main content of the item.
*
* @type {Node}
* @required
* @public
*/
children: PropTypes.node.isRequired,
/**
* When `true`, applies a disabled style and the control becomes non-interactive.
*
* @type {Boolean}
* @public
*/
disabled: PropTypes.bool,
/**
* The label to be displayed along with the text.
*
* @type {Node}
* @public
*/
label: PropTypes.node,
/**
* Icon to be displayed next to the title text.
*
* @type {String}
* @public
*/
titleIcon: PropTypes.string
},
styles: {
css,
className: 'labeleditem'
},
render: ({children, disabled, label, titleIcon, ...rest}) => (
<Controller disabled={disabled} {...rest}>
<div className={css.text}>
<MarqueeText disabled={disabled} className={css.title}>{children}</MarqueeText>
{(titleIcon != null) ? <Icon small className={css.icon}>{titleIcon}</Icon> : null}
</div>
{(label != null) ? <MarqueeText disabled={disabled} className={css.label}>{label}</MarqueeText> : null}
</Controller>
)
});
const LabeledItem = Pure(
Skinnable(
LabeledItemBase
)
);
export default LabeledItem;
export {LabeledItem, LabeledItemBase};