diff --git a/src/css/injected.scss b/src/css/injected.scss index a55815e9..0421500b 100644 --- a/src/css/injected.scss +++ b/src/css/injected.scss @@ -3892,14 +3892,56 @@ div.day-empty { box-sizing: border-box; } .userInfoHouseWrap .bsplus-founder-badge-slot { - width: 100%; + display: block; + width: max-content; + max-width: 100%; margin-top: 4px; + margin-left: auto; + margin-right: auto; } -.bsplus-founder-badge-stack { - display: flex; - flex-direction: column; - gap: 4px; +.bsplus-founder-badge-carousel { + display: grid; + max-width: 100%; + margin-left: auto; + margin-right: auto; +} +.bsplus-founder-badge-carousel > .bsplus-founder-badge { + grid-area: 1 / 1; width: 100%; + min-width: 0; + opacity: 0; + visibility: hidden; + transform: translateY(5px); + transition: + opacity 0.45s ease, + transform 0.45s ease, + visibility 0s linear 0.45s; + pointer-events: none; +} +.bsplus-founder-badge-carousel > .bsplus-founder-badge--active { + opacity: 1; + visibility: visible; + transform: translateY(0); + transition: + opacity 0.45s ease, + transform 0.45s ease, + visibility 0s; + pointer-events: auto; + z-index: 1; +} +.bsplus-founder-badge-carousel--static > .bsplus-founder-badge { + transition: none; + transform: none; + visibility: hidden; +} +.bsplus-founder-badge-carousel--static > .bsplus-founder-badge--active { + visibility: visible; +} +@media (prefers-reduced-motion: reduce) { + .bsplus-founder-badge-carousel > .bsplus-founder-badge { + transition: none; + transform: none; + } } .userInfoHouseWrap .bsplus-founder-badge-slot[hidden], .bsplus-founder-badge-slot[hidden] { @@ -3909,28 +3951,35 @@ div.day-empty { display: block; width: 100%; border-radius: 5px; + overflow: hidden; } -.bsplus-founder-badge--titlebar .bsplus-founder-badge__glass, -.bsplus-founder-badge--titlebar .bsplus-founder-badge__content { +.bsplus-founder-badge--titlebar .bsplus-founder-badge__glass { + display: flex; width: 100%; border-radius: 5px; box-sizing: border-box; + box-shadow: + inset 0 0 0 1px rgba(255, 255, 255, 0.22), + inset 0 1px 0 rgba(255, 255, 255, 0.12); } .bsplus-founder-badge--titlebar .bsplus-founder-badge__content { + display: flex; + flex: 1 1 auto; + width: 100%; justify-content: center; padding: 0 6px; gap: 0; min-height: 0; + min-width: 0; height: auto; font-size: 15px; line-height: normal; + border-radius: 5px; + box-sizing: border-box; backdrop-filter: none; -webkit-backdrop-filter: none; - background: rgba(255, 255, 255, 0.12); - box-shadow: - inset 0 0 0 1px rgba(255, 255, 255, 0.28), - inset 0 1px 0 rgba(255, 255, 255, 0.16), - inset 0 -1px 0 rgba(0, 0, 0, 0.12); + background: rgba(255, 255, 255, 0.1); + box-shadow: none; } .bsplus-founder-badge--titlebar .bsplus-founder-badge__label { display: block; @@ -3939,11 +3988,16 @@ div.day-empty { white-space: nowrap; text-align: center; } -.bsplus-founder-badge--titlebar:focus-visible .bsplus-founder-badge__content { +.bsplus-founder-badge--titlebar:hover { + transform: none; +} +.bsplus-founder-badge--titlebar:focus-visible { + outline: none; +} +.bsplus-founder-badge--titlebar:focus-visible .bsplus-founder-badge__glass { box-shadow: - inset 0 0 0 1px rgba(255, 255, 255, 0.28), - inset 0 1px 0 rgba(255, 255, 255, 0.16), - inset 0 -1px 0 rgba(0, 0, 0, 0.12), + inset 0 0 0 1px rgba(255, 255, 255, 0.22), + inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 2px var(--theme-primary, #f97316), 0 0 0 4px rgba(249, 115, 22, 0.35); } diff --git a/src/seqta/ui/founderBadge/mountTitlebarFounderBadge.ts b/src/seqta/ui/founderBadge/mountTitlebarFounderBadge.ts index 47b7f441..30cb7358 100644 --- a/src/seqta/ui/founderBadge/mountTitlebarFounderBadge.ts +++ b/src/seqta/ui/founderBadge/mountTitlebarFounderBadge.ts @@ -1,6 +1,7 @@ import { cloudAuth } from "@/seqta/utils/CloudAuth"; import { refreshCloudUserFromServer } from "@/seqta/utils/cloudPfpSync"; import { settingsState } from "@/seqta/utils/listeners/SettingsState"; +import { fullMotionEffectsEnabled } from "@/seqta/utils/performanceMode"; import { badgesForTitlebar, founderBadgeChipHtml, @@ -12,11 +13,88 @@ let subscribed = false; let refreshPending = false; let profileSyncedThisSession = false; +const BADGE_CYCLE_MS = 4500; +const carouselTimers = new WeakMap>(); + +function stopBadgeCarousel(slot: HTMLElement): void { + const timer = carouselTimers.get(slot); + if (timer != null) { + clearInterval(timer); + carouselTimers.delete(slot); + } +} + +function wireBadgeChip( + chip: HTMLButtonElement, + badge: BadgeItem, + signupNumber?: number | null, +): void { + chip.setAttribute("aria-label", `${badge.label}, click for details`); + chip.addEventListener("click", () => openFounderBadgeModal(badge, signupNumber)); +} + +function setActiveBadgeChip(chips: HTMLButtonElement[], index: number): void { + chips.forEach((chip, i) => { + const active = i === index; + chip.classList.toggle("bsplus-founder-badge--active", active); + chip.setAttribute("aria-hidden", active ? "false" : "true"); + chip.tabIndex = active ? 0 : -1; + }); +} + +/** Carousel chips share the widest label width so the pill does not shrink while cycling. */ +function syncCarouselTrackWidth( + carousel: HTMLElement, + chips: HTMLButtonElement[], +): void { + carousel.style.removeProperty("width"); + for (const chip of chips) chip.style.width = "max-content"; + + let maxWidth = 0; + for (const chip of chips) { + maxWidth = Math.max(maxWidth, chip.getBoundingClientRect().width); + } + if (maxWidth <= 0) return; + + const px = `${Math.ceil(maxWidth)}px`; + carousel.style.width = px; + for (const chip of chips) chip.style.width = "100%"; +} + +function startBadgeCarousel( + slot: HTMLElement, + chips: HTMLButtonElement[], + badges: BadgeItem[], + signupNumber?: number | null, +): void { + stopBadgeCarousel(slot); + if (chips.length <= 1) return; + + let index = 0; + setActiveBadgeChip(chips, index); + slot.setAttribute( + "aria-label", + `${badges[index]?.label ?? "Cloud badge"}. Cycles through ${badges.length} badges.`, + ); + + carouselTimers.set( + slot, + setInterval(() => { + index = (index + 1) % chips.length; + setActiveBadgeChip(chips, index); + const label = badges[index]?.label; + if (label) slot.setAttribute("aria-label", `${label}. Badge ${index + 1} of ${badges.length}.`); + }, BADGE_CYCLE_MS), + ); +} + function renderTitlebarBadges( slot: HTMLElement, badges: BadgeItem[], signupNumber?: number | null, ): void { + stopBadgeCarousel(slot); + const house = slot .closest(".userInfoHouseWrap") ?.querySelector(".userInfohouse"); @@ -26,30 +104,53 @@ function renderTitlebarBadges( return; } - const chips = badges - .map((b) => founderBadgeChipHtml(b, { titlebar: true })) - .filter(Boolean) - .join(""); - if (!chips) { + const rendered = badges + .map((b) => ({ badge: b, html: founderBadgeChipHtml(b, { titlebar: true }) })) + .filter((entry) => entry.html.length > 0); + + if (rendered.length === 0) { slot.replaceChildren(); slot.hidden = true; return; } slot.hidden = false; - slot.innerHTML = `
${chips}
`; + slot.removeAttribute("aria-label"); - slot.querySelectorAll(".bsplus-founder-badge").forEach((chip) => { - const badge = badges.find((b) => b.key === chip.dataset.tier); - if (!badge) return; - chip.setAttribute("aria-label", `${badge.label}, click for details`); - chip.addEventListener("click", () => openFounderBadgeModal(badge, signupNumber)); + if (rendered.length === 1) { + slot.innerHTML = rendered[0].html; + const chip = slot.querySelector(".bsplus-founder-badge"); + if (chip) wireBadgeChip(chip, rendered[0].badge, signupNumber); + return; + } + + const motionClass = fullMotionEffectsEnabled() + ? "bsplus-founder-badge-carousel" + : "bsplus-founder-badge-carousel bsplus-founder-badge-carousel--static"; + slot.innerHTML = `
${rendered.map((r) => r.html).join("")}
`; + + const chips = [...slot.querySelectorAll(".bsplus-founder-badge")]; + chips.forEach((chip, i) => { + const entry = rendered[i]; + if (!entry) return; + wireBadgeChip(chip, entry.badge, signupNumber); }); + + const carousel = slot.querySelector(".bsplus-founder-badge-carousel"); + if (carousel) syncCarouselTrackWidth(carousel, chips); + + startBadgeCarousel( + slot, + chips, + rendered.map((r) => r.badge), + signupNumber, + ); } async function syncTitlebarFounderBadge(): Promise { const slots = document.querySelectorAll(".titlebar .bsplus-founder-badge-slot"); for (const slot of slots) { + stopBadgeCarousel(slot); slot.replaceChildren(); slot.hidden = true; }