forked from reactjs/react-tabs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push
lib
folder to resemble official npm package
- Loading branch information
Showing
8 changed files
with
651 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _reactDom = require('react-dom'); | ||
|
||
var _classnames = require('classnames'); | ||
|
||
var _classnames2 = _interopRequireDefault(_classnames); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function syncNodeAttributes(node, props) { | ||
if (props.selected) { | ||
node.setAttribute('tabindex', 0); | ||
node.setAttribute('selected', 'selected'); | ||
if (props.focus) { | ||
node.focus(); | ||
} | ||
} else { | ||
node.removeAttribute('tabindex'); | ||
node.removeAttribute('selected'); | ||
} | ||
} | ||
|
||
module.exports = _react2.default.createClass({ | ||
displayName: 'Tab', | ||
|
||
propTypes: { | ||
className: _react.PropTypes.string, | ||
id: _react.PropTypes.string, | ||
selected: _react.PropTypes.bool, | ||
disabled: _react.PropTypes.bool, | ||
panelId: _react.PropTypes.string, | ||
children: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.object, _react.PropTypes.string]) | ||
}, | ||
|
||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
focus: false, | ||
selected: false, | ||
id: null, | ||
panelId: null | ||
}; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
syncNodeAttributes((0, _reactDom.findDOMNode)(this), this.props); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
syncNodeAttributes((0, _reactDom.findDOMNode)(this), this.props); | ||
}, | ||
render: function render() { | ||
return _react2.default.createElement( | ||
'li', | ||
{ | ||
className: (0, _classnames2.default)('ReactTabs__Tab', this.props.className, { | ||
'ReactTabs__Tab--selected': this.props.selected, | ||
'ReactTabs__Tab--disabled': this.props.disabled | ||
}), | ||
role: 'tab', | ||
id: this.props.id, | ||
'aria-selected': this.props.selected ? 'true' : 'false', | ||
'aria-expanded': this.props.selected ? 'true' : 'false', | ||
'aria-disabled': this.props.disabled ? 'true' : 'false', | ||
'aria-controls': this.props.panelId | ||
}, | ||
this.props.children | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _classnames = require('classnames'); | ||
|
||
var _classnames2 = _interopRequireDefault(_classnames); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
module.exports = _react2.default.createClass({ | ||
displayName: 'TabList', | ||
|
||
propTypes: { | ||
className: _react.PropTypes.string, | ||
children: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.array]) | ||
}, | ||
|
||
render: function render() { | ||
return _react2.default.createElement( | ||
'ul', | ||
{ | ||
className: (0, _classnames2.default)('ReactTabs__TabList', this.props.className), | ||
role: 'tablist' | ||
}, | ||
this.props.children | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
var _react = require('react'); | ||
|
||
var _react2 = _interopRequireDefault(_react); | ||
|
||
var _classnames = require('classnames'); | ||
|
||
var _classnames2 = _interopRequireDefault(_classnames); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
module.exports = _react2.default.createClass({ | ||
displayName: 'TabPanel', | ||
|
||
propTypes: { | ||
className: _react.PropTypes.string, | ||
selected: _react.PropTypes.bool, | ||
id: _react.PropTypes.string, | ||
tabId: _react.PropTypes.string, | ||
children: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.object, _react.PropTypes.string]) | ||
}, | ||
|
||
contextTypes: { | ||
forceRenderTabPanel: _react.PropTypes.bool | ||
}, | ||
|
||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
selected: false, | ||
id: null, | ||
tabId: null | ||
}; | ||
}, | ||
render: function render() { | ||
var children = this.context.forceRenderTabPanel || this.props.selected ? this.props.children : null; | ||
|
||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
className: (0, _classnames2.default)('ReactTabs__TabPanel', this.props.className, { | ||
'ReactTabs__TabPanel--selected': this.props.selected | ||
}), | ||
role: 'tabpanel', | ||
id: this.props.id, | ||
'aria-labelledby': this.props.tabId, | ||
style: { display: this.props.selected ? null : 'none' } | ||
}, | ||
children | ||
); | ||
} | ||
}); |
Oops, something went wrong.