3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00

Badge: Fix alignment and simplify markup and styles ()

This commit is contained in:
Torkel Ödegaard 2023-04-05 10:37:30 +02:00 committed by GitHub
parent 91a61f1e0d
commit f69304fd50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,6 @@ import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '../../themes/ThemeContext';
import { IconName } from '../../types';
import { Icon } from '../Icon/Icon';
import { HorizontalGroup } from '../Layout/Layout';
import { Tooltip } from '../Tooltip/Tooltip';
export type BadgeColor = 'blue' | 'red' | 'green' | 'orange' | 'purple';
@ -23,10 +22,8 @@ export const Badge = React.memo<BadgeProps>(({ icon, color, text, tooltip, class
const styles = useStyles2(useCallback((theme) => getStyles(theme, color), [color]));
const badge = (
<div className={cx(styles.wrapper, className)} {...otherProps}>
<HorizontalGroup align="center" spacing="xs">
{icon && <Icon name={icon} size="sm" />}
<span>{text}</span>
</HorizontalGroup>
{icon && <Icon name={icon} size="sm" />}
{text}
</div>
);
@ -59,7 +56,6 @@ const getStyles = (theme: GrafanaTheme2, color: BadgeColor) => {
return {
wrapper: css`
font-size: ${theme.typography.size.sm};
display: inline-flex;
padding: 1px 4px;
border-radius: ${theme.shape.radius.default};
@ -67,12 +63,10 @@ const getStyles = (theme: GrafanaTheme2, color: BadgeColor) => {
border: 1px solid ${borderColor};
color: ${textColor};
font-weight: ${theme.typography.fontWeightRegular};
> span {
position: relative;
top: 1px;
margin-left: 2px;
}
gap: 2px;
font-size: ${theme.typography.bodySmall.fontSize};
line-height: ${theme.typography.bodySmall.lineHeight};
align-items: center;
`,
};
};