Skip to content
2 changes: 2 additions & 0 deletions packages/eui-theme-borealis/changelogs/upcoming/9224.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added component token `components.tableFooterBackground`

2 changes: 2 additions & 0 deletions packages/eui-theme-borealis/src/variables/_components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ const component_colors: _EuiThemeComponentColors = {
([backgroundFilledText]) => backgroundFilledText,
['colors.backgroundFilledText']
),
tableFooterBackground: SEMANTIC_COLORS.shade15,

tooltipBackground: dark_background_colors.backgroundBaseSubdued,
tooltipBorder: dark_border_colors.borderBaseSubdued,
Expand Down Expand Up @@ -419,5 +420,6 @@ export const components: _EuiThemeComponents = {
),
tableRowBackgroundMarked: SEMANTIC_COLORS.warning140,
tableRowBackgroundMarkedHover: SEMANTIC_COLORS.warning130,
tableFooterBackground: SEMANTIC_COLORS.shade135,
},
};
2 changes: 2 additions & 0 deletions packages/eui-theme-common/changelogs/upcoming/9224.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added type for component token `components.tableFooterBackground`

Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export type _EuiThemeComponentColors = {
tableRowBackgroundMarked: ColorModeSwitch;
tableRowBackgroundMarkedHover: ColorModeSwitch;
tableCellSortableIconColor: ColorModeSwitch;
tableFooterBackground: ColorModeSwitch;

tooltipBackground: ColorModeSwitch;
tooltipBorder: ColorModeSwitch;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/eui/changelogs/upcoming/9224.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- Added `hasBackground` prop on `EuiTable`, `EuiBasicTable` and `EuiInMemoryTable`
- Added component token `components.tableFooterBackground`
- Updated the color of mobile table header cells to use `colors.textSubdued`

**Bug fixes**

- Fixed a visual bug for mobile table action buttons that causes shifting positions when changing color mode ([#8231](https://github.com/elastic/eui/issues/8231))

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`EuiBasicTable actions custom item actions 1`] = `
<tr
class="euiTableRow euiTableRow-isSelectable euiTableRow-hasActions emotion-euiTableRow-mobile"
class="euiTableRow euiTableRow-isSelectable euiTableRow-hasActions emotion-euiTableRow-mobile-hasBackground"
>
<td
class="euiTableRowCell euiTableRowCell--hasActions emotion-euiTableRowCell-hasActions-middle-mobile-customActions"
Expand Down Expand Up @@ -45,7 +45,7 @@ exports[`EuiBasicTable renders (bare-bones) 1`] = `
𐘂𐘂
</span>
<table
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-hasBackground-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down Expand Up @@ -199,7 +199,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
𐘂𐘂
</span>
<table
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-hasBackground-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down Expand Up @@ -831,7 +831,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand All @@ -842,7 +842,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
</div>
</td>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand All @@ -853,7 +853,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
</div>
</td>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand All @@ -869,7 +869,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
</div>
</td>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand All @@ -880,7 +880,7 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
</div>
</td>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ exports[`EuiInMemoryTable empty array 1`] = `
𐘂𐘂
</span>
<table
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-hasBackground-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down Expand Up @@ -270,7 +270,7 @@ exports[`EuiInMemoryTable with items 1`] = `
𐘂𐘂
</span>
<table
class="euiTable emotion-euiTable-fixed-uncompressed-desktop"
class="euiTable emotion-euiTable-fixed-uncompressed-hasBackground-desktop"
id="__table_generated-id"
tabindex="-1"
>
Expand Down
59 changes: 52 additions & 7 deletions packages/eui/src/components/basic_table/basic_table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
} from './basic_table';
import { EuiBasicTable, EuiBasicTableProps } from './basic_table';
import { EuiIcon } from '../icon';
import { Pagination } from './pagination_bar';

// Set static seed so that the generated faker data is consistent between page loads
faker.seed(8_02_2010);
Expand All @@ -40,6 +41,7 @@ const meta: Meta<EuiBasicTableProps<User>> = {
// Inherited from EuiTable
responsiveBreakpoint: 'm',
tableLayout: 'fixed',
hasBackground: true,
// set up for easier testing/QA
cellProps: {
'data-test-subj': `basic-table-cell`,
Expand All @@ -52,7 +54,7 @@ const meta: Meta<EuiBasicTableProps<User>> = {
};
moveStorybookControlsToCategory(
meta,
['responsiveBreakpoint', 'tableLayout'],
['responsiveBreakpoint', 'tableLayout', 'hasBackground'],
'EuiTable props'
);

Expand Down Expand Up @@ -259,7 +261,7 @@ export const MarkedRow: Story = {
})} />`,
},
controls: {
include: ['rowProps', 'columns', 'items'],
include: ['rowProps', 'columns', 'items', 'hasBackground'],
},
},
args: {
Expand All @@ -275,7 +277,7 @@ export const MarkedRow: Story = {
export const ExpandedRow: Story = {
parameters: {
controls: {
include: ['columns', 'items', 'itemIdToExpandedRowMap'],
include: ['columns', 'items', 'itemIdToExpandedRowMap', 'hasBackground'],
},
},
args: {
Expand All @@ -295,11 +297,15 @@ export const ExpandedRow: Story = {
},
};

type NestedTableProps = {
hasLeadingIcon?: boolean;
hasBackground?: boolean;
};

const NestedTable = ({
hasLeadingIcon = false,
}: {
hasLeadingIcon?: boolean;
}) => {
hasBackground = true,
}: NestedTableProps) => {
const { euiTheme } = useEuiTheme();

const _items = users.slice(0, 3);
Expand All @@ -321,14 +327,15 @@ const NestedTable = ({
itemId="id"
rowHeader="firstName"
columns={_columns}
hasBackground={hasBackground}
/>
);
};

export const ExpandedNestedTable: Story = {
parameters: {
controls: {
include: ['columns', 'items', 'itemIdToExpandedRowMap'],
include: ['columns', 'items', 'itemIdToExpandedRowMap', 'hasBackground'],
},
},
args: {
Expand All @@ -348,6 +355,32 @@ export const ExpandedNestedTable: Story = {
onSelectionChange: action('onSelectionChange'),
},
},
render: function Render({
itemIdToExpandedRowMap,
hasBackground,
...rest
}: EuiBasicTableProps<User>) {
// story-only logic to inject hasBackground into nested tables
// do not use in consumer code, set hasBackground directly on the nested table instead
const _itemIdToExpandedRowMap = Object.fromEntries(
Object.entries(itemIdToExpandedRowMap || {}).map(([key, value]) => [
key,
React.isValidElement(value)
? React.cloneElement(value, { hasBackground } as NestedTableProps)
: value,
])
);

return (
<StatefulPlayground
// only passed to ensure same base size, casting to prevent showing the pagination controls
pagination={{ pageSize: 5 } as Pagination}
hasBackground={hasBackground}
itemIdToExpandedRowMap={_itemIdToExpandedRowMap}
{...rest}
/>
);
},
};

export const DarkMode: Story = {
Expand Down Expand Up @@ -394,6 +427,18 @@ export const LargeExpandedRow: Story = {
},
};

export const ExpandedNestedTableWithoutBackground: Story = {
tags: ['vrt-only'],
args: {
...ExpandedNestedTable.args,
hasBackground: false,
itemIdToExpandedRowMap: {
1: <NestedTable hasBackground={false} />,
3: <NestedTable hasBackground={false} hasLeadingIcon />,
},
},
};

const StatefulPlayground = ({
items,
pagination,
Expand Down
11 changes: 9 additions & 2 deletions packages/eui/src/components/basic_table/basic_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ export class EuiBasicTable<T extends object = any> extends Component<
tableCaption,
rowHeader,
tableLayout,
hasBackground,
...rest
} = this.props;

Expand All @@ -541,8 +542,13 @@ export class EuiBasicTable<T extends object = any> extends Component<
}

renderTable() {
const { compressed, responsiveBreakpoint, tableLayout, loading } =
this.props;
const {
compressed,
responsiveBreakpoint,
tableLayout,
hasBackground,
loading,
} = this.props;

return (
<>
Expand All @@ -556,6 +562,7 @@ export class EuiBasicTable<T extends object = any> extends Component<
tableLayout={tableLayout}
responsiveBreakpoint={responsiveBreakpoint}
compressed={compressed}
hasBackground={hasBackground}
css={loading && safariLoadingWorkaround}
>
{this.renderTableCaption()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ const meta: Meta<EuiInMemoryTableProps> = {
// Inherited from EuiTable
responsiveBreakpoint: 'm',
tableLayout: 'fixed',
hasBackground: true,
},
};
moveStorybookControlsToCategory(
meta,
['responsiveBreakpoint', 'tableLayout'],
['responsiveBreakpoint', 'tableLayout', 'hasBackground'],
'EuiTable props'
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`EuiTable renders 1`] = `
<table
aria-label="aria-label"
class="euiTable testClass1 testClass2 emotion-euiTable-fixed-uncompressed-desktop-euiTestCss"
class="euiTable testClass1 testClass2 emotion-euiTable-fixed-uncompressed-hasBackground-desktop-euiTestCss"
data-test-subj="test subject string"
tabindex="-1"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`EuiTableFooterCell align defaults to left 1`] = `
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-truncateText"
Expand All @@ -25,7 +25,7 @@ exports[`EuiTableFooterCell align renders center when specified 1`] = `
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-center-truncateText"
Expand All @@ -45,7 +45,7 @@ exports[`EuiTableFooterCell align renders right when specified 1`] = `
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
>
<div
class="euiTableCellContent emotion-euiTableCellContent-right-truncateText"
Expand All @@ -66,7 +66,7 @@ exports[`EuiTableFooterCell is rendered 1`] = `
<tr>
<td
aria-label="aria-label"
class="euiTableFooterCell testClass1 testClass2 emotion-euiTableFooterCell-euiTestCss"
class="euiTableFooterCell testClass1 testClass2 emotion-euiTableFooterCell-hasBackground-euiTestCss"
data-test-subj="test subject string"
>
<div
Expand All @@ -89,7 +89,7 @@ exports[`EuiTableFooterCell width and style accepts style attribute 1`] = `
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
style="width: 20%;"
>
<div
Expand All @@ -112,7 +112,7 @@ exports[`EuiTableFooterCell width and style accepts width attribute 1`] = `
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
style="width: 10%;"
>
<div
Expand All @@ -135,7 +135,7 @@ exports[`EuiTableFooterCell width and style accepts width attribute as number 1`
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
style="width: 100px;"
>
<div
Expand All @@ -158,7 +158,7 @@ exports[`EuiTableFooterCell width and style resolves style and width attribute 1
<tfoot>
<tr>
<td
class="euiTableFooterCell emotion-euiTableFooterCell"
class="euiTableFooterCell emotion-euiTableFooterCell-hasBackground"
style="width: 10%;"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const euiTableCellContentStyles = ({ euiTheme }: UseEuiTheme) => ({
`,
mobile: css`
flex-direction: column;
padding: 0;
`,
},
});
Loading