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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
import { useEffect } from "react";
import type { FullscreenState } from "../types/app";
import { TweetCard } from "./TweetCard";
interface FullscreenColumnProps {
state: FullscreenState;
onExit: () => void;
onNavigate: (step: number) => void;
onSwitchColumn: (step: number) => void;
hasPrevColumn: boolean;
hasNextColumn: boolean;
onAddColumn: () => void;
}
export function FullscreenColumn({
state,
onExit,
onNavigate,
onSwitchColumn,
hasPrevColumn,
hasNextColumn,
onAddColumn,
}: FullscreenColumnProps) {
console.log({ state });
const tweet = state.tweets[state.index];
const hasTweets = state.tweets.length > 0;
useEffect(() => {
const handler = (event: KeyboardEvent) => {
if (event.key === "Escape") {
onExit();
return;
}
if (event.key === "ArrowDown") {
event.preventDefault();
onNavigate(1);
}
if (event.key === "ArrowUp") {
event.preventDefault();
onNavigate(-1);
}
if (event.key === "ArrowRight") {
event.preventDefault();
if (hasNextColumn) {
onSwitchColumn(1);
} else {
onAddColumn();
}
}
if (event.key === "ArrowLeft") {
event.preventDefault();
if (hasPrevColumn) {
onSwitchColumn(-1);
}
}
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [
onExit,
onNavigate,
onSwitchColumn,
hasPrevColumn,
hasNextColumn,
onAddColumn,
]);
return (
<div className="fullscreen-overlay">
<button
className="ghost fullscreen-close"
onClick={onExit}
aria-label="Close fullscreen view"
>
×
</button>
<div className="fullscreen-content">
<header>
<p className="eyebrow">
{state.columnLabel}@{state.column.account}
</p>
<p className="muted tiny">
{hasTweets
? `${state.index + 1} / ${state.tweets.length}`
: "0 / 0"}
</p>
</header>
<div className="fullscreen-card">
{hasTweets && tweet ? (
<TweetCard tweet={tweet} accent={state.accent} />
) : (
<div className="fullscreen-empty">
<p>No tweets loaded for this column yet.</p>
<p className="muted">
Try refreshing the column or exit fullscreen.
</p>
</div>
)}
</div>
<div className="fullscreen-controls">
<button
className="ghost"
onClick={() => onNavigate(-1)}
disabled={!hasTweets || state.index === 0}
>
↑ Previous tweet
</button>
<button
className="ghost"
onClick={() => onNavigate(1)}
disabled={!hasTweets || state.index >= state.tweets.length - 1}
>
Next tweet ↓
</button>
</div>
<div className="fullscreen-column-controls">
<button
className="ghost"
onClick={() => onSwitchColumn(-1)}
disabled={!hasPrevColumn}
>
← Previous column
</button>
<button
className="ghost"
onClick={() => (hasNextColumn ? onSwitchColumn(1) : onAddColumn())}
>
{hasNextColumn ? "Next column →" : "+ Add column →"}
</button>
</div>
</div>
</div>
);
}
|