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

Add Tabs component #85

Merged
merged 5 commits into from
May 3, 2017
Merged

Add Tabs component #85

merged 5 commits into from
May 3, 2017

Conversation

kangax
Copy link
Contributor

@kangax kangax commented May 3, 2017

I made this pretty minimal for now — just a way to pass an array of strings and a single callback for all of them that's being passed an index of a selected tab.

Added support for the keyboard as well since it's not too complicated although not sure how important that is at the moment. It'd be nice to add ARIA roles as well but that'd probably be overkill right now.

selectedIndex: index
});
if (this.props.onClick) {
this.props.onClick(index);
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm wondering if we can somehow give a key to each tab, so that what's passed to the handler is like, 'my_tab' and 'another_tab' instead of 0 or 1. that would be less fragile if we were to add new tabs or reorder existing ones.

@yale
Copy link
Contributor

yale commented May 3, 2017

the style & component in general look good, however see my comment about using some sort of key in the onClick handler.

@yale yale closed this May 3, 2017
@yale yale reopened this May 3, 2017
@yale
Copy link
Contributor

yale commented May 3, 2017

whoops didn't mean to close, sorry!

constructor(props) {
super(props);

let selectedIndex = _.findIndex(props.items, item => item.selected);
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: maybe the lodash shorthand exists for this: _.findIndex(props.items, 'selected')

@kangax kangax merged commit 2d4f5ad into master May 3, 2017
@kangax kangax mentioned this pull request May 4, 2017
@kangax kangax deleted the feature/tabs branch November 26, 2018 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants