mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
feat: display multiple badges better
This commit is contained in:
1 parent
6e2251159e
commit
6081b1446b
2 files changed
+182
-27
No files matched your search
+70
-16
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<HTMLElement, ReturnType<typeof setInterval>>();
|
||||
|
||||
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<HTMLElement>(".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 = `<div class="bsplus-founder-badge-stack">${chips}</div>`;
|
||||
slot.removeAttribute("aria-label");
|
||||
|
||||
slot.querySelectorAll<HTMLButtonElement>(".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<HTMLButtonElement>(".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 = `<div class="${motionClass}">${rendered.map((r) => r.html).join("")}</div>`;
|
||||
|
||||
const chips = [...slot.querySelectorAll<HTMLButtonElement>(".bsplus-founder-badge")];
|
||||
chips.forEach((chip, i) => {
|
||||
const entry = rendered[i];
|
||||
if (!entry) return;
|
||||
wireBadgeChip(chip, entry.badge, signupNumber);
|
||||
});
|
||||
|
||||
const carousel = slot.querySelector<HTMLElement>(".bsplus-founder-badge-carousel");
|
||||
if (carousel) syncCarouselTrackWidth(carousel, chips);
|
||||
|
||||
startBadgeCarousel(
|
||||
slot,
|
||||
chips,
|
||||
rendered.map((r) => r.badge),
|
||||
signupNumber,
|
||||
);
|
||||
}
|
||||
|
||||
async function syncTitlebarFounderBadge(): Promise<void> {
|
||||
const slots = document.querySelectorAll<HTMLElement>(".titlebar .bsplus-founder-badge-slot");
|
||||
for (const slot of slots) {
|
||||
stopBadgeCarousel(slot);
|
||||
slot.replaceChildren();
|
||||
slot.hidden = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user