1
- import { type ClassValue , tcls } from '@/lib/tailwind' ;
2
- import type { DocumentBlockColumns , Length } from '@gitbook/api' ;
1
+ import { tcls } from '@/lib/tailwind' ;
2
+ import { type DocumentBlockColumns , type Length , VerticalAlignment } from '@gitbook/api' ;
3
3
import type { BlockProps } from '../Block' ;
4
4
import { Blocks } from '../Blocks' ;
5
5
@@ -8,10 +8,12 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
8
8
return (
9
9
< div className = { tcls ( 'flex flex-col gap-x-8 md:flex-row' , style ) } >
10
10
{ block . nodes . map ( ( columnBlock ) => {
11
- const width = columnBlock . data . width ;
12
- const { className, style } = transformLengthToCSS ( width ) ;
13
11
return (
14
- < Column key = { columnBlock . key } className = { className } style = { style } >
12
+ < Column
13
+ key = { columnBlock . key }
14
+ width = { columnBlock . data . width }
15
+ verticalAlignment = { columnBlock . data . verticalAlignment }
16
+ >
15
17
< Blocks
16
18
key = { columnBlock . key }
17
19
nodes = { columnBlock . nodes }
@@ -29,11 +31,23 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
29
31
30
32
export function Column ( props : {
31
33
children ?: React . ReactNode ;
32
- className ?: ClassValue ;
33
- style ?: React . CSSProperties ;
34
+ width ?: Length ;
35
+ verticalAlignment ?: VerticalAlignment ;
34
36
} ) {
37
+ const { width, verticalAlignment } = props ;
38
+ const { className, style } = transformLengthToCSS ( width ) ;
35
39
return (
36
- < div className = { tcls ( 'flex-col' , props . className ) } style = { props . style } >
40
+ < div
41
+ className = { tcls (
42
+ 'flex flex-col' ,
43
+ ( verticalAlignment === VerticalAlignment . Top || ! verticalAlignment ) &&
44
+ 'justify-start' ,
45
+ verticalAlignment === VerticalAlignment . Middle && 'justify-center' ,
46
+ verticalAlignment === VerticalAlignment . Bottom && 'justify-end' ,
47
+ className
48
+ ) }
49
+ style = { style }
50
+ >
37
51
{ props . children }
38
52
</ div >
39
53
) ;
0 commit comments