mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
style: one spacing, title and skeleton language across the app
Icons inside buttons drop their manual margins in favour of the button's built-in gap (two hundred call sites), form field stacks settle on one spacing step, card titles on exactly two sizes, inline field errors on one text size, and a dozen hand-rolled loading pulses move onto the shared skeleton primitive while keeping their silhouettes. The intake dialog wording joins the rest of the app on 'übersprungen', and the UI guidelines now document the two deliberate footer and touch-target systems.
This commit is contained in:
1 parent
4ca3de5ff3
commit
04765ea8ac
92 files changed
+1433
-1445
No files matched your search
@@ -18,10 +18,7 @@ describe("correlation-card scatter skeleton mirrors loaded chart", () => {
|
||||
"utf8",
|
||||
);
|
||||
const chartSrc = readFileSync(
|
||||
join(
|
||||
process.cwd(),
|
||||
"src/components/charts/scatter-correlation-chart.tsx",
|
||||
),
|
||||
join(process.cwd(), "src/components/charts/scatter-correlation-chart.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
@@ -35,7 +32,10 @@ describe("correlation-card scatter skeleton mirrors loaded chart", () => {
|
||||
expect(block).toContain("min-h-[180px]");
|
||||
expect(block).toContain("sm:aspect-[3/2]");
|
||||
expect(block).toContain("sm:h-auto");
|
||||
expect(block).toContain("motion-reduce:animate-none");
|
||||
// Reduced-motion handling comes from the shared <Skeleton>
|
||||
// primitive (its base classes carry `motion-reduce:animate-none`),
|
||||
// so the loader block must render it rather than a raw pulse div.
|
||||
expect(block).toContain("<Skeleton");
|
||||
});
|
||||
|
||||
it("loaded scatter chart still owns the same aspect-ratio quartet", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { CorrelationResult } from "@/lib/insights/correlations";
|
||||
@@ -36,7 +37,7 @@ const ScatterCorrelationChart = dynamic(
|
||||
// skeleton reserves the same space across breakpoints. The
|
||||
// legacy `h-[180px]` was ~60 px shorter than the painted chart
|
||||
// at `sm+` and caused a visible CLS shift on insights mount.
|
||||
<div className="bg-muted/40 aspect-square min-h-[180px] w-full animate-pulse rounded-md motion-reduce:animate-none sm:aspect-[3/2] sm:h-auto" />
|
||||
<Skeleton className="bg-muted/40 aspect-square min-h-[180px] w-full sm:aspect-[3/2] sm:h-auto" />
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { SectionHeading } from "@/components/insights/section-heading";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { formatRelativeTime } from "@/lib/i18n/relative-time";
|
||||
@@ -250,10 +251,10 @@ function BriefingSkeleton() {
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div className="space-y-2">
|
||||
<div className="bg-muted/60 h-3 w-11/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted/60 h-3 w-10/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted/60 h-3 w-9/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted/60 h-3 w-8/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<Skeleton className="h-3 w-11/12 rounded" />
|
||||
<Skeleton className="h-3 w-10/12 rounded" />
|
||||
<Skeleton className="h-3 w-9/12 rounded" />
|
||||
<Skeleton className="h-3 w-8/12 rounded" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{[0, 1, 2].map((i) => (
|
||||
@@ -261,7 +262,7 @@ function BriefingSkeleton() {
|
||||
key={i}
|
||||
className="border-border/40 bg-card/30 flex h-16 items-center rounded-md border p-3"
|
||||
>
|
||||
<div className="bg-muted/60 h-3 w-1/3 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<Skeleton className="h-3 w-1/3 rounded" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { TileHeader } from "@/components/insights/tile-header";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { formatRelativeTime } from "@/lib/i18n/relative-time";
|
||||
@@ -91,9 +92,9 @@ export function InsightStatusCard({
|
||||
<TileHeader icon={nodeIcon(icon)} title={title} />
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="bg-muted h-3.5 w-full animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted h-3.5 w-11/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted h-3.5 w-9/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<Skeleton className="bg-muted h-3.5 w-full rounded" />
|
||||
<Skeleton className="bg-muted h-3.5 w-11/12 rounded" />
|
||||
<Skeleton className="bg-muted h-3.5 w-9/12 rounded" />
|
||||
<p className="text-muted-foreground text-xs">
|
||||
{t("insights.assessmentPreparing")}
|
||||
</p>
|
||||
@@ -126,15 +127,15 @@ export function InsightStatusCard({
|
||||
>
|
||||
<CardHeader className="pb-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="bg-muted h-5 w-5 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted h-4 w-32 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<Skeleton className="bg-muted h-5 w-5 rounded" />
|
||||
<Skeleton className="bg-muted h-4 w-32 rounded" />
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="bg-muted h-3.5 w-full animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted h-3.5 w-11/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted h-3.5 w-9/12 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<div className="bg-muted/70 h-3 w-1/3 animate-pulse rounded motion-reduce:animate-none" />
|
||||
<Skeleton className="bg-muted h-3.5 w-full rounded" />
|
||||
<Skeleton className="bg-muted h-3.5 w-11/12 rounded" />
|
||||
<Skeleton className="bg-muted h-3.5 w-9/12 rounded" />
|
||||
<Skeleton className="bg-muted/70 h-3 w-1/3 rounded" />
|
||||
<span className="sr-only">{t("common.loading")}</span>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -4,13 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
Eye,
|
||||
EyeOff,
|
||||
GripVertical,
|
||||
Loader2,
|
||||
RotateCcw,
|
||||
} from "lucide-react";
|
||||
import { Eye, EyeOff, GripVertical, Loader2, RotateCcw } from "lucide-react";
|
||||
import {
|
||||
DndContext,
|
||||
KeyboardSensor,
|
||||
@@ -222,9 +216,9 @@ export function InsightsEditMode({
|
||||
data-slot="insights-edit-reset"
|
||||
>
|
||||
{resetMutation.isPending ? (
|
||||
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />
|
||||
) : (
|
||||
<RotateCcw className="mr-2 h-3.5 w-3.5" />
|
||||
<RotateCcw className="h-3.5 w-3.5" />
|
||||
)}
|
||||
{t("insights.editMode.reset")}
|
||||
</Button>
|
||||
@@ -235,7 +229,7 @@ export function InsightsEditMode({
|
||||
data-slot="insights-edit-done"
|
||||
>
|
||||
{saveMutation.isPending && (
|
||||
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />
|
||||
)}
|
||||
{t("insights.editMode.done")}
|
||||
</Button>
|
||||
@@ -335,11 +329,7 @@ function EyeToggle({
|
||||
data-visible={visible ? "true" : "false"}
|
||||
className="text-muted-foreground hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background inline-flex h-11 w-11 shrink-0 items-center justify-center rounded transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none sm:h-9 sm:w-9"
|
||||
>
|
||||
{visible ? (
|
||||
<Eye className="h-4 w-4" />
|
||||
) : (
|
||||
<EyeOff className="h-4 w-4" />
|
||||
)}
|
||||
{visible ? <Eye className="h-4 w-4" /> : <EyeOff className="h-4 w-4" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -361,8 +351,14 @@ function SortableSectionRow({
|
||||
labels,
|
||||
onToggle,
|
||||
}: SortableSectionRowProps) {
|
||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
||||
useSortable({ id: section.id });
|
||||
const {
|
||||
attributes,
|
||||
listeners,
|
||||
setNodeRef,
|
||||
transform,
|
||||
transition,
|
||||
isDragging,
|
||||
} = useSortable({ id: section.id });
|
||||
|
||||
const style: React.CSSProperties = {
|
||||
transform: CSS.Transform.toString(transform),
|
||||
@@ -427,4 +423,3 @@ function SortableSectionRow({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Activity } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import type { CorrelationResult } from "@/lib/analytics/correlations";
|
||||
import { MoodExplainerIcon } from "./mood-explainer-icon";
|
||||
@@ -29,7 +30,7 @@ const ScatterCorrelationChart = dynamic(
|
||||
{
|
||||
ssr: false,
|
||||
loading: () => (
|
||||
<div className="bg-muted/40 aspect-square min-h-[180px] w-full animate-pulse rounded-md motion-reduce:animate-none sm:aspect-[3/2] sm:h-auto" />
|
||||
<Skeleton className="bg-muted/40 aspect-square min-h-[180px] w-full sm:aspect-[3/2] sm:h-auto" />
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -68,7 +68,14 @@ export interface SleepHypnogramProps {
|
||||
* Lane order top → bottom. Awake highest, Deep lowest — depth increases
|
||||
* downward, matching Apple Health / Oura's "cityscape" convention.
|
||||
*/
|
||||
const LANE_ORDER = ["AWAKE", "IN_BED", "ASLEEP", "REM", "CORE", "DEEP"] as const;
|
||||
const LANE_ORDER = [
|
||||
"AWAKE",
|
||||
"IN_BED",
|
||||
"ASLEEP",
|
||||
"REM",
|
||||
"CORE",
|
||||
"DEEP",
|
||||
] as const;
|
||||
const LANE_OF: Record<string, number> = Object.fromEntries(
|
||||
// Reverse-index so AWAKE (first) sits at the highest y value.
|
||||
LANE_ORDER.map((s, i) => [s, LANE_ORDER.length - 1 - i]),
|
||||
@@ -126,10 +133,7 @@ export function SleepHypnogram({ session }: SleepHypnogramProps) {
|
||||
}, [session.segments]);
|
||||
|
||||
const domain = useMemo<[number, number]>(
|
||||
() => [
|
||||
new Date(session.start).getTime(),
|
||||
new Date(session.end).getTime(),
|
||||
],
|
||||
() => [new Date(session.start).getTime(), new Date(session.end).getTime()],
|
||||
[session.start, session.end],
|
||||
);
|
||||
|
||||
@@ -148,9 +152,10 @@ export function SleepHypnogram({ session }: SleepHypnogramProps) {
|
||||
// First whole hour at or after `from`, aligned to the step grid.
|
||||
const firstHour = new Date(from);
|
||||
firstHour.setMinutes(0, 0, 0);
|
||||
if (firstHour.getTime() < from) firstHour.setTime(firstHour.getTime() + 3_600_000);
|
||||
if (firstHour.getTime() < from)
|
||||
firstHour.setTime(firstHour.getTime() + 3_600_000);
|
||||
// Align the first tick to a multiple of the step (relative to midnight).
|
||||
while ((firstHour.getHours() % stepHours) !== 0) {
|
||||
while (firstHour.getHours() % stepHours !== 0) {
|
||||
firstHour.setTime(firstHour.getTime() + 3_600_000);
|
||||
}
|
||||
const ticks: number[] = [];
|
||||
@@ -203,7 +208,7 @@ export function SleepHypnogram({ session }: SleepHypnogramProps) {
|
||||
<Card data-slot="sleep-hypnogram" className="gap-3 md:gap-3">
|
||||
<CardHeader className="pb-0">
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<CardTitle className="text-sm font-medium">
|
||||
<CardTitle className="text-base font-semibold">
|
||||
{t("insights.sleep.hypnogram.title")}
|
||||
</CardTitle>
|
||||
<span className="text-muted-foreground text-xs">
|
||||
@@ -249,7 +254,9 @@ export function SleepHypnogram({ session }: SleepHypnogramProps) {
|
||||
type="number"
|
||||
dataKey="lane"
|
||||
domain={[-0.5, LANE_ORDER.length - 0.5]}
|
||||
ticks={LANE_ORDER.map((_, i) => LANE_ORDER.length - 1 - i)}
|
||||
ticks={LANE_ORDER.map(
|
||||
(_, i) => LANE_ORDER.length - 1 - i,
|
||||
)}
|
||||
stroke="var(--muted-foreground)"
|
||||
fontSize={10}
|
||||
width={56}
|
||||
|
||||
@@ -16,10 +16,7 @@ import {
|
||||
SleepStageStackedBar,
|
||||
type SleepStageBreakdown,
|
||||
} from "./sleep-stage-stacked-bar";
|
||||
import {
|
||||
SleepHypnogram,
|
||||
type SleepHypnogramSession,
|
||||
} from "./sleep-hypnogram";
|
||||
import { SleepHypnogram, type SleepHypnogramSession } from "./sleep-hypnogram";
|
||||
import { SleepDurationChart } from "./sleep-duration-chart";
|
||||
|
||||
/**
|
||||
@@ -138,7 +135,7 @@ export function SleepOverview() {
|
||||
<CardHeader className="pb-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<Moon className="text-dracula-cyan h-4 w-4" />
|
||||
<CardTitle className="text-sm font-medium">
|
||||
<CardTitle className="text-base font-semibold">
|
||||
{t("insights.sleep.headlineTitle")}
|
||||
</CardTitle>
|
||||
</div>
|
||||
|
||||
@@ -81,13 +81,7 @@ type WindowSize = (typeof WINDOW_DAYS)[number];
|
||||
* token + the `insights.sleep.stages.inBed` label survive for the
|
||||
* last-night hypnogram, which still renders the in-bed span.
|
||||
*/
|
||||
export const STAGE_ORDER = [
|
||||
"DEEP",
|
||||
"REM",
|
||||
"CORE",
|
||||
"ASLEEP",
|
||||
"AWAKE",
|
||||
] as const;
|
||||
export const STAGE_ORDER = ["DEEP", "REM", "CORE", "ASLEEP", "AWAKE"] as const;
|
||||
|
||||
/**
|
||||
* Dracula stage palette. Exported so the last-night hypnogram
|
||||
@@ -218,7 +212,7 @@ export function SleepStageStackedBar({ breakdown }: SleepStageStackedBarProps) {
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<CardTitle className="text-sm font-medium">
|
||||
<CardTitle className="text-base font-semibold">
|
||||
{t("insights.sleep.compositionTitle")}
|
||||
</CardTitle>
|
||||
<span className="text-muted-foreground text-xs">
|
||||
|
||||
@@ -290,7 +290,7 @@ export function SubPageShell({
|
||||
pathname ? `?from=${encodeURIComponent(pathname)}` : ""
|
||||
}`}
|
||||
>
|
||||
<ListOrdered className="mr-1.5 size-4" aria-hidden="true" />
|
||||
<ListOrdered className="size-4" aria-hidden="true" />
|
||||
{t("insights.subPage.showAllValues")}
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useMemo } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Sparkles } from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
@@ -158,9 +159,9 @@ export function TrendAnnotation({
|
||||
className="border-border/60 bg-card/40 space-y-1.5 rounded-md border p-3 motion-reduce:animate-none"
|
||||
aria-label={t("insights.trendAnnotation.pendingLabel")}
|
||||
>
|
||||
<div className="bg-muted/60 h-2.5 w-11/12 animate-pulse motion-reduce:animate-none rounded" />
|
||||
<div className="bg-muted/60 h-2.5 w-9/12 animate-pulse motion-reduce:animate-none rounded" />
|
||||
<div className="bg-muted/60 h-2.5 w-7/12 animate-pulse motion-reduce:animate-none rounded" />
|
||||
<Skeleton className="h-2.5 w-11/12 rounded" />
|
||||
<Skeleton className="h-2.5 w-9/12 rounded" />
|
||||
<Skeleton className="h-2.5 w-7/12 rounded" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -289,9 +290,7 @@ export function TrendDescriptorCaption({
|
||||
queryKey: queryKeys.insightsTrendSeries(primaryType),
|
||||
queryFn: async () => {
|
||||
const to = new Date();
|
||||
const from = new Date(
|
||||
to.getTime() - DESCRIPTOR_WINDOW_DAYS * 86_400_000,
|
||||
);
|
||||
const from = new Date(to.getTime() - DESCRIPTOR_WINDOW_DAYS * 86_400_000);
|
||||
const params = new URLSearchParams({
|
||||
type: primaryType,
|
||||
sortBy: "measuredAt",
|
||||
@@ -364,7 +363,8 @@ export function TrendDescriptorCaption({
|
||||
// copy defensively (should not happen for the legacy triple).
|
||||
const copy = isMood
|
||||
? moodDescriptorCopy(descriptor)
|
||||
: (numericDescriptorCopy(metric, descriptor) ?? moodDescriptorCopy(descriptor));
|
||||
: (numericDescriptorCopy(metric, descriptor) ??
|
||||
moodDescriptorCopy(descriptor));
|
||||
|
||||
return (
|
||||
<TrendCaptionCard
|
||||
|
||||
Reference in new issue
Block a user