Skip to content

Commit b6fab32

Browse files
author
Hector Arce De Las Heras
committed
Improve table componente
Include new helper to modify align and background for cells and header
1 parent 18d78fc commit b6fab32

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

src/components/table/component/listColumnHeaderPriority.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const ListColumnHeaderValue = (props: IListColumnHeaderValue): JSX.Element => {
8888
rowHeader,
8989
getExpandedAria,
9090
getValue,
91-
getBackgroundColorCellValue,
91+
getCellTokenValue,
9292
handleShowExpandedContent,
9393
hasExpandedContentRow,
9494
showExpandedContent,
@@ -123,13 +123,15 @@ const ListColumnHeaderValue = (props: IListColumnHeaderValue): JSX.Element => {
123123
<ListItemHeaderPriorityStyled
124124
borderPosition={props.value.rowBorderPosition}
125125
customAlign={
126+
getCellTokenValue({ headerValue: props.header, token: 'align' }) ||
126127
props.header?.config?.alignValue?.[props.device] ||
127128
props.header?.config?.alignValue ||
128129
props.header?.config?.alignHeader?.[props.device] ||
129130
props.header?.config?.alignHeader
130131
}
131132
customBackgroundColor={
132-
getBackgroundColorCellValue(props.header) ?? props.value.backgroundColor
133+
getCellTokenValue({ headerValue: props.header, token: 'backgroundColor' }) ??
134+
props.value.backgroundColor
133135
}
134136
customWidth={props.header?.config?.width}
135137
flexWidth={props.header?.config?.flexWidth}

src/components/table/component/listRowHeaderPriority.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const ListRowHeaderPriority = (props: IListRowHeaderPriority): JSX.Elemen
2424
dividerValue,
2525
getExpandedAria,
2626
getValue,
27-
getBackgroundColorCellValue,
27+
getCellTokenValue,
2828
handleShowExpandedContent,
2929
hasExpandedContentRow,
3030
showExpandedContent,
@@ -94,13 +94,15 @@ export const ListRowHeaderPriority = (props: IListRowHeaderPriority): JSX.Elemen
9494
<ListItemHeaderPriorityStyled
9595
borderPosition={props.value.rowBorderPosition}
9696
customAlign={
97+
getCellTokenValue({ headerValue: header, token: 'align' }) ||
9798
header?.config?.alignValue?.[props.device] ||
9899
header?.config?.alignValue ||
99100
header?.config?.alignHeader?.[props.device] ||
100101
header?.config?.alignHeader
101102
}
102103
customBackgroundColor={
103-
getBackgroundColorCellValue(header) ?? props.value.backgroundColor
104+
getCellTokenValue({ headerValue: header, token: 'backgroundColor' }) ??
105+
props.value.backgroundColor
104106
}
105107
customWidth={header?.config?.width}
106108
data-testid={`${props.dataTestId}ItemList${indexHeader}`}

src/components/table/component/tableRow.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const TableRow = (props: ITableRow): JSX.Element => {
3737
dividerValue,
3838
getExpandedAria,
3939
getValue,
40-
getBackgroundColorCellValue,
40+
getCellTokenValue,
4141
handleShowExpandedContent,
4242
hasExpandedContentRow,
4343
hasFooter,
@@ -88,13 +88,15 @@ export const TableRow = (props: ITableRow): JSX.Element => {
8888
<TableColumnBodyStyled
8989
key={indexHeader}
9090
customAlign={
91+
getCellTokenValue({ headerValue, token: 'align' }) ||
9192
headerValue?.config?.alignValue?.[props.device] ||
9293
headerValue?.config?.alignValue ||
9394
headerValue?.config?.alignHeader?.[props.device] ||
9495
headerValue?.config?.alignHeader
9596
}
9697
customBackgroundColor={
97-
getBackgroundColorCellValue(headerValue) ?? props.value.backgroundColor
98+
getCellTokenValue({ headerValue, token: 'backgroundColor' }) ??
99+
props.value.backgroundColor
98100
}
99101
customWidth={headerValue?.config?.width}
100102
data-testid={`${props.dataTestId}Row${props.indexRow}Content${indexHeader}`}

src/components/table/stories/mockTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ export const mockCustomizableTable = {
566566
},
567567
{
568568
date: '18 DIC',
569-
name: { value: 'Dwight', backgroundColor: 'green' },
569+
name: { value: 'Dwight', backgroundColor: 'green', align: 'right' },
570570
surname: 'Malone',
571571
routingNumber: '123456789',
572572
accountNumber: '****999999',

src/components/table/types/table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export type ValueConfigType = {
7272
| number
7373
| boolean;
7474
backgroundColor?: string;
75+
align?: string;
7576
};
7677

7778
export type IValueConfigPropsType = {
@@ -83,6 +84,7 @@ export type IValueConfigPropsType = {
8384
rowHeader?: ITableRowHeader;
8485
rowBorderPosition?: LineSeparatorPositionType;
8586
backgroundColor?: string;
87+
align?: string;
8688
};
8789

8890
/**

0 commit comments

Comments
 (0)