Skip to content

Commit a633f75

Browse files
committed
fixed tab navigation component
1 parent bdb4fa1 commit a633f75

File tree

4 files changed

+1377
-605
lines changed

4 files changed

+1377
-605
lines changed

es/TabNavigation/index.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", {
66

77
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
88

9-
var _style = require('styled-jsx/style');
10-
11-
var _style2 = _interopRequireDefault(_style);
12-
139
var _react = require('react');
1410

1511
var _react2 = _interopRequireDefault(_react);
@@ -38,11 +34,11 @@ var TabNavigation = function (_React$Component) {
3834

3935
var _this = _possibleConstructorReturn(this, (TabNavigation.__proto__ || Object.getPrototypeOf(TabNavigation)).call(this, props));
4036

41-
var tabs = _this.props.children.map(function (el) {
37+
var tabs = _this.props && _this.props.children instanceof Array && _this.props.children.map(function (el) {
4238
return el.props.tab;
4339
});
4440
_this.state = {
45-
currentTab: tabs[0].name,
41+
currentTab: tabs && tabs[0] && tabs[0].name,
4642
tabs: tabs || []
4743
};
4844
return _this;
@@ -64,14 +60,10 @@ var TabNavigation = function (_React$Component) {
6460

6561
return _react2.default.createElement(
6662
'div',
67-
{
68-
className: 'jsx-3106214966'
69-
},
63+
null,
7064
_react2.default.createElement(
7165
'div',
72-
{
73-
className: 'jsx-3106214966' + ' ' + 'flex flex-row justify-center'
74-
},
66+
{ className: 'flex flex-row justify-center' },
7567
tabs.map(function (tab) {
7668
return _react2.default.createElement(_NavButton2.default, {
7769
onClick: _this2.buttonClickHandler.bind(_this2, tab.name),
@@ -84,10 +76,6 @@ var TabNavigation = function (_React$Component) {
8476
),
8577
(0, _arrayPrototype2.default)(this.props.children, function (el) {
8678
return el.props.tab.name === currentTab;
87-
}),
88-
_react2.default.createElement(_style2.default, {
89-
styleId: '3106214966',
90-
css: ''
9179
})
9280
);
9381
}

lib/TabNavigation/index.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", {
66

77
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
88

9-
var _style = require('styled-jsx/style');
10-
11-
var _style2 = _interopRequireDefault(_style);
12-
139
var _react = require('react');
1410

1511
var _react2 = _interopRequireDefault(_react);
@@ -38,11 +34,11 @@ var TabNavigation = function (_React$Component) {
3834

3935
var _this = _possibleConstructorReturn(this, (TabNavigation.__proto__ || Object.getPrototypeOf(TabNavigation)).call(this, props));
4036

41-
var tabs = _this.props.children.map(function (el) {
37+
var tabs = _this.props && _this.props.children instanceof Array && _this.props.children.map(function (el) {
4238
return el.props.tab;
4339
});
4440
_this.state = {
45-
currentTab: tabs[0].name,
41+
currentTab: tabs && tabs[0] && tabs[0].name,
4642
tabs: tabs || []
4743
};
4844
return _this;
@@ -64,14 +60,10 @@ var TabNavigation = function (_React$Component) {
6460

6561
return _react2.default.createElement(
6662
'div',
67-
{
68-
className: 'jsx-3106214966'
69-
},
63+
null,
7064
_react2.default.createElement(
7165
'div',
72-
{
73-
className: 'jsx-3106214966' + ' ' + 'flex flex-row justify-center'
74-
},
66+
{ className: 'flex flex-row justify-center' },
7567
tabs.map(function (tab) {
7668
return _react2.default.createElement(_NavButton2.default, {
7769
onClick: _this2.buttonClickHandler.bind(_this2, tab.name),
@@ -84,10 +76,6 @@ var TabNavigation = function (_React$Component) {
8476
),
8577
(0, _arrayPrototype2.default)(this.props.children, function (el) {
8678
return el.props.tab.name === currentTab;
87-
}),
88-
_react2.default.createElement(_style2.default, {
89-
styleId: '3106214966',
90-
css: ''
9179
})
9280
);
9381
}

0 commit comments

Comments
 (0)