Repository URL to install this package:
|
Version:
4.0.61 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
const SocialIcon_1 = tslib_1.__importDefault(require("../../atoms/Icons/SocialIcon"));
const styled_1 = require("./styled");
function toWrapperProps(item, index) {
const {
label,
url
} = item;
const attributes = {
target: '_blank',
className: 'social-' + index,
title: label,
href: url
};
return attributes;
}
/**
* using to render social icon
* it uses SocialIcon from atoms with atom link wrapper
*/
function defaultRenderIconWrapper(item, index) {
// console.debug('[SocialIconList] defaultRenderIconWrapper')
// console.dir(item)
const {
color,
bgColor,
children,
dataQa,
props
} = item;
const {
onClick
} = props;
const handleClick = event => {
if (exotic_1.isFunction(onClick)) {
onClick(event, item);
}
};
const attributes = toWrapperProps(item, index); // @todo need to change the fillColor & bgColor out of the IconLink into a styled.withComponent(Icon)
return react_1.default.createElement(styled_1.IconListPanel, {
key: index
}, react_1.default.createElement(styled_1.IconLink, Object.assign({}, attributes, {
fillColor: color,
bgColor: bgColor,
"data-qa": dataQa,
onClick: handleClick
}), children));
}
exports.defaultRenderIconWrapper = defaultRenderIconWrapper;
function renderSocialIconOnly(item) {
return react_1.default.createElement(SocialIcon_1.default, {
type: item.label,
breed: item.breed
});
}
exports.renderSocialIconOnly = renderSocialIconOnly;
function defaultRenderIcon(item, index, props) {
// console.debug('[SocialIconList] defaultRenderIcon')
// console.dir({ item, props })
const {
renderIconWrapper
} = props,
remainingProps = tslib_1.__rest(props, ["renderIconWrapper"]);
const children = renderSocialIconOnly(item);
return renderIconWrapper(Object.assign({}, item, {
children,
props: remainingProps
}), index);
}
exports.defaultRenderIcon = defaultRenderIcon;
/**
* rendering all social icons list based on the fixtures shared
*/
function defaultRenderIconList(props) {
const {
iconsList,
renderIcon
} = props;
const icon = (item, index) => renderIcon(item, index, props);
const socialIconsView = iconsList.map(icon);
return socialIconsView;
}
exports.defaultRenderIconList = defaultRenderIconList;
/**
* combining all childrens in one wrapper as a children node
*/
function defaultRenderWrapper(props) {
const {
children,
className
} = props;
return react_1.default.createElement(styled_1.IconsListWrapper, {
className: className
}, children);
}
exports.defaultRenderWrapper = defaultRenderWrapper; //# sourceMappingURL=renderProps.js.map