Repository URL to install this package:
|
Version:
1.2.6 ▾
|
"use strict";
var _jsxFileName = "chain-able/examples/packages/react/Mixin.js";
function Tab(thisArg) {
// onClick, class, icons, text, when
// state(props)
const tab = new Chain();
tab.self = instance => tab.set('self', instance).set('props', instance.props);
tab.self(thisArg);
tab.extend(['onClick', 'name', 'icon', 'text', 'when', 'link']);
tab.render = () => {
const _tab$entries = tab.entries(),
link = _tab$entries.link,
self = _tab$entries.self,
props = _tab$entries.props,
onClick = _tab$entries.onClick,
text = _tab$entries.text,
name = _tab$entries.name,
icon = _tab$entries.icon,
badge = _tab$entries.badge;
const className = name === props.activeTab ? 'active' : '';
const badgeClass = `badge ${name}-badge`;
const cb = () => onClick ? onClick() : props.setActiveTab(name);
const a = (to, ...child) => React.createElement(Link, {
to: to,
__source: {
fileName: _jsxFileName,
lineNumber: 15
},
__self: this
}, child);
const li = (...child) => React.createElement("li", {
className: className,
onClick: cb,
__source: {
fileName: _jsxFileName,
lineNumber: 16
},
__self: this
}, child);
const i = txt => React.createElement("i", {
className: "material-icons",
__source: {
fileName: _jsxFileName,
lineNumber: 17
},
__self: this
}, txt);
const t = txt => React.createElement("span", {
className: "text",
__source: {
fileName: _jsxFileName,
lineNumber: 18
},
__self: this
}, txt);
const badger = txt => React.createElement("span", {
className: badgeClass,
__source: {
fileName: _jsxFileName,
lineNumber: 19
},
__self: this
}, txt);
const badged = badge ? badger(badge) : null;
/* prettier-ignore */
return li(a(link, i(icon), t(text), badged));
};
return tab;
} // mixin React?
// class ReactChain extends React.Component {
// willMount(...args) {
// return super.componentWillMount(...args)
// }
// willUnmount(...args) {
// return super.componentWillUnmount(...args)
// }
// shouldUpdate(...args) {
// return super.componentShouldUpdate(...args)
// }
// didUpdate(...args) {
// return super.componentDidUpdate(...args)
// }
// }