Skip to content

Commit

Permalink
feat: support all margins
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 9, 2024
1 parent a2a1c81 commit 2b5d84a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export function makeTable<T extends ScalarDict>(options: TableProps<T>): void {

function Container(props: ContainerProps) {
return (
<Box columnGap={props.columnGap} alignItems={props.alignItems} rowGap={props.rowGap} margin={props.margin} flexWrap="wrap" flexDirection={props.direction ?? 'row'}>
<Box flexWrap="wrap" flexDirection={props.direction ?? 'row'} {...props}>
{props.children}
</Box>
)
Expand All @@ -324,7 +324,9 @@ export function makeTables<T extends ScalarDict[]>(
tables: {[P in keyof T]: TableProps<T[P]>},
options?: Omit<ContainerProps, 'children'>
): void {
const columns = process.stdout.columns - ((options?.margin ?? 0) * 2)
const leftMargin = options?.marginLeft ?? options?.margin ?? 0
const rightMargin = options?.marginRight ?? options?.margin ?? 0
const columns = process.stdout.columns - (leftMargin + rightMargin)

const processed = tables.map((table) => ({
...table,
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,9 @@ export type ContainerProps = {
readonly columnGap?: number
readonly direction?: 'row' | 'column'
readonly margin?: number
readonly marginLeft?: number
readonly marginRight?: number
readonly marginTop?: number
readonly marginBottom?: number
readonly rowGap?: number
}

0 comments on commit 2b5d84a

Please sign in to comment.