Skip to content

Commit 3a93f8c

Browse files
committed
feat(PaginatedTable): add note for column head
1 parent 0a20373 commit 3a93f8c

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

src/components/PaginatedTable/PaginatedTable.scss

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,50 +79,69 @@
7979
display: flex;
8080
flex-direction: row;
8181
align-items: center;
82+
gap: var(--g-spacing-2);
8283

8384
width: 100%;
8485
max-width: 100%;
8586
padding: var(--paginated-table-cell-vertical-padding)
8687
var(--paginated-table-cell-horizontal-padding);
8788

89+
font-weight: bold;
90+
cursor: default;
8891
&_align {
8992
&_left {
9093
justify-content: left;
94+
95+
text-align: left;
9196
}
9297
&_center {
9398
justify-content: center;
99+
100+
text-align: center;
94101
}
95102
&_right {
96103
justify-content: right;
104+
105+
text-align: right;
106+
107+
#{$block}__head-cell-content-container {
108+
flex-direction: row-reverse;
109+
}
97110
}
98111
}
99112
}
100113

101-
&__head-cell {
102-
gap: 8px;
103-
104-
font-weight: bold;
105-
cursor: default;
106-
107-
&_sortable {
108-
cursor: pointer;
114+
&__head-cell_sortable {
115+
cursor: pointer;
109116

110-
&#{$block}__head-cell_align_right {
111-
flex-direction: row-reverse;
112-
}
117+
&#{$block}__head-cell_align_right {
118+
flex-direction: row-reverse;
113119
}
114120
}
115121

122+
&__head-cell-note {
123+
display: flex;
124+
}
125+
116126
// Separate head cell content class for correct text ellipsis overflow
117127
&__head-cell-content {
118128
overflow: hidden;
119129

120-
width: min-content;
121-
122130
white-space: nowrap;
123131
text-overflow: ellipsis;
124132
}
125133

134+
&__head-cell-content-container {
135+
display: inline-flex;
136+
overflow: hidden;
137+
gap: var(--g-spacing-1);
138+
139+
.g-help-mark__button {
140+
display: inline-flex;
141+
align-items: center;
142+
}
143+
}
144+
126145
&__row-cell {
127146
display: table-cell;
128147
overflow-x: hidden;

src/components/PaginatedTable/TableHead.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react';
22

3+
import type {HelpMarkProps} from '@gravity-ui/uikit';
4+
import {HelpMark} from '@gravity-ui/uikit';
5+
36
import {ResizeHandler} from './ResizeHandler';
47
import {
58
ASCENDING,
@@ -9,7 +12,14 @@ import {
912
DESCENDING,
1013
} from './constants';
1114
import {b} from './shared';
12-
import type {Column, HandleTableColumnsResize, OnSort, SortOrderType, SortParams} from './types';
15+
import type {
16+
AlignType,
17+
Column,
18+
HandleTableColumnsResize,
19+
OnSort,
20+
SortOrderType,
21+
SortParams,
22+
} from './types';
1323

1424
// Icon similar to original DataTable icons to keep the same tables across diferent pages and tabs
1525
const SortIcon = ({order}: {order?: SortOrderType}) => {
@@ -43,6 +53,12 @@ const ColumnSortIcon = ({sortOrder, sortable, defaultSortOrder}: ColumnSortIconP
4353
}
4454
};
4555

56+
const columnAlignToHelpMarkPlacement: Record<AlignType, HelpMarkProps['placement']> = {
57+
left: 'right',
58+
right: 'left',
59+
center: 'right',
60+
};
61+
4662
interface TableHeadCellProps<T> {
4763
column: Column<T>;
4864
resizeable?: boolean;
@@ -115,7 +131,17 @@ export const TableHeadCell = <T,>({
115131
}
116132
}}
117133
>
118-
<div className={b('head-cell-content')}>{content}</div>
134+
<div className={b('head-cell-content-container')}>
135+
<div className={b('head-cell-content')}>{content}</div>
136+
{column.note && (
137+
<HelpMark
138+
placement={columnAlignToHelpMarkPlacement[column.align]}
139+
className={b('head-cell-note')}
140+
>
141+
{column.note}
142+
</HelpMark>
143+
)}
144+
</div>
119145
<ColumnSortIcon
120146
sortOrder={sortOrder}
121147
sortable={column.sortable}

src/components/PaginatedTable/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type HandleTableColumnsResize = (columnId: string, width: number) => void
2525

2626
export interface Column<T> {
2727
name: string;
28+
note?: string;
2829
header?: React.ReactNode;
2930
className?: string;
3031
sortable?: boolean;

0 commit comments

Comments
 (0)