Browse Source

fix menu responsivenes on repo-header

Nostr-Signature: 4dd8101d8edc9431df49d9fe23b7e1e545e11ef32b024b44f871bb962fb8ad4c 573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc dbcfbfafe02495971b3f3d18466ecf1d894e4001a41e4038d17fd78bb65124de347017273a0a437c397a79ff8226ec6b0718436193e474ef8969392df027fa34
main
Silberengel 3 weeks ago
parent
commit
6fb45e7ce1
  1. 1
      nostr/commit-signatures.jsonl
  2. 46
      src/lib/components/RepoHeaderEnhanced.svelte
  3. 21
      src/lib/styles/components.css

1
nostr/commit-signatures.jsonl

@ -53,3 +53,4 @@ @@ -53,3 +53,4 @@
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771750234,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","reformatting design"]],"content":"Signed commit: reformatting design","id":"3d9cac8d0ed3abac1a42c891a2352f21e6bf60c98af7fcac3b1703c5ab965f9f","sig":"d08ea355c001bf0c83eb0ab06e3dcae32a1bad0c565b626167e9c2218372532b2ba11e87f79521cafabc58c8cc5be5d9fb72235aec4dcb9f3f2556c040fc3599"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771750596,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","fix git folders"]],"content":"Signed commit: fix git folders","id":"3d2475034fdfa5eea36e5caad946460b034a1e4e16b6ba6e3f7fb9b6e1b0a31f","sig":"3eb6e3300081a53434e0f692f0c46618369089bb25047a83138ef3ffd485f749cf817b480f5c8ff0458bb846d04654ba2730ba7d42272739af18a13e8dcb4ed4"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771753256,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","markup and csv previews in file viewer\ncorrect image view\ncorrect syntax view\nadd copy, raw, and download buttons"]],"content":"Signed commit: markup and csv previews in file viewer\ncorrect image view\ncorrect syntax view\nadd copy, raw, and download buttons","id":"40e64c0a716e0ff594b736db14021e43583d5ff0918c1ec0c4fe2c07ddbdbc73","sig":"bb3a50267214a005104853e9b78dd94e4980024146978baef8612ef0400024032dd620749621f832ee9f0458e582084f12ed9c85a40c306f5bbc92e925198a97"}
{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1771754094,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","bug-fixes"]],"content":"Signed commit: bug-fixes","id":"146ea5bbc462c4f0188ec4a35a248c2cf518af7088714a4c1ce8e6e35f524e2a","sig":"dfc5d8d9a2f35e1898404d096f6e3e334885cdb0076caab0f3ea3efd1236e53d4172ed2b9ec16cff80ff364898c287ddb400b7a52cb65a3aedc05bb9df0f7ace"}

46
src/lib/components/RepoHeaderEnhanced.svelte

@ -92,34 +92,49 @@ @@ -92,34 +92,49 @@
let showBranchMenu = $state(false);
let showOwnerMenu = $state(false);
let moreMenuElement = $state<HTMLDivElement | null>(null);
let menuButtonElement = $state<HTMLButtonElement | null>(null);
// Adjust menu position to prevent overflow on both sides on mobile
// Adjust menu position to prevent overflow on the right side
$effect(() => {
if (showMoreMenu && moreMenuElement) {
// Use requestAnimationFrame to ensure DOM is updated
if (showMoreMenu && moreMenuElement && menuButtonElement) {
// Use double requestAnimationFrame to ensure DOM is fully rendered
requestAnimationFrame(() => {
if (!moreMenuElement) return;
const rect = moreMenuElement.getBoundingClientRect();
requestAnimationFrame(() => {
if (!moreMenuElement || !menuButtonElement) return;
const menuRect = moreMenuElement.getBoundingClientRect();
const buttonRect = menuButtonElement.getBoundingClientRect();
const viewportWidth = window.innerWidth;
const padding = 10; // Padding from viewport edges
const padding = 16; // Padding from viewport edges
// Menu is positioned with left: 0, so its left edge aligns with button's left edge
// Calculate where the menu's right edge currently is
const menuWidth = menuRect.width || 280; // Fallback to min-width
const currentLeft = buttonRect.left;
const currentRight = currentLeft + menuWidth;
let transformX = 0;
// Check if menu overflows on the right
if (rect.right > viewportWidth - padding) {
const overflow = rect.right - (viewportWidth - padding);
transformX = -overflow;
}
if (currentRight > viewportWidth - padding) {
// Menu would overflow on the right, shift it left
const rightOverflow = currentRight - (viewportWidth - padding);
transformX = -rightOverflow;
// Check if menu overflows on the left (after right adjustment)
const adjustedLeft = rect.left + transformX;
if (adjustedLeft < padding) {
// Menu would be cut off on the left, shift it right
transformX = padding - rect.left;
// Re-check left after adjustment - ensure we don't go off left
const finalLeft = currentLeft + transformX;
if (finalLeft < padding) {
// If we'd go off left, position it at the left edge with padding
transformX = padding - currentLeft;
}
}
moreMenuElement.style.transform = `translateX(${transformX}px)`;
});
});
} else if (moreMenuElement) {
// Reset transform when menu closes
moreMenuElement.style.transform = '';
}
});
</script>
@ -149,6 +164,7 @@ @@ -149,6 +164,7 @@
<div class="menu-button-wrapper">
<button
class="menu-button"
bind:this={menuButtonElement}
onclick={() => {
onMenuToggle?.();
showMoreMenu = !showMoreMenu;

21
src/lib/styles/components.css

@ -415,7 +415,7 @@ @@ -415,7 +415,7 @@
.more-menu {
position: absolute;
top: calc(100% + 0.25rem);
right: 0;
left: 0;
background: var(--card-bg, #ffffff);
border: 1px solid var(--border-color, #e0e0e0);
border-radius: 0.375rem;
@ -425,30 +425,23 @@ @@ -425,30 +425,23 @@
max-width: min(90vw, 400px);
}
/* On mobile, ensure menu doesn't overflow screen and expands leftward */
/* On mobile, ensure menu doesn't overflow screen */
@media (max-width: 768px) {
.repo-header-actions .more-menu {
right: 0;
left: auto;
left: 0;
right: auto;
max-width: calc(100vw - 1rem);
min-width: min(280px, calc(100vw - 1rem));
/* Ensure menu aligns to right edge of button but doesn't overflow */
transform: translateX(0);
}
/* If menu would overflow, it will be constrained by max-width */
/* The menu will naturally expand leftward when constrained */
}
/* On very small screens, ensure menu expands leftward and doesn't get cut off */
/* On very small screens, ensure menu doesn't get cut off */
@media (max-width: 480px) {
.repo-header-actions .more-menu {
right: 0;
left: auto;
left: 0;
right: auto;
max-width: calc(100vw - 0.5rem);
min-width: min(260px, calc(100vw - 0.5rem));
/* Ensure menu doesn't get cut off on the left */
/* Position relative to viewport to prevent cutoff */
}
/* Ensure menu-button-wrapper allows proper positioning */

Loading…
Cancel
Save