From cb1b56f5a0eddbf77446f415f2beda57c8305f85 Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 23 Nov 2025 01:12:53 +0700 Subject: wut --- packages/tweetdeck/src/components/ColumnBoard.tsx | 93 +++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 packages/tweetdeck/src/components/ColumnBoard.tsx (limited to 'packages/tweetdeck/src/components/ColumnBoard.tsx') diff --git a/packages/tweetdeck/src/components/ColumnBoard.tsx b/packages/tweetdeck/src/components/ColumnBoard.tsx new file mode 100644 index 0000000..87da3e1 --- /dev/null +++ b/packages/tweetdeck/src/components/ColumnBoard.tsx @@ -0,0 +1,93 @@ +import { useMemo } from "react"; +import type { + ColumnSnapshot, + ColumnState, + DeckAccount, + DeckColumn, + FullscreenState, +} from "../types/app"; +import { TimelineColumn, type TimelineConfig } from "./TimelineColumn"; +import { ChatColumn } from "./ChatColumn"; + +interface ColumnBoardProps { + columns: DeckColumn[]; + accounts: DeckAccount[]; + onRemove: (id: string) => void; + onStateChange: (columnId: string, state: ColumnState) => void; + onSnapshot: (columnId: string, snapshot: ColumnSnapshot) => void; + onEnterFullscreen: (payload: FullscreenState) => void; +} + +export function ColumnBoard({ + columns, + accounts, + onRemove, + onStateChange, + onSnapshot, + onEnterFullscreen, +}: ColumnBoardProps) { + const accountMap = useMemo( + () => Object.fromEntries(accounts.map(account => [account.id, account])), + [accounts], + ); + + if (!columns.length) { + return ( +
+

No columns yet

+

Build your deck

+

Add some columns from the left panel to start streaming timelines.

+
+ ); + } + + return ( +
+ {columns.map((column, columnIndex) => { + const account = accountMap[column.accountId]; + if (!account) { + return ( +
+
+
+

Account missing

+

{column.title}

+
+ +
+

The account for this column was removed.

+
+ ); + } + if (isChatColumn(column)) { + return ( + onRemove(column.id)} + /> + ); + } + return ( + onRemove(column.id)} + onStateChange={onStateChange} + onSnapshot={onSnapshot} + onEnterFullscreen={onEnterFullscreen} + columnIndex={columnIndex} + /> + ); + })} +
+ ); +} + +function isChatColumn(column: DeckColumn): column is DeckColumn & { kind: "chat" } { + return column.kind === "chat"; +} -- cgit v1.2.3