Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tabs] Add a disabled property #6112

Merged
merged 3 commits into from
Feb 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/Tabs/Tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ Props
| className | string | | The CSS class name of the root element. |
| icon | node | | The icon element. If a string is passed, it will be used as a material icon font ligature. |
| label | node | | The label element. |
| disabled | bool | false | Disables the tab if set to true. |

Any other properties supplied will be spread to the root element.
35 changes: 35 additions & 0 deletions docs/site/src/demos/tabs/DisabledTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// @flow weak
/* eslint-disable react/no-multi-comp */

import React, { Component } from 'react';
import customPropTypes from 'material-ui/utils/customPropTypes';
import Paper from 'material-ui/Paper';
import Tabs from 'material-ui/Tabs';
import Tab from 'material-ui/Tabs/Tab';

export default class DisabledTabs extends Component {
static contextTypes = {
styleManager: customPropTypes.muiRequired,
};

state = {
index: 1,
};

handleChange = (event, index) => {
this.setState({ index });
};

render() {
return (
<Paper>
<Tabs index={this.state.index} onChange={this.handleChange}>
<Tab label="Disabled" disabled />
<Tab label="Active" />
<Tab label="Disabled" disabled />
<Tab label="Active" />
</Tabs>
</Paper>
);
}
}
6 changes: 6 additions & 0 deletions docs/site/src/demos/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ Tab labels may be either all icons or all text.

{{demo='demos/tabs/IconTabs.js'}}
{{demo='demos/tabs/IconLabelTabs.js'}}

## Disabled Tab
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need a new example section for that. We could add a disable variation in one of the previous examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure which example to modify. There are four here

  1. Basic Tabs
  2. Full width Tabs
  3. Centered
  4. Icon Tabs

Can you point out which should be modified?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that sounds good to me like this 👍


Tab may be disabled by setting `disabled` property.

{{demo='demos/tabs/DisabledTabs.js'}}
8 changes: 8 additions & 0 deletions src/Tabs/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export default class Tab extends Component {
* The CSS class name of the root element.
*/
className: PropTypes.string,
/**
* Disables the tab if set to true.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you follow this pattern for prop naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out

*/
disabled: PropTypes.bool,
/**
* @ignore
*/
Expand Down Expand Up @@ -105,6 +109,10 @@ export default class Tab extends Component {
]),
};

static defaultProps = {
disabled: false,
};

static contextTypes = {
styleManager: customPropTypes.muiRequired,
};
Expand Down