Fix button layout and spacing for professional UI
Browse filesLAYOUT IMPROVEMENTS:
- Create compact single-row header with logo and text side-by-side
- Fix cramped feedback/retry button layout with proper spacing
- Add generous margins and padding for better visual hierarchy
- Use balanced column ratios [2, 2, 1, 1] for optimal button sizing
BUTTON DESIGN:
- Single row layout: [β¨ Excellent] [π§ Needs work] [space] [π Retry]
- Full-width buttons with use_container_width=True for consistency
- Beautiful green gradient feedback confirmation
- Clean alignment and professional appearance
SPACE OPTIMIZATION:
- Compact header saves vertical space while maintaining branding
- Proper spacer above action buttons (1.5rem margin)
- Eliminated awkward multi-line button layouts
- Much better proportions and visual balance
Perfect for screenshots and professional demos\! πΈβ¨
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
@@ -573,35 +573,34 @@ if "gpt-oss-120b" in available_models:
|
|
573 |
elif "deepseek-R1" in available_models:
|
574 |
default_index = available_models.index("deepseek-R1")
|
575 |
|
576 |
-
#
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
<h1 style='
|
584 |
margin: 0;
|
585 |
-
font-size:
|
586 |
font-weight: 700;
|
587 |
-
|
588 |
-
-webkit-background-clip: text;
|
589 |
-
-webkit-text-fill-color: transparent;
|
590 |
-
background-clip: text;
|
591 |
'>VayuChat</h1>
|
592 |
<p style='
|
593 |
-
margin:
|
594 |
-
font-size:
|
595 |
-
color: #6b7280;
|
596 |
-
|
597 |
-
'>AI-Powered Air Quality Data Analysis</p>
|
598 |
-
<p style='
|
599 |
-
margin: 2px 0 0 0;
|
600 |
-
font-size: 0.9rem;
|
601 |
-
color: #9ca3af;
|
602 |
-
'>Sustainability Lab β’ IIT Gandhinagar</p>
|
603 |
</div>
|
604 |
-
|
|
|
605 |
|
606 |
|
607 |
# Load data with caching for better performance
|
@@ -862,66 +861,70 @@ for response_id, response in enumerate(st.session_state.responses):
|
|
862 |
code = response.get("gen_code", "")
|
863 |
|
864 |
|
865 |
-
#
|
|
|
|
|
866 |
if "feedback" in st.session_state.responses[response_id]:
|
|
|
867 |
feedback_data = st.session_state.responses[response_id]["feedback"]
|
868 |
-
st.
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
885 |
else:
|
886 |
-
#
|
887 |
-
st.
|
888 |
-
<div style='margin: 0.5rem 0; color: #6b7280; font-size: 0.9rem; font-weight: 500;'>
|
889 |
-
How was this response?
|
890 |
-
</div>
|
891 |
-
""", unsafe_allow_html=True)
|
892 |
|
893 |
-
col1, col2, col3 = st.columns([1, 1, 3])
|
894 |
with col1:
|
895 |
-
if st.button("β¨ Excellent", key=f"{feedback_key}_excellent",
|
896 |
feedback = {"score": "β¨ Excellent", "text": ""}
|
897 |
st.session_state.responses[response_id]["feedback"] = feedback
|
898 |
st.rerun()
|
|
|
899 |
with col2:
|
900 |
-
if st.button("π§ Needs work", key=f"{feedback_key}_poor",
|
901 |
feedback = {"score": "π§ Needs work", "text": ""}
|
902 |
st.session_state.responses[response_id]["feedback"] = feedback
|
903 |
st.rerun()
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
if st.button("π Retry", key=f"retry_{response_id}", help="Regenerate with current model"):
|
909 |
-
# Get the last user prompt that led to this response
|
910 |
-
user_prompt = ""
|
911 |
-
if response_id > 0:
|
912 |
-
user_prompt = st.session_state.responses[response_id-1].get("content", "")
|
913 |
-
|
914 |
-
if user_prompt:
|
915 |
-
# Remove this response and the user message before it, then re-add the user message
|
916 |
if response_id > 0:
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
|
926 |
# Chat input with better guidance
|
927 |
prompt = st.chat_input("π¬ Ask about air quality trends, pollution analysis, or city comparisons...", key="main_chat")
|
|
|
573 |
elif "deepseek-R1" in available_models:
|
574 |
default_index = available_models.index("deepseek-R1")
|
575 |
|
576 |
+
# Compact header - everything in one row
|
577 |
+
st.markdown("""
|
578 |
+
<div style='
|
579 |
+
display: flex;
|
580 |
+
align-items: center;
|
581 |
+
justify-content: center;
|
582 |
+
padding: 0.5rem 0;
|
583 |
+
gap: 15px;
|
584 |
+
border-bottom: 1px solid #e5e7eb;
|
585 |
+
margin-bottom: 1rem;
|
586 |
+
'>
|
587 |
+
<img src='https://sustainability-lab.github.io/images/logo_light.svg'
|
588 |
+
style='height: 40px;' />
|
589 |
+
<div>
|
590 |
<h1 style='
|
591 |
margin: 0;
|
592 |
+
font-size: 1.8rem;
|
593 |
font-weight: 700;
|
594 |
+
color: #1f2937;
|
|
|
|
|
|
|
595 |
'>VayuChat</h1>
|
596 |
<p style='
|
597 |
+
margin: 0;
|
598 |
+
font-size: 0.8rem;
|
599 |
+
color: #6b7280;
|
600 |
+
'>AI Air Quality Analysis β’ Sustainability Lab, IIT Gandhinagar</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
</div>
|
602 |
+
</div>
|
603 |
+
""", unsafe_allow_html=True)
|
604 |
|
605 |
|
606 |
# Load data with caching for better performance
|
|
|
861 |
code = response.get("gen_code", "")
|
862 |
|
863 |
|
864 |
+
# Beautiful action bar with feedback and retry
|
865 |
+
st.markdown('<div style="margin: 1.5rem 0 0.5rem 0;"></div>', unsafe_allow_html=True) # Spacer
|
866 |
+
|
867 |
if "feedback" in st.session_state.responses[response_id]:
|
868 |
+
# Show submitted feedback nicely
|
869 |
feedback_data = st.session_state.responses[response_id]["feedback"]
|
870 |
+
col1, col2 = st.columns([3, 1])
|
871 |
+
with col1:
|
872 |
+
st.markdown(f"""
|
873 |
+
<div style='
|
874 |
+
background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
|
875 |
+
border: 1px solid #a7f3d0;
|
876 |
+
border-radius: 8px;
|
877 |
+
padding: 0.75rem 1rem;
|
878 |
+
display: flex;
|
879 |
+
align-items: center;
|
880 |
+
gap: 8px;
|
881 |
+
'>
|
882 |
+
<span style='font-size: 1.1rem;'>{feedback_data.get('score', '')}</span>
|
883 |
+
<span style='color: #059669; font-weight: 500; font-size: 0.9rem;'>
|
884 |
+
Thanks for your feedback!
|
885 |
+
</span>
|
886 |
+
</div>
|
887 |
+
""", unsafe_allow_html=True)
|
888 |
+
with col2:
|
889 |
+
if st.button("π Retry", key=f"retry_{response_id}", use_container_width=True):
|
890 |
+
user_prompt = ""
|
891 |
+
if response_id > 0:
|
892 |
+
user_prompt = st.session_state.responses[response_id-1].get("content", "")
|
893 |
+
if user_prompt:
|
894 |
+
if response_id > 0:
|
895 |
+
retry_prompt = st.session_state.responses[response_id-1].get("content", "")
|
896 |
+
del st.session_state.responses[response_id]
|
897 |
+
del st.session_state.responses[response_id-1]
|
898 |
+
st.session_state.follow_up_prompt = retry_prompt
|
899 |
+
st.rerun()
|
900 |
else:
|
901 |
+
# Clean feedback and retry layout
|
902 |
+
col1, col2, col3, col4 = st.columns([2, 2, 1, 1])
|
|
|
|
|
|
|
|
|
903 |
|
|
|
904 |
with col1:
|
905 |
+
if st.button("β¨ Excellent", key=f"{feedback_key}_excellent", use_container_width=True):
|
906 |
feedback = {"score": "β¨ Excellent", "text": ""}
|
907 |
st.session_state.responses[response_id]["feedback"] = feedback
|
908 |
st.rerun()
|
909 |
+
|
910 |
with col2:
|
911 |
+
if st.button("π§ Needs work", key=f"{feedback_key}_poor", use_container_width=True):
|
912 |
feedback = {"score": "π§ Needs work", "text": ""}
|
913 |
st.session_state.responses[response_id]["feedback"] = feedback
|
914 |
st.rerun()
|
915 |
+
|
916 |
+
with col4:
|
917 |
+
if st.button("π Retry", key=f"retry_{response_id}", use_container_width=True):
|
918 |
+
user_prompt = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
919 |
if response_id > 0:
|
920 |
+
user_prompt = st.session_state.responses[response_id-1].get("content", "")
|
921 |
+
if user_prompt:
|
922 |
+
if response_id > 0:
|
923 |
+
retry_prompt = st.session_state.responses[response_id-1].get("content", "")
|
924 |
+
del st.session_state.responses[response_id]
|
925 |
+
del st.session_state.responses[response_id-1]
|
926 |
+
st.session_state.follow_up_prompt = retry_prompt
|
927 |
+
st.rerun()
|
928 |
|
929 |
# Chat input with better guidance
|
930 |
prompt = st.chat_input("π¬ Ask about air quality trends, pollution analysis, or city comparisons...", key="main_chat")
|