ankanghosh commited on
Commit
ca9cc5e
Β·
verified Β·
1 Parent(s): b8a9661

Update app,py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -27,7 +27,7 @@ from utils import setup_all_auth
27
  # Create a placeholder for our initialization message
28
  init_message = st.empty()
29
 
30
- # Custom styling (CSS)
31
  st.markdown("""
32
  <style>
33
  /* Styling for the main title */
@@ -38,7 +38,7 @@ st.markdown("""
38
  margin-bottom: 1rem;
39
  }
40
 
41
- /* βœ… Initially green border */
42
  input[type="text"] {
43
  border: 2px solid #4CAF50 !important;
44
  border-radius: 8px !important;
@@ -50,17 +50,17 @@ input[type="text"]:focus {
50
  border: 2px solid #FF5722 !important;
51
  }
52
 
53
- /* βœ… Revert to green after submission */
54
- .answered-query input[type="text"] {
55
  border: 2px solid #4CAF50 !important;
56
  }
57
 
58
- /* βœ… Green-bordered button (not filled) */
59
  .stButton>button {
 
 
60
  border: 2px solid #4CAF50 !important;
61
  border-radius: 8px !important;
62
- color: black !important;
63
- background-color: white !important;
64
  }
65
  </style>
66
  <div class="main-title">Indian Spiritual Texts Q&A</div>
@@ -106,6 +106,12 @@ def handle_form_submit():
106
  st.session_state.query_answered = False # Mark as not yet answered
107
  st.session_state.query_input = "" # Clear input box after submission
108
 
 
 
 
 
 
 
109
  # βœ… Create a form for handling user input
110
  with st.form(key="query_form"):
111
  # Input field with dynamic border behavior
@@ -119,6 +125,8 @@ with st.form(key="query_form"):
119
  # Submit button
120
  submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit)
121
 
 
 
122
  # βœ… Display the last question after submission
123
  if st.session_state.submit_clicked and st.session_state.last_query:
124
  st.markdown("### Current Question:")
@@ -147,6 +155,7 @@ if st.session_state.submit_clicked and st.session_state.last_query:
147
  st.write(citation)
148
 
149
  st.session_state.query_answered = True # βœ… Mark query as answered
 
150
 
151
  except Exception as e:
152
  st.error(f"Error processing query: {str(e)}")
 
27
  # Create a placeholder for our initialization message
28
  init_message = st.empty()
29
 
30
+ # βœ… Custom CSS to handle dynamic text box color change
31
  st.markdown("""
32
  <style>
33
  /* Styling for the main title */
 
38
  margin-bottom: 1rem;
39
  }
40
 
41
+ /* βœ… Green by default */
42
  input[type="text"] {
43
  border: 2px solid #4CAF50 !important;
44
  border-radius: 8px !important;
 
50
  border: 2px solid #FF5722 !important;
51
  }
52
 
53
+ /* βœ… Change back to green AFTER submission */
54
+ .answered input[type="text"] {
55
  border: 2px solid #4CAF50 !important;
56
  }
57
 
58
+ /* βœ… FULLY GREEN BUTTON */
59
  .stButton>button {
60
+ background-color: #4CAF50 !important;
61
+ color: #E8F5E9 !important;
62
  border: 2px solid #4CAF50 !important;
63
  border-radius: 8px !important;
 
 
64
  }
65
  </style>
66
  <div class="main-title">Indian Spiritual Texts Q&A</div>
 
106
  st.session_state.query_answered = False # Mark as not yet answered
107
  st.session_state.query_input = "" # Clear input box after submission
108
 
109
+ # βœ… Conditionally apply CSS class based on query answered status
110
+ input_css_class = "answered" if st.session_state.query_answered else ""
111
+
112
+ # βœ… Wrap the text input inside a div to allow dynamic styling
113
+ st.markdown(f'<div class="{input_css_class}">', unsafe_allow_html=True)
114
+
115
  # βœ… Create a form for handling user input
116
  with st.form(key="query_form"):
117
  # Input field with dynamic border behavior
 
125
  # Submit button
126
  submit_button = st.form_submit_button("Get Answer", on_click=handle_form_submit)
127
 
128
+ st.markdown("</div>", unsafe_allow_html=True) # βœ… Close the div for styling
129
+
130
  # βœ… Display the last question after submission
131
  if st.session_state.submit_clicked and st.session_state.last_query:
132
  st.markdown("### Current Question:")
 
155
  st.write(citation)
156
 
157
  st.session_state.query_answered = True # βœ… Mark query as answered
158
+ st.rerun() # βœ… Refresh UI so that text box turns green again
159
 
160
  except Exception as e:
161
  st.error(f"Error processing query: {str(e)}")