Bring daily check-ins forward with compact workspace layout
This commit is contained in:
@@ -8,12 +8,14 @@ export function WelcomePanel({
|
|||||||
date,
|
date,
|
||||||
timezone,
|
timezone,
|
||||||
children,
|
children,
|
||||||
|
compact = false,
|
||||||
}: {
|
}: {
|
||||||
name: string;
|
name: string;
|
||||||
avatarUrl: string | null;
|
avatarUrl: string | null;
|
||||||
date?: string;
|
date?: string;
|
||||||
timezone: string;
|
timezone: string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
compact?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const [failedAvatar, setFailedAvatar] = useState<string | null>(null);
|
const [failedAvatar, setFailedAvatar] = useState<string | null>(null);
|
||||||
// The API date already belongs to the account's timezone. Keep its date parts
|
// 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;
|
const day = date ? new Date(`${date}T12:00:00Z`) : null;
|
||||||
|
|
||||||
return (
|
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-content">
|
||||||
<div className="ds-welcome-identity">
|
<div className="ds-welcome-identity">
|
||||||
<div className="ds-avatar">
|
<div className="ds-avatar">
|
||||||
@@ -41,14 +43,16 @@ export function WelcomePanel({
|
|||||||
</div>
|
</div>
|
||||||
<p className="ds-eyebrow">YOUR DAILY CHECK-IN</p>
|
<p className="ds-eyebrow">YOUR DAILY CHECK-IN</p>
|
||||||
</div>
|
</div>
|
||||||
<h1 id="dashboard-title" className="type-display">
|
<h1 id="dashboard-title" className={compact ? "type-title" : "type-display"}>
|
||||||
Welcome back, <em>{name}.</em>
|
Welcome back, <em>{name}.</em>
|
||||||
</h1>
|
</h1>
|
||||||
<p className="ds-welcome-subtitle">Make time for today.</p>
|
{!compact && <p className="ds-welcome-subtitle">Make time for today.</p>}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
<div className="ds-welcome-calendar">
|
<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)}>
|
<time className="ds-date-sheet" dateTime={date} aria-label={formatTrackingDate(date)}>
|
||||||
<span className="ds-date-month">
|
<span className="ds-date-month">
|
||||||
{day.toLocaleDateString("en", { month: "long", timeZone: "UTC" })}
|
{day.toLocaleDateString("en", { month: "long", timeZone: "UTC" })}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export function DesignSystem() {
|
|||||||
<div className="ds-component-row">
|
<div className="ds-component-row">
|
||||||
<div>
|
<div>
|
||||||
<h3>A little more</h3>
|
<h3>A little more</h3>
|
||||||
<span className="ds-code">Counter · bounded 0–8</span>
|
<span className="ds-code">Counter · editable total</span>
|
||||||
</div>
|
</div>
|
||||||
<Counter
|
<Counter
|
||||||
label="example count"
|
label="example count"
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
const [revision, setRevision] = useState(0);
|
const [revision, setRevision] = useState(0);
|
||||||
const [attempt, setAttempt] = useState(0);
|
const [attempt, setAttempt] = useState(0);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [habitView, setHabitView] = useState<"today" | "all">("today");
|
||||||
const [adding, setAdding] = useState(false);
|
const [adding, setAdding] = useState(false);
|
||||||
const [sharing, setSharing] = useState(false);
|
const [sharing, setSharing] = useState(false);
|
||||||
const [settings, setSettings] = 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");
|
const refreshed = await habitRequest<TodayResponse>("/today");
|
||||||
if (mounted.current) {
|
if (mounted.current) {
|
||||||
setToday(refreshed);
|
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);
|
setNeedsRefresh(false);
|
||||||
setRevision((value) => value + 1);
|
setRevision((value) => value + 1);
|
||||||
}
|
}
|
||||||
@@ -337,6 +340,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<WelcomePanel
|
<WelcomePanel
|
||||||
|
compact
|
||||||
name={user.displayName || user.username}
|
name={user.displayName || user.username}
|
||||||
avatarUrl={user.avatarUrl}
|
avatarUrl={user.avatarUrl}
|
||||||
date={today?.date}
|
date={today?.date}
|
||||||
@@ -379,7 +383,6 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
{today.habits.length > 0 && (
|
{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>
|
<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>
|
</div>
|
||||||
@@ -421,6 +424,7 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
focusAddAfterRefresh.current = true;
|
focusAddAfterRefresh.current = true;
|
||||||
setAdding(false);
|
setAdding(false);
|
||||||
setNotice(`${name} created.`);
|
setNotice(`${name} created.`);
|
||||||
|
setHabitView("all");
|
||||||
setAttempt((value) => value + 1);
|
setAttempt((value) => value + 1);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -440,13 +444,18 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
id="habits-title"
|
id="habits-title"
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
One day <em>at a time.</em>
|
Today, <em>at your pace.</em>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="ds-habit-chart-grid">
|
<div className="ds-action-row ds-habit-filters" role="group" aria-label="Show habits">
|
||||||
{today.habits.map((habit) => (
|
<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">You’re 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
|
<SavedHabit
|
||||||
key={habit.habitId}
|
key={habit.habitId}
|
||||||
habit={habit}
|
habit={habit}
|
||||||
@@ -579,6 +588,7 @@ function SavedHabit({
|
|||||||
>
|
>
|
||||||
{habit.method === "count" ? (
|
{habit.method === "count" ? (
|
||||||
<Counter
|
<Counter
|
||||||
|
key={date}
|
||||||
label={habit.name ?? "habit count"}
|
label={habit.name ?? "habit count"}
|
||||||
value={habit.value}
|
value={habit.value}
|
||||||
target={habit.target ?? 0}
|
target={habit.target ?? 0}
|
||||||
|
|||||||
@@ -1522,3 +1522,34 @@
|
|||||||
.ds-modal-heading h2 { @apply type-title; }
|
.ds-modal-heading h2 { @apply type-title; }
|
||||||
.ds-modal-body { padding: 20px; }
|
.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; }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user