Refine publisher dashboard layout
All checks were successful
buildbot/nix-eval Build done.
buildbot/nix-build Build done.
buildbot/nix-effects Build done.

This commit is contained in:
Abel Luck 2026-06-02 11:11:36 +02:00
parent 2147d9c999
commit 813f19f355
8 changed files with 350 additions and 53 deletions

View file

@ -291,29 +291,37 @@ def table_section(
headers: tuple[str, ...],
rows: tuple[tuple[Node, ...], ...],
row_attrs: tuple[Mapping[str, str], ...] | None = None,
header_classes: tuple[str, ...] | None = None,
cell_classes: tuple[str, ...] | None = None,
table_class: str = "relative w-full min-w-[64rem] divide-y divide-slate-200 table-auto",
first_header_class: str | None = None,
first_cell_class: str | None = None,
actions: Node | None = None,
) -> Renderable:
def header_class(index: int) -> str:
if header_classes is not None and index < len(header_classes):
return header_classes[index]
if index == 0 and first_header_class is not None:
return first_header_class
return "px-2.5 py-2.5 text-left text-xs font-semibold uppercase tracking-[0.18em] whitespace-nowrap text-slate-500 first:pl-3 sm:first:pl-4"
def cell_class(index: int) -> str:
if cell_classes is not None and index < len(cell_classes):
return cell_classes[index]
if index == 0:
return (
first_cell_class
or "py-3 pr-5 pl-3 text-sm font-medium text-slate-950 sm:pl-4"
)
return "px-2.5 py-3 align-top text-sm whitespace-nowrap text-slate-600"
def render_row(
row: tuple[Node, ...], attrs: Mapping[str, str] | None = None
) -> Renderable:
first_cell, *other_cells = row
row_attributes = dict(attrs or {})
row_attributes["class"] = f"align-top {row_attributes.get('class', '')}".strip()
return h.tr(row_attributes)[
h.td(
class_=(
first_cell_class
or "py-3 pr-5 pl-3 text-sm font-medium text-slate-950 sm:pl-4"
)
)[first_cell],
(
h.td(
class_="px-2.5 py-3 align-top text-sm whitespace-nowrap text-slate-600"
)[cell]
for cell in other_cells
),
(h.td(class_=cell_class(index))[cell] for index, cell in enumerate(row)),
]
body_rows: Node
@ -362,19 +370,13 @@ def table_section(
)
)[
h.div(class_="overflow-x-auto")[
h.table(
class_="relative w-full min-w-[64rem] divide-y divide-slate-200 table-auto"
)[
h.table(class_=table_class)[
h.thead(class_="bg-stone-50")[
h.tr[
(
h.th(
scope="col",
class_=(
first_header_class
if index == 0 and first_header_class is not None
else "px-2.5 py-2.5 text-left text-xs font-semibold uppercase tracking-[0.18em] whitespace-nowrap text-slate-500 first:pl-3 sm:first:pl-4"
),
class_=header_class(index),
)[header]
for index, header in enumerate(headers)
)