Nipun Claude commited on
Commit
2a57e86
Β·
1 Parent(s): 7b4da8e

Fix button layout and spacing for professional UI

Browse files

LAYOUT 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]>

Files changed (1) hide show
  1. app.py +73 -70
app.py CHANGED
@@ -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
- # Beautiful header with logo and branding
577
- col1, col2, col3 = st.columns([1, 2, 1])
578
- with col2:
579
- st.markdown("""
580
- <div style='text-align: center; padding: 1rem 0;'>
581
- <img src='https://sustainability-lab.github.io/images/logo_light.svg'
582
- style='height: 60px; margin-bottom: 10px;' />
 
 
 
 
 
 
 
583
  <h1 style='
584
  margin: 0;
585
- font-size: 2.5rem;
586
  font-weight: 700;
587
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
588
- -webkit-background-clip: text;
589
- -webkit-text-fill-color: transparent;
590
- background-clip: text;
591
  '>VayuChat</h1>
592
  <p style='
593
- margin: 5px 0 0 0;
594
- font-size: 1.1rem;
595
- color: #6b7280;
596
- font-weight: 500;
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
- """, unsafe_allow_html=True)
 
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
- # Awesome feedback system
 
 
866
  if "feedback" in st.session_state.responses[response_id]:
 
867
  feedback_data = st.session_state.responses[response_id]["feedback"]
868
- st.markdown(f"""
869
- <div style='
870
- background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
871
- border: 1px solid #d1d5db;
872
- border-radius: 12px;
873
- padding: 1rem;
874
- margin: 0.5rem 0;
875
- display: flex;
876
- align-items: center;
877
- gap: 12px;
878
- '>
879
- <span style='font-size: 1.2rem;'>{feedback_data.get('score', '')}</span>
880
- <span style='color: #6b7280; font-weight: 500;'>
881
- {feedback_data.get('text', 'Thanks for your feedback!')}
882
- </span>
883
- </div>
884
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
885
  else:
886
- # Beautiful feedback buttons
887
- st.markdown("""
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", help="This response was very helpful!"):
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", help="This response could be improved"):
901
  feedback = {"score": "πŸ”§ Needs work", "text": ""}
902
  st.session_state.responses[response_id]["feedback"] = feedback
903
  st.rerun()
904
-
905
- # Clean action buttons
906
- col1, col2, col3 = st.columns([1, 4, 1])
907
- with col1:
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
- # Store the user prompt
918
- retry_prompt = st.session_state.responses[response_id-1].get("content", "")
919
- # Remove both user message and assistant response
920
- del st.session_state.responses[response_id]
921
- del st.session_state.responses[response_id-1]
922
- # Re-add user message and trigger new response
923
- st.session_state.follow_up_prompt = retry_prompt
924
- st.rerun()
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")