Give every empty list one empty state and one add action

EmptyState now has a single action shape: centred at its own width on
the 44 px tap floor, never stretched edge to edge on some pages and
compact on others; the per-call-site size switch is gone, and the
dashed card takes the card radius. While a list is empty its empty
state carries the add action, so the header drops its own add button
there (measurements, mood, medications, labs, vaccinations, documents,
illness, check-ups, visits, procedures). The dashboard medication tile
of an account without medications offers 'Add a medication' instead of
'no data in the chosen range'.
This commit is contained in:
Marc-André Bombeck committed 2026-10-08 18:53:24 +02:00
1 parent 793c19e179
commit 005cb32ea8
30 files changed
+158 -65

No files matched your search

+12 -1
View File
@@ -174,9 +174,14 @@ interface MoodListProps {
* rendering a no-op button.
*/
onAddFirst?: () => void;
/**
* Told whether the unfiltered list is empty, so the page can drop its
* header add button while the empty state carries the add action.
*/
onEmptyChange?: (empty: boolean) => void;
}
export function MoodList({ onAddFirst }: MoodListProps = {}) {
export function MoodList({ onAddFirst, onEmptyChange }: MoodListProps = {}) {
const { t } = useTranslations();
const fmt = useFormatters();
const { isAuthenticated } = useAuth();
@@ -362,6 +367,12 @@ export function MoodList({ onAddFirst }: MoodListProps = {}) {
enabled: isAuthenticated,
});
const listEmpty =
!isLoading && !isError && !data?.entries?.length && moodFilter === "ALL";
useEffect(() => {
onEmptyChange?.(listEmpty);
}, [listEmpty, onEmptyChange]);
// v1.16.4 — deletes are soft (tombstones), so the success toast can
// carry a real Undo: it POSTs the ids to `/api/mood-entries/restore`,
// which clears `deletedAt` and re-fires the same dependent-key bundle.