Skip to content

Commit 9201e2c

Browse files
Add vertical align property to column block (#3596)
Co-authored-by: Samy Pessé <[email protected]>
1 parent 2e0d706 commit 9201e2c

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.changeset/proud-lemons-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Adds vertical align to column block

bun.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
"react-dom": "^19.0.0",
294294
},
295295
"catalog": {
296-
"@gitbook/api": "^0.136.0",
296+
"@gitbook/api": "^0.137.0",
297297
"bidc": "^0.0.2",
298298
},
299299
"packages": {
@@ -659,7 +659,7 @@
659659

660660
"@fortawesome/fontawesome-svg-core": ["@fortawesome/[email protected]", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
661661

662-
"@gitbook/api": ["@gitbook/api@0.136.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-IxNqmXE6yUEUq0IzbenN8S/PcMfgxr4+akY8xh6V5ShI/+U37ixujJHZp2zJq6NdZOdBQoR3UQmhPnvtWrkF7g=="],
662+
"@gitbook/api": ["@gitbook/api@0.137.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-3pTNbHI4kJT7ikqSdSLa2UCB0dOPOTzOUHcsCTLrk+rJVjTAFAJmTEW/Ax2prnwZ75ran2hz9/FhxUAGhp/8Mg=="],
663663

664664
"@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"],
665665

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"workspaces": {
3535
"packages": ["packages/*"],
3636
"catalog": {
37-
"@gitbook/api": "^0.136.0",
37+
"@gitbook/api": "^0.137.0",
3838
"bidc": "^0.0.2"
3939
}
4040
},

packages/gitbook/src/components/DocumentView/Columns/Columns.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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';
33
import type { BlockProps } from '../Block';
44
import { Blocks } from '../Blocks';
55

@@ -8,10 +8,12 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
88
return (
99
<div className={tcls('flex flex-col gap-x-8 md:flex-row', style)}>
1010
{block.nodes.map((columnBlock) => {
11-
const width = columnBlock.data.width;
12-
const { className, style } = transformLengthToCSS(width);
1311
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+
>
1517
<Blocks
1618
key={columnBlock.key}
1719
nodes={columnBlock.nodes}
@@ -29,11 +31,23 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
2931

3032
export function Column(props: {
3133
children?: React.ReactNode;
32-
className?: ClassValue;
33-
style?: React.CSSProperties;
34+
width?: Length;
35+
verticalAlignment?: VerticalAlignment;
3436
}) {
37+
const { width, verticalAlignment } = props;
38+
const { className, style } = transformLengthToCSS(width);
3539
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+
>
3751
{props.children}
3852
</div>
3953
);

0 commit comments

Comments
 (0)