import { h, Component, VNode } from 'preact';
class WBTabs extends Component {
render({ tabs, onTabChanged }) {
return (
{ tabs.map((t, idx) => {
let name, isActive, isDisabled, onClick;
if (!t)
return null;
if (typeof(t) === 'object') {
name = t.name;
isActive = t.isActive;
isDisabled = t.isDisabled;
onClick = t.onClick;
} else if (typeof(t) === 'string') {
name = t;
}
let cls = ['nav-link'];
if (isActive)
cls.push('active');
if (isDisabled)
cls.push('disabled');
cls = cls.join(' ');
return (
-
{ e.preventDefault();
onClick ? onClick() : onTabChanged(t); } }>
{ name }
);
}) }
);
}
}
WBTabs.defaultProps = {
'onTabChanged': () => {}
};
export default WBTabs;