fix: align the tiles, title and padding of the cards
images / check (push) Successful in 32s
images / image (push) Successful in 35s

This commit is contained in:
2026-11-18 16:17:41 +01:00
parent 8df74a849c
commit 177280753d
2 changed files with 17 additions and 6 deletions
+14 -4
View File
@@ -142,7 +142,8 @@ export function CardGrid({
setDragged(null)
}}
>
<div className="flex w-full max-w-6xl flex-wrap items-start justify-center gap-4">
{/* cards in a row share a height, so their edges line up */}
<div className="flex w-full max-w-6xl flex-wrap justify-center gap-4">
{cards.map((card) => (
<CardPanel
key={card.id}
@@ -181,6 +182,8 @@ function CardPanel({
}: { card: DashCard; target: boolean } & Handlers) {
const titleId = useId()
const { setNodeRef } = useDroppable({ id: card.id })
// one column per link, at most 8. An empty card is as wide as two links.
const columns = Math.min(card.links.length, 8) || 2
const subtle =
"rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-white/60"
return (
@@ -193,7 +196,8 @@ function CardPanel({
target && "border-white/30"
)}
>
<header className="flex h-8 items-center gap-2 pr-1 pl-3">
{/* the title starts where the first icon does, the plus ends where the last one does */}
<header className="flex h-10 min-w-48 items-center gap-2 pr-3.5 pl-5">
<h2 id={titleId} className="m-0 min-w-0 text-sm">
<button
type="button"
@@ -223,7 +227,12 @@ function CardPanel({
items={card.links.map((l) => l.id)}
strategy={rectSortingStrategy}
>
<div className="flex min-h-[7.5rem] max-w-[50rem] min-w-52 flex-wrap gap-x-1 gap-y-2">
{/* 6rem is a tile's width. On a narrow screen fewer columns fit: they stay
centered in the card, and a last row that is not full starts at the left. */}
<div
style={{ width: `${columns * 6}rem` }}
className="mx-auto grid max-w-full grid-cols-[repeat(auto-fill,6rem)] justify-center gap-y-2"
>
{card.links.map((link) => (
<LinkTile
key={link.id}
@@ -237,7 +246,8 @@ function CardPanel({
onClick={() => onAddLink(card)}
className={cn(
subtle,
"min-h-[7.5rem] flex-1 rounded-2xl px-4 text-sm text-white/50 hover:bg-white/5 hover:text-white/80"
// as tall as a tile, so the card keeps its height when its last link leaves
"col-span-full min-h-27 rounded-2xl px-4 text-sm text-balance text-white/50 hover:bg-white/5 hover:text-white/80"
)}
>
Add a link, or drag one here
+3 -2
View File
@@ -84,7 +84,7 @@ export function TileFace({
return (
<span className={cn(tile, className)}>
<LinkIcon link={link} className="size-14" />
<span className="line-clamp-2 w-full text-center leading-tight break-words [text-shadow:0_1px_8px_rgb(0_0_0/0.6)]">
<span className="line-clamp-2 w-full text-center leading-4.5 break-words [text-shadow:0_1px_8px_rgb(0_0_0/0.6)]">
{link.name}
</span>
</span>
@@ -111,7 +111,8 @@ export function LinkTile({
<div
ref={setNodeRef}
style={{ transform: CSS.Translate.toString(transform), transition }}
className={cn("group relative", isDragging && "opacity-30")}
// flex: the link fills the row's height, also next to a two line name
className={cn("group relative flex", isDragging && "opacity-30")}
>
<a
href={link.url}