mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Set tw classes correctly for horizontal alignment in tables (#3375)
This commit is contained in:
@@ -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]']}
|
||||
|
||||
Reference in New Issue
Block a user