Repository URL to install this package:
|
Version:
4.0.75 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const utils_1 = require("@skava/utils");
const styled_1 = require("./styled");
/**
* Rendering a Image tag with inside the div tag
*/
function renderWrap(props) {
const {
width,
height,
nowrap,
className,
children,
alt
} = props;
/** https://bitbucket.org/skava-admin/documentation/wiki/Meta/QA
* Need to remove data-qa for the image tag
* Automation needs to change the script to make the above changes. It needs to point to the parent data-qa attribute to refer the image
*/
const passThroughProps = Object.freeze({
'data-qa': props['data-qa']
});
if (nowrap === true) {
return react_1.default.createElement(react_1.default.Fragment, null, children);
} else {
return react_1.default.createElement(styled_1.ImageWrapper, Object.assign({
className: className,
width: width,
height: height,
alt: alt
}, passThroughProps), children);
}
}
exports.renderWrap = renderWrap;
/**
* rendering the image tag
*/
function renderImageAsSemanticTag(props) {
// if there is no wrapper, we apply the classname to the element
return react_1.default.createElement(styled_1.ImageElement, {
className: props.nowrap && props.className,
src: props.src,
alt: props.alt,
doAutoAlign: props.doAutoAlign,
"data-qa": props['data-qa']
});
}
exports.renderImageAsSemanticTag = renderImageAsSemanticTag;
/**
* Rendering as a Background Image
*/
function renderImageAsBackground(props) {
// may need to pass in more, but those need to be defined
const {
src
} = props,
remainingProps = tslib_1.__rest(props, ["src"]);
return react_1.default.createElement(styled_1.ImageBackground, Object.assign({
src: src
}, remainingProps));
}
exports.renderImageAsBackground = renderImageAsBackground;
/**
* Main rendering method of the Image Component
*/
function renderImage(props) {
const remainingProps = utils_1.omit(props, 'isBackground');
if (props.isBackground === true) {
return renderImageAsBackground(remainingProps);
} else {
return renderImageAsSemanticTag(remainingProps);
}
}
exports.renderImage = renderImage; //# sourceMappingURL=renderProps.js.map