@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.
- package/app/main.py +47 -23
- 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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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:
|
|
308
|
+
background: ${COLOR} !important;
|
|
292
309
|
background-image: none !important;
|
|
293
310
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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