Skip to content

Commit 06edf4c

Browse files
authored
Feature/null search (#421)
* show custom message when search results are empty * reduce padding on empty message for small screens * sort categories so empty results are at the end * format * overflow hidden for tables with empty messge * only iterate over selected categories once when ordering buckets * format
1 parent c3a0a47 commit 06edf4c

3 files changed

Lines changed: 109 additions & 2 deletions

File tree

src/components/CategorySections.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,20 @@ const CategorySections: React.FC<CategorySectionsProps> = ({
5858
[filteredList, selectedCategories],
5959
);
6060

61+
// Sort categories: non-empty first, empty last (preserves relative order)
62+
const sortedCategories = React.useMemo(() => {
63+
const nonEmpty: CategoryLabel[] = [];
64+
const empty: CategoryLabel[] = [];
65+
for (const cat of selectedCategories) {
66+
(buckets[cat]?.length ? nonEmpty : empty).push(cat);
67+
}
68+
return [...nonEmpty, ...empty];
69+
}, [selectedCategories, buckets]);
70+
6171
return (
6272
<>
63-
{selectedCategories.map((cat) => {
73+
{sortedCategories.map((cat) => {
6474
const data = buckets[cat] || [];
65-
if (!data.length) return null;
6675
return (
6776
<CellLineTable
6877
key={cat}

src/components/CellLineTable/index.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const {
1515
comingSoon,
1616
container,
1717
dataComplete,
18+
emptyMessage,
1819
hoveredRow,
20+
link,
1921
tableTitle,
2022
titleContainer,
2123
} = require("../../style/table.module.css");
@@ -118,6 +120,36 @@ const CellLineTable = ({
118120
};
119121
});
120122

123+
const noDataMessage = (
124+
<div className={emptyMessage}>
125+
<h2>We can't seem to find what you're looking for...</h2>
126+
<p>
127+
But don't cell yourself short! Try adjusting your search
128+
parameters or reach out to our{" "}
129+
<a
130+
rel="noopener noreferrer"
131+
target="_blank"
132+
href="https://forum.allencell.org/"
133+
className={link}
134+
>
135+
forum
136+
</a>{" "}
137+
to ask about availability.
138+
</p>
139+
<p>
140+
Looking for a cell line with a disease mutation?{" "}
141+
<a
142+
rel="noopener noreferrer"
143+
target="_blank"
144+
href="https://cell-catalog.allencell.org/disease-catalog/"
145+
className={link}
146+
>
147+
Check out our Disease Cell Catalog.
148+
</a>
149+
</p>
150+
</div>
151+
);
152+
121153
return (
122154
<>
123155
<Table
@@ -148,6 +180,8 @@ const CellLineTable = ({
148180
dataSource={cellLines}
149181
showSorterTooltip={false}
150182
sortDirections={["ascend", "descend", "ascend"]}
183+
showHeader={cellLines.length > 0}
184+
locale={{ emptyText: noDataMessage }}
151185
/>
152186
</>
153187
);

src/style/table.module.css

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,44 @@
325325
background-color: var(--WHITE);
326326
}
327327

328+
.container :global(.ant-table-content):has(.empty-message) {
329+
overflow: hidden !important;
330+
}
331+
332+
.container .empty-message {
333+
padding: 40px 0;
334+
color: var(--BLACK);
335+
text-align: center;
336+
margin: 0px 29%;
337+
}
338+
339+
.container .empty-message h2 {
340+
font-size: 32px;
341+
font-weight: 600;
342+
}
343+
344+
.container .empty-message p {
345+
font-size: 24px;
346+
}
347+
348+
.link {
349+
color: var(--link-color);
350+
}
351+
352+
@media screen and (max-width: 1720px) {
353+
.container .empty-message {
354+
margin: 0px 18%;
355+
}
356+
357+
.container .empty-message h2 {
358+
font-size: 22px;
359+
}
360+
361+
.container .empty-message p {
362+
font-size: 18px;
363+
}
364+
}
365+
328366
@media screen and (max-width: 744px) {
329367
.container h4 {
330368
font-size: 20px;
@@ -334,6 +372,19 @@
334372
.container :global(.ant-table-cell).cell-line-id {
335373
padding: 8px 4px 8px 14px;
336374
}
375+
376+
.container .empty-message {
377+
padding: 30px 0;
378+
margin: 0px 14%;
379+
}
380+
381+
.container .empty-message h2 {
382+
font-size: 20px;
383+
}
384+
385+
.container .empty-message p {
386+
font-size: 16px;
387+
}
337388
}
338389

339390
@media screen and (max-width: 576px) {
@@ -361,4 +412,17 @@
361412
) {
362413
width: initial;
363414
}
415+
416+
.container .empty-message {
417+
padding: 0px;
418+
margin: 0px 6%;
419+
}
420+
421+
.container .empty-message h2 {
422+
font-size: 20px;
423+
}
424+
425+
.container .empty-message p {
426+
font-size: 16px;
427+
}
364428
}

0 commit comments

Comments
 (0)