UNPKG

6.32 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 warnedOnce = false;
102/**
103 * ⚠️ The GridListTileBar component was renamed to ImageListItemBar to align with the current Material Design naming.
104 *
105 * You should use `import { ImageListItemBar } from '@material-ui/core'`
106 * or `import ImageListItemBar from '@material-ui/core/ImageListItemBar'`.
107 */
108
109var GridListTileBar = /*#__PURE__*/React.forwardRef(function GridListTileBar(props, ref) {
110 if (process.env.NODE_ENV !== 'production') {
111 if (!warnedOnce) {
112 warnedOnce = true;
113 console.error(['Material-UI: The GridListTileBar component was renamed to ImageListItemBar to align with the current Material Design naming.', '', "You should use `import { ImageListItemBar } from '@material-ui/core'`", "or `import ImageListItemBar from '@material-ui/core/ImageListItemBar'`."].join('\n'));
114 }
115 }
116
117 var actionIcon = props.actionIcon,
118 _props$actionPosition = props.actionPosition,
119 actionPosition = _props$actionPosition === void 0 ? 'right' : _props$actionPosition,
120 classes = props.classes,
121 className = props.className,
122 subtitle = props.subtitle,
123 title = props.title,
124 _props$titlePosition = props.titlePosition,
125 titlePosition = _props$titlePosition === void 0 ? 'bottom' : _props$titlePosition,
126 other = (0, _objectWithoutProperties2.default)(props, ["actionIcon", "actionPosition", "classes", "className", "subtitle", "title", "titlePosition"]);
127 var actionPos = actionIcon && actionPosition;
128 return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
129 className: (0, _clsx.default)(classes.root, className, titlePosition === 'top' ? classes.titlePositionTop : classes.titlePositionBottom, subtitle && classes.rootSubtitle),
130 ref: ref
131 }, other), /*#__PURE__*/React.createElement("div", {
132 className: (0, _clsx.default)(classes.titleWrap, {
133 'left': classes.titleWrapActionPosLeft,
134 'right': classes.titleWrapActionPosRight
135 }[actionPos])
136 }, /*#__PURE__*/React.createElement("div", {
137 className: classes.title
138 }, title), subtitle ? /*#__PURE__*/React.createElement("div", {
139 className: classes.subtitle
140 }, subtitle) : null), actionIcon ? /*#__PURE__*/React.createElement("div", {
141 className: (0, _clsx.default)(classes.actionIcon, actionPos === 'left' && classes.actionIconActionPosLeft)
142 }, actionIcon) : null);
143});
144process.env.NODE_ENV !== "production" ? GridListTileBar.propTypes = {
145 // ----------------------------- Warning --------------------------------
146 // | These PropTypes are generated from the TypeScript type definitions |
147 // | To update them edit the d.ts file and run "yarn proptypes" |
148 // ----------------------------------------------------------------------
149
150 /**
151 * An IconButton element to be used as secondary action target
152 * (primary action target is the tile itself).
153 */
154 actionIcon: _propTypes.default.node,
155
156 /**
157 * Position of secondary action IconButton.
158 */
159 actionPosition: _propTypes.default.oneOf(['left', 'right']),
160
161 /**
162 * Override or extend the styles applied to the component.
163 * See [CSS API](#css) below for more details.
164 */
165 classes: _propTypes.default.object,
166
167 /**
168 * @ignore
169 */
170 className: _propTypes.default.string,
171
172 /**
173 * String or element serving as subtitle (support text).
174 */
175 subtitle: _propTypes.default.node,
176
177 /**
178 * Title to be displayed on tile.
179 */
180 title: _propTypes.default.node,
181
182 /**
183 * Position of the title bar.
184 */
185 titlePosition: _propTypes.default.oneOf(['bottom', 'top'])
186} : void 0;
187
188var _default = (0, _withStyles.default)(styles, {
189 name: 'MuiGridListTileBar'
190})(GridListTileBar);
191
192exports.default = _default;
\No newline at end of file