UNPKG

5.59 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var styles = function styles(theme) {
25 return {
26 /* Styles applied to the root element. */
27 root: {
28 position: 'absolute',
29 left: 0,
30 right: 0,
31 height: 48,
32 background: 'rgba(0, 0, 0, 0.5)',
33 display: 'flex',
34 alignItems: 'center',
35 fontFamily: theme.typography.fontFamily
36 },
37
38 /* Styles applied to the root element if `titlePosition="bottom"`. */
39 titlePositionBottom: {
40 bottom: 0
41 },
42
43 /* Styles applied to the root element if `titlePosition="top"`. */
44 titlePositionTop: {
45 top: 0
46 },
47
48 /* Styles applied to the root element if a `subtitle` is provided. */
49 rootSubtitle: {
50 height: 68
51 },
52
53 /* Styles applied to the title and subtitle container element. */
54 titleWrap: {
55 flexGrow: 1,
56 marginLeft: 16,
57 marginRight: 16,
58 color: theme.palette.common.white,
59 overflow: 'hidden'
60 },
61
62 /* Styles applied to the container element if `actionPosition="left"`. */
63 titleWrapActionPosLeft: {
64 marginLeft: 0
65 },
66
67 /* Styles applied to the container element if `actionPosition="right"`. */
68 titleWrapActionPosRight: {
69 marginRight: 0
70 },
71
72 /* Styles applied to the title container element. */
73 title: {
74 fontSize: theme.typography.pxToRem(16),
75 lineHeight: '24px',
76 textOverflow: 'ellipsis',
77 overflow: 'hidden',
78 whiteSpace: 'nowrap'
79 },
80
81 /* Styles applied to the subtitle container element. */
82 subtitle: {
83 fontSize: theme.typography.pxToRem(12),
84 lineHeight: 1,
85 textOverflow: 'ellipsis',
86 overflow: 'hidden',
87 whiteSpace: 'nowrap'
88 },
89
90 /* Styles applied to the actionIcon if supplied. */
91 actionIcon: {},
92
93 /* Styles applied to the actionIcon if `actionPosition="left"`. */
94 actionIconActionPosLeft: {
95 order: -1
96 }
97 };
98};
99
100exports.styles = styles;
101var GridListTileBar = /*#__PURE__*/React.forwardRef(function GridListTileBar(props, ref) {
102 var actionIcon = props.actionIcon,
103 _props$actionPosition = props.actionPosition,
104 actionPosition = _props$actionPosition === void 0 ? 'right' : _props$actionPosition,
105 classes = props.classes,
106 className = props.className,
107 subtitle = props.subtitle,
108 title = props.title,
109 _props$titlePosition = props.titlePosition,
110 titlePosition = _props$titlePosition === void 0 ? 'bottom' : _props$titlePosition,
111 other = (0, _objectWithoutProperties2.default)(props, ["actionIcon", "actionPosition", "classes", "className", "subtitle", "title", "titlePosition"]);
112 var actionPos = actionIcon && actionPosition;
113 return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
114 className: (0, _clsx.default)(classes.root, className, titlePosition === 'top' ? classes.titlePositionTop : classes.titlePositionBottom, subtitle && classes.rootSubtitle),
115 ref: ref
116 }, other), /*#__PURE__*/React.createElement("div", {
117 className: (0, _clsx.default)(classes.titleWrap, {
118 'left': classes.titleWrapActionPosLeft,
119 'right': classes.titleWrapActionPosRight
120 }[actionPos])
121 }, /*#__PURE__*/React.createElement("div", {
122 className: classes.title
123 }, title), subtitle ? /*#__PURE__*/React.createElement("div", {
124 className: classes.subtitle
125 }, subtitle) : null), actionIcon ? /*#__PURE__*/React.createElement("div", {
126 className: (0, _clsx.default)(classes.actionIcon, actionPos === 'left' && classes.actionIconActionPosLeft)
127 }, actionIcon) : null);
128});
129process.env.NODE_ENV !== "production" ? GridListTileBar.propTypes = {
130 // ----------------------------- Warning --------------------------------
131 // | These PropTypes are generated from the TypeScript type definitions |
132 // | To update them edit the d.ts file and run "yarn proptypes" |
133 // ----------------------------------------------------------------------
134
135 /**
136 * An IconButton element to be used as secondary action target
137 * (primary action target is the tile itself).
138 */
139 actionIcon: _propTypes.default.node,
140
141 /**
142 * Position of secondary action IconButton.
143 */
144 actionPosition: _propTypes.default.oneOf(['left', 'right']),
145
146 /**
147 * Override or extend the styles applied to the component.
148 * See [CSS API](#css) below for more details.
149 */
150 classes: _propTypes.default.object,
151
152 /**
153 * @ignore
154 */
155 className: _propTypes.default.string,
156
157 /**
158 * String or element serving as subtitle (support text).
159 */
160 subtitle: _propTypes.default.node,
161
162 /**
163 * Title to be displayed on tile.
164 */
165 title: _propTypes.default.node,
166
167 /**
168 * Position of the title bar.
169 */
170 titlePosition: _propTypes.default.oneOf(['bottom', 'top'])
171} : void 0;
172
173var _default = (0, _withStyles.default)(styles, {
174 name: 'MuiGridListTileBar'
175})(GridListTileBar);
176
177exports.default = _default;
\No newline at end of file