Skip to content

Commit

Permalink
deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Sep 15, 2020
1 parent 0d39555 commit d44589b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
6 changes: 3 additions & 3 deletions docs/pages/api-docs/image-list-item-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ The `MuiImageListItemBar` name can be used for providing [default props](/custom
| <span class="prop-name">actionIcon</span> | <span class="prop-type">node</span> | | An IconButton element to be used as secondary action target (primary action target is the item itself). |
| <span class="prop-name">actionPosition</span> | <span class="prop-type">'left'<br>&#124;&nbsp;'right'</span> | <span class="prop-default">'right'</span> | Position of secondary action IconButton. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">position</span> | <span class="prop-type">'bottom'<br>&#124;&nbsp;'top'</span> | <span class="prop-default">'bottom'</span> | Position of the title bar. |
| <span class="prop-name">subtitle</span> | <span class="prop-type">node</span> | | String or element serving as subtitle (support text). |
| <span class="prop-name">title</span> | <span class="prop-type">node</span> | | Title to be displayed on item. |
| <span class="prop-name">titlePosition</span> | <span class="prop-type">'bottom'<br>&#124;&nbsp;'top'</span> | <span class="prop-default">'bottom'</span> | Position of the title bar. |

The `ref` is forwarded to the root element.

Expand All @@ -44,8 +44,8 @@ Any other props supplied will be provided to the root element (native element).
| Rule name | Global class | Description |
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiImageListItemBar-root</span> | Styles applied to the root element.
| <span class="prop-name">titlePositionBottom</span> | <span class="prop-name">.MuiImageListItemBar-titlePositionBottom</span> | Styles applied to the root element if `titlePosition="bottom"`.
| <span class="prop-name">titlePositionTop</span> | <span class="prop-name">.MuiImageListItemBar-titlePositionTop</span> | Styles applied to the root element if `titlePosition="top"`.
| <span class="prop-name">positionBottom</span> | <span class="prop-name">.MuiImageListItemBar-positionBottom</span> | Styles applied to the root element if `position="bottom"`.
| <span class="prop-name">positionTop</span> | <span class="prop-name">.MuiImageListItemBar-positionTop</span> | Styles applied to the root element if `position="top"`.
| <span class="prop-name">rootSubtitle</span> | <span class="prop-name">.MuiImageListItemBar-rootSubtitle</span> | Styles applied to the root element if a `subtitle` is provided.
| <span class="prop-name">titleWrap</span> | <span class="prop-name">.MuiImageListItemBar-titleWrap</span> | Styles applied to the title and subtitle container element.
| <span class="prop-name">titleWrapActionPosLeft</span> | <span class="prop-name">.MuiImageListItemBar-titleWrapActionPosLeft</span> | Styles applied to the container element if `actionPosition="left"`.
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/api-docs/image-list-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ The `MuiImageListItem` name can be used for providing [default props](/customiza

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">children</span> | <span class="prop-type">node</span> | | While you can pass any node as children, the main use case is for an img. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">cols</span> | <span class="prop-type">number</span> | <span class="prop-default">1</span> | Width of the item in number of grid columns. |
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'li'</span> | The component used for the root node. Either a string to use a HTML element or a component. |
| <span class="prop-name">rows</span> | <span class="prop-type">number</span> | <span class="prop-default">1</span> | Height of the item in number of grid rows. |

The `ref` is forwarded to the root element.

Expand Down
4 changes: 4 additions & 0 deletions docs/pages/api-docs/image-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ The `MuiImageList` name can be used for providing [default props](/customization

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name required">children<abbr title="required">*</abbr></span> | <span class="prop-type">node</span> | | Items that will be in the image list. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">cols</span> | <span class="prop-type">number</span> | <span class="prop-default">2</span> | Number of columns. |
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'ul'</span> | The component used for the root node. Either a string to use a HTML element or a component. |
| <span class="prop-name">gap</span> | <span class="prop-type">number</span> | <span class="prop-default">4</span> | The gap between items in `px`. |
| <span class="prop-name">rowHeight</span> | <span class="prop-type">number<br>&#124;&nbsp;'auto'</span> | <span class="prop-default">180</span> | The height of one row in `px`. |

The `ref` is forwarded to the root element.

Expand Down
37 changes: 25 additions & 12 deletions packages/material-ui/src/ImageList/ImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { isFragment } from 'react-is';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import deprecatedPropType from '../utils/deprecatedPropType';

export const styles = {
/* Styles applied to the root element. */
Expand All @@ -18,17 +19,22 @@ export const styles = {

const ImageList = React.forwardRef(function ImageList(props, ref) {
const {
rowHeight = 180,
cellHeight,
children,
classes,
className,
cols = 2,
component: Component = 'ul',
gap = 4,
gap: gapProp = 4,
rowHeight: rowHeightProp = 180,
spacing,
style,
...other
} = props;

const gap = spacing || gapProp;
const rowHeight = cellHeight || rowHeightProp;

return (
<Component
className={clsx(classes.root, className)}
Expand Down Expand Up @@ -69,29 +75,28 @@ const ImageList = React.forwardRef(function ImageList(props, ref) {
});

ImageList.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* @ignore
*/
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
cellHeight: deprecatedPropType(
PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
'Use the `rowHeight` prop instead.',
),
/**
* @ignore
* Items that will be in the image list.
*/
children: PropTypes.node,
children: PropTypes.node.isRequired,
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
*/
classes: PropTypes.object,
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* @ignore
* Number of columns.
*/
cols: PropTypes.number,
/**
Expand All @@ -100,9 +105,17 @@ ImageList.propTypes = {
*/
component: PropTypes /* @typescript-to-proptypes-ignore */.elementType,
/**
* @ignore
* The gap between items in `px`.
*/
gap: PropTypes.number,
/**
* The height of one row in `px`.
*/
rowHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
/**
* @ignore
*/
spacing: deprecatedPropType(PropTypes.number, 'Use the `rowHeight` prop instead.'),
/**
* @ignore
*/
Expand Down
10 changes: 3 additions & 7 deletions packages/material-ui/src/ImageListItem/ImageListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,8 @@ const ImageListItem = React.forwardRef(function ImageListItem(props, ref) {
});

ImageListItem.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the d.ts file and run "yarn proptypes" |
// ----------------------------------------------------------------------
/**
* @ignore
* While you can pass any node as children, the main use case is for an img.
*/
children: PropTypes.node,
/**
Expand All @@ -137,7 +133,7 @@ ImageListItem.propTypes = {
*/
className: PropTypes.string,
/**
* @ignore
* Width of the item in number of grid columns.
*/
cols: PropTypes.number,
/**
Expand All @@ -146,7 +142,7 @@ ImageListItem.propTypes = {
*/
component: PropTypes /* @typescript-to-proptypes-ignore */.elementType,
/**
* @ignore
* Height of the item in number of grid rows.
*/
rows: PropTypes.number,
};
Expand Down
16 changes: 13 additions & 3 deletions packages/material-ui/src/ImageListItemBar/ImageListItemBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import deprecatedPropType from '../utils/deprecatedPropType';

export const styles = (theme) => ({
/* Styles applied to the root element. */
Expand Down Expand Up @@ -75,10 +76,12 @@ const ImageListItemBar = React.forwardRef(function ImageListItemBar(props, ref)
className,
subtitle,
title,
position = 'bottom',
position: positionProp = 'bottom',
titlePosition,
...other
} = props;

const position = titlePosition || positionProp;
const actionPos = actionIcon && actionPosition;

return (
Expand Down Expand Up @@ -140,6 +143,10 @@ ImageListItemBar.propTypes = {
* @ignore
*/
className: PropTypes.string,
/**
* Position of the title bar.
*/
position: PropTypes.oneOf(['bottom', 'top']),
/**
* String or element serving as subtitle (support text).
*/
Expand All @@ -149,9 +156,12 @@ ImageListItemBar.propTypes = {
*/
title: PropTypes.node,
/**
* Position of the title bar.
* @ignore
*/
position: PropTypes.oneOf(['bottom', 'top']),
titlePosition: deprecatedPropType(
PropTypes.oneOf(['bottom', 'top']),
'Use the `position` prop instead.',
),
};

export default withStyles(styles, { name: 'MuiImageListItemBar' })(ImageListItemBar);

0 comments on commit d44589b

Please sign in to comment.