import { css, cx } from '@emotion/css'; import React from 'react'; import Skeleton from 'react-loading-skeleton'; import { GrafanaTheme2 } from '@grafana/data'; import { Card, Stack, useStyles2, Tooltip, Icon } from '@grafana/ui'; interface StatItem { name: string; value: string | number | undefined; tooltip?: string; highlight?: boolean; indent?: boolean; } export interface Props { content: StatItem[]; isLoading?: boolean; footer?: JSX.Element | boolean; } export const ServerStatsCard = ({ content, footer, isLoading }: Props) => { const styles = useStyles2(getStyles); return ( {content.map((item, index) => ( {item.name} {item.tooltip && ( )} {isLoading ? ( ) : ( {item.value} )} ))} {footer &&
{footer}
}
); }; const getStyles = (theme: GrafanaTheme2) => { return { container: css({ display: 'flex', flexDirection: 'column', gap: theme.spacing(2), padding: theme.spacing(2), }), indent: css({ marginLeft: theme.spacing(2), }), tooltip: css({ color: theme.colors.secondary.text, }), highlight: css({ color: theme.colors.warning.text, padding: `${theme.spacing(0.5)} ${theme.spacing(1)}`, marginRight: `-${theme.spacing(1)}`, }), }; };