From 5614b0fd41b6a8767ac8baf8fb6ad1f0237cc2a4 Mon Sep 17 00:00:00 2001 From: Greg Thompson Date: Fri, 15 Jan 2021 12:00:15 -0600 Subject: [PATCH] table colors via css-in-js --- src/components/table/_table.scss | 60 +++++++++---------- src/components/table/table.tsx | 8 ++- src/components/table/table_footer_cell.tsx | 8 ++- src/components/table/table_header_button.tsx | 16 ++++- src/components/table/table_header_cell.tsx | 23 ++++++++ src/components/table/table_row.tsx | 61 +++++++++++++++++++- src/components/table/table_row_cell.tsx | 7 +++ 7 files changed, 149 insertions(+), 34 deletions(-) diff --git a/src/components/table/_table.scss b/src/components/table/_table.scss index 0e7405fb66a..adbb99f9037 100644 --- a/src/components/table/_table.scss +++ b/src/components/table/_table.scss @@ -10,7 +10,7 @@ table-layout: fixed; border: none; border-collapse: collapse; - background-color: $euiColorEmptyShade; + // background-color: $euiColorEmptyShade; &.euiTable--auto { table-layout: auto; @@ -58,12 +58,12 @@ &:focus { .euiTableCellContent__text { text-decoration: underline; - color: $euiColorPrimary; + // color: $euiColorPrimary; } - .euiTableSortIcon { - fill: $euiColorPrimary; - } + // .euiTableSortIcon { + // fill: $euiColorPrimary; + // } } } @@ -71,9 +71,9 @@ margin-left: $euiSizeXS; flex-shrink: 0; // makes sure the icon doesn't change size because the text is long - .euiTableHeaderButton-isSorted & { - fill: $euiTitleColor; - } + // .euiTableHeaderButton-isSorted & { + // fill: $euiTitleColor; + // } } .euiTableHeaderCellCheckbox { @@ -82,38 +82,38 @@ } .euiTableRow { - &:hover { - background-color: $euiTableHoverColor; - } + // &:hover { + // background-color: $euiTableHoverColor; + // } &.euiTableRow-isExpandedRow { - .euiTableRowCell { - background-color: $euiTableHoverColor; - } + // .euiTableRowCell { + // background-color: $euiTableHoverColor; + // } &.euiTableRow-isSelectable .euiTableCellContent { padding-left: $euiTableCellCheckboxWidth + $euiTableCellContentPadding; } } - &.euiTableRow-isSelected { - background-color: $euiTableSelectedColor; + // &.euiTableRow-isSelected { + // background-color: $euiTableSelectedColor; - + .euiTableRow.euiTableRow-isExpandedRow .euiTableRowCell { - background-color: $euiTableSelectedColor; - } + // + .euiTableRow.euiTableRow-isExpandedRow .euiTableRowCell { + // background-color: $euiTableSelectedColor; + // } - &:hover, - &:hover + .euiTableRow.euiTableRow-isExpandedRow .euiTableRowCell { - background-color: $euiTableHoverSelectedColor; - } - } + // &:hover, + // &:hover + .euiTableRow.euiTableRow-isExpandedRow .euiTableRowCell { + // background-color: $euiTableHoverSelectedColor; + // } + // } } .euiTableRowCell { @include euiTableCell; - color: $euiTextColor; + // color: $euiTextColor; &.euiTableRowCell--isMobileHeader { display: none; // Hide if not mobile breakpoint @@ -126,7 +126,7 @@ // Must come after .euiTableRowCell selector for border to be removed .euiTableFooterCell { - background-color: $euiColorLightestShade; + // background-color: $euiColorLightestShade; border-bottom: none; } @@ -237,11 +237,11 @@ .euiTableRow-isClickable { &:hover { - background-color: $euiTableHoverClickableColor; + // background-color: $euiTableHoverClickableColor; cursor: pointer; } - &:focus { - background-color: $euiTableFocusClickableColor; - } + // &:focus { + // background-color: $euiTableFocusClickableColor; + // } } diff --git a/src/components/table/table.tsx b/src/components/table/table.tsx index 738e9603af9..7aa43e57e2f 100644 --- a/src/components/table/table.tsx +++ b/src/components/table/table.tsx @@ -19,7 +19,9 @@ import React, { FunctionComponent, TableHTMLAttributes } from 'react'; import classNames from 'classnames'; +import { css } from '@emotion/react'; import { CommonProps } from '../common'; +import { useEuiTheme } from '../../services/theme'; export interface EuiTableProps extends CommonProps, @@ -45,6 +47,10 @@ export const EuiTable: FunctionComponent = ({ responsive = true, ...rest }) => { + const [theme] = useEuiTheme(); + const styles = css` + background-color: ${theme.colors.euiColorEmptyShade}; + `; const classes = classNames( 'euiTable', className, @@ -56,7 +62,7 @@ export const EuiTable: FunctionComponent = ({ ); return ( - +
{children}
); diff --git a/src/components/table/table_footer_cell.tsx b/src/components/table/table_footer_cell.tsx index dd3737f32f1..1315bee92c3 100644 --- a/src/components/table/table_footer_cell.tsx +++ b/src/components/table/table_footer_cell.tsx @@ -18,8 +18,10 @@ */ import React, { FunctionComponent, TdHTMLAttributes } from 'react'; +import { css } from '@emotion/react'; import { CommonProps } from '../common'; import classNames from 'classnames'; +import { useEuiTheme } from '../../services/theme'; import { HorizontalAlignment, @@ -44,6 +46,10 @@ export const EuiTableFooterCell: FunctionComponent = ({ style, ...rest }) => { + const [theme] = useEuiTheme(); + const styles = css` + background-color: ${theme.colors.euiColorLightestShade}; + `; const classes = classNames('euiTableFooterCell', className); const contentClasses = classNames('euiTableCellContent', className, { 'euiTableCellContent--alignRight': align === RIGHT_ALIGNMENT, @@ -52,7 +58,7 @@ export const EuiTableFooterCell: FunctionComponent = ({ const styleObj = resolveWidthAsStyle(style, width); return ( - +
{children}
diff --git a/src/components/table/table_header_button.tsx b/src/components/table/table_header_button.tsx index b72d6fabc69..0940f387090 100644 --- a/src/components/table/table_header_button.tsx +++ b/src/components/table/table_header_button.tsx @@ -19,8 +19,10 @@ import React, { ButtonHTMLAttributes, FunctionComponent } from 'react'; import classNames from 'classnames'; +import { css } from '@emotion/react'; import { CommonProps } from '../common'; import { EuiInnerText } from '../inner_text'; +import { useEuiTheme } from '../../services/theme'; import { IconType, EuiIcon } from '../icon'; @@ -35,6 +37,18 @@ export const EuiTableHeaderButton: FunctionComponent = ({ iconType, ...rest }) => { + const [theme] = useEuiTheme(); + const styles = css` + &:hover, + &:focus { + & .euiTableCellContent__text { + color: ${theme.colors.euiColorPrimary}; + } + + & .euiTableSortIcon { + fill: ${theme.colors.euiColorPrimary}; + } + `; const classes = classNames('euiTableHeaderButton', className); // Add an icon to the button if one exists. @@ -52,7 +66,7 @@ export const EuiTableHeaderButton: FunctionComponent = ({ } return ( -