Skip to content

Commit

Permalink
[BottomNavigation] Add component prop (#13960)
Browse files Browse the repository at this point in the history
* [BottomNavigation] add component prop

* sort default props
  • Loading branch information
lychyi authored and oliviertassinari committed Dec 20, 2018
1 parent 91a95d3 commit 458feaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface BottomNavigationProps
'onChange'
> {
children: React.ReactNode;
component?: React.ReactType<BottomNavigationProps>;
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
showLabels?: boolean;
value?: any;
Expand Down
12 changes: 10 additions & 2 deletions packages/material-ui/src/BottomNavigation/BottomNavigation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { componentPropType } from '@material-ui/utils';
import warning from 'warning';
import withStyles from '../styles/withStyles';

Expand All @@ -19,6 +20,7 @@ function BottomNavigation(props) {
children: childrenProp,
classes,
className: classNameProp,
component: Component,
onChange,
showLabels,
value,
Expand Down Expand Up @@ -50,9 +52,9 @@ function BottomNavigation(props) {
});

return (
<div className={className} {...other}>
<Component className={className} {...other}>
{children}
</div>
</Component>
);
}

Expand All @@ -70,6 +72,11 @@ BottomNavigation.propTypes = {
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: componentPropType,
/**
* Callback fired when the value changes.
*
Expand All @@ -89,6 +96,7 @@ BottomNavigation.propTypes = {
};

BottomNavigation.defaultProps = {
component: 'div',
showLabels: false,
};

Expand Down
1 change: 1 addition & 0 deletions pages/api/bottom-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import BottomNavigation from '@material-ui/core/BottomNavigation';
|:-----|:-----|:--------|:------------|
| <span class="prop-name required">children *</span> | <span class="prop-type">node</span> |   | The content of the component. |
| <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">componentPropType</span> | <span class="prop-default">'div'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
| <span class="prop-name">onChange</span> | <span class="prop-type">func</span> |   | Callback fired when the value changes.<br><br>**Signature:**<br>`function(event: object, value: any) => void`<br>*event:* The event source of the callback<br>*value:* We default to the index of the child |
| <span class="prop-name">showLabels</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, all `BottomNavigationAction`s will show their labels. By default, only the selected `BottomNavigationAction` will show its label. |
| <span class="prop-name">value</span> | <span class="prop-type">any</span> |   | The value of the currently selected `BottomNavigationAction`. |
Expand Down

0 comments on commit 458feaa

Please sign in to comment.