From 9313988f9be291228a18299fce44d77d2059c85a Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Fri, 20 Oct 2023 10:30:31 -0500 Subject: [PATCH] CE-604 Add HeaderIcon component; minor style updates for supporting tabs --- src/qqq/components/widgets/Widget.tsx | 83 +++++++++++++++++++++------ 1 file changed, 65 insertions(+), 18 deletions(-) diff --git a/src/qqq/components/widgets/Widget.tsx b/src/qqq/components/widgets/Widget.tsx index da59312..8266593 100644 --- a/src/qqq/components/widgets/Widget.tsx +++ b/src/qqq/components/widgets/Widget.tsx @@ -119,6 +119,49 @@ export class HeaderLink extends LabelComponent } +/******************************************************************************* + ** + *******************************************************************************/ +export class HeaderIcon extends LabelComponent +{ + iconName: string; + color: string; + coloredBG: boolean; + + iconColor: string; + bgColor: string; + + constructor(iconName: string, color: string, coloredBG: boolean = true) + { + super(); + this.iconName = iconName; + this.color = color; + this.coloredBG = coloredBG; + + this.iconColor = this.coloredBG ? "#FFFFFF" : this.color; + this.bgColor = this.coloredBG ? this.color : "none"; + } + + + render = (args: LabelComponentRenderArgs): JSX.Element => + { + return ( + {this.iconName} + ) + } +} + + /******************************************************************************* ** *******************************************************************************/ @@ -456,18 +499,35 @@ function Widget(props: React.PropsWithChildren): JSX.Element needLabelBox ||= isSet(props.widgetMetaData?.label); } + ////////////////////////////////////////////////////////////////////////////////////////// + // first look for a label in the widget data, which would override that in the metadata // + // note - previously this had a ?: and one was pl={2}, the other was pl={3}... // + ////////////////////////////////////////////////////////////////////////////////////////// + const labelToUse = props.widgetData?.label ?? props.widgetMetaData?.label + let labelElement = ( + + {labelToUse} + + ); + + if(props.widgetMetaData.tooltip) + { + labelElement = {labelElement} + } + const errorLoading = props.widgetData?.errorLoading !== undefined && props.widgetData?.errorLoading === true; const widgetContent = { needLabelBox && - - + + { hasPermission ? props.widgetMetaData?.icon && ( ): JSX.Element ) } { - ////////////////////////////////////////////////////////////////////////////////////////// - // first look for a label in the widget data, which would override that in the metadata // - ////////////////////////////////////////////////////////////////////////////////////////// - hasPermission && props.widgetData?.label ? ( - - {props.widgetData.label} - - ) : ( - hasPermission && props.widgetMetaData?.label && ( - - {props.widgetMetaData.label} - - ) - ) + hasPermission && labelToUse && (labelElement) } { hasPermission && ( @@ -579,7 +626,7 @@ function Widget(props: React.PropsWithChildren): JSX.Element ? {widgetContent} - : widgetContent; + : {widgetContent}; } export default Widget;