@mikezimm/fps-library-v2
Version:
Library of reusable typescript/javascript functions, interfaces and constants
59 lines (58 loc) • 2.28 kB
JavaScript
/**
* CodeAnalizerComment: Updated 1 imports on 2024-09-22 14:49:52
* Update:: import { IFPSItem } to '@mikezimm/fps-core-v7/lib/components/molecules/AnyContent/IAnyContent;'
*/
import { getImgCover, getImgFit } from '../../../../common/Images/imgFit';
import { mergeDeep } from './mergeDeep';
import { EmptyFPSItemSearch } from '@mikezimm/fps-core-v7/lib/components/molecules/AnyContent/IFPSItemSearch';
/**
* This will take WP Props and create a shell FpsItem object which can be added to the item later on or passed in to some components
* @param wpProps
* @returns
*
*/
export function buildFpsTileWPProps(wpProps, hUnit = 'px', wUnit = 'px') {
const tileImgWidth = wpProps.tileLayout === 'small' || wpProps.tileLayout === 'med' ? Math.max(wpProps.tileImgWidth, 250) : wpProps.tileImgWidth;
const FpsItem = {
Image: {
src: ``,
css: {
height: `${wpProps.tileImgHeight}${hUnit}`,
width: `${tileImgWidth}${wUnit}`,
background: wpProps.tileImgBackground,
},
fabric: {
imgCover: getImgCover(wpProps.tileImgCover),
imgFit: getImgFit(wpProps.tileImgFit),
}
},
Link: {
href: ``,
},
Search: EmptyFPSItemSearch,
// 2024-09-08: Added File: undefined as any, to pass updated IFPSItem
File: undefined,
Icon: {
name: ``,
},
IsA: { allIsAKeys: [], allIsAKeysStr: '' }
};
return FpsItem;
}
/**
* mergeFPSItemProps will take the wpProps and create FPSItem.
* Then, if there is a previousFpsItem, it will merge those into the ones based on current props.
* This means that if you run this type of function twice, the second time will take precedence on the same object.
*
* @param wpProps
* @param previousFpsItem
* @returns
*/
export function mergeFPSItemProps(wpProps, previousFpsItem) {
const thisFPSItem = buildFpsTileWPProps(wpProps);
if (!previousFpsItem)
return thisFPSItem;
const mergedFPSItem = mergeDeep(thisFPSItem, previousFpsItem, ['Elements',]);
return mergedFPSItem;
}
//# sourceMappingURL=packageFPSTileProps.js.map