Skip to content

Commit 6b5d7e6

Browse files
Improve styles of Tables (#2623)
1 parent 076dc48 commit 6b5d7e6

File tree

3 files changed

+116
-9
lines changed

3 files changed

+116
-9
lines changed

packages/gitbook/e2e/pages.spec.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,90 @@ const testCases: TestsCase[] = [
10181018
},
10191019
],
10201020
},
1021+
{
1022+
name: 'Tables',
1023+
baseUrl: 'https://gitbook.gitbook.io/test-gitbook-open/',
1024+
tests: [
1025+
{
1026+
name: 'Default table',
1027+
url: 'blocks/tables',
1028+
run: waitForCookiesDialog,
1029+
fullPage: true,
1030+
},
1031+
{
1032+
name: 'Table with straight corners',
1033+
url:
1034+
'blocks/tables' +
1035+
getCustomizationURL({
1036+
styling: {
1037+
corners: CustomizationCorners.Straight,
1038+
},
1039+
}),
1040+
run: waitForCookiesDialog,
1041+
fullPage: true,
1042+
},
1043+
{
1044+
name: 'Table with primary color',
1045+
url:
1046+
'blocks/tables' +
1047+
getCustomizationURL({
1048+
styling: {
1049+
tint: { color: { light: '#346DDB', dark: '#346DDB' } },
1050+
},
1051+
}),
1052+
run: waitForCookiesDialog,
1053+
fullPage: true,
1054+
},
1055+
// Test dark mode for each variant
1056+
...allThemeModes.flatMap((theme) => [
1057+
{
1058+
name: `Table in ${theme} mode`,
1059+
url:
1060+
'blocks/tables' +
1061+
getCustomizationURL({
1062+
themes: {
1063+
default: theme,
1064+
toggeable: false,
1065+
},
1066+
}),
1067+
run: waitForCookiesDialog,
1068+
fullPage: true,
1069+
},
1070+
{
1071+
name: `Table with straight corners in ${theme} mode`,
1072+
url:
1073+
'blocks/tables' +
1074+
getCustomizationURL({
1075+
styling: {
1076+
corners: CustomizationCorners.Straight,
1077+
},
1078+
themes: {
1079+
default: theme,
1080+
toggeable: false,
1081+
},
1082+
}),
1083+
run: waitForCookiesDialog,
1084+
fullPage: true,
1085+
},
1086+
{
1087+
name: `Table with primary color in ${theme} mode`,
1088+
url:
1089+
'blocks/tables' +
1090+
getCustomizationURL({
1091+
styling: {
1092+
tint: { color: { light: '#346DDB', dark: '#346DDB' } },
1093+
},
1094+
themes: {
1095+
default: theme,
1096+
toggeable: false,
1097+
},
1098+
}),
1099+
run: waitForCookiesDialog,
1100+
fullPage: true,
1101+
},
1102+
]),
1103+
],
1104+
},
10211105
];
10221106

10231107
for (const testCase of testCases) {

packages/gitbook/src/components/DocumentView/Table/ViewGrid.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ export function ViewGrid(props: TableViewProps<DocumentTableViewGrid>) {
3434
<div role="table" className={tcls('flex', 'flex-col')}>
3535
{/* Header */}
3636
{withHeader && (
37-
<div role="rowgroup" className={tcls('flex flex-col', tableWidth)}>
38-
<div role="row" className={tcls('flex', 'w-full', '[&>*+*]:border-l')}>
37+
<div
38+
role="rowgroup"
39+
className={tcls(
40+
tableWidth,
41+
styles.rowGroup,
42+
'straight-corners:rounded-none',
43+
)}
44+
>
45+
<div role="row" className={tcls('flex', 'w-full')}>
3946
{view.columns.map((column) => {
4047
const alignment = getColumnAlignment(block.data.definition[column]);
4148
return (

packages/gitbook/src/components/DocumentView/Table/table.module.css

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,37 @@
2323
}
2424

2525
:global(.dark) .tableWrapper {
26-
@apply border-light/2;
26+
@apply border-tint-50;
27+
}
28+
29+
.columnHeader {
30+
@apply text-sm font-medium py-3 px-4 text-tint-900;
31+
}
32+
33+
:global(.dark) .columnHeader {
34+
@apply text-white;
2735
}
2836

2937
.row {
30-
@apply flex border-dark/3 dark:border-light/2;
38+
@apply flex border-tint-700/2;
3139
}
3240

33-
.row > * + * {
34-
@apply border-l;
41+
:global(.dark) .row {
42+
@apply border-tint-300/3;
43+
}
44+
45+
.rowGroup {
46+
@apply flex flex-col border rounded-lg bg-tint-800/1 border-tint-700/2;
47+
}
48+
49+
:global(.dark) .rowGroup {
50+
@apply bg-tint-300/2 border-tint-300/3;
3551
}
3652

3753
.cell {
38-
@apply flex-1 align-middle border-dark/2 py-2 px-3 text-sm lg:text-base dark:border-light/2;
54+
@apply flex-1 align-middle border-dark/2 py-2 px-4 text-sm;
3955
}
4056

41-
.columnHeader {
42-
@apply align-middle text-left text-base font-medium border-b dark:border-l-light/2 dark:border-b-light/4 py-2 px-3;
57+
:global(.dark) .cell {
58+
@apply border-light/2;
4359
}

0 commit comments

Comments
 (0)