From f0cc4850b3d0e47bd366a2a57b841678569e3751 Mon Sep 17 00:00:00 2001 From: Ohualtex <230626673+Ohualtex@users.noreply.github.com> Date: Mon, 8 Jun 2026 18:19:07 +0300 Subject: [PATCH] =?UTF-8?q?fix(welcome):=20inline=20tema=20script'ini=20ha?= =?UTF-8?q?rici=20src/theme-init.js'e=20al=20(CI=20d=C3=BCzeltmesi)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - welcome'ın head'deki inline anti-FOUC tema script'i TestAssetSplit:: test_no_inline_script_block'u kırıyordu (proje kuralı: inline + transition tetiklenmez → gündüz/gece statik gelir). Toggle yine animasyonlu. + HARİCİ + render-blocking KLASİK script (inline DEĞİL → asset-split/CSP kuralı; + type=module DEĞİL → boyamadan önce koşar). Kaynak: src/theme-init.js --> + diff --git a/frontend/src/theme-init.js b/frontend/src/theme-init.js new file mode 100644 index 0000000..e181cb5 --- /dev/null +++ b/frontend/src/theme-init.js @@ -0,0 +1,19 @@ +// SFDAP — tema ilk-boya senkronu (FOUC önleme). +// index.html 'inde HARİCİ + render-blocking KLASİK script olarak yüklenir: +// - inline değil → asset-split / CSP kuralına (TestAssetSplit) takılmaz, +// - type=module DEĞİL → modüller defer'lı koşup boyamadan SONRA çalışırdı; bu +// dosya senkron çalışıp temayı CSS boyamadan ÖNCE uygular (aksi halde welcome'da +// ilk yüklemede gün/gece geçiş animasyonu oynar). +// Temayı üzerine yazar; durum değişmediği için transition tetiklenmez. +(function () { + try { + var t = localStorage.getItem('sfdap-theme'); + if (!t) { + // İlk açılış: saat 06:00–20:00 arası GÜNDÜZ, 20:00–06:00 arası GECE. + var h = new Date().getHours(); + t = (h >= 6 && h < 20) ? 'light' : 'dark'; + localStorage.setItem('sfdap-theme', t); // sabitle → refresh değiştirmez + } + if (t === 'light') document.documentElement.dataset.theme = 'light'; + } catch (e) {} +})();