@danhachuel/thunderbolt 0.6.94 → 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 +46 -55
- 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,67 +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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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;
|
|
305
|
+
background-image: none !important;
|
|
295
306
|
}
|
|
296
|
-
|
|
297
307
|
[data-testid="stSidebar"] {
|
|
298
|
-
background:
|
|
308
|
+
background: ${COLOR} !important;
|
|
309
|
+
background-image: none !important;
|
|
299
310
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
0% { background-position: 0% 0%; }
|
|
303
|
-
50% { background-position: 100% 100%; }
|
|
304
|
-
100% { background-position: 0% 0%; }
|
|
305
|
-
}
|
|
306
|
-
</style>
|
|
307
|
-
<script>
|
|
308
|
-
(function () {
|
|
309
|
-
const gradient = 'linear-gradient(315deg, #4f2991 3%, #7dc4ff 38%, #36cfcc 68%, #a92ed3 98%)';
|
|
310
|
-
const selectors = [
|
|
311
|
-
'html',
|
|
312
|
-
'body',
|
|
313
|
-
'.stApp',
|
|
314
|
-
'[data-testid="stAppViewContainer"]',
|
|
315
|
-
'[data-testid="stAppViewContainer"] > .main'
|
|
316
|
-
];
|
|
317
|
-
const applyGradient = () => selectors.forEach((selector) => {
|
|
318
|
-
document.querySelectorAll(selector).forEach((element) => {
|
|
319
|
-
element.style.setProperty('background-image', gradient, 'important');
|
|
320
|
-
element.style.setProperty('background-size', '400% 400%', 'important');
|
|
321
|
-
element.style.setProperty('background-attachment', 'fixed');
|
|
322
|
-
});
|
|
311
|
+
`;
|
|
312
|
+
if (!existing) document.head.appendChild(style);
|
|
323
313
|
};
|
|
324
|
-
|
|
325
|
-
|
|
314
|
+
applyTheme();
|
|
315
|
+
window.setInterval(applyTheme, 500);
|
|
326
316
|
})();
|
|
327
317
|
</script>
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
318
|
+
""",
|
|
319
|
+
height=0,
|
|
320
|
+
width=0,
|
|
321
|
+
)
|
|
331
322
|
|
|
332
323
|
st.markdown("""
|
|
333
324
|
<style>
|
package/package.json
CHANGED