Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/Table/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
@use './variables';

#{variables.$block} {
--_--sticky-background: var(--g-table-sticky-column-background, var(--g-color-base-background));
--_--sticky-hover-background: var(
--g-table-sticky-column-hover-background,
var(--g-color-base-simple-hover-solid)
);

overflow: auto;
position: relative;

Expand Down Expand Up @@ -87,7 +93,7 @@
position: sticky;
z-index: 2;

background: var(--g-color-base-background);
background: var(--_--sticky-background);
}

&_border_right {
Expand Down Expand Up @@ -133,7 +139,7 @@

#{variables.$block}__cell_sticky_start,
#{variables.$block}__cell_sticky_end {
background: var(--g-color-base-simple-hover-solid);
background: var(--_--sticky-hover-background);
}
}

Expand Down
37 changes: 37 additions & 0 deletions src/components/Table/__stories__/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,40 @@ export const HOCWithTableSorting = WithTableSortingTemplate.bind({});
HOCWithTableSorting.args = {
columns: columnsWithSorting,
};

// ---------------------------------
const columnsWithSticky = cloneDeep(columns);
columnsWithSticky[0].sticky = 'start';
columnsWithSticky[0].width = 150;
columnsWithSticky[1].width = 200;
columnsWithSticky[2].width = 200;
columnsWithSticky[3].width = 200;
columnsWithSticky[4].width = 150;
columnsWithSticky[5].width = 150;

// Note: --g-color-base-info-light is semi-transparent (rgba), so we use
// the solid equivalent --g-color-private-blue-100-solid for sticky columns
const CUSTOM_BG_COLOR = 'var(--g-color-private-blue-100-solid)';

const StickyColumnsCustomBackgroundTemplate: StoryFn<TableProps<DataItem>> = (args) => {
return (
<div
style={{
padding: 20,
backgroundColor: CUSTOM_BG_COLOR,
}}
>
<div
style={{
maxWidth: 500,
// @ts-expect-error CSS custom property
'--g-table-sticky-column-background': CUSTOM_BG_COLOR,
}}
>
<Table {...args} columns={columnsWithSticky} />
</div>
</div>
);
};
export const StickyColumnsCustomBackground = StickyColumnsCustomBackgroundTemplate.bind({});
StickyColumnsCustomBackground.storyName = 'Sticky Columns: Custom Background';
7 changes: 7 additions & 0 deletions src/components/TableColumnSetup/README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,10 @@ LANDING_BLOCK-->
| :-------- | :--------------------------------------------------- | :---------------------------------------: |
| onClick | Обработчик события клика для переключателя | `React.MouseEventHandler<HTMLElement>` |
| onKeyDown | Обработчик события нажатия клавиши для переключателя | `React.KeyboardEventHandler<HTMLElement>` |

## CSS API

| Имя | Описание |
| :----------------------------------------- | :-------------------------------------------------------------------------------------- |
| `--g-table-sticky-column-background` | Цвет фона для sticky столбцов (должен быть непрозрачным цветом) |
| `--g-table-sticky-column-hover-background` | Цвет фона для sticky столбцов при наведении на строку (должен быть непрозрачным цветом) |
7 changes: 7 additions & 0 deletions src/components/TableColumnSetup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,10 @@ LANDING_BLOCK-->
| :-------- | :------------------------------------- | :---------------------------------------: |
| onClick | Click event handler for the switcher | `React.MouseEventHandler<HTMLElement>` |
| onKeyDown | KeyDown event handler for the switcher | `React.KeyboardEventHandler<HTMLElement>` |

## CSS API

| Name | Description |
| :----------------------------------------- | :--------------------------------------------------------------------------- |
| `--g-table-sticky-column-background` | Background color for sticky columns (should be an opaque color) |
| `--g-table-sticky-column-hover-background` | Background color for sticky columns on row hover (should be an opaque color) |
Loading