import styled from '@emotion/styled'; import {defined} from 'sentry/utils'; import { BigNumberWidgetVisualization, type BigNumberWidgetVisualizationProps, } from 'sentry/views/dashboards/widgets/bigNumberWidget/bigNumberWidgetVisualization'; import { WidgetFrame, type WidgetFrameProps, } from 'sentry/views/dashboards/widgets/common/widgetFrame'; import { DEFAULT_FIELD, MISSING_DATA_MESSAGE, NON_FINITE_NUMBER_MESSAGE, X_GUTTER, Y_GUTTER, } from '../common/settings'; import type {StateProps} from '../common/types'; import {DEEMPHASIS_COLOR_NAME, LOADING_PLACEHOLDER} from './settings'; interface Props extends StateProps, Omit, Partial {} export function BigNumberWidget(props: Props) { const {value, previousPeriodValue, field} = props; if (props.isLoading) { return ( {LOADING_PLACEHOLDER} ); } let parsingError: string | undefined = undefined; if (!defined(value)) { parsingError = MISSING_DATA_MESSAGE; } else if ( (typeof value === 'number' && !Number.isFinite(value)) || Number.isNaN(value) ) { parsingError = NON_FINITE_NUMBER_MESSAGE; } const error = props.error ?? parsingError; return ( {defined(value) && ( )} ); } const BigNumberResizeWrapper = styled('div')` position: relative; flex-grow: 1; `; const LoadingPlaceholder = styled('span')` color: ${p => p.theme[DEEMPHASIS_COLOR_NAME]}; padding: ${X_GUTTER} ${Y_GUTTER}; font-size: ${p => p.theme.fontSizeLarge}; `;