UNPKG

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