The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/alerting/unified/components/Label.tsx

62 lines
1.7 KiB

import { css } from '@emotion/css';
import React, { ReactNode } from 'react';
import { GrafanaTheme2, IconName } from '@grafana/data';
import { Stack } from '@grafana/experimental';
import { Icon, useStyles2 } from '@grafana/ui';
interface Props {
icon?: IconName;
label?: ReactNode;
value: ReactNode;
color?: string;
}
// TODO allow customization with color prop
const Label = ({ label, value, icon }: Props) => {
const styles = useStyles2(getStyles);
return (
<div className={styles.meta().wrapper}>
<Stack direction="row" gap={0} alignItems="stretch">
<div className={styles.meta().label}>
<Stack direction="row" gap={0.5} alignItems="center">
{icon && <Icon name={icon} />} {label ?? ''}
</Stack>
</div>
<div className={styles.meta().value}>{value}</div>
</Stack>
</div>
);
};
const getStyles = (theme: GrafanaTheme2) => ({
meta: (color?: string) => ({
wrapper: css`
font-size: ${theme.typography.bodySmall.fontSize};
`,
label: css`
display: flex;
align-items: center;
padding: ${theme.spacing(0.33)} ${theme.spacing(1)};
background: ${theme.colors.secondary.transparent};
border: solid 1px ${theme.colors.border.medium};
border-top-left-radius: ${theme.shape.borderRadius(2)};
border-bottom-left-radius: ${theme.shape.borderRadius(2)};
`,
value: css`
padding: ${theme.spacing(0.33)} ${theme.spacing(1)};
font-weight: ${theme.typography.fontWeightBold};
border: solid 1px ${theme.colors.border.medium};
border-left: none;
border-top-right-radius: ${theme.shape.borderRadius(2)};
border-bottom-right-radius: ${theme.shape.borderRadius(2)};
`,
}),
});
export { Label };