forge
Explore
Log in

Don't you dare go Hollow

🐛 table column widths, compact phone cards, insights frame

Browse files at this commit

bd48f3f25c0cfad1eb8bd98e4ade023867a3a2bcBurak BoduroğluParent: 10d1fa4
  • fix
    • 🐛 table column widths, compact phone cards, insights frame
Show full message
fix: 🐛 table column widths, compact phone cards, insights frame
- table columns take their declared size: a calc() mixing % and px on a
  <col> reads as auto in Chrome, so every table split into equal columns;
  the shares are plain percentages now, beside the fixed action column
- phone cards lay fields out two per line, label over value, and pull
  cell content back to the left — cells centred for a table column had
  values drifting to the middle of the card
- a toolbar action too long to share the search row stretches across its
  own row instead of hanging off the right edge
- insights tables lose the extra card around them, which boxed the
  toolbar and grid twice
- insights student columns are sized to fit a 1440px screen beside the
  sidebar without a horizontal scroll
src/components/ai/insights-board.tsxmodified+4 -2
@@ -85,7 +85,9 @@ export function InsightsBoard() {
85 </Show>85 </Show>
86 <Show when={!students.error && students()}>86 <Show when={!students.error && students()}>
87 <InsightOverview overview={overview()} />87 <InsightOverview overview={overview()} />
88- <section class="data-shell space-y-4 p-4">88+ {/* No frame of its own: the table already draws its toolbar and
89+ grid as cards, and a third card around them boxed them twice. */}
90+ <section>
89 <InsightStudentsTable91 <InsightStudentsTable
90 rows={rows()}92 rows={rows()}
91 title={tx("insights.title")}93 title={tx("insights.title")}
@@ -114,7 +116,7 @@ export function InsightsBoard() {
114 );116 );
115 117
116 const runAnalysis = () => (118 const runAnalysis = () => (
117- <section class="data-shell p-4">119+ <section>
118 <Suspense fallback={<DataTableSkeleton columns={6} rows={5} />}>120 <Suspense fallback={<DataTableSkeleton columns={6} rows={5} />}>
119 <Show when={runs.error}>121 <Show when={runs.error}>
120 <ErrorAlert message={formatApiError(runs.error)} onRetry={() => void refetchRuns()} />122 <ErrorAlert message={formatApiError(runs.error)} onRetry={() => void refetchRuns()} />
src/components/insights/insight-students-table.tsxmodified+12 -1
@@ -60,12 +60,15 @@ export function InsightStudentsTable(props: {
60 }).format(new Date(value));60 }).format(new Date(value));
61 };61 };
62 62
63+ // Widths sum to ~1095px with the action column, so the grid fits a 1440px
64+ // screen beside the sidebar; at the 120px default every column got, the
65+ // last one slid under the sticky actions and the table asked to scroll.
63 const columns = createMemo<ColumnDef<StudentSignal>[]>(() => [66 const columns = createMemo<ColumnDef<StudentSignal>[]>(() => [
64 {67 {
65 id: "student",68 id: "student",
66 accessorFn: (row) => row.name,69 accessorFn: (row) => row.name,
67 header: rt("student"),70 header: rt("student"),
68- size: 220,71+ size: 130,
69 meta: { align: "center" },72 meta: { align: "center" },
70 cell: (cell) => (73 cell: (cell) => (
71 <Link to="/ai/insights/$userId" params={{ userId: cell.row.original.id }} class="font-medium text-text-default hover:text-primary-text hover:underline">74 <Link to="/ai/insights/$userId" params={{ userId: cell.row.original.id }} class="font-medium text-text-default hover:text-primary-text hover:underline">
@@ -75,6 +78,7 @@ export function InsightStudentsTable(props: {
75 },78 },
76 {79 {
77 id: "status",80 id: "status",
81+ size: 110,
78 accessorFn: (row) => row.state,82 accessorFn: (row) => row.state,
79 header: rt("status" as never),83 header: rt("status" as never),
80 meta: { align: "center" },84 meta: { align: "center" },
@@ -98,6 +102,7 @@ export function InsightStudentsTable(props: {
98 },102 },
99 {103 {
100 id: "attention",104 id: "attention",
105+ size: 95,
101 accessorFn: (row) => row.attention,106 accessorFn: (row) => row.attention,
102 header: rt("attention"),107 header: rt("attention"),
103 meta: { align: "center" },108 meta: { align: "center" },
@@ -109,6 +114,7 @@ export function InsightStudentsTable(props: {
109 },114 },
110 {115 {
111 id: "cards",116 id: "cards",
117+ size: 95,
112 accessorFn: (row) => row.cards,118 accessorFn: (row) => row.cards,
113 header: rt("cards"),119 header: rt("cards"),
114 meta: { align: "center" },120 meta: { align: "center" },
@@ -116,6 +122,7 @@ export function InsightStudentsTable(props: {
116 },122 },
117 {123 {
118 id: "marks",124 id: "marks",
125+ size: 135,
119 accessorFn: (row) => row.marks.average ?? -1,126 accessorFn: (row) => row.marks.average ?? -1,
120 header: rt("marksAverage"),127 header: rt("marksAverage"),
121 meta: { align: "center" },128 meta: { align: "center" },
@@ -123,6 +130,7 @@ export function InsightStudentsTable(props: {
123 },130 },
124 {131 {
125 id: "attendance",132 id: "attendance",
133+ size: 125,
126 accessorFn: (row) => (row.attendance.observed > 0 ? row.attendance.rate ?? -1 : -1),134 accessorFn: (row) => (row.attendance.observed > 0 ? row.attendance.rate ?? -1 : -1),
127 header: rt("attendanceRate"),135 header: rt("attendanceRate"),
128 meta: { align: "center" },136 meta: { align: "center" },
@@ -134,6 +142,7 @@ export function InsightStudentsTable(props: {
134 },142 },
135 {143 {
136 id: "study",144 id: "study",
145+ size: 95,
137 accessorFn: (row) => row.study.stints,146 accessorFn: (row) => row.study.stints,
138 header: t("insights.studyStints"),147 header: t("insights.studyStints"),
139 meta: { align: "center" },148 meta: { align: "center" },
@@ -141,6 +150,7 @@ export function InsightStudentsTable(props: {
141 },150 },
142 {151 {
143 id: "confidence",152 id: "confidence",
153+ size: 105,
144 accessorFn: (row) => row.confidence ?? "",154 accessorFn: (row) => row.confidence ?? "",
145 header: rt("confidence"),155 header: rt("confidence"),
146 meta: { align: "center" },156 meta: { align: "center" },
@@ -148,6 +158,7 @@ export function InsightStudentsTable(props: {
148 },158 },
149 {159 {
150 id: "computedAt",160 id: "computedAt",
161+ size: 95,
151 accessorFn: (row) => row.computed_at ?? 0,162 accessorFn: (row) => row.computed_at ?? 0,
152 header: t("insights.computedAt"),163 header: t("insights.computedAt"),
153 meta: { align: "center", cellClass: "text-xs text-muted-foreground whitespace-nowrap" },164 meta: { align: "center", cellClass: "text-xs text-muted-foreground whitespace-nowrap" },
src/components/ui/data-table.test.tsxmodified+4 -2
@@ -48,8 +48,10 @@ test("keeps only the rightmost action column sticky and fixed at 110x45", () =>
48 expect(actionsCell.classList).not.toContain("text-right");48 expect(actionsCell.classList).not.toContain("text-right");
49 expect(actionsCell.style.width).toBe("110px");49 expect(actionsCell.style.width).toBe("110px");
50 const columnTracks = document.querySelectorAll("col");50 const columnTracks = document.querySelectorAll("col");
51- expect(columnTracks[0]?.style.width).toBe("calc(50% - 55px)");51+ // Plain percentages: Chrome reads a %-and-px calc() on a table column as
52- expect(columnTracks[1]?.style.width).toBe("calc(50% - 55px)");52+ // auto and splits the table evenly, whatever each column's size says.
53+ expect(columnTracks[0]?.style.width).toBe("50%");
54+ expect(columnTracks[1]?.style.width).toBe("50%");
53 expect(columnTracks[2]?.style.width).toBe("110px");55 expect(columnTracks[2]?.style.width).toBe("110px");
54 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));56 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));
55 expect(roleHeader?.classList).not.toContain("table-sticky-head-right");57 expect(roleHeader?.classList).not.toContain("table-sticky-head-right");
src/components/ui/data-table.tsxmodified+23 -10
@@ -208,8 +208,11 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
208 if (stickyRightLocked(column.id)) return "110px";208 if (stickyRightLocked(column.id)) return "110px";
209 const total = dataColumnsWidth();209 const total = dataColumnsWidth();
210 if (total === 0) return `${column.getSize()}px`;210 if (total === 0) return `${column.getSize()}px`;
211- const share = column.getSize() / total;211+ // A plain percentage: Chrome treats a calc() that mixes % and px on a
212- return `calc(${share * 100}% - ${share * actionColumnsWidth()}px)`;212+ // table column as auto, which split every table into equal columns and
213+ // ignored each column's size. The shares sum to 100% beside the fixed
214+ // 110px action column; the fixed layout scales them into what is left.
215+ return `${(column.getSize() / total) * 100}%`;
213 };216 };
214 const compactScreen = createMediaQuery(COMPACT_SCREEN_QUERY);217 const compactScreen = createMediaQuery(COMPACT_SCREEN_QUERY);
215 const useCards = () => (props.mobileLayout ?? "cards") === "cards" && compactScreen();218 const useCards = () => (props.mobileLayout ?? "cards") === "cards" && compactScreen();
@@ -326,7 +329,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
326 <div class={cn("flex flex-wrap items-center gap-2", sectioned() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}>329 <div class={cn("flex flex-wrap items-center gap-2", sectioned() && "rounded-xl border border-border-line bg-surface-base p-3 shadow-xs")}>
327 <Show when={showSearch()}>330 <Show when={showSearch()}>
328 <DataTableSearch331 <DataTableSearch
329- class="order-1 w-auto min-w-40 flex-1 sm:max-w-xs"332+ class="order-1 w-auto min-w-40 flex-1 grow-[100] sm:max-w-xs"
330 value={searchFieldValue()}333 value={searchFieldValue()}
331 onChange={handleSearch}334 onChange={handleSearch}
332 placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")}335 placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")}
@@ -337,11 +340,15 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
337 <div class="order-3 -my-1 flex w-full items-center gap-2 overflow-x-auto py-1 [scrollbar-width:none] sm:my-0 sm:py-0 sm:flex-wrap sm:overflow-visible lg:order-2 lg:w-auto [&_button]:h-10 [&_button]:shrink-0 [&_button]:rounded-lg [&_button]:text-[13px] sm:[&_button]:h-8 [&_select]:h-10 [&_select]:rounded-lg [&_select]:text-[13px] sm:[&_select]:h-8 max-sm:[&>*]:flex-nowrap max-sm:[&>*]:shrink-0">{props.filters}</div>340 <div class="order-3 -my-1 flex w-full items-center gap-2 overflow-x-auto py-1 [scrollbar-width:none] sm:my-0 sm:py-0 sm:flex-wrap sm:overflow-visible lg:order-2 lg:w-auto [&_button]:h-10 [&_button]:shrink-0 [&_button]:rounded-lg [&_button]:text-[13px] sm:[&_button]:h-8 [&_select]:h-10 [&_select]:rounded-lg [&_select]:text-[13px] sm:[&_select]:h-8 max-sm:[&>*]:flex-nowrap max-sm:[&>*]:shrink-0">{props.filters}</div>
338 </Show>341 </Show>
339 <Show when={props.actions || showColumnMenu()}>342 <Show when={props.actions || showColumnMenu()}>
340- <div class="order-2 ml-auto flex shrink-0 flex-wrap items-center justify-end gap-2 lg:order-3">343+ {/* Beside the search the actions keep their own width (the search
344+ out-grows them 100:1). A label too long to fit there wraps to
345+ a line of its own, where the sole grower takes the full row and
346+ the button stretches instead of hanging off the right edge. */}
347+ <div class="order-2 ml-auto flex shrink-0 grow flex-wrap items-center justify-end gap-2 sm:grow-0 lg:order-3">
341 <Show when={props.actions}>348 <Show when={props.actions}>
342 {/* A "yakında" button does nothing yet; on a phone it only349 {/* A "yakında" button does nothing yet; on a phone it only
343 pushes the working action off the search row. */}350 pushes the working action off the search row. */}
344- <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:[&_button]:h-10 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div>351+ <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:flex-1 max-sm:[&_button]:h-10 max-sm:[&_button]:flex-1 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div>
345 </Show>352 </Show>
346 <Show when={showColumnMenu()}>353 <Show when={showColumnMenu()}>
347 <DataTableViewMenu columns={viewMenuColumns()} />354 <DataTableViewMenu columns={viewMenuColumns()} />
@@ -395,13 +402,19 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
395 <Show when={action()}>{(cell) => <div class="-my-1 shrink-0 [&_[data-row-actions-label]]:hidden [&_[data-row-actions-trigger]]:h-10 [&_[data-row-actions-trigger]]:w-10 [&_[data-row-actions-trigger]]:min-w-0 [&_[data-row-actions-trigger]]:px-0">{flexRender(cell().column.columnDef.cell, cell().getContext())}</div>}</Show>402 <Show when={action()}>{(cell) => <div class="-my-1 shrink-0 [&_[data-row-actions-label]]:hidden [&_[data-row-actions-trigger]]:h-10 [&_[data-row-actions-trigger]]:w-10 [&_[data-row-actions-trigger]]:min-w-0 [&_[data-row-actions-trigger]]:px-0">{flexRender(cell().column.columnDef.cell, cell().getContext())}</div>}</Show>
396 </div>403 </div>
397 <Show when={details().length > 0}>404 <Show when={details().length > 0}>
398- <dl class="mt-2 grid grid-cols-[minmax(6rem,auto)_minmax(0,1fr)] gap-x-3 gap-y-1.5">405+ {/* Two fields per line, label over value: a label/value
406+ row per field made every card as tall as its column
407+ count. Cells are written for a centred table column,
408+ so the card pulls their content back to the left. */}
409+ <dl class="mt-2 grid grid-cols-2 gap-x-4 gap-y-2">
399 <For each={details()}>410 <For each={details()}>
400 {(cell) => (411 {(cell) => (
401- <>412+ <div class="min-w-0">
402- <dt class="truncate text-xs text-muted-foreground">{headerLabel(cell.column.id)}</dt>413+ <dt class="truncate text-[11px] leading-4 text-muted-foreground">{headerLabel(cell.column.id)}</dt>
403- <dd class="min-w-0 break-words text-foreground">{flexRender(cell.column.columnDef.cell, cell.getContext())}</dd>414+ <dd class="mt-0.5 min-w-0 break-words text-[13px] leading-5 text-foreground text-left [&_*]:text-left [&_.items-center]:items-start [&_.justify-center]:justify-start [&_.justify-end]:justify-start [&_.mx-auto]:mx-0">
404- </>415+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
416+ </dd>
417+ </div>
405 )}418 )}
406 </For>419 </For>
407 </dl>420 </dl>
src/components/ui/data-toolbar.tsxmodified+2 -2
@@ -25,7 +25,7 @@ export function DataToolbar(props: {
25 <div class={cn("flex flex-wrap items-center gap-2 sm:gap-3", props.class)}>25 <div class={cn("flex flex-wrap items-center gap-2 sm:gap-3", props.class)}>
26 <Show when={hasSearch()}>26 <Show when={hasSearch()}>
27 <DataTableSearch27 <DataTableSearch
28- class={cn("order-1 w-auto min-w-40 flex-1", !props.inline && "sm:max-w-72")}28+ class={cn("order-1 w-auto min-w-40 flex-1 grow-[100]", !props.inline && "sm:max-w-72")}
29 value={props.searchValue ?? ""}29 value={props.searchValue ?? ""}
30 placeholder={props.searchPlaceholder}30 placeholder={props.searchPlaceholder}
31 hint={props.searchHint}31 hint={props.searchHint}
@@ -36,7 +36,7 @@ export function DataToolbar(props: {
36 <div class="order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto">{props.filters}</div>36 <div class="order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto">{props.filters}</div>
37 </Show>37 </Show>
38 <Show when={props.actions}>38 <Show when={props.actions}>
39- <div class="order-2 ml-auto flex shrink-0 items-center gap-2 sm:order-3 max-sm:[&_button]:h-10 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div>39+ <div class="order-2 ml-auto flex shrink-0 grow items-center justify-end gap-2 sm:order-3 sm:grow-0 max-sm:[&_button]:h-10 max-sm:[&_button]:flex-1 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div>
40 </Show>40 </Show>
41 </div>41 </div>
42 );42 );