Bring daily check-ins forward with compact workspace layout

This commit is contained in:
syntaxbullet
2026-09-05 07:52:28 +02:00
parent 419bdce36b
commit 7ebbf4ed6c
4 changed files with 54 additions and 9 deletions

View File

@@ -8,12 +8,14 @@ export function WelcomePanel({
date,
timezone,
children,
compact = false,
}: {
name: string;
avatarUrl: string | null;
date?: string;
timezone: string;
children: ReactNode;
compact?: boolean;
}) {
const [failedAvatar, setFailedAvatar] = useState<string | null>(null);
// The API date already belongs to the account's timezone. Keep its date parts
@@ -21,7 +23,7 @@ export function WelcomePanel({
const day = date ? new Date(`${date}T12:00:00Z`) : null;
return (
<section className="ds-welcome-panel" aria-labelledby="dashboard-title">
<section className={`ds-welcome-panel${compact ? " ds-welcome-panel--compact" : ""}`} aria-labelledby="dashboard-title">
<div className="ds-welcome-content">
<div className="ds-welcome-identity">
<div className="ds-avatar">
@@ -41,14 +43,16 @@ export function WelcomePanel({
</div>
<p className="ds-eyebrow">YOUR DAILY CHECK-IN</p>
</div>
<h1 id="dashboard-title" className="type-display">
<h1 id="dashboard-title" className={compact ? "type-title" : "type-display"}>
Welcome back, <em>{name}.</em>
</h1>
<p className="ds-welcome-subtitle">Make time for today.</p>
{!compact && <p className="ds-welcome-subtitle">Make time for today.</p>}
{children}
</div>
<div className="ds-welcome-calendar">
{day && date ? (
{compact && date ? (
<time dateTime={date} className="type-small">{formatTrackingDate(date)}</time>
) : day && date ? (
<time className="ds-date-sheet" dateTime={date} aria-label={formatTrackingDate(date)}>
<span className="ds-date-month">
{day.toLocaleDateString("en", { month: "long", timeZone: "UTC" })}

View File

@@ -181,7 +181,7 @@ export function DesignSystem() {
<div className="ds-component-row">
<div>
<h3>A little more</h3>
<span className="ds-code">Counter · bounded 08</span>
<span className="ds-code">Counter · editable total</span>
</div>
<Counter
label="example count"

View File

@@ -166,6 +166,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
const [revision, setRevision] = useState(0);
const [attempt, setAttempt] = useState(0);
const [loading, setLoading] = useState(true);
const [habitView, setHabitView] = useState<"today" | "all">("today");
const [adding, setAdding] = useState(false);
const [sharing, setSharing] = useState(false);
const [settings, setSettings] = useState(false);
@@ -300,6 +301,8 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
const refreshed = await habitRequest<TodayResponse>("/today");
if (mounted.current) {
setToday(refreshed);
// Keep a habit reachable when an edit makes it unscheduled (including an empty routine).
if (refreshed.habits.some(item => item.habitId === habit.habitId && !item.due)) setHabitView("all");
setNeedsRefresh(false);
setRevision((value) => value + 1);
}
@@ -337,6 +340,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
return (
<>
<WelcomePanel
compact
name={user.displayName || user.username}
avatarUrl={user.avatarUrl}
date={today?.date}
@@ -379,7 +383,6 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
{today.habits.length > 0 && (
<>
<Button id="open-sharing" aria-haspopup="dialog" variant="secondary" disabled={busy || loading || needsRefresh || sharing} aria-expanded={sharing} aria-controls={sharing ? "share-progress" : undefined} onClick={() => setSharing(true)}>Share progress</Button>
<ButtonLink href="#habits-title">View your habits </ButtonLink>
</>
)}
</div>
@@ -421,6 +424,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
focusAddAfterRefresh.current = true;
setAdding(false);
setNotice(`${name} created.`);
setHabitView("all");
setAttempt((value) => value + 1);
}}
/>
@@ -440,13 +444,18 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
id="habits-title"
title={
<>
One day <em>at a time.</em>
Today, <em>at your pace.</em>
</>
}
/>
</div>
<div className="ds-habit-chart-grid">
{today.habits.map((habit) => (
<div className="ds-action-row ds-habit-filters" role="group" aria-label="Show habits">
<Button variant={habitView === "today" ? "primary" : "text"} aria-pressed={habitView === "today"} onClick={() => setHabitView("today")}>Today · {today.due}</Button>
<Button variant={habitView === "all" ? "primary" : "text"} aria-pressed={habitView === "all"} onClick={() => setHabitView("all")}>All habits · {today.habits.length}</Button>
</div>
{habitView === "today" && today.due === 0 && <p className="ds-supporting-copy">Youre all set for today. Choose All habits to view or edit your routines.</p>}
<div className="ds-habit-chart-grid ds-habit-list">
{today.habits.filter(habit => habitView === "all" || habit.due).map((habit) => (
<SavedHabit
key={habit.habitId}
habit={habit}
@@ -579,6 +588,7 @@ function SavedHabit({
>
{habit.method === "count" ? (
<Counter
key={date}
label={habit.name ?? "habit count"}
value={habit.value}
target={habit.target ?? 0}

View File

@@ -1522,3 +1522,34 @@
.ds-modal-heading h2 { @apply type-title; }
.ds-modal-body { padding: 20px; }
}
/* Compact workspace variants keep everyday actions near the top. */
.ds-welcome-panel--compact { grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 24px 28px; margin-bottom: 24px; }
.ds-welcome-panel--compact .ds-welcome-identity { gap: 10px; margin-bottom: 12px; }
.ds-welcome-panel--compact .ds-avatar { width: 32px; height: 32px; flex-basis: 32px; @apply type-body; }
.ds-welcome-panel--compact h1 em { display: inline; }
.ds-welcome-panel--compact .ds-welcome-progress { margin-top: 12px; }
.ds-welcome-panel--compact .ds-primary-actions { margin-top: 16px; }
.ds-welcome-panel--compact .ds-utility-row { margin-top: 12px; padding-top: 8px; }
.ds-welcome-panel--compact .ds-welcome-calendar { padding-left: 24px; text-align: right; justify-content: flex-start; }
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-end; margin-top: 8px !important; }
.ds-habit-filters { margin-bottom: 12px; }
.ds-habit-list { grid-template-columns: minmax(0, 1fr); gap: 20px; }
.ds-habit-list > .ds-habit-chart + .ds-habit-chart { border-top: 1px solid var(--ds-rule); }
.ds-habit-list .ds-habit-chart-progress { margin: 12px 0 8px !important; gap: 12px; }
.ds-habit-history-toggle { display: inline-flex; align-items: center; gap: 8px; }
.ds-habit-history-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.ds-habit-history-panel { margin-top: 16px; }
.ds-counter { flex-wrap: wrap; max-width: 100%; }
.ds-counter-input { box-sizing: border-box; width: 7ch; min-width: 56px; min-height: 44px; padding: 8px; border: 1px solid var(--ds-control-border); background: var(--ds-paper); color: var(--ds-ink); text-align: center; font: inherit; font-variant-numeric: tabular-nums; border-radius: 0; }
.ds-counter .ds-button.ds-counter-save { width: auto; padding: 8px 12px; @apply type-small; font-weight: 500; }
.ds-counter-error { flex-basis: 100%; @apply type-small; }
.ds-habit-starters { margin-bottom: 16px; }
.ds-habit-starter-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ds-color-swatches--compact { flex-wrap: wrap; }
@media (max-width: 700px) {
.ds-welcome-panel--compact { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px; }
.ds-welcome-panel--compact .ds-welcome-calendar { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--ds-rule); text-align: left; }
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-start; }
.ds-habit-list .ds-habit-chart-heading { align-items: flex-start; }
}