Set tw classes correctly for horizontal alignment in tables (#3375)

This commit is contained in:
Viktor Renkema
2025-06-23 14:35:32 +02:00
committed by GitHub
parent 1e013cd87c
commit ec92075ef8
@@ -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<Tag extends React.ElementType = 'div'>(
}
const horizontalAlignment = getColumnAlignment(definition);
const childrenHorizontalAlignment = `[&_*]:${horizontalAlignment}`;
const horizontalClasses = alignmentMap[horizontalAlignment];
return (
<Blocks
@@ -131,8 +137,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
'lg:space-y-3',
'leading-normal',
verticalAlignment,
horizontalAlignment,
childrenHorizontalAlignment,
horizontalClasses,
]}
context={context}
blockStyle={['w-full', 'max-w-[unset]']}