vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
62 lines (56 loc) • 1.41 kB
JavaScript
function get2xImage(_ref) {
var type = _ref.type,
images = _ref.images;
return images["".concat(type, "2x")];
}
function getDefaultImageSources(_ref2) {
var type = _ref2.type,
images = _ref2.images,
pathPrefix = _ref2.pathPrefix;
return {
src: "".concat(pathPrefix).concat(images[type]),
srcSet: "".concat(pathPrefix).concat(images[type], ", ").concat(pathPrefix).concat(get2xImage({
type: type,
images: images
}), " 2x")
};
}
function getThemeImageSources(_ref3) {
var type = _ref3.type,
images = _ref3.images;
return {
src: images[type],
srcSet: "".concat(images[type], ", ").concat(get2xImage({
type: type,
images: images
}), " 2x")
};
}
function isValidThemeLogoImages(_ref4) {
var type = _ref4.type,
theme = _ref4.theme;
return theme && theme.logoImages && theme.logoImages[type] && get2xImage({
type: type,
images: theme.logoImages
});
}
export function getImagesSrc(_ref5) {
var type = _ref5.type,
theme = _ref5.theme,
defaultImages = _ref5.defaultImages,
pathPrefix = _ref5.pathPrefix;
if (isValidThemeLogoImages({
type: type,
theme: theme
})) {
return getThemeImageSources({
type: type,
images: theme.logoImages
});
}
return getDefaultImageSources({
type: type,
images: defaultImages,
pathPrefix: pathPrefix
});
}