Skip to content

Commit 529ac00

Browse files
committed
WIP: Remove redundant cell styling hook
1 parent e85e84e commit 529ac00

File tree

2 files changed

+47
-50
lines changed

2 files changed

+47
-50
lines changed

packages/main/src/components/AnalyticalTable/hooks/useCellStyling.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

packages/main/src/components/AnalyticalTable/hooks/useTableCellStyling.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1+
import { TextAlign } from '@ui5/webcomponents-react/lib/TextAlign';
2+
import { VerticalAlign } from '@ui5/webcomponents-react/lib/VerticalAlign';
3+
import { CSSProperties } from 'react';
14
import { PluginHook } from 'react-table';
2-
import { useCellStyling } from './useCellStyling';
35

46
export const useTableCellStyling = (classes, rowHeight) => {
57
const hook: PluginHook<{}> = (instance) => {
6-
instance.getCellProps.push(useCellStyling({ rowHeight }, classes));
8+
instance.getCellProps.push(({ column }) => {
9+
const style: CSSProperties = {};
10+
11+
if (rowHeight) {
12+
style.height = `${rowHeight}px`;
13+
}
14+
switch (column.hAlign) {
15+
case TextAlign.Begin:
16+
style.textAlign = 'start';
17+
break;
18+
case TextAlign.Center:
19+
style.textAlign = 'center';
20+
break;
21+
case TextAlign.End:
22+
style.textAlign = 'end';
23+
break;
24+
case TextAlign.Left:
25+
style.textAlign = 'left';
26+
break;
27+
case TextAlign.Right:
28+
style.textAlign = 'right';
29+
break;
30+
}
31+
switch (column.vAlign) {
32+
case VerticalAlign.Bottom:
33+
style.verticalAlign = 'bottom';
34+
break;
35+
case VerticalAlign.Middle:
36+
style.verticalAlign = 'middle';
37+
break;
38+
case VerticalAlign.Top:
39+
style.verticalAlign = 'top';
40+
break;
41+
}
42+
43+
let className = classes.tableCell;
44+
if (column.className) {
45+
className += ` ${column.className}`;
46+
}
47+
return {
48+
className,
49+
style
50+
};
51+
});
752
};
853
hook.pluginName = 'useTableCellStyling';
954
return hook;

0 commit comments

Comments
 (0)