fix: align the tiles, title and padding of the cards
This commit is contained in:
@@ -142,7 +142,8 @@ export function CardGrid({
|
|||||||
setDragged(null)
|
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) => (
|
{cards.map((card) => (
|
||||||
<CardPanel
|
<CardPanel
|
||||||
key={card.id}
|
key={card.id}
|
||||||
@@ -181,6 +182,8 @@ function CardPanel({
|
|||||||
}: { card: DashCard; target: boolean } & Handlers) {
|
}: { card: DashCard; target: boolean } & Handlers) {
|
||||||
const titleId = useId()
|
const titleId = useId()
|
||||||
const { setNodeRef } = useDroppable({ id: card.id })
|
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 =
|
const subtle =
|
||||||
"rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-white/60"
|
"rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-white/60"
|
||||||
return (
|
return (
|
||||||
@@ -193,7 +196,8 @@ function CardPanel({
|
|||||||
target && "border-white/30"
|
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">
|
<h2 id={titleId} className="m-0 min-w-0 text-sm">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -223,7 +227,12 @@ function CardPanel({
|
|||||||
items={card.links.map((l) => l.id)}
|
items={card.links.map((l) => l.id)}
|
||||||
strategy={rectSortingStrategy}
|
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) => (
|
{card.links.map((link) => (
|
||||||
<LinkTile
|
<LinkTile
|
||||||
key={link.id}
|
key={link.id}
|
||||||
@@ -237,7 +246,8 @@ function CardPanel({
|
|||||||
onClick={() => onAddLink(card)}
|
onClick={() => onAddLink(card)}
|
||||||
className={cn(
|
className={cn(
|
||||||
subtle,
|
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
|
Add a link, or drag one here
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function TileFace({
|
|||||||
return (
|
return (
|
||||||
<span className={cn(tile, className)}>
|
<span className={cn(tile, className)}>
|
||||||
<LinkIcon link={link} className="size-14" />
|
<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}
|
{link.name}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -111,7 +111,8 @@ export function LinkTile({
|
|||||||
<div
|
<div
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
style={{ transform: CSS.Translate.toString(transform), transition }}
|
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
|
<a
|
||||||
href={link.url}
|
href={link.url}
|
||||||
|
|||||||
Reference in New Issue
Block a user