Polish dashboard hierarchy and unify daily controls
This commit is contained in:
@@ -22,37 +22,58 @@ export function WelcomePanel({
|
|||||||
// intact instead of interpreting them in the browser's timezone.
|
// intact instead of interpreting them in the browser's timezone.
|
||||||
const day = date ? new Date(`${date}T12:00:00Z`) : null;
|
const day = date ? new Date(`${date}T12:00:00Z`) : null;
|
||||||
|
|
||||||
|
const avatar = (
|
||||||
|
<div className="ds-avatar">
|
||||||
|
{avatarUrl && failedAvatar !== avatarUrl ? (
|
||||||
|
<img
|
||||||
|
src={avatarUrl}
|
||||||
|
alt={`${name}’s Discord avatar`}
|
||||||
|
width={64}
|
||||||
|
height={64}
|
||||||
|
onError={() => setFailedAvatar(avatarUrl)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<span aria-label={`${name}’s avatar`} role="img">
|
||||||
|
{Array.from(name.trim())[0]?.toUpperCase() || "?"}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (compact) return (
|
||||||
|
<section className="ds-welcome-panel ds-welcome-panel--compact" aria-labelledby="dashboard-title">
|
||||||
|
<div className="ds-welcome-top">
|
||||||
|
<div className="ds-welcome-identity">
|
||||||
|
{avatar}
|
||||||
|
<div>
|
||||||
|
<p className="ds-eyebrow">YOUR DAILY CHECK-IN</p>
|
||||||
|
<h1 id="dashboard-title" className="type-title">Welcome back, <em>{name}.</em></h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="ds-welcome-calendar">
|
||||||
|
{date ? <time dateTime={date} className="type-small">{formatTrackingDate(date)}</time> : <p role="status">Your day is loading…</p>}
|
||||||
|
<p className="ds-welcome-timezone"><Globe2 size={16} aria-hidden="true" /><span>{timezone}</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="ds-welcome-body">{children}</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={`ds-welcome-panel${compact ? " ds-welcome-panel--compact" : ""}`} aria-labelledby="dashboard-title">
|
<section className="ds-welcome-panel" 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">
|
{avatar}
|
||||||
{avatarUrl && failedAvatar !== avatarUrl ? (
|
|
||||||
<img
|
|
||||||
src={avatarUrl}
|
|
||||||
alt={`${name}’s Discord avatar`}
|
|
||||||
width={64}
|
|
||||||
height={64}
|
|
||||||
onError={() => setFailedAvatar(avatarUrl)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<span aria-label={`${name}’s avatar`} role="img">
|
|
||||||
{Array.from(name.trim())[0]?.toUpperCase() || "?"}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</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={compact ? "type-title" : "type-display"}>
|
<h1 id="dashboard-title" className="type-display">
|
||||||
Welcome back, <em>{name}.</em>
|
Welcome back, <em>{name}.</em>
|
||||||
</h1>
|
</h1>
|
||||||
{!compact && <p className="ds-welcome-subtitle">Make time for today.</p>}
|
<p className="ds-welcome-subtitle">Make time for today.</p>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
<div className="ds-welcome-calendar">
|
<div className="ds-welcome-calendar">
|
||||||
{compact && date ? (
|
{day && 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" })}
|
||||||
|
|||||||
@@ -369,26 +369,28 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="ds-action-row ds-primary-actions">
|
<div className="ds-workspace-actions">
|
||||||
<Button
|
<div className="ds-action-row ds-primary-actions">
|
||||||
id="add-habit"
|
<Button
|
||||||
aria-haspopup="dialog"
|
id="add-habit"
|
||||||
disabled={adding || busy || loading || needsRefresh}
|
aria-haspopup="dialog"
|
||||||
onClick={() => setAdding(true)}
|
disabled={adding || busy || loading || needsRefresh}
|
||||||
aria-expanded={adding}
|
onClick={() => setAdding(true)}
|
||||||
aria-controls={adding ? "new-habit" : undefined}
|
aria-expanded={adding}
|
||||||
>
|
aria-controls={adding ? "new-habit" : undefined}
|
||||||
Add a habit +
|
>
|
||||||
</Button>
|
Add a habit +
|
||||||
{today.habits.length > 0 && (
|
</Button>
|
||||||
<>
|
{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>
|
||||||
)}
|
</>
|
||||||
</div>
|
)}
|
||||||
<div className="ds-action-row ds-utility-row">
|
</div>
|
||||||
<Button variant="text" disabled={busy} aria-haspopup="dialog" aria-expanded={archive} aria-controls={archive ? "archived-habits" : undefined} onClick={() => setArchive(!archive)}><Archive size={16} aria-hidden="true" />Archived habits</Button>
|
<div className="ds-action-row ds-utility-row">
|
||||||
<Button variant="text" disabled={busy} aria-haspopup="dialog" aria-expanded={settings} aria-controls={settings ? "account-settings" : undefined} onClick={() => setSettings(!settings)}><Settings2 size={16} aria-hidden="true" />Settings</Button>
|
<Button variant="text" disabled={busy} aria-haspopup="dialog" aria-expanded={archive} aria-controls={archive ? "archived-habits" : undefined} onClick={() => setArchive(!archive)}><Archive size={16} aria-hidden="true" />Archived habits</Button>
|
||||||
|
<Button variant="text" disabled={busy} aria-haspopup="dialog" aria-expanded={settings} aria-controls={settings ? "account-settings" : undefined} onClick={() => setSettings(!settings)}><Settings2 size={16} aria-hidden="true" />Settings</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -429,12 +431,12 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<p className="ds-form-feedback" role="status">
|
<p className="ds-form-feedback ds-save-notice" role="status">
|
||||||
{notice}
|
{notice}
|
||||||
</p>
|
</p>
|
||||||
{today.habits.length > 0 && (
|
{today.habits.length > 0 && (
|
||||||
<section
|
<section
|
||||||
className="ds-section"
|
className="ds-section ds-habits-section"
|
||||||
aria-labelledby="habits-title"
|
aria-labelledby="habits-title"
|
||||||
aria-busy={busy || loading}
|
aria-busy={busy || loading}
|
||||||
>
|
>
|
||||||
@@ -448,11 +450,11 @@ function Dashboard({ user, onExpired }: { user: PublicUser; onExpired: () => voi
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<div className="ds-action-row ds-habit-filters" role="group" aria-label="Show habits">
|
<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 === "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>
|
<Button variant={habitView === "all" ? "primary" : "text"} aria-pressed={habitView === "all"} onClick={() => setHabitView("all")}>All habits · {today.habits.length}</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</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>}
|
{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">
|
<div className="ds-habit-chart-grid ds-habit-list">
|
||||||
{today.habits.filter(habit => habitView === "all" || habit.due).map((habit) => (
|
{today.habits.filter(habit => habitView === "all" || habit.due).map((habit) => (
|
||||||
|
|||||||
@@ -1523,33 +1523,68 @@
|
|||||||
.ds-modal-body { padding: 20px; }
|
.ds-modal-body { padding: 20px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compact workspace variants keep everyday actions near the top. */
|
/* Compact workspace variants share the same spacing and control language. */
|
||||||
.ds-welcome-panel--compact { grid-template-columns: minmax(0, 1fr) auto; gap: 24px; padding: 24px 28px; margin-bottom: 24px; }
|
.ds-welcome-panel--compact { display: block; padding: 24px 28px; margin: 28px 0 0; }
|
||||||
.ds-welcome-panel--compact .ds-welcome-identity { gap: 10px; margin-bottom: 12px; }
|
.ds-welcome-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
|
||||||
.ds-welcome-panel--compact .ds-avatar { width: 32px; height: 32px; flex-basis: 32px; @apply type-body; }
|
.ds-welcome-panel--compact .ds-welcome-identity { gap: 14px; margin: 0; min-width: 0; }
|
||||||
|
.ds-welcome-panel--compact .ds-welcome-identity > div:last-child { min-width: 0; }
|
||||||
|
.ds-welcome-panel--compact .ds-avatar { width: 44px; height: 44px; flex-basis: 44px; background: var(--ds-paper); @apply type-lead; }
|
||||||
|
.ds-welcome-panel--compact h1 { margin-top: 4px; overflow-wrap: anywhere; }
|
||||||
.ds-welcome-panel--compact h1 em { display: inline; }
|
.ds-welcome-panel--compact h1 em { display: inline; }
|
||||||
.ds-welcome-panel--compact .ds-welcome-progress { margin-top: 12px; }
|
.ds-welcome-panel--compact .ds-welcome-calendar { padding: 0; border: 0; text-align: right; flex-shrink: 0; }
|
||||||
.ds-welcome-panel--compact .ds-primary-actions { margin-top: 16px; }
|
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-end; margin-top: 4px !important; }
|
||||||
.ds-welcome-panel--compact .ds-utility-row { margin-top: 12px; padding-top: 8px; }
|
.ds-welcome-body { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--ds-rule); }
|
||||||
.ds-welcome-panel--compact .ds-welcome-calendar { padding-left: 24px; text-align: right; justify-content: flex-start; }
|
.ds-welcome-panel--compact .ds-welcome-progress { margin: 0; gap: 10px; @apply type-small; }
|
||||||
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-end; margin-top: 8px !important; }
|
.ds-workspace-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
|
||||||
.ds-habit-filters { margin-bottom: 12px; }
|
.ds-welcome-panel--compact .ds-primary-actions { margin: 0; gap: 8px; }
|
||||||
.ds-habit-list { grid-template-columns: minmax(0, 1fr); gap: 20px; }
|
.ds-welcome-panel--compact .ds-utility-row { border: 0; margin: 0; padding: 0; gap: 0; }
|
||||||
.ds-habit-list > .ds-habit-chart + .ds-habit-chart { border-top: 1px solid var(--ds-rule); }
|
.ds-welcome-panel--compact .ds-utility-row .ds-button { padding-inline: 12px; }
|
||||||
.ds-habit-list .ds-habit-chart-progress { margin: 12px 0 8px !important; gap: 12px; }
|
.ds-habits-section { padding-top: 28px; border-top: 0; }
|
||||||
.ds-habit-history-toggle { display: inline-flex; align-items: center; gap: 8px; }
|
.ds-habits-section .ds-section-top { margin-bottom: 24px; align-items: center; flex-wrap: wrap; }
|
||||||
|
.ds-habits-section .ds-section-top h2 { @apply type-title; margin-top: 8px; }
|
||||||
|
.ds-habit-filters { display: inline-flex; width: fit-content; gap: 4px; padding: 4px; background: var(--ds-surface); border: 1px solid var(--ds-rule); border-radius: 6px; }
|
||||||
|
.ds-habit-filters .ds-button { @apply type-small; color: var(--ds-secondary); border: 1px solid transparent; background: transparent; border-radius: 3px; }
|
||||||
|
.ds-habit-filters .ds-button[aria-pressed="true"] { color: var(--ds-ink); background: var(--ds-paper); border-color: var(--ds-rule); box-shadow: 0 1px 2px #00000008; }
|
||||||
|
.ds-habit-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
|
||||||
|
.ds-habit-list > .ds-habit-chart { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; padding: 24px 0; border-top: 1px solid var(--ds-rule); }
|
||||||
|
.ds-habit-list .ds-habit-chart-heading { grid-column: 1 / -1; gap: 16px; }
|
||||||
|
.ds-habit-list .ds-habit-chart-heading > div:first-child { flex: 1 1 280px; }
|
||||||
|
.ds-habit-list .ds-habit-chart-heading > .ds-counter { flex: 0 1 auto; }
|
||||||
|
.ds-habit-list .ds-habit-chart-progress { margin: 8px 0 0 !important; justify-content: flex-start; flex-wrap: wrap; gap: 8px 16px; }
|
||||||
|
.ds-habit-list .ds-habit-chart-progress > span + span { color: var(--ds-ink); }
|
||||||
|
.ds-habit-list .ds-habit-history { justify-self: end; margin-top: 8px; }
|
||||||
|
.ds-habit-list .ds-habit-history:has([aria-expanded="true"]) { grid-column: 1 / -1; justify-self: stretch; }
|
||||||
|
.ds-habit-list .ds-task-accordion { grid-column: 1 / -1; }
|
||||||
|
.ds-habit-history-toggle { display: inline-flex; align-items: center; gap: 8px; @apply type-small; color: var(--ds-secondary); }
|
||||||
.ds-habit-history-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
|
.ds-habit-history-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
|
||||||
.ds-habit-history-panel { margin-top: 16px; }
|
.ds-habit-history-panel { margin-top: 16px; }
|
||||||
.ds-counter { flex-wrap: wrap; max-width: 100%; }
|
.ds-save-notice { margin: 0 !important; padding-top: 12px; min-height: 0; }
|
||||||
.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-save-notice:empty { padding: 0; }
|
||||||
|
.ds-counter { flex-wrap: wrap; max-width: 100%; gap: 4px; padding: 4px; border: 1px solid var(--ds-rule); border-radius: 6px; background: var(--ds-paper); }
|
||||||
|
.ds-counter-input { box-sizing: border-box; width: 7ch; min-width: 56px; min-height: 44px; padding: 8px; border: 1px solid transparent; background: var(--ds-surface); color: var(--ds-ink); text-align: center; font: inherit; font-variant-numeric: tabular-nums; border-radius: 3px; }
|
||||||
|
.ds-counter-input:hover:not(:disabled) { border-color: var(--ds-control-border); }
|
||||||
|
.ds-counter .ds-muted { padding-right: 8px; font-variant-numeric: tabular-nums; }
|
||||||
.ds-counter .ds-button.ds-counter-save { width: auto; padding: 8px 12px; @apply type-small; font-weight: 500; }
|
.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-counter-error { flex-basis: 100%; padding: 4px 8px; @apply type-small; }
|
||||||
.ds-habit-starters { margin-bottom: 16px; }
|
.ds-habit-starters { margin-bottom: 16px; padding: 16px; background: var(--ds-surface); border-radius: 4px; }
|
||||||
.ds-habit-starter-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
|
.ds-habit-starter-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
|
||||||
|
.ds-habit-starter-options .ds-button { @apply type-small; background: var(--ds-paper); }
|
||||||
|
.ds-habit-starter-options .ds-button--text { background: transparent; }
|
||||||
.ds-color-swatches--compact { flex-wrap: wrap; }
|
.ds-color-swatches--compact { flex-wrap: wrap; }
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.ds-welcome-panel--compact { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px; }
|
.ds-welcome-panel--compact { padding: 20px; margin-top: 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-top { align-items: flex-start; flex-wrap: wrap; gap: 16px; }
|
||||||
|
.ds-welcome-panel--compact .ds-welcome-calendar { text-align: left; }
|
||||||
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-start; }
|
.ds-welcome-panel--compact .ds-welcome-timezone { justify-content: flex-start; }
|
||||||
|
.ds-welcome-body { margin-top: 20px; padding-top: 16px; gap: 16px; }
|
||||||
|
.ds-workspace-actions { gap: 8px; }
|
||||||
.ds-habit-list .ds-habit-chart-heading { align-items: flex-start; }
|
.ds-habit-list .ds-habit-chart-heading { align-items: flex-start; }
|
||||||
|
.ds-habit-list .ds-habit-chart-heading > div:first-child { flex-basis: 100%; }
|
||||||
|
.ds-habit-list > .ds-habit-chart { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
.ds-habit-list .ds-habit-history { justify-self: start; }
|
||||||
|
.ds-habits-section .ds-section-top { gap: 16px; }
|
||||||
|
}
|
||||||
|
@media (forced-colors: active) {
|
||||||
|
.ds-habit-filters .ds-button[aria-pressed="true"] { border-color: Highlight; }
|
||||||
|
.ds-counter-input { border-color: ButtonText; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user