From ec92075ef802a2b8024f87d9fc0f97c409ac7fb8 Mon Sep 17 00:00:00 2001 From: Viktor Renkema <49148610+viktorrenkema@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:35:32 +0200 Subject: [PATCH] Set tw classes correctly for horizontal alignment in tables (#3375) --- .../DocumentView/Table/RecordColumnValue.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/Table/RecordColumnValue.tsx b/packages/gitbook/src/components/DocumentView/Table/RecordColumnValue.tsx index 50dc0d827..710746a92 100644 --- a/packages/gitbook/src/components/DocumentView/Table/RecordColumnValue.tsx +++ b/packages/gitbook/src/components/DocumentView/Table/RecordColumnValue.tsx @@ -22,6 +22,12 @@ import { FileIcon } from '../FileIcon'; import type { TableRecordKV } from './Table'; import { type VerticalAlignment, getColumnAlignment } from './utils'; +const alignmentMap: Record<'text-left' | 'text-center' | 'text-right', string> = { + 'text-left': '[&_*]:text-left text-left', + 'text-center': '[&_*]:text-center text-center', + 'text-right': '[&_*]:text-right text-right', +}; + /** * Render the value for a column in a record. */ @@ -116,7 +122,7 @@ export async function RecordColumnValue( } const horizontalAlignment = getColumnAlignment(definition); - const childrenHorizontalAlignment = `[&_*]:${horizontalAlignment}`; + const horizontalClasses = alignmentMap[horizontalAlignment]; return ( ( 'lg:space-y-3', 'leading-normal', verticalAlignment, - horizontalAlignment, - childrenHorizontalAlignment, + horizontalClasses, ]} context={context} blockStyle={['w-full', 'max-w-[unset]']}