Chore: fixed text-alignment on hovering tableCells (#27311)

## FilterableTableCell

### added
- added `display: inline-flex` and `align-items: center` to
  `tableCellWrapper` class
- added `flex: 1` to `tableCell` class

### removed
- unused imports
- removed ternary if since it has no use anymore
- removed `tableCellWrapper` style definition from stylesFactory
This commit is contained in:
Michel Engelen 2020-09-08 18:20:44 +02:00 committed by GitHub
parent b2fe359a5e
commit 5b6e156934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 18 deletions

View File

@ -1,10 +1,9 @@
import React, { FC, useCallback, useState } from 'react'; import React, { FC, useCallback, useState } from 'react';
import { TableCellProps } from 'react-table'; import { TableCellProps } from 'react-table';
import { GrafanaTheme } from '@grafana/data'; import { GrafanaTheme } from '@grafana/data';
import { css, cx } from 'emotion'; import { css } from 'emotion';
import { stylesFactory, useTheme } from '../../themes'; import { stylesFactory, useTheme } from '../../themes';
import { TableStyles } from './styles';
import { FILTER_FOR_OPERATOR, FILTER_OUT_OPERATOR, TableFilterActionCallback } from './types'; import { FILTER_FOR_OPERATOR, FILTER_OUT_OPERATOR, TableFilterActionCallback } from './types';
import { Icon, Tooltip } from '..'; import { Icon, Tooltip } from '..';
import { Props, renderCell } from './TableCell'; import { Props, renderCell } from './TableCell';
@ -35,15 +34,10 @@ export const FilterableTableCell: FC<FilterableTableCellProps> = ({
[cell, field, onCellFilterAdded] [cell, field, onCellFilterAdded]
); );
const theme = useTheme(); const theme = useTheme();
const styles = getFilterableTableCellStyles(theme, tableStyles); const styles = getFilterableTableCellStyles(theme);
return ( return (
<div <div {...cellProps} className={tableStyles.tableCellWrapper} onMouseOver={onMouseOver} onMouseLeave={onMouseLeave}>
{...cellProps}
className={showFilters ? styles.tableCellWrapper : tableStyles.tableCellWrapper}
onMouseOver={onMouseOver}
onMouseLeave={onMouseLeave}
>
{renderCell(cell, field, tableStyles)} {renderCell(cell, field, tableStyles)}
{showFilters && cell.value && ( {showFilters && cell.value && (
<div className={styles.filterWrapper}> <div className={styles.filterWrapper}>
@ -63,15 +57,7 @@ export const FilterableTableCell: FC<FilterableTableCellProps> = ({
); );
}; };
const getFilterableTableCellStyles = stylesFactory((theme: GrafanaTheme, tableStyles: TableStyles) => ({ const getFilterableTableCellStyles = stylesFactory((theme: GrafanaTheme) => ({
tableCellWrapper: cx(
tableStyles.tableCellWrapper,
css`
display: inline-flex;
justify-content: space-between;
align-items: center;
`
),
filterWrapper: css` filterWrapper: css`
label: filterWrapper; label: filterWrapper;
display: inline-flex; display: inline-flex;

View File

@ -89,6 +89,8 @@ export const getTableStyles = stylesFactory(
`, `,
tableCellWrapper: css` tableCellWrapper: css`
border-right: 1px solid ${borderColor}; border-right: 1px solid ${borderColor};
display: inline-flex;
align-items: center;
height: 100%; height: 100%;
&:last-child { &:last-child {
@ -107,6 +109,7 @@ export const getTableStyles = stylesFactory(
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
flex: 1;
`, `,
overflow: css` overflow: css`
overflow: hidden; overflow: hidden;