Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19cc9ca88a |
@@ -38,6 +38,7 @@ export const AnalyticsApi = {
|
|||||||
health: () => api.get('/analytics/health').then((r) => r.data),
|
health: () => api.get('/analytics/health').then((r) => r.data),
|
||||||
topSenders: (take = 20) => api.get(`/analytics/top-senders?take=${take}`).then((r) => r.data),
|
topSenders: (take = 20) => api.get(`/analytics/top-senders?take=${take}`).then((r) => r.data),
|
||||||
volume: (days = 90) => api.get(`/analytics/volume?days=${days}`).then((r) => r.data),
|
volume: (days = 90) => api.get(`/analytics/volume?days=${days}`).then((r) => r.data),
|
||||||
|
heatmap: () => api.get('/analytics/heatmap').then((r) => r.data),
|
||||||
categoryHeatmap: () => api.get('/analytics/category-heatmap').then((r) => r.data),
|
categoryHeatmap: () => api.get('/analytics/category-heatmap').then((r) => r.data),
|
||||||
attachments: () => api.get('/analytics/attachments').then((r) => r.data),
|
attachments: () => api.get('/analytics/attachments').then((r) => r.data),
|
||||||
sidebarCounts: () => api.get('/analytics/sidebar-counts').then((r) => r.data),
|
sidebarCounts: () => api.get('/analytics/sidebar-counts').then((r) => r.data),
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { EmailApi } from '../api/client.js';
|
||||||
|
|
||||||
|
// ── helpers ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const fmtSize = (b) => {
|
||||||
|
if (!b) return '';
|
||||||
|
if (b < 1024) return `${b} B`;
|
||||||
|
if (b < 1048576) return `${(b / 1024).toFixed(0)} KB`;
|
||||||
|
return `${(b / 1048576).toFixed(1)} MB`;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared reading-pane / full single-email view.
|
||||||
|
*
|
||||||
|
* Accepts either an `email` summary object (as emitted by the list rows) or a
|
||||||
|
* bare `emailId`. Fetches the full detail via EmailApi.get(id) and the AI
|
||||||
|
* summary lazily via EmailApi.summary(id). Renders subject, metadata, an AI
|
||||||
|
* summary button, the body, and per-email actions including "Open in Gmail".
|
||||||
|
*
|
||||||
|
* `onClose` collapses the pane.
|
||||||
|
*/
|
||||||
|
export default function EmailDetail({ email: summary, emailId, onClose }) {
|
||||||
|
const id = summary?.id ?? emailId;
|
||||||
|
|
||||||
|
const [detail, setDetail] = useState(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [aiSummary, setAiSummary] = useState(null);
|
||||||
|
const [aiLoading, setAiLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (id == null) return;
|
||||||
|
let cancelled = false;
|
||||||
|
setDetail(null);
|
||||||
|
setLoading(true);
|
||||||
|
setAiSummary(null);
|
||||||
|
setAiLoading(false);
|
||||||
|
EmailApi.get(id)
|
||||||
|
.then((d) => { if (!cancelled) setDetail(d); })
|
||||||
|
.catch(() => { if (!cancelled) setDetail(null); })
|
||||||
|
.finally(() => { if (!cancelled) setLoading(false); });
|
||||||
|
return () => { cancelled = true; };
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const email = detail ?? summary ?? {};
|
||||||
|
|
||||||
|
const fetchAiSummary = () => {
|
||||||
|
if (id == null) return;
|
||||||
|
setAiLoading(true);
|
||||||
|
EmailApi.summary(id)
|
||||||
|
.then((r) => setAiSummary(r.summary))
|
||||||
|
.catch(() => setAiSummary(null))
|
||||||
|
.finally(() => setAiLoading(false));
|
||||||
|
};
|
||||||
|
|
||||||
|
const openInGmail = () => window.open(
|
||||||
|
`https://mail.google.com/mail/u/0/#all/${email.gmailMessageId}`,
|
||||||
|
'_blank', 'noopener,noreferrer'
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="sv-detail">
|
||||||
|
<div className="sv-detail-topbar">
|
||||||
|
<button className="sv-close" onClick={onClose} aria-label="Close reading pane" title="Close">
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="sv-detail-header">
|
||||||
|
<div className="sv-detail-subject">{email.subject || '(no subject)'}</div>
|
||||||
|
<div className="sv-detail-meta">
|
||||||
|
<span>{email.senderDisplayName || email.senderAddress}</span>
|
||||||
|
{email.sentAtUtc && (
|
||||||
|
<>
|
||||||
|
<span className="sv-detail-sep">·</span>
|
||||||
|
<span>{new Date(email.sentAtUtc).toLocaleString()}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{email.sizeEstimateBytes > 0 && (
|
||||||
|
<>
|
||||||
|
<span className="sv-detail-sep">·</span>
|
||||||
|
<span>{fmtSize(email.sizeEstimateBytes)}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!loading && (
|
||||||
|
<div className="sv-ai-summary">
|
||||||
|
{aiSummary != null ? (
|
||||||
|
<div className="sv-ai-summary-text">✨ {aiSummary}</div>
|
||||||
|
) : (
|
||||||
|
<button className="btn-sm" onClick={fetchAiSummary} disabled={aiLoading}>
|
||||||
|
{aiLoading ? 'Summarising…' : '✨ AI summary'}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{loading && <div className="sv-body-loading muted">Loading message…</div>}
|
||||||
|
|
||||||
|
{!loading && detail?.bodyText && (
|
||||||
|
<div className="sv-body">{detail.bodyText}</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!loading && !detail?.bodyText && email.snippet && (
|
||||||
|
<div className="sv-snippet">{email.snippet}</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="sv-detail-actions">
|
||||||
|
<button className="btn-sm" onClick={openInGmail}>Open in Gmail ↗</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,16 +1,13 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Line, Doughnut } from 'react-chartjs-2';
|
import { Bar, Line, Doughnut } from 'react-chartjs-2';
|
||||||
import { Inbox } from 'lucide-react';
|
|
||||||
import { AnalyticsApi } from '../api/client.js';
|
import { AnalyticsApi } from '../api/client.js';
|
||||||
import { Skeleton } from './ui/skeleton.jsx';
|
|
||||||
import { EmptyState } from './ui/misc.jsx';
|
|
||||||
import {
|
import {
|
||||||
Chart as ChartJS, CategoryScale, LinearScale, PointElement,
|
Chart as ChartJS, CategoryScale, LinearScale, BarElement, PointElement,
|
||||||
LineElement, ArcElement, Tooltip, Legend
|
LineElement, ArcElement, Tooltip, Legend
|
||||||
} from 'chart.js';
|
} from 'chart.js';
|
||||||
|
|
||||||
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, ArcElement, Tooltip, Legend);
|
ChartJS.register(CategoryScale, LinearScale, BarElement, PointElement, LineElement, ArcElement, Tooltip, Legend);
|
||||||
|
|
||||||
const fmtBytes = (b) => {
|
const fmtBytes = (b) => {
|
||||||
if (!b) return '0 B';
|
if (!b) return '0 B';
|
||||||
@@ -80,6 +77,32 @@ export function VolumeWidget({ volume }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function HeatmapWidget({ heatmap }) {
|
||||||
|
if (!heatmap) return <Empty />;
|
||||||
|
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
|
const max = Math.max(1, ...heatmap.map((c) => c.count));
|
||||||
|
const grid = {};
|
||||||
|
heatmap.forEach((c) => { grid[`${c.dayOfWeek}-${c.hour}`] = c.count; });
|
||||||
|
return (
|
||||||
|
<div className="widget">
|
||||||
|
<h3>Activity Heatmap</h3>
|
||||||
|
<div className="heatmap">
|
||||||
|
{days.map((d, dow) => (
|
||||||
|
<div className="hm-row" key={dow}>
|
||||||
|
<span className="hm-day">{d}</span>
|
||||||
|
{Array.from({ length: 24 }, (_, h) => {
|
||||||
|
const v = grid[`${dow}-${h}`] || 0;
|
||||||
|
return <span key={h} className="hm-cell" style={{ opacity: 0.1 + 0.9 * (v / max) }} title={`${d} ${h}:00 — ${v}`} />;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
|
|
||||||
// Maps EmailCategory enum name → folder slug or search query
|
// Maps EmailCategory enum name → folder slug or search query
|
||||||
const CAT_SLUG = {
|
const CAT_SLUG = {
|
||||||
Finance: '/app/folder/finance',
|
Finance: '/app/folder/finance',
|
||||||
@@ -112,64 +135,41 @@ const CAT_SLUG = {
|
|||||||
Unknown: '/app/folder/allmail',
|
Unknown: '/app/folder/allmail',
|
||||||
};
|
};
|
||||||
|
|
||||||
// "Emails by Category" — ranked horizontal bar list. Aggregates the
|
export function CategoryHeatmapWidget() {
|
||||||
// category×day-of-week cells into per-category totals; each bar links to
|
|
||||||
// that category's folder via CAT_SLUG.
|
|
||||||
export function CategoryBreakdownWidget() {
|
|
||||||
const [cells, setCells] = useState(null);
|
const [cells, setCells] = useState(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
useEffect(() => { AnalyticsApi.categoryHeatmap().then(setCells).catch(() => setCells([])); }, []);
|
useEffect(() => { AnalyticsApi.categoryHeatmap().then(setCells).catch(() => setCells([])); }, []);
|
||||||
|
|
||||||
if (!cells) {
|
if (!cells) return <div className="widget"><div className="muted">Loading…</div></div>;
|
||||||
return (
|
if (cells.length === 0) return <div className="widget"><h3>Category Heatmap</h3><div className="muted">No data yet — run a sync.</div></div>;
|
||||||
<div className="widget">
|
|
||||||
<h3>Emails by Category</h3>
|
|
||||||
<div className="cat-bars">
|
|
||||||
{Array.from({ length: 6 }, (_, i) => <Skeleton key={i} className="h-6 w-full" />)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const totals = {};
|
const categories = [...new Set(cells.map((c) => c.category))].sort();
|
||||||
cells.forEach((c) => { totals[c.category] = (totals[c.category] || 0) + c.count; });
|
const max = Math.max(1, ...cells.map((c) => c.count));
|
||||||
const ranked = Object.entries(totals)
|
const grid = {};
|
||||||
.map(([category, count]) => ({ category, count }))
|
cells.forEach((c) => { grid[`${c.category}-${c.dayOfWeek}`] = c.count; });
|
||||||
.sort((a, b) => b.count - a.count)
|
|
||||||
.slice(0, 8);
|
|
||||||
|
|
||||||
if (ranked.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="widget">
|
|
||||||
<h3>Emails by Category</h3>
|
|
||||||
<EmptyState icon={Inbox} title="No data yet — run a sync" description="Category totals appear once your inbox has been synced." />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const max = Math.max(1, ...ranked.map((r) => r.count));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="widget">
|
<div className="widget">
|
||||||
<h3>Emails by Category</h3>
|
<h3>Category Heatmap</h3>
|
||||||
<div className="cat-bars">
|
<div className="cat-heatmap">
|
||||||
{ranked.map(({ category, count }) => {
|
<div className="chm-row chm-head">
|
||||||
const dest = CAT_SLUG[category];
|
<span className="chm-label" />
|
||||||
|
{DOW.map((d) => <span key={d} className="chm-col">{d}</span>)}
|
||||||
|
</div>
|
||||||
|
{categories.map((cat) => {
|
||||||
|
const dest = CAT_SLUG[cat];
|
||||||
return (
|
return (
|
||||||
<button
|
<div className="chm-row" key={cat}>
|
||||||
type="button"
|
<span
|
||||||
className={`cat-bar${dest ? ' cat-bar--link' : ''}`}
|
className={`chm-label${dest ? ' chm-label--link' : ''}`}
|
||||||
key={category}
|
title={dest ? `View ${cat} emails` : cat}
|
||||||
disabled={!dest}
|
|
||||||
title={dest ? `View ${category} emails` : category}
|
|
||||||
onClick={dest ? () => navigate(dest) : undefined}
|
onClick={dest ? () => navigate(dest) : undefined}
|
||||||
>
|
>{cat}</span>
|
||||||
<span className="cat-bar-label">{category}</span>
|
{DOW.map((_, dow) => {
|
||||||
<span className="cat-bar-track">
|
const v = grid[`${cat}-${dow}`] || 0;
|
||||||
<span className="cat-bar-fill" style={{ width: `${(count / max) * 100}%` }} />
|
return <span key={dow} className="chm-cell" style={{ opacity: 0.12 + 0.88 * (v / max) }} title={`${cat} · ${DOW[dow]} — ${v}`}>{v || ''}</span>;
|
||||||
</span>
|
})}
|
||||||
<span className="cat-bar-count">{count.toLocaleString()}</span>
|
</div>
|
||||||
</button>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
@@ -196,10 +196,4 @@ export function StorageWidget({ bytes }) {
|
|||||||
return <StatCard label="Estimated Storage" value={fmtBytes(bytes)} />;
|
return <StatCard label="Estimated Storage" value={fmtBytes(bytes)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Empty() {
|
function Empty() { return <div className="widget"><div className="muted">No data yet — run a sync.</div></div>; }
|
||||||
return (
|
|
||||||
<div className="widget">
|
|
||||||
<EmptyState icon={Inbox} title="No data yet — run a sync" description="This widget populates after your inbox has been synced." />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import Layout from './components/Layout.jsx';
|
|||||||
import { ToastProvider, TooltipProvider } from './components/ui';
|
import { ToastProvider, TooltipProvider } from './components/ui';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
|
import './split.css';
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import { AnalyticsApi, LayoutApi, ExportApi, SyncApi } from '../api/client.js';
|
|||||||
import SyncSplash from '../components/SyncSplash.jsx';
|
import SyncSplash from '../components/SyncSplash.jsx';
|
||||||
import {
|
import {
|
||||||
HealthWidget, StatCard, TopSendersWidget, VolumeWidget,
|
HealthWidget, StatCard, TopSendersWidget, VolumeWidget,
|
||||||
CategoryBreakdownWidget, AttachmentsWidget, StorageWidget
|
CategoryHeatmapWidget, AttachmentsWidget, StorageWidget
|
||||||
} from '../components/widgets.jsx';
|
} from '../components/widgets.jsx';
|
||||||
import { Skeleton } from '../components/ui/skeleton.jsx';
|
|
||||||
|
|
||||||
// Default grid geometry; overridden by the user's saved layout.
|
// Default grid geometry; overridden by the user's saved layout.
|
||||||
const DEFAULT_LAYOUT = [
|
const DEFAULT_LAYOUT = [
|
||||||
@@ -18,23 +17,12 @@ const DEFAULT_LAYOUT = [
|
|||||||
{ i: 'storage', x: 7, y: 0, w: 2, h: 2 },
|
{ i: 'storage', x: 7, y: 0, w: 2, h: 2 },
|
||||||
{ i: 'top-senders', x: 3, y: 2, w: 3, h: 5 },
|
{ i: 'top-senders', x: 3, y: 2, w: 3, h: 5 },
|
||||||
{ i: 'volume', x: 6, y: 2, w: 6, h: 4 },
|
{ i: 'volume', x: 6, y: 2, w: 6, h: 4 },
|
||||||
{ i: 'category-breakdown', x: 0, y: 5, w: 6, h: 5 },
|
{ i: 'category-heatmap', x: 0, y: 5, w: 6, h: 5 },
|
||||||
{ i: 'attachments', x: 6, y: 6, w: 4, h: 4 },
|
{ i: 'attachments', x: 6, y: 6, w: 4, h: 4 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const ALL_WIDGETS = DEFAULT_LAYOUT.map((l) => l.i);
|
const ALL_WIDGETS = DEFAULT_LAYOUT.map((l) => l.i);
|
||||||
|
|
||||||
function WidgetSkeleton() {
|
|
||||||
return (
|
|
||||||
<div className="widget">
|
|
||||||
<Skeleton className="mb-3 h-4 w-1/3" />
|
|
||||||
<Skeleton className="mb-2 h-3 w-full" />
|
|
||||||
<Skeleton className="mb-2 h-3 w-5/6" />
|
|
||||||
<Skeleton className="h-3 w-2/3" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
const [data, setData] = useState(null);
|
const [data, setData] = useState(null);
|
||||||
const [layout, setLayout] = useState(DEFAULT_LAYOUT);
|
const [layout, setLayout] = useState(DEFAULT_LAYOUT);
|
||||||
@@ -99,18 +87,15 @@ export default function Dashboard() {
|
|||||||
const visibleLayout = useMemo(() => layout.filter((l) => !hidden.includes(l.i)), [layout, hidden]);
|
const visibleLayout = useMemo(() => layout.filter((l) => !hidden.includes(l.i)), [layout, hidden]);
|
||||||
|
|
||||||
const render = (key) => {
|
const render = (key) => {
|
||||||
// category-breakdown self-fetches, so it renders regardless of dashboard load state.
|
|
||||||
if (key === 'category-breakdown') return <CategoryBreakdownWidget />;
|
|
||||||
// While the dashboard payload loads, show a skeleton placeholder per widget.
|
|
||||||
if (!data) return <WidgetSkeleton />;
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'inbox-health': return <HealthWidget health={data.health} />;
|
case 'inbox-health': return <HealthWidget health={data?.health} />;
|
||||||
case 'total-emails': return <StatCard label="Total Emails" value={(data.totalEmails ?? 0).toLocaleString()} to="/app/folder/allmail" />;
|
case 'total-emails': return <StatCard label="Total Emails" value={(data?.totalEmails ?? 0).toLocaleString()} to="/app/folder/allmail" />;
|
||||||
case 'unread-emails': return <StatCard label="Unread" value={(data.unreadEmails ?? 0).toLocaleString()} to="/app/folder/unread" />;
|
case 'unread-emails': return <StatCard label="Unread" value={(data?.unreadEmails ?? 0).toLocaleString()} to="/app/folder/unread" />;
|
||||||
case 'storage': return <StorageWidget bytes={data.storageEstimateBytes} />;
|
case 'storage': return <StorageWidget bytes={data?.storageEstimateBytes} />;
|
||||||
case 'top-senders': return <TopSendersWidget senders={data.topSenders} />;
|
case 'top-senders': return <TopSendersWidget senders={data?.topSenders} />;
|
||||||
case 'volume': return <VolumeWidget volume={data.volumeOverTime} />;
|
case 'volume': return <VolumeWidget volume={data?.volumeOverTime} />;
|
||||||
case 'attachments': return <AttachmentsWidget attachments={data.attachmentBreakdown} />;
|
case 'category-heatmap': return <CategoryHeatmapWidget />;
|
||||||
|
case 'attachments': return <AttachmentsWidget attachments={data?.attachmentBreakdown} />;
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import { useEffect, useState, useCallback, useRef } from 'react';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { SearchApi } from '../api/client.js';
|
import { SearchApi } from '../api/client.js';
|
||||||
import EmailRow from '../components/EmailRow.jsx';
|
import EmailRow from '../components/EmailRow.jsx';
|
||||||
|
import EmailDetail from '../components/EmailDetail.jsx';
|
||||||
import BulkToolbar from '../components/BulkToolbar.jsx';
|
import BulkToolbar from '../components/BulkToolbar.jsx';
|
||||||
|
import { Skeleton, EmptyState } from '../components/ui';
|
||||||
import useSelection from '../hooks/useSelection.js';
|
import useSelection from '../hooks/useSelection.js';
|
||||||
import useListKeyboardNav from '../hooks/useListKeyboardNav.js';
|
import useListKeyboardNav from '../hooks/useListKeyboardNav.js';
|
||||||
|
|
||||||
@@ -35,6 +37,20 @@ const FOLDER_META = {
|
|||||||
|
|
||||||
const PAGE_SIZE = 50;
|
const PAGE_SIZE = 50;
|
||||||
|
|
||||||
|
function ListSkeleton({ rows = 6 }) {
|
||||||
|
return (
|
||||||
|
<div className="sv-skeleton-list" aria-hidden="true">
|
||||||
|
{Array.from({ length: rows }).map((_, i) => (
|
||||||
|
<div className="sv-skeleton-row" key={i}>
|
||||||
|
<Skeleton className="h-3 w-3 rounded-full" />
|
||||||
|
<Skeleton className="h-3 flex-1" />
|
||||||
|
<Skeleton className="h-3 w-16" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function FolderView() {
|
export default function FolderView() {
|
||||||
const { slug } = useParams();
|
const { slug } = useParams();
|
||||||
@@ -46,6 +62,7 @@ export default function FolderView() {
|
|||||||
const [hasMore, setHasMore] = useState(true);
|
const [hasMore, setHasMore] = useState(true);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
const [selectedEmail, setSelectedEmail] = useState(null);
|
||||||
const { selected, toggle, clear, removeIds, selectedIds } = useSelection();
|
const { selected, toggle, clear, removeIds, selectedIds } = useSelection();
|
||||||
const focusedId = useListKeyboardNav(emails, (id) => setEmails((prev) => prev.filter((x) => x.id !== id)));
|
const focusedId = useListKeyboardNav(emails, (id) => setEmails((prev) => prev.filter((x) => x.id !== id)));
|
||||||
|
|
||||||
@@ -56,6 +73,7 @@ export default function FolderView() {
|
|||||||
setPage(1);
|
setPage(1);
|
||||||
setHasMore(true);
|
setHasMore(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
setSelectedEmail(null);
|
||||||
clear();
|
clear();
|
||||||
}, [slug, clear]);
|
}, [slug, clear]);
|
||||||
|
|
||||||
@@ -115,8 +133,15 @@ export default function FolderView() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<div className={`sv-split${selectedEmail ? ' sv-split--open' : ''}`}>
|
||||||
|
<div className="sv-list-pane">
|
||||||
|
{loading && emails.length === 0 && !error && <ListSkeleton />}
|
||||||
|
|
||||||
{!loading && !error && emails.length === 0 && (
|
{!loading && !error && emails.length === 0 && (
|
||||||
<div className="fv-empty">No emails in this folder.</div>
|
<EmptyState
|
||||||
|
title="No emails in this folder"
|
||||||
|
description="Nothing here yet — try another folder or run a sync."
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{emails.length > 0 && (
|
{emails.length > 0 && (
|
||||||
@@ -129,7 +154,11 @@ export default function FolderView() {
|
|||||||
selected={selected.has(e.id)}
|
selected={selected.has(e.id)}
|
||||||
onToggleSelect={toggle}
|
onToggleSelect={toggle}
|
||||||
focused={focusedId === e.id}
|
focused={focusedId === e.id}
|
||||||
onRemove={(id) => setEmails((prev) => prev.filter((x) => x.id !== id))}
|
onOpen={(email) => setSelectedEmail(email)}
|
||||||
|
onRemove={(id) => {
|
||||||
|
setEmails((prev) => prev.filter((x) => x.id !== id));
|
||||||
|
setSelectedEmail((cur) => (cur?.id === id ? null : cur));
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -139,10 +168,22 @@ export default function FolderView() {
|
|||||||
{/* Sentinel — triggers next page load when scrolled into view */}
|
{/* Sentinel — triggers next page load when scrolled into view */}
|
||||||
<div ref={sentinelRef} className="fv-sentinel" />
|
<div ref={sentinelRef} className="fv-sentinel" />
|
||||||
|
|
||||||
{loading && <div className="fv-loading-more">Loading…</div>}
|
{loading && emails.length > 0 && <div className="fv-loading-more">Loading…</div>}
|
||||||
{!hasMore && emails.length > 0 && (
|
{!hasMore && emails.length > 0 && (
|
||||||
<div className="fv-end">— {emails.length.toLocaleString()} emails —</div>
|
<div className="fv-end">— {emails.length.toLocaleString()} emails —</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{selectedEmail && (
|
||||||
|
<aside className="sv-reading-pane">
|
||||||
|
<EmailDetail
|
||||||
|
key={selectedEmail.id}
|
||||||
|
email={selectedEmail}
|
||||||
|
onClose={() => setSelectedEmail(null)}
|
||||||
|
/>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,29 @@ import { useEffect, useState, useCallback, useRef } from 'react';
|
|||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { SearchApi } from '../api/client.js';
|
import { SearchApi } from '../api/client.js';
|
||||||
import EmailRow from '../components/EmailRow.jsx';
|
import EmailRow from '../components/EmailRow.jsx';
|
||||||
|
import EmailDetail from '../components/EmailDetail.jsx';
|
||||||
import BulkToolbar from '../components/BulkToolbar.jsx';
|
import BulkToolbar from '../components/BulkToolbar.jsx';
|
||||||
|
import { Skeleton, EmptyState } from '../components/ui';
|
||||||
import useSelection from '../hooks/useSelection.js';
|
import useSelection from '../hooks/useSelection.js';
|
||||||
import useListKeyboardNav from '../hooks/useListKeyboardNav.js';
|
import useListKeyboardNav from '../hooks/useListKeyboardNav.js';
|
||||||
import useSavedSearches from '../hooks/useSavedSearches.js';
|
import useSavedSearches from '../hooks/useSavedSearches.js';
|
||||||
|
|
||||||
const PAGE_SIZE = 50;
|
const PAGE_SIZE = 50;
|
||||||
|
|
||||||
|
function ListSkeleton({ rows = 6 }) {
|
||||||
|
return (
|
||||||
|
<div className="sv-skeleton-list" aria-hidden="true">
|
||||||
|
{Array.from({ length: rows }).map((_, i) => (
|
||||||
|
<div className="sv-skeleton-row" key={i}>
|
||||||
|
<Skeleton className="h-3 w-3 rounded-full" />
|
||||||
|
<Skeleton className="h-3 flex-1" />
|
||||||
|
<Skeleton className="h-3 w-16" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function SearchResults() {
|
export default function SearchResults() {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@@ -20,6 +36,7 @@ export default function SearchResults() {
|
|||||||
const [hasMore, setHasMore] = useState(true);
|
const [hasMore, setHasMore] = useState(true);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
const [selectedEmail, setSelectedEmail] = useState(null);
|
||||||
const { selected, toggle, clear, removeIds, selectedIds } = useSelection();
|
const { selected, toggle, clear, removeIds, selectedIds } = useSelection();
|
||||||
const focusedId = useListKeyboardNav(emails, (id) => setEmails((prev) => prev.filter((x) => x.id !== id)));
|
const focusedId = useListKeyboardNav(emails, (id) => setEmails((prev) => prev.filter((x) => x.id !== id)));
|
||||||
const { searches: savedSearches, add: addSavedSearch } = useSavedSearches();
|
const { searches: savedSearches, add: addSavedSearch } = useSavedSearches();
|
||||||
@@ -36,6 +53,7 @@ export default function SearchResults() {
|
|||||||
setPage(1);
|
setPage(1);
|
||||||
setHasMore(true);
|
setHasMore(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
setSelectedEmail(null);
|
||||||
clear();
|
clear();
|
||||||
}, [q, clear]);
|
}, [q, clear]);
|
||||||
|
|
||||||
@@ -83,11 +101,13 @@ export default function SearchResults() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!q.trim() && <div className="fv-empty">Enter a search query above.</div>}
|
{!q.trim() && (
|
||||||
{error && <div className="fv-error">{error}</div>}
|
<EmptyState
|
||||||
{!loading && !error && q.trim() && emails.length === 0 && !hasMore && (
|
title="Search your mail"
|
||||||
<div className="fv-empty">No results for "{q}".</div>
|
description="Enter a search query above to find emails."
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
{error && <div className="fv-error">{error}</div>}
|
||||||
|
|
||||||
<BulkToolbar
|
<BulkToolbar
|
||||||
selectedIds={selectedIds}
|
selectedIds={selectedIds}
|
||||||
@@ -100,6 +120,18 @@ export default function SearchResults() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{q.trim() && (
|
||||||
|
<div className={`sv-split${selectedEmail ? ' sv-split--open' : ''}`}>
|
||||||
|
<div className="sv-list-pane">
|
||||||
|
{loading && emails.length === 0 && !error && <ListSkeleton />}
|
||||||
|
|
||||||
|
{!loading && !error && emails.length === 0 && !hasMore && (
|
||||||
|
<EmptyState
|
||||||
|
title={`No results for "${q}"`}
|
||||||
|
description="Try a different search term or filter."
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{emails.length > 0 && (
|
{emails.length > 0 && (
|
||||||
<table className="email-list">
|
<table className="email-list">
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -110,7 +142,11 @@ export default function SearchResults() {
|
|||||||
selected={selected.has(e.id)}
|
selected={selected.has(e.id)}
|
||||||
onToggleSelect={toggle}
|
onToggleSelect={toggle}
|
||||||
focused={focusedId === e.id}
|
focused={focusedId === e.id}
|
||||||
onRemove={(id) => setEmails((prev) => prev.filter((x) => x.id !== id))}
|
onOpen={(email) => setSelectedEmail(email)}
|
||||||
|
onRemove={(id) => {
|
||||||
|
setEmails((prev) => prev.filter((x) => x.id !== id));
|
||||||
|
setSelectedEmail((cur) => (cur?.id === id ? null : cur));
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -118,10 +154,23 @@ export default function SearchResults() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div ref={sentinelRef} className="fv-sentinel" />
|
<div ref={sentinelRef} className="fv-sentinel" />
|
||||||
{loading && <div className="fv-loading-more">Loading…</div>}
|
{loading && emails.length > 0 && <div className="fv-loading-more">Loading…</div>}
|
||||||
{!hasMore && emails.length > 0 && (
|
{!hasMore && emails.length > 0 && (
|
||||||
<div className="fv-end">— {emails.length.toLocaleString()} results —</div>
|
<div className="fv-end">— {emails.length.toLocaleString()} results —</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{selectedEmail && (
|
||||||
|
<aside className="sv-reading-pane">
|
||||||
|
<EmailDetail
|
||||||
|
key={selectedEmail.id}
|
||||||
|
email={selectedEmail}
|
||||||
|
onClose={() => setSelectedEmail(null)}
|
||||||
|
/>
|
||||||
|
</aside>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
/* ── Split-view reading pane ────────────────────────────────────────────────
|
||||||
|
* Owned by Unit 1. Gmail/Outlook-style master-detail: the email list stays on
|
||||||
|
* the left, a collapsible + horizontally resizable reading pane sits on the
|
||||||
|
* right. Below 768px the pane overlays the list (mobile stack) instead of
|
||||||
|
* squishing the columns side-by-side.
|
||||||
|
*
|
||||||
|
* These pages (.folder-view) are styled from styles.css, so we reference its
|
||||||
|
* legacy CSS variables (--panel, --panel-2, --text, --muted, --accent) with
|
||||||
|
* hardcoded hex fallbacks. The modern index.css tokens are stored as raw HSL
|
||||||
|
* channel triplets and only work via hsl(var(--x)), so they are NOT used bare
|
||||||
|
* here.
|
||||||
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
.sv-split {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Left column — the list. Flexes to fill remaining space and scrolls itself. */
|
||||||
|
.sv-list-pane {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Right column — the reading pane. Resizable via the native handle; the width
|
||||||
|
* gives it a sensible default, and the user can drag the bottom-right corner.
|
||||||
|
* `resize: horizontal` needs `overflow` other than visible. */
|
||||||
|
.sv-reading-pane {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: clamp(320px, 42%, 640px);
|
||||||
|
min-width: 300px;
|
||||||
|
max-width: 80vw;
|
||||||
|
border-left: 1px solid var(--panel-2, #222a3d);
|
||||||
|
overflow: auto;
|
||||||
|
resize: horizontal;
|
||||||
|
background: var(--panel, #1a2030);
|
||||||
|
align-self: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Reading pane inner content ─────────────────────────────────────────── */
|
||||||
|
.sv-detail { padding: 18px 20px; }
|
||||||
|
|
||||||
|
.sv-detail-topbar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
.sv-close {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--panel-2, #222a3d);
|
||||||
|
color: var(--muted, #8b93a7);
|
||||||
|
border-radius: 6px;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.sv-close:hover {
|
||||||
|
background: var(--panel-2, #222a3d);
|
||||||
|
color: var(--text, #e6e9f0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sv-detail-header { margin-bottom: 14px; }
|
||||||
|
.sv-detail-subject {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
color: var(--text, #e6e9f0);
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
.sv-detail-meta {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--muted, #8b93a7);
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.sv-detail-sep { opacity: 0.4; }
|
||||||
|
|
||||||
|
.sv-ai-summary { margin-bottom: 14px; }
|
||||||
|
.sv-ai-summary-text {
|
||||||
|
background: var(--panel-2, #222a3d);
|
||||||
|
border: 1px solid var(--panel-2, #222a3d);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text, #e6e9f0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sv-body-loading { padding: 8px 0 18px; }
|
||||||
|
.sv-body {
|
||||||
|
background: var(--panel, #1a2030);
|
||||||
|
border: 1px solid var(--panel-2, #222a3d);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 16px 18px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: var(--text, #e6e9f0);
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
max-height: 60vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.sv-snippet {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--muted, #8b93a7);
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
.sv-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||||
|
|
||||||
|
/* ── List loading / empty states ───────────────────────────────────────── */
|
||||||
|
.sv-skeleton-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
.sv-skeleton-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Mobile: stack / overlay the reading pane ──────────────────────────── */
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.sv-reading-pane {
|
||||||
|
position: fixed;
|
||||||
|
inset: 56px 0 0 0; /* below the topbar */
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100vw;
|
||||||
|
min-width: 0;
|
||||||
|
border-left: none;
|
||||||
|
resize: none;
|
||||||
|
z-index: 40;
|
||||||
|
}
|
||||||
|
/* When the pane is open, hide the underlying list to avoid double-scroll. */
|
||||||
|
.sv-split.sv-split--open .sv-list-pane {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-15
@@ -115,6 +115,8 @@ button:disabled { opacity: 0.5; cursor: default; }
|
|||||||
.widget--link:hover { border-color: var(--accent); }
|
.widget--link:hover { border-color: var(--accent); }
|
||||||
.mini-row--link { cursor: pointer; }
|
.mini-row--link { cursor: pointer; }
|
||||||
.mini-row--link:hover td { color: var(--accent); }
|
.mini-row--link:hover td { color: var(--accent); }
|
||||||
|
.chm-label--link { cursor: pointer; text-decoration: underline dotted; }
|
||||||
|
.chm-label--link:hover { color: var(--accent); }
|
||||||
.widget canvas { flex: 1; min-height: 0; }
|
.widget canvas { flex: 1; min-height: 0; }
|
||||||
|
|
||||||
.stat { align-items: flex-start; justify-content: center; }
|
.stat { align-items: flex-start; justify-content: center; }
|
||||||
@@ -133,21 +135,17 @@ table.grid th, table.grid td { padding: 8px; border-bottom: 1px solid #2c3550; t
|
|||||||
.num { text-align: right; }
|
.num { text-align: right; }
|
||||||
.muted { color: var(--muted); font-size: 12px; }
|
.muted { color: var(--muted); font-size: 12px; }
|
||||||
|
|
||||||
/* Emails by Category — ranked horizontal bars */
|
.heatmap { display: flex; flex-direction: column; gap: 2px; }
|
||||||
.cat-bars { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
|
.hm-row { display: flex; align-items: center; gap: 2px; }
|
||||||
.cat-bar {
|
.hm-day { width: 30px; font-size: 10px; color: var(--muted); }
|
||||||
display: grid; grid-template-columns: 92px 1fr 40px; gap: 8px; align-items: center;
|
.hm-cell { width: 10px; height: 10px; background: var(--accent); border-radius: 2px; }
|
||||||
width: 100%; padding: 3px 4px; margin: 0; border: none; background: transparent;
|
|
||||||
border-radius: 6px; text-align: left; font: inherit; color: inherit;
|
/* Category heatmap */
|
||||||
}
|
.cat-heatmap { display: flex; flex-direction: column; gap: 3px; overflow: auto; }
|
||||||
.cat-bar--link { cursor: pointer; }
|
.chm-row { display: grid; grid-template-columns: 92px repeat(7, 1fr); gap: 3px; align-items: stretch; }
|
||||||
.cat-bar--link:hover { background: rgba(255, 255, 255, 0.04); }
|
.chm-head .chm-col { font-size: 10px; color: var(--muted); text-align: center; }
|
||||||
.cat-bar:disabled { cursor: default; }
|
.chm-label { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
.cat-bar-label { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
.chm-cell { background: var(--accent); border-radius: 3px; min-height: 22px; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
|
||||||
.cat-bar-track { height: 14px; background: rgba(255, 255, 255, 0.06); border-radius: 4px; overflow: hidden; }
|
|
||||||
.cat-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
|
|
||||||
.cat-bar-count { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
|
|
||||||
.cat-bar--link:hover .cat-bar-label { color: var(--accent); }
|
|
||||||
|
|
||||||
/* react-grid-layout resize handle — make it clearly visible on the dark theme */
|
/* react-grid-layout resize handle — make it clearly visible on the dark theme */
|
||||||
.react-resizable-handle {
|
.react-resizable-handle {
|
||||||
|
|||||||
Reference in New Issue
Block a user