From 5bb2c7966a32a7831c9926ea0d66788c27079df9 Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Mon, 26 Jan 2026 08:43:04 +0000 Subject: [PATCH] some fixes --- CLAUDE.md | 1 + src/lib/helper.ts | 34 ++++++++++++++++++++++++++++++++++ src/lib/website/EditableProfile.svelte | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/lib/website/EditableWebsite.svelte | 29 ++++++++++++++++++++++++++--- src/lib/cards/DrawCard/EditingDrawCard.svelte | 4 ++-- 5 file(s) changed, 111 insertion(s)(+), 10 deletion(s)(-) diff --git a/CLAUDE.md b/CLAUDE.md --- a/CLAUDE.md +++ b/CLAUDE.md @@ -64,6 +64,7 @@ - `auth.svelte.ts` - OAuth client state and login/logout flow using `@atcute/oauth-browser-client` - `atproto.ts` - ATProto API helpers: `resolveHandle`, `listRecords`, `getRecord`, `putRecord`, `deleteRecord`, `uploadImage` - Data is stored in user's PDS under collection `app.blento.card` +- **Important**: ATProto does not allow floating point numbers in records. All numeric values must be integers. **Data Loading (`src/lib/website/`):** diff --git a/src/lib/helper.ts b/src/lib/helper.ts --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -268,6 +268,40 @@ } } +/** + * Find a valid position for a new item in a single mode (desktop or mobile). + * This modifies the item's position properties in-place. + */ +export function findValidPosition(newItem: Item, items: Item[], mobile: boolean) { + if (mobile) { + let foundPosition = false; + newItem.mobileY = 0; + while (!foundPosition) { + for (newItem.mobileX = 0; newItem.mobileX <= COLUMNS - newItem.mobileW; newItem.mobileX++) { + const collision = items.find((item) => overlaps(newItem, item, true)); + if (!collision) { + foundPosition = true; + break; + } + } + if (!foundPosition) newItem.mobileY! += 1; + } + } else { + let foundPosition = false; + newItem.y = 0; + while (!foundPosition) { + for (newItem.x = 0; newItem.x <= COLUMNS - newItem.w; newItem.x++) { + const collision = items.find((item) => overlaps(newItem, item, false)); + if (!collision) { + foundPosition = true; + break; + } + } + if (!foundPosition) newItem.y += 1; + } + } +} + export async function refreshData(data: { updatedAt?: number; handle: string }) { const TEN_MINUTES = 10 * 60 * 1000; const now = Date.now(); diff --git a/src/lib/website/EditableProfile.svelte b/src/lib/website/EditableProfile.svelte --- a/src/lib/website/EditableProfile.svelte +++ b/src/lib/website/EditableProfile.svelte @@ -62,9 +62,9 @@ : '@5xl/wrapper:max-w-4xl @5xl/wrapper:px-12' ]} > -
+
{#if !isMobile()} - {/if}
diff --git a/src/lib/website/EditableWebsite.svelte b/src/lib/website/EditableWebsite.svelte --- a/src/lib/website/EditableWebsite.svelte +++ b/src/lib/website/EditableWebsite.svelte @@ -6,6 +6,7 @@ clamp, compactItems, createEmptyCard, + findValidPosition, fixCollisions, getHideProfileSection, getProfilePosition, @@ -334,9 +335,13 @@ if (isMobile) { item.mobileX = gridX; item.mobileY = gridY; + // Find valid desktop position + findValidPosition(item, items, false); } else { item.x = gridX; item.y = gridY; + // Find valid mobile position + findValidPosition(item, items, true); } items = [...items, item]; @@ -576,16 +581,34 @@ > {#if getHideProfileSection(data)} {/if}
diff --git a/src/lib/cards/DrawCard/EditingDrawCard.svelte b/src/lib/cards/DrawCard/EditingDrawCard.svelte --- a/src/lib/cards/DrawCard/EditingDrawCard.svelte +++ b/src/lib/cards/DrawCard/EditingDrawCard.svelte @@ -152,13 +152,13 @@ {@const pathData = getSvgPathFromStroke( getStroke(stroke.points, getStrokeOptions(stroke.size ?? 3)) )} - + {/each} {#if currentStroke.length > 0} {@const pathData = getSvgPathFromStroke( getStroke(currentStroke, getStrokeOptions(strokeSizes[strokeWidth])) )} - + {/if} -- tangled.sh