File size: 892 Bytes
3199d61
 
 
 
 
 
064bfd6
3199d61
 
064bfd6
3199d61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8a167e
3199d61
 
 
 
 
064bfd6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as React from 'react'
import { Box } from '../../ink.js'
import { Divider } from '../design-system/Divider.js'
import type { FeedConfig } from './Feed.js'
import { calculateFeedWidth, Feed } from './Feed.js'

type FeedColumnProps = {
  feeds: FeedConfig[]
  maxWidth: number
}

export function FeedColumn({
  feeds,
  maxWidth,
}: FeedColumnProps): React.ReactNode {
  const feedWidths = feeds.map(feed => calculateFeedWidth(feed))
  const maxOfAllFeeds = Math.max(...feedWidths)
  const actualWidth = Math.min(maxOfAllFeeds, maxWidth)

  return (
    <Box flexDirection="column">
      {feeds.map((feed, index) => (
        <React.Fragment key={index}>
          <Feed config={feed} actualWidth={actualWidth} />
          {index < feeds.length - 1 && (
            <Divider color="clawd_body" width={actualWidth} />
          )}
        </React.Fragment>
      ))}
    </Box>
  )
}