Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Home.py #73

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 50 additions & 72 deletions Home.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import streamlit as st

st.set_page_config(page_title="College.ai", page_icon='src/Logo College.png', layout='centered',initial_sidebar_state="auto")
st.set_page_config(page_title="College.ai", page_icon='src/Logo College.png', layout='centered', initial_sidebar_state="auto")
st.markdown('<style>' + open('./src/style.css').read() + '</style>', unsafe_allow_html=True)

from streamlit_lottie import st_lottie
Expand All @@ -15,48 +15,45 @@
from menu.Resume_Analyser import main as resume_analyser_page
from menu.User import main as user_page

#Theme---------
ms = st.session_state
if "themes" not in ms:
ms.themes = {"current_theme": "light",
"refreshed": True,

"light": {"theme.base": "dark",
"theme.backgroundColor": "black",
"theme.primaryColor": "#c98bdb",
"theme.secondaryBackgroundColor": "#5591f5",
"theme.textColor": "white",
"theme.textColor": "white",
"button_face": "🌜"},

"dark": {"theme.base": "light",
"theme.backgroundColor": "white",
"theme.primaryColor": "#5591f5",
"theme.secondaryBackgroundColor": "#82E1D7",
"theme.textColor": "#0a1464",
"button_face": "🌞"},
}


def ChangeTheme():
previous_theme = ms.themes["current_theme"]
tdict = ms.themes["light"] if ms.themes["current_theme"] == "light" else ms.themes["dark"]
for vkey, vval in tdict.items():
if vkey.startswith("theme"): st._config.set_option(vkey, vval)

ms.themes["refreshed"] = False
if previous_theme == "dark": ms.themes["current_theme"] = "light"
elif previous_theme == "light": ms.themes["current_theme"] = "dark"


btn_face = ms.themes["light"]["button_face"] if ms.themes["current_theme"] == "light" else ms.themes["dark"]["button_face"]
st.button(btn_face, on_click=ChangeTheme)

if ms.themes["refreshed"] == False:
ms.themes["refreshed"] = True
st.rerun()

#Home-----------
# Initialize session state for theme
if "current_theme" not in st.session_state:
st.session_state.current_theme = "light"

themes = {
"light": {
"theme.base": "dark",
"theme.backgroundColor": "black",
"theme.primaryColor": "#c98bdb",
"theme.secondaryBackgroundColor": "#5591f5",
"theme.textColor": "white",
"button_face": "🌜"
},
"dark": {
"theme.base": "light",
"theme.backgroundColor": "white",
"theme.primaryColor": "#5591f5",
"theme.secondaryBackgroundColor": "#82E1D7",
"theme.textColor": "#0a1464",
"button_face": "🌞"
}
}

# Change theme function
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
for key, value in themes[new_theme].items():
st._config.set_option(key, value)
# Only re-render the necessary components
st.experimental_rerun()

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

# Home Page Function
def home():
st.markdown("<h1 style='text-align: center;'>Welcome to College.ai!</h1>", unsafe_allow_html=True)
st.markdown("<h4 style='text-align: center;'>AI-powered System for Students</h4>", unsafe_allow_html=True)
Expand All @@ -76,46 +73,27 @@ def home():
st.markdown("<a href='https://devpost.com/software/college-ai-m3o0bx' target='_blank'><button style='color: white; background-color: #4CAF50; border: none; padding: 10px 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; border-radius: 12px;'>Tutorial</button></a>", unsafe_allow_html=True)
st.markdown("</div>", unsafe_allow_html=True)


# Main Function
def main():

st.markdown("""
<style>
/* Target the root container and reduce its padding */
.css-1y0tads {
/* Reduce padding for the entire page */
.css-1y0tads, .block-container, .css-1lcbmhc {
padding-top: 0px !important;
padding-bottom: 0px !important;
}

/* Further reduce padding within the main block container */
.block-container {
padding-top: 0px !important;
margin-top: 0px !important;
padding-bottom: 0px !important;
margin-bottom: 0px !important;
}

/* Reduce space around the main area */
.css-1lcbmhc {
padding-top: 0px !important;
padding-bottom: 0px !important;
}

/* Adjust Streamlit markdown blocks to reduce top margin */
.stMarkdown {
margin-top: 0px !important;
}

</style>
""", unsafe_allow_html=True)
""", unsafe_allow_html=True)

with st.sidebar:
st.image('src/Logo College.png', width=70)
tabs = on_hover_tabs(tabName=['Home', 'AI Lens', 'Ask To PDF', 'Resume Analyser', 'ATS', 'Prompt Examples', 'About', 'Account'],
iconName=['home', 'center_focus_weak', 'search', 'article', 'work', 'edit', 'info', 'account_circle'],
default_choice=0)
tabs = on_hover_tabs(
tabName=['Home', 'AI Lens', 'Ask To PDF', 'Resume Analyser', 'ATS', 'Prompt Examples', 'About', 'Account'],
iconName=['home', 'center_focus_weak', 'search', 'article', 'work', 'edit', 'info', 'account_circle'],
default_choice=0
)

menu = {

'Home': home,
'AI Lens': ai_lens_page,
'Ask To PDF': ask_to_pdf_page,
Expand Down