UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

64 lines (63 loc) 3.84 kB
/** * CodeAnalizerComment: Updated 5 imports on 2024-09-21 23:07:24 * Update:: import { createBannerStyleStr } to '@mikezimm/fps-core-v7/lib/common/commandStyles/defaults;' * Update:: import { IConfigurationProp } to '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/IPreConfig;' * Update:: import { doesObjectExistInArray } to '@mikezimm/fps-core-v7/lib/logic/Arrays/searching/objectfind;' * Update:: import { IMinBannerThemeProps } to '@mikezimm/fps-core-v7/lib/banner/interfaces/Theme/Interfaces;' * Update:: import { IPinMeState } to '@mikezimm/fps-core-v7/lib/banner/features/PinMe/Interfaces;' */ import { createBannerStyleStr } from "@mikezimm/fps-core-v7/lib/common/commandStyles/defaults"; import { doesObjectExistInArray } from "@mikezimm/fps-core-v7/lib/logic/Arrays/searching/objectfind"; /** * This will update bannerStyle and bannerCmdStyle in the following way * Typically the appPresetCollectionDefaults run before this so it's possible the defBannerTheme is already preset. * If for some reason the bannerStyle or bannerCmdStyle are not properly set in the Pre-ConfiguredProps, this will udpate them based on the bannerStyleChoice * * Then it will adjust bannerCmdStyle fontSize, margins and paddings down so that the PinMe buttons are larger. * NOTE This may have to be adjusted when PinMe is not activated. * * @param thisProps * @param serverRelativeUrl * @param bannerStyleChoice * @returns */ export function updateBannerThemeStyles(thisProps, bannerStyleChoice, forceUpdate, defPinState, forcedProps) { // DEFAULTS SECTION: Banner <<< ================================================================ //This updates unlocks styles only when bannerStyleChoice === custom. Rest are locked in the ui. if (bannerStyleChoice === 'custom') { thisProps.lockStyles = false; } else { thisProps.lockStyles = true; } const checkForcebannerStyle = doesObjectExistInArray(forcedProps, 'prop', 'bannerStyle', true); //Update bannerStyle if (checkForcebannerStyle === false && (forceUpdate === true || !thisProps.bannerStyle)) { // https://github.com/mikezimm/drilldown7/issues/189 if (thisProps.bannerStyleChoice !== 'custom' && thisProps.bannerStyleChoice !== 'lock') thisProps.bannerStyle = createBannerStyleStr(bannerStyleChoice, 'banner'); } const checkForcebannerCmdStyle = doesObjectExistInArray(forcedProps, 'prop', 'bannerCmdStyle', true); //Update bannerCmdStyle if (checkForcebannerCmdStyle === false && (forceUpdate === true || !thisProps.bannerCmdStyle)) { // https://github.com/mikezimm/drilldown7/issues/189 let bannerCmdStyle = thisProps.bannerStyleChoice === 'custom' || thisProps.bannerStyleChoice === 'lock' ? thisProps.bannerCmdStyle : createBannerStyleStr(bannerStyleChoice, 'cmd'); //Adjust the default size down compared to PinMe buttons which are primary functions in the web part if (defPinState && defPinState !== 'disabled') { // bannerCmdStyle.replace('"fontSize":20,', '"fontSize":16,') ; bannerCmdStyle = bannerCmdStyle.replace('"fontSize":20,', '"fontSize":16,'); bannerCmdStyle = bannerCmdStyle.replace('"marginRight":"9px"', '"marginRight":"0px"'); bannerCmdStyle = bannerCmdStyle.replace('"padding":"7px"', '"padding":"7px 4px"'); } thisProps.bannerCmdStyle = bannerCmdStyle; } return thisProps; } export function refreshBannerStylesOnPropChange(thisProps, propertyPath, newValue, refreshPane) { if (propertyPath === 'bannerStyle' || propertyPath === 'bannerCmdStyle') { thisProps[propertyPath] = newValue; refreshPane(); } } //# sourceMappingURL=bannerThemes.js.map