Skip to content

Commit 67b8359

Browse files
authored
Fix layout issues with the empty states (#96)
2 parents 90883e2 + 4facecc commit 67b8359

File tree

5 files changed

+26
-37
lines changed

5 files changed

+26
-37
lines changed

src/components/EmptyState.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
export function EmptyState() {
22
return (
3-
<div className="mx-auto max-w-4xl py-16 text-center">
3+
<div className="mx-auto max-w-4xl py-8 text-center">
44
<h2 className="mb-4 font-semibold text-2xl">No comments open</h2>
55
<p className="mb-6 text-gray-600">
66
Your drafts will appear here when you start typing in comment boxes
77
across GitHub and Reddit.
88
</p>
9-
<div className="space-y-2">
10-
<button type="button" className="text-blue-600 hover:underline">
11-
How it works
12-
</button>
13-
<span className="mx-2">·</span>
14-
<button type="button" className="text-blue-600 hover:underline">
15-
Check permissions
16-
</button>
17-
</div>
189
</div>
1910
)
2011
}

src/components/NoMatchesState.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ type NoMatchesStateProps = {
33
}
44
export function NoMatchesState({ onClearFilters }: NoMatchesStateProps) {
55
return (
6-
<div className="py-16 text-center">
6+
<div className="py-8 text-center">
77
<p className="mb-4 text-gray-600">No matches found</p>
88
<button
99
type="button"
1010
onClick={onClearFilters}
11-
className="text-blue-600 hover:underline"
11+
className="cursor-pointer text-blue-600 hover:underline"
1212
>
1313
Clear filters
1414
</button>

src/components/PopupRoot.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,8 @@ export function PopupRoot({ drafts }: PopupRootProps) {
101101
})
102102
}
103103

104-
const getTableBody = () => {
105-
if (drafts.length === 0) {
106-
return <EmptyState />
107-
}
108-
109-
if (
110-
filteredDrafts.length === 0 &&
111-
(filters.searchQuery || filters.sentFilter !== "both")
112-
) {
113-
return <NoMatchesState onClearFilters={clearFilters} />
114-
}
115-
116-
return filteredDrafts.map((row) => (
117-
<CommentRow
118-
key={row.spot.unique_key}
119-
row={row}
120-
selectedIds={selectedIds}
121-
toggleSelection={toggleSelection}
122-
handleOpen={handleOpen}
123-
handleTrash={handleTrash}
124-
/>
125-
))
104+
if (drafts.length === 0) {
105+
return <EmptyState />
126106
}
127107

128108
return (
@@ -233,7 +213,25 @@ export function PopupRoot({ drafts }: PopupRootProps) {
233213
</th>
234214
</tr>
235215
</thead>
236-
<tbody className="divide-y divide-gray-200">{getTableBody()}</tbody>
216+
<tbody className="divide-y divide-gray-200">
217+
{filteredDrafts.length === 0 && (
218+
<tr>
219+
<td colSpan={2}>
220+
<NoMatchesState onClearFilters={clearFilters} />
221+
</td>
222+
</tr>
223+
)}
224+
{filteredDrafts.map((row) => (
225+
<CommentRow
226+
key={row.spot.unique_key}
227+
row={row}
228+
selectedIds={selectedIds}
229+
toggleSelection={toggleSelection}
230+
handleOpen={handleOpen}
231+
handleTrash={handleTrash}
232+
/>
233+
))}
234+
</tbody>
237235
</table>
238236
</div>
239237
</div>

src/entrypoints/popup/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
body {
1010
width: var(--popup-width);
11-
height: var(--popup-height);
11+
max-height: var(--popup-height);
1212
font-family:
1313
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
1414
font-size: 14px;

tests/playground/playground-styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body {
1717
/* Popup simulator frame */
1818
.popup-frame {
1919
width: var(--popup-width);
20-
height: var(--popup-height);
20+
max-height: var(--popup-height);
2121
font-size: 14px;
2222
line-height: 1.4;
2323
background: white;

0 commit comments

Comments
 (0)