From 9021a9624868508ad414d3829c62c884d8fb9ff3 Mon Sep 17 00:00:00 2001 From: Davis McPhee Date: Thu, 4 Jan 2024 17:40:45 -0400 Subject: [PATCH] [Discover] Improve numeric column text wrapping and some minor touchups --- .../components/data_table_column_header.tsx | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/kbn-unified-data-table/src/components/data_table_column_header.tsx b/packages/kbn-unified-data-table/src/components/data_table_column_header.tsx index df436cdf922a3..b5fb22ff12263 100644 --- a/packages/kbn-unified-data-table/src/components/data_table_column_header.tsx +++ b/packages/kbn-unified-data-table/src/components/data_table_column_header.tsx @@ -7,12 +7,13 @@ */ import React, { useMemo } from 'react'; -import { css } from '@emotion/react'; +import { css, CSSObject } from '@emotion/react'; import { EuiIcon, EuiTextBlockTruncate, EuiToolTip } from '@elastic/eui'; import type { DataView, DataViewField } from '@kbn/data-views-plugin/common'; import { FieldIcon, getFieldIconProps } from '@kbn/field-utils'; import { isNestedFieldParent } from '@kbn/discover-utils'; import { i18n } from '@kbn/i18n'; +import { euiThemeVars } from '@kbn/ui-theme'; import type { DataTableColumnTypes } from '../types'; interface DataTableColumnHeaderProps { @@ -58,15 +59,7 @@ const DataTableColumnToken: React.FC< ); return columnToken ? ( - - {columnToken} - + {columnToken} ) : null; }; @@ -76,6 +69,8 @@ const DataTableColumnTitle: React.FC{columnDisplayName}; }; +const fieldIconCss: CSSObject = { verticalAlign: 'bottom' }; + function getRenderedToken({ dataView, columnName, @@ -88,18 +83,18 @@ function getRenderedToken({ // for text-based searches if (columnTypes) { return columnTypes[columnName] && columnTypes[columnName] !== 'unknown' ? ( // renders an icon or nothing - + ) : null; } const dataViewField = dataView.getFieldByName(columnName); if (dataViewField) { - return ; + return ; } if (isNestedFieldParent(columnName, dataView)) { - return ; + return ; } return null; @@ -120,9 +115,9 @@ const ColumnHeaderTruncateContainer = ({ overflow: auto; white-space: normal; word-break: break-all; - line-height: 16px; + line-height: ${euiThemeVars.euiSize}; .euiDataGridHeaderCell--numeric & { - text-align: right; + float: right; } `} >