Skip to content

Commit 4c568e4

Browse files
Bikram GoleBikram Gole
authored andcommitted
Fix theme URL precedence and harden pulse/terminal fallbacks
1 parent 93baadf commit 4c568e4

5 files changed

Lines changed: 92 additions & 35 deletions

File tree

about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
const params = new URLSearchParams(window.location.search);
2323
const urlTheme = params.get("theme");
2424
const savedTheme = window.localStorage.getItem(themeKey);
25-
const selected = validThemes.has(savedTheme) ? savedTheme : (validThemes.has(urlTheme) ? urlTheme : null);
25+
const selected = validThemes.has(urlTheme) ? urlTheme : (validThemes.has(savedTheme) ? savedTheme : null);
2626
if (selected) {
2727
document.documentElement.dataset.theme = selected;
2828
document.body.dataset.theme = selected;

contact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
const params = new URLSearchParams(window.location.search);
2323
const urlTheme = params.get("theme");
2424
const savedTheme = window.localStorage.getItem(themeKey);
25-
const selected = validThemes.has(savedTheme) ? savedTheme : (validThemes.has(urlTheme) ? urlTheme : null);
25+
const selected = validThemes.has(urlTheme) ? urlTheme : (validThemes.has(savedTheme) ? savedTheme : null);
2626
if (selected) {
2727
document.documentElement.dataset.theme = selected;
2828
document.body.dataset.theme = selected;

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
const params = new URLSearchParams(window.location.search);
2323
const urlTheme = params.get("theme");
2424
const savedTheme = window.localStorage.getItem(themeKey);
25-
const selected = validThemes.has(savedTheme) ? savedTheme : (validThemes.has(urlTheme) ? urlTheme : null);
25+
const selected = validThemes.has(urlTheme) ? urlTheme : (validThemes.has(savedTheme) ? savedTheme : null);
2626
if (selected) {
2727
document.documentElement.dataset.theme = selected;
2828
document.body.dataset.theme = selected;

script.js

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ const BS_CONVERTER_URL = "https://cdn.jsdelivr.net/npm/nepali-date-library@1.1.9
172172
const THEME_STORAGE_KEY = "neoThemeVariant.v1";
173173
const ACTION_STORAGE_KEY = "neoAutoAction.v1";
174174
const HERO_TYPED_KEY = "neoHeroTyped.v1";
175-
const MINI_PROMPT = "╰─❯";
175+
const MINI_PROMPT_NERD = "╰─❯";
176+
const MINI_PROMPT_FALLBACK = "$";
176177
const NERD_FONT_FAMILIES = [
177178
"JetBrainsMono Nerd Font",
178179
"FiraCode Nerd Font",
@@ -214,6 +215,7 @@ let blackflagShotLockUntil = 0;
214215
let pulseWaveLayer = null;
215216
let pulseWaveRing = null;
216217
let pulseCoreFlash = null;
218+
let pulseFallbackTimeout = 0;
217219
const typewriterTokens = new WeakMap();
218220
const heroTaglineVariants = [
219221
"Aura Farmer // Chaotic Fun 🚀",
@@ -556,37 +558,57 @@ function triggerPulseBackdrop(clientX = null, clientY = null) {
556558
pulseCoreFlash.style.left = `${x}px`;
557559
pulseCoreFlash.style.top = `${y}px`;
558560

561+
pulseWaveLayer.classList.remove("pulse-active");
562+
pulseCoreFlash.classList.remove("pulse-active");
563+
// Reflow so fallback class animation retriggers on rapid launches.
564+
void pulseWaveLayer.offsetWidth;
565+
pulseWaveLayer.classList.add("pulse-active");
566+
pulseCoreFlash.classList.add("pulse-active");
567+
if (pulseFallbackTimeout) window.clearTimeout(pulseFallbackTimeout);
568+
pulseFallbackTimeout = window.setTimeout(() => {
569+
pulseWaveLayer?.classList.remove("pulse-active");
570+
pulseCoreFlash?.classList.remove("pulse-active");
571+
}, 920);
572+
573+
if (typeof pulseWaveLayer.animate !== "function" || typeof pulseCoreFlash.animate !== "function") {
574+
return;
575+
}
576+
559577
pulseWaveLayer.getAnimations().forEach((animation) => animation.cancel());
560578
pulseWaveRing?.getAnimations().forEach((animation) => animation.cancel());
561579
pulseCoreFlash.getAnimations().forEach((animation) => animation.cancel());
562580

563581
const waveDuration = isConstrained ? 640 : 820;
564582
const waveScaleTo = isConstrained ? 1.12 : 1.2;
565-
pulseWaveLayer.animate(
566-
[
567-
{ transform: "scale(0.92)", opacity: 0 },
568-
{ opacity: isFirefoxLike ? 0.62 : 0.82, offset: 0.18 },
569-
{ opacity: 0.3, offset: 0.6 },
570-
{ transform: `scale(${waveScaleTo})`, opacity: 0 },
571-
],
572-
{ duration: waveDuration, easing: "cubic-bezier(0.16, 0.82, 0.27, 1)", fill: "forwards" }
573-
);
574-
575-
pulseWaveRing?.animate(
576-
[
577-
{ transform: "translate(-50%, -50%) scale(0.34)", opacity: 0.95 },
578-
{ transform: `translate(-50%, -50%) scale(${isConstrained ? 9.5 : 13})`, opacity: 0 },
579-
],
580-
{ duration: waveDuration, easing: "ease-out", fill: "forwards" }
581-
);
582-
583-
pulseCoreFlash.animate(
584-
[
585-
{ transform: "translate(-50%, -50%) scale(0.45)", opacity: 0.9 },
586-
{ transform: "translate(-50%, -50%) scale(3.4)", opacity: 0 },
587-
],
588-
{ duration: isConstrained ? 320 : 420, easing: "cubic-bezier(0.2, 0.7, 0.3, 1)", fill: "forwards" }
589-
);
583+
try {
584+
pulseWaveLayer.animate(
585+
[
586+
{ transform: "scale(0.92)", opacity: 0 },
587+
{ opacity: isFirefoxLike ? 0.62 : 0.82, offset: 0.18 },
588+
{ opacity: 0.3, offset: 0.6 },
589+
{ transform: `scale(${waveScaleTo})`, opacity: 0 },
590+
],
591+
{ duration: waveDuration, easing: "cubic-bezier(0.16, 0.82, 0.27, 1)", fill: "forwards" }
592+
);
593+
594+
pulseWaveRing?.animate(
595+
[
596+
{ transform: "translate(-50%, -50%) scale(0.34)", opacity: 0.95 },
597+
{ transform: `translate(-50%, -50%) scale(${isConstrained ? 9.5 : 13})`, opacity: 0 },
598+
],
599+
{ duration: waveDuration, easing: "ease-out", fill: "forwards" }
600+
);
601+
602+
pulseCoreFlash.animate(
603+
[
604+
{ transform: "translate(-50%, -50%) scale(0.45)", opacity: 0.9 },
605+
{ transform: "translate(-50%, -50%) scale(3.4)", opacity: 0 },
606+
],
607+
{ duration: isConstrained ? 320 : 420, easing: "cubic-bezier(0.2, 0.7, 0.3, 1)", fill: "forwards" }
608+
);
609+
} catch (error) {
610+
// Class-based fallback above already guarantees a visible pulse.
611+
}
590612
}
591613

592614
function playPulseSound(pulseCount = 1) {
@@ -786,12 +808,11 @@ function applyTheme(theme, notify = false) {
786808

787809
function initThemeSwitcher() {
788810
let savedTheme = "neo";
789-
let urlTheme = null;
790811
try {
791-
urlTheme = getThemeFromUrl();
812+
const urlTheme = getThemeFromUrl();
792813
const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY);
793-
savedTheme = storedTheme || urlTheme || "neo";
794-
if (!storedTheme && urlTheme) {
814+
savedTheme = urlTheme || storedTheme || "neo";
815+
if (urlTheme && urlTheme !== storedTheme) {
795816
window.localStorage.setItem(THEME_STORAGE_KEY, urlTheme);
796817
}
797818
} catch (error) {
@@ -802,7 +823,7 @@ function initThemeSwitcher() {
802823
window.addEventListener("pageshow", () => {
803824
let latestTheme = "neo";
804825
try {
805-
latestTheme = window.localStorage.getItem(THEME_STORAGE_KEY) || getThemeFromUrl() || "neo";
826+
latestTheme = getThemeFromUrl() || window.localStorage.getItem(THEME_STORAGE_KEY) || "neo";
806827
} catch (error) {
807828
latestTheme = "neo";
808829
}
@@ -950,6 +971,13 @@ function appendTerminalLine(text, type = "out") {
950971
miniTerminalOutput.scrollTop = miniTerminalOutput.scrollHeight;
951972
}
952973

974+
function getMiniPrompt() {
975+
if (document.body.classList.contains("no-nerd-font") || document.body.classList.contains("force-terminal-fallback")) {
976+
return MINI_PROMPT_FALLBACK;
977+
}
978+
return MINI_PROMPT_NERD;
979+
}
980+
953981
function clearTerminalOutput() {
954982
if (!miniTerminalOutput) return;
955983
miniTerminalOutput.innerHTML = "";
@@ -1001,7 +1029,7 @@ function runTerminalCommand(rawCommand) {
10011029
const command = rawCommand.trim();
10021030
if (!command) return;
10031031

1004-
appendTerminalLine(`${MINI_PROMPT} ${command}`, "cmd");
1032+
appendTerminalLine(`${getMiniPrompt()} ${command}`, "cmd");
10051033
const [actionRaw, ...rest] = command.split(/\s+/);
10061034
const action = actionRaw.toLowerCase();
10071035
const arg = rest.join(" ");

styles.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,14 @@ body[data-theme="liquidglass"] .theme-cycle-btn {
26672667
will-change: transform, opacity;
26682668
}
26692669

2670+
.pulse-wave.pulse-active {
2671+
animation: pulse-wave-fallback 820ms cubic-bezier(0.16, 0.82, 0.27, 1) forwards;
2672+
}
2673+
2674+
.pulse-wave.pulse-active .pulse-wave-ring {
2675+
animation: pulse-ring-fallback 820ms ease-out forwards;
2676+
}
2677+
26702678
body.browser-firefox .pulse-wave {
26712679
mix-blend-mode: normal;
26722680
filter: none;
@@ -2691,6 +2699,10 @@ body.browser-firefox .pulse-wave {
26912699
will-change: transform, opacity;
26922700
}
26932701

2702+
.pulse-core-flash.pulse-active {
2703+
animation: pulse-core-fallback 420ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
2704+
}
2705+
26942706
.pulse-wave-ring {
26952707
position: absolute;
26962708
left: var(--pulse-x, 50%);
@@ -2705,6 +2717,23 @@ body.browser-firefox .pulse-wave {
27052717
will-change: transform, opacity;
27062718
}
27072719

2720+
@keyframes pulse-wave-fallback {
2721+
0% { transform: scale(0.92); opacity: 0; }
2722+
18% { opacity: 0.74; }
2723+
60% { opacity: 0.3; }
2724+
100% { transform: scale(1.2); opacity: 0; }
2725+
}
2726+
2727+
@keyframes pulse-ring-fallback {
2728+
0% { transform: translate(-50%, -50%) scale(0.34); opacity: 0.95; }
2729+
100% { transform: translate(-50%, -50%) scale(13); opacity: 0; }
2730+
}
2731+
2732+
@keyframes pulse-core-fallback {
2733+
0% { transform: translate(-50%, -50%) scale(0.45); opacity: 0.9; }
2734+
100% { transform: translate(-50%, -50%) scale(3.4); opacity: 0; }
2735+
}
2736+
27082737
body.force-terminal-fallback .pulse-wave {
27092738
inset: -8%;
27102739
filter: none;

0 commit comments

Comments
 (0)