Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(collections/dashboard): basic indicator of empty collection
Elian Dorana366213b5daf
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex d6e31553b6..4708b28497 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2349,7 +2349,8 @@},"dashboard_view": {"refresh-widget": "Refresh",- "remove-widget": "Remove from dashboard"+ "remove-widget": "Remove from dashboard",+ "empty-hint": "Any child note becomes a widget. Drag a note here from tree or create a new one."},"presentation_view": {"edit-slide": "Edit this slide",diff --git a/apps/client/src/widgets/collections/dashboard/index.css b/apps/client/src/widgets/collections/dashboard/index.cssindex d286c6e7e0..1502f90475 100644--- a/apps/client/src/widgets/collections/dashboard/index.css+++ b/apps/client/src/widgets/collections/dashboard/index.css@@ -10,6 +10,52 @@padding: 0 calc(var(--content-margin-inline) - 8px);}+ /* Empty-state illustration: ghost tiles laid out on the same metrics as the real grid+ (12 columns, 80px rows, 8px gaps) so they preview where widgets will land, with the hint+ flowing below them rather than overlapping. */+ .dashboard-empty-state {+ pointer-events: none;+ padding: 8px;+ }++ .dashboard-ghost-grid {+ display: grid;+ grid-template-columns: repeat(12, 1fr);+ grid-auto-rows: 80px;+ gap: 8px;+ }++ .dashboard-ghost-widget {+ border: 2px dashed var(--main-border-color);+ border-radius: 6px;+ opacity: 0.5;++ &:nth-child(1) { grid-area: 1 / 1 / 4 / 5; }+ &:nth-child(2) { grid-area: 1 / 5 / 3 / 9; }+ &:nth-child(3) { grid-area: 1 / 9 / 5 / 13; }+ &:nth-child(4) { grid-area: 4 / 1 / 6 / 5; }+ &:nth-child(5) { grid-area: 3 / 5 / 6 / 9; }+ }++ .dashboard-empty-hint {+ margin-top: 1.5em;+ color: var(--muted-text-color);+ text-align: center;++ p {+ margin: 0 auto;+ max-width: 22em;+ }+ }++ /* The ghost grid mirrors the 12-column layout, which is meaningless once the real grid+ collapses to a single column — drop it there and keep just the hint. */+ @media (max-width: 768px) {+ .dashboard-ghost-grid {+ display: none;+ }+ }+.dashboard-widget {display: flex;flex-direction: column;diff --git a/apps/client/src/widgets/collections/dashboard/index.tsx b/apps/client/src/widgets/collections/dashboard/index.tsxindex 96ebcfc524..1c3edd1020 100644--- a/apps/client/src/widgets/collections/dashboard/index.tsx+++ b/apps/client/src/widgets/collections/dashboard/index.tsx@@ -214,6 +214,7 @@ export default function DashboardView({ note, noteIds, viewConfig, saveConfig, h/>))}</div>+ {noteIds.length === 0 && <DashboardEmptyState />}</div></div>);@@ -308,6 +309,24 @@ function DashboardWidget({ note, parentNote, highlightedTokens, includeArchived,);}+/** Shown when the dashboard has no widgets: a few ghost tiles hint at the underlying grid, with a+ * prompt to drag notes in. Purely decorative — pointer-events are disabled so drops still land on+ * the scroll container behind it. */+function DashboardEmptyState() {+ return (+ <div className="dashboard-empty-state">+ <div className="dashboard-ghost-grid" aria-hidden="true">+ {Array.from({ length: 5 }).map((_, index) => (+ <div key={index} className="dashboard-ghost-widget" />+ ))}+ </div>+ <div className="dashboard-empty-hint">+ <p>{t("dashboard_view.empty-hint")}</p>+ </div>+ </div>+ );+}+/** Translate a drop event's viewport coordinates into a grid cell, or null when auto-positioning* is preferable (the grid is in collapsed single-column mode or has no measurable geometry yet). */function computeDropCell(grid: GridStack, container: HTMLElement, e: DragEvent): Pick<DashboardWidgetLayout, "x" | "y"> | null {