Files
daily-counter/app/themes.py

40 lines
1.2 KiB
Python
Raw Permalink Normal View History

2026-04-30 21:31:19 +02:00
import streamlit as st
from queries import crud
2026-05-01 17:41:42 +02:00
from user import is_logged_in, is_login_enabled
2026-04-30 21:31:19 +02:00
def init_themes():
if 'themes' not in st.session_state:
st.session_state.themes = {
"light": {
"theme.base": "light",
"theme.backgroundColor": "white",
"theme.primaryColor": "#5591f5",
"theme.textColor": "#0a1464",
"button_face_label": "Light",
"button_face_icon": ":material/light_mode:"
},
2026-05-01 17:41:42 +02:00
"dark": {
"theme.base": "dark",
"theme.backgroundColor": "black",
"theme.primaryColor": "#c98bdb",
"theme.textColor": "white",
"button_face_label": "Dark",
"button_face_icon": ":material/dark_mode:"
}
2026-04-30 21:31:19 +02:00
}
if 'current_theme' not in st.session_state:
st.session_state.current_theme = 'light'
change_theme('light')
def change_theme(theme):
2026-05-01 17:41:42 +02:00
if is_logged_in():
crud.set_theme(theme)
st.session_state.current_theme = theme
2026-04-30 21:31:19 +02:00
for key, val in st.session_state.themes[theme].items():
if key.startswith("theme"):
st._config.set_option(key, val)