UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

37 lines (35 loc) 1.94 kB
/** * CodeAnalizerComment: Updated 1 imports on 2024-09-22 14:49:52 * Update:: import { ICallbackAddParamToUrl } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' */ /** * CodeAnalizerComment: Updated 1 imports on 2024-09-21 23:07:24 * Update:: import { ICallbackAddParamToUrl } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' */ import * as React from 'react'; import { Icon, } from '@fluentui/react/lib/Icon'; const LinkStyles = { padding: '3px 0px', margin: '5px 8px', color: 'darkblue', cursor: 'pointer', whiteSpace: 'nowrap' }; /** * createParamLink will create a paramter link like: setLayout=Layout2 * that will be clickable to call function on class level to update Url and re-render the web part * This will let you both update the page url with the parameter, open the current page with new paramter in a new tab and also rerender the web part * @param param * @param onClick * @param newTab * @returns */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export function createParamLink(param, onClick, newTab = false) { const iconName = window.location.search.toLowerCase().indexOf(param.toLowerCase()) > -1 ? 'CheckboxComposite' : 'Checkbox'; const iconColor = iconName === 'Checkbox' ? 'darkgreen' : 'darkred'; const linky = React.createElement("a", { style: { ...LinkStyles, ...{ color: iconColor } }, onClick: () => { onClick(param, newTab === true ? false : true, newTab); } }, React.createElement(Icon, { style: { paddingRight: '5px' }, iconName: iconName }), "?", param); return linky; } export function paramLinks(showParams, addParamToUrl) { const paramLinks = React.createElement("div", null, showParams.map(param => { return createParamLink(param, addParamToUrl); })); return paramLinks; } //# sourceMappingURL=CallBackLinks.js.map