Skip to content

Commit

Permalink
[docs] Improve documentation of ListItemSecondaryAction interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 30, 2019
1 parent d6edc6d commit 42bbcdc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions packages/material-ui/src/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export const styles = theme => ({
selected: {},
});

/**
* Uses an additional container component if `ListItemSecondaryAction` is the
* last child.
*/
function ListItem(props) {
const {
alignItems,
Expand Down Expand Up @@ -179,7 +183,8 @@ ListItem.propTypes = {
*/
button: PropTypes.bool,
/**
* The content of the component.
* The content of the component. If a `ListItemSecondaryAction` is used it must
* be the last child.
*/
children: chainPropTypes(PropTypes.node, props => {
const children = React.Children.toArray(props.children);
Expand Down Expand Up @@ -223,12 +228,11 @@ ListItem.propTypes = {
*/
component: componentPropType,
/**
* The container component used when a `ListItemSecondaryAction` is rendered.
* The container component used when a `ListItemSecondaryAction` is the last child.
*/
ContainerComponent: componentPropType,
/**
* Properties applied to the container element when the component
* is used to display a `ListItemSecondaryAction`.
* Properties applied to the container component if used.
*/
ContainerProps: PropTypes.object,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const styles = {
},
};

/**
* Must be used as the last child of ListItem to function properly.
*/
function ListItemSecondaryAction(props) {
const { children, classes, className, ...other } = props;

Expand Down
2 changes: 1 addition & 1 deletion pages/api/list-item-secondary-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ filename: /packages/material-ui/src/ListItemSecondaryAction/ListItemSecondaryAct
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
```


Must be used as the last child of ListItem to function properly.

## Props

Expand Down
9 changes: 5 additions & 4 deletions pages/api/list-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ filename: /packages/material-ui/src/ListItem/ListItem.js
import ListItem from '@material-ui/core/ListItem';
```


Uses an additional container component if `ListItemSecondaryAction` is the
last child.

## Props

| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">alignItems</span> | <span class="prop-type">enum:&nbsp;'flex-start'&nbsp;&#124;<br>&nbsp;'center'<br></span> | <span class="prop-default">'center'</span> | Defines the `align-items` style property. |
| <span class="prop-name">button</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the list item will be a button (using `ButtonBase`). |
| <span class="prop-name">children</span> | <span class="prop-type">node</span> |   | The content of the component. |
| <span class="prop-name">children</span> | <span class="prop-type">node</span> |   | The content of the component. If a `ListItemSecondaryAction` is used it must be the last child. |
| <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-api) below for more details. |
| <span class="prop-name">component</span> | <span class="prop-type">Component</span> |   | The component used for the root node. Either a string to use a DOM element or a component. By default, it's a `li` when `button` is `false` and a `div` when `button` is `true`. |
| <span class="prop-name">ContainerComponent</span> | <span class="prop-type">Component</span> | <span class="prop-default">'li'</span> | The container component used when a `ListItemSecondaryAction` is rendered. |
| <span class="prop-name">ContainerProps</span> | <span class="prop-type">object</span> |   | Properties applied to the container element when the component is used to display a `ListItemSecondaryAction`. |
| <span class="prop-name">ContainerComponent</span> | <span class="prop-type">Component</span> | <span class="prop-default">'li'</span> | The container component used when a `ListItemSecondaryAction` is the last child. |
| <span class="prop-name">ContainerProps</span> | <span class="prop-type">object</span> |   | Properties applied to the container component if used. |
| <span class="prop-name">dense</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, compact vertical padding designed for keyboard and mouse input will be used. |
| <span class="prop-name">disabled</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the list item will be disabled. |
| <span class="prop-name">disableGutters</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the left and right padding is removed. |
Expand Down

0 comments on commit 42bbcdc

Please sign in to comment.