Skip to content

Commit

Permalink
Update Home.py (#74)
Browse files Browse the repository at this point in the history
### Description
Now theme mode will not changes after page change


Fixes # (issue)

### Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update


### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

### Screenshots (if appropriate)

### Additional Notes

Please provide any additional notes regarding this pull request.
  • Loading branch information
SurajSanap authored Jun 6, 2024
2 parents 991cc79 + d8db6ea commit 8bb746b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Home.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import streamlit as st

st.set_page_config(page_title="College.ai", page_icon='src/Logo College.png', layout='centered', initial_sidebar_state="auto")

# Load CSS file
st.markdown('<style>' + open('./src/style.css').read() + '</style>', unsafe_allow_html=True)

from streamlit_lottie import st_lottie
Expand All @@ -18,8 +20,6 @@
# Initialize session state for theme
if "current_theme" not in st.session_state:
st.session_state.current_theme = "light"
if "theme_changed" not in st.session_state:
st.session_state.theme_changed = False

themes = {
"light": {
Expand All @@ -35,7 +35,7 @@
"theme.backgroundColor": "white",
"theme.primaryColor": "#c19ad9",
"theme.secondaryBackgroundColor": "#c98bdb",
"theme.textColor": "#black",
"theme.textColor": "black",
"button_face": "🌞"
}
}
Expand All @@ -45,19 +45,16 @@ def change_theme():
current_theme = st.session_state.current_theme
new_theme = "dark" if current_theme == "light" else "light"
st.session_state.current_theme = new_theme
st.session_state.theme_changed = True

# Display theme change button
btn_face = themes[st.session_state.current_theme]["button_face"]
if st.button(btn_face, on_click=change_theme):
pass

# Apply theme changes if theme has changed
if st.session_state.theme_changed:
tdict = themes[st.session_state.current_theme]
for key, value in tdict.items():
st._config.set_option(key, value)
st.session_state.theme_changed = False
# Apply theme changes
tdict = themes[st.session_state.current_theme]
for key, value in tdict.items():
st._config.set_option(key, value)

# Home Page Function
def home():
Expand Down

0 comments on commit 8bb746b

Please sign in to comment.