@danhachuel/thunderbolt 0.6.95 → 0.6.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app/main.py +47 -23
  2. package/package.json +1 -1
package/app/main.py CHANGED
@@ -35,6 +35,7 @@ from typing import Any
35
35
 
36
36
  import requests
37
37
  import streamlit as st
38
+ import streamlit.components.v1 as components
38
39
 
39
40
  ROOT = Path(__file__).resolve().parents[1]
40
41
  if str(ROOT) not in sys.path:
@@ -267,34 +268,57 @@ ensure_storage()
267
268
  st.set_page_config(page_title="Thunderbolt", page_icon="T", layout="wide", initial_sidebar_state="expanded")
268
269
 
269
270
  theme_base = (st.get_option("theme.base") or "dark").lower()
270
-
271
- if theme_base == "light":
272
- st.markdown(
273
- """
274
- <style>
275
- :root {
276
- --primary-bg-color: #7A6FE4;
277
- }
278
-
279
- html,
280
- body,
281
- .stApp,
282
- [data-testid="stAppViewContainer"],
283
- [data-testid="stAppViewContainer"] > .main {
284
- min-height: 100vh;
285
- margin: 0;
286
- background: var(--primary-bg-color) !important;
271
+ components.html(
272
+ """
273
+ <script>
274
+ (() => {
275
+ const STYLE_ID = "thunderbolt-light-theme-style";
276
+ const COLOR = "#7A6FE4";
277
+ const getStoredTheme = () => {
278
+ try {
279
+ return JSON.parse(window.parent.localStorage.getItem("stActiveTheme-/-v2") || '"System"');
280
+ } catch (_error) {
281
+ return "System";
282
+ }
283
+ };
284
+ const isLightTheme = () => {
285
+ const selected = getStoredTheme();
286
+ if (selected === "Light") return true;
287
+ if (selected === "Dark") return false;
288
+ return window.parent.matchMedia("(prefers-color-scheme: light)").matches;
289
+ };
290
+ const applyTheme = () => {
291
+ const document = window.parent.document;
292
+ const existing = document.getElementById(STYLE_ID);
293
+ if (!isLightTheme()) {
294
+ if (existing) existing.remove();
295
+ return;
296
+ }
297
+ const style = existing || document.createElement("style");
298
+ style.id = STYLE_ID;
299
+ style.textContent = `
300
+ :root { --primary-bg-color: ${COLOR}; }
301
+ html, body, .stApp, [data-testid="stAppViewContainer"], [data-testid="stAppViewContainer"] > .main {
302
+ min-height: 100vh !important;
303
+ margin: 0 !important;
304
+ background: ${COLOR} !important;
287
305
  background-image: none !important;
288
306
  }
289
-
290
307
  [data-testid="stSidebar"] {
291
- background: var(--primary-bg-color) !important;
308
+ background: ${COLOR} !important;
292
309
  background-image: none !important;
293
310
  }
294
- </style>
295
- """,
296
- unsafe_allow_html=True,
297
- )
311
+ `;
312
+ if (!existing) document.head.appendChild(style);
313
+ };
314
+ applyTheme();
315
+ window.setInterval(applyTheme, 500);
316
+ })();
317
+ </script>
318
+ """,
319
+ height=0,
320
+ width=0,
321
+ )
298
322
 
299
323
  st.markdown("""
300
324
  <style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.6.95",
3
+ "version": "0.6.96",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",