Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui / dist / components / molecules / SocialIconList / renderProps.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const tslib_1 = require("tslib");

const react_1 = tslib_1.__importDefault(require("react"));

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
  } = 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
  }), 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;
  const children = renderSocialIconOnly(item);
  return renderIconWrapper(Object.assign({}, item, {
    children
  }), 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