aligning badges

This commit is contained in:
James Gowdy 2023-01-26 16:29:59 +00:00
parent fbf2177e64
commit 5f8fecfe77
2 changed files with 19 additions and 12 deletions

View file

@ -20,6 +20,7 @@ import {
EuiTabbedContent,
EuiTabbedContentTab,
EuiTitle,
useEuiPaddingSize,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { FIELD_FORMAT_IDS } from '@kbn/field-formats-plugin/common';
@ -35,22 +36,28 @@ interface ExpandedRowProps {
item: ModelItemFull;
}
const badgeFormatter = (items: string[]) => {
if (items.length === 0) return;
return (
<div>
{items.map((item) => (
<EuiBadge key={item} color="hollow">
{item}
</EuiBadge>
))}
</div>
);
const useBadgeFormatter = () => {
const xs = useEuiPaddingSize('xs');
function badgeFormatter(items: string[]) {
if (items.length === 0) return;
return (
<div>
{items.map((item) => (
<span css={{ marginRight: xs! }} key={item}>
<EuiBadge color="hollow">{item}</EuiBadge>
</span>
))}
</div>
);
}
return { badgeFormatter };
};
export function useListItemsFormatter() {
const bytesFormatter = useFieldFormatter(FIELD_FORMAT_IDS.BYTES);
const dateFormatter = useFieldFormatter(FIELD_FORMAT_IDS.DATE);
const { badgeFormatter } = useBadgeFormatter();
const formatterDictionary: Record<string, (value: any) => JSX.Element | string | undefined> =
useMemo(

View file

@ -119,7 +119,7 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
<h5>
<FormattedMessage
id="xpack.ml.trainedModels.nodesList.expandedRow.allocatedModelsTitle"
defaultMessage="Allocated models"
defaultMessage="Allocated trained models"
/>
</h5>
</EuiTitle>