chenemii commited on
Commit
a8f3657
·
1 Parent(s): f0557d7

Replace floating sidebar with hamburger menu navigation

Browse files

- Remove floating sidebar navigation box from right side
- Replace Streamlit sidebar arrow with hamburger menu (☰) in top left
- Add CSS for styled hamburger menu with dropdown
- Include JavaScript for menu toggle functionality
- Menu contains: Improvements, Chatbot, and Start Over options
- Auto-close menu when clicking outside or selecting option
- Clean, modern navigation pattern following UX best practices

Files changed (1) hide show
  1. app/streamlit_app.py +98 -56
app/streamlit_app.py CHANGED
@@ -625,36 +625,7 @@ def main():
625
  border-radius: 5px;
626
  }
627
 
628
- .sidebar-nav {
629
- position: fixed;
630
- top: 100px;
631
- right: 20px;
632
- background: rgba(76, 175, 80, 0.05);
633
- border: 2px solid rgba(76, 175, 80, 0.2);
634
- border-radius: 15px;
635
- padding: 15px;
636
- z-index: 1000;
637
- min-width: 150px;
638
- }
639
-
640
- .nav-button {
641
- display: block;
642
- width: 100%;
643
- margin: 5px 0;
644
- padding: 8px 12px;
645
- background: #0B3B0B;
646
- color: white;
647
- border: none;
648
- border-radius: 20px;
649
- text-align: center;
650
- text-decoration: none;
651
- font-size: 12px;
652
- cursor: pointer;
653
- }
654
-
655
- .nav-button:hover {
656
- background: #4CAF50;
657
- }
658
 
659
  .stButton > button {
660
  background-color: #0B3B0B;
@@ -715,42 +686,113 @@ def main():
715
  enable_gpt = any_service_available
716
  sample_rate = 1
717
 
718
- # Floating sidebar navigation (appears after Step 3)
719
  if st.session_state.current_step >= 3:
720
- st.session_state.show_sidebar = True
721
-
722
- if st.session_state.show_sidebar:
723
  st.markdown("""
724
- <div class="sidebar-nav">
725
- <h4 style="color: #0B3B0B; margin: 0 0 10px 0; font-size: 14px;">Navigation</h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
  """, unsafe_allow_html=True)
728
 
729
- # Navigation buttons in sidebar
730
- sidebar_col = st.sidebar
731
- with sidebar_col:
732
- st.markdown("### 🧭 Quick Navigation")
733
 
734
- if st.button("⚙️ Options", key="nav_options", use_container_width=True):
735
- st.session_state.current_step = 3
 
 
 
736
  st.rerun()
 
 
 
 
 
737
 
738
- if st.button("🎯 Improvements", key="nav_improvements", use_container_width=True):
739
- st.session_state.current_step = 4
740
- st.rerun()
741
 
742
- if st.button("💬 Chatbot", key="nav_chatbot", use_container_width=True):
743
- st.session_state.current_step = 5
744
- st.rerun()
 
 
 
 
 
 
 
 
745
 
746
- st.markdown("---")
747
- if st.button("🔄 Start Over", key="nav_start_over", use_container_width=True):
748
- # Reset all session state
749
- for key in list(st.session_state.keys()):
750
- if key != 'session_initialized':
751
- del st.session_state[key]
752
- st.session_state.current_step = 1
753
- st.rerun()
 
754
 
755
  # Step-based content rendering
756
  if st.session_state.current_step == 1:
 
625
  border-radius: 5px;
626
  }
627
 
628
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
 
630
  .stButton > button {
631
  background-color: #0B3B0B;
 
686
  enable_gpt = any_service_available
687
  sample_rate = 1
688
 
689
+ # Hamburger menu navigation (appears after Step 3)
690
  if st.session_state.current_step >= 3:
691
+ # Add hamburger menu CSS and HTML
 
 
692
  st.markdown("""
693
+ <style>
694
+ .hamburger-menu {
695
+ position: fixed;
696
+ top: 20px;
697
+ left: 20px;
698
+ z-index: 1000;
699
+ background: #0B3B0B;
700
+ color: white;
701
+ border: none;
702
+ border-radius: 8px;
703
+ padding: 10px;
704
+ font-size: 18px;
705
+ cursor: pointer;
706
+ box-shadow: 0 2px 8px rgba(11, 59, 11, 0.3);
707
+ }
708
+
709
+ .hamburger-menu:hover {
710
+ background: #4CAF50;
711
+ }
712
+
713
+ .menu-content {
714
+ position: fixed;
715
+ top: 60px;
716
+ left: 20px;
717
+ background: rgba(255, 255, 255, 0.95);
718
+ border: 2px solid #4CAF50;
719
+ border-radius: 10px;
720
+ padding: 15px;
721
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
722
+ z-index: 999;
723
+ min-width: 180px;
724
+ backdrop-filter: blur(10px);
725
+ }
726
+
727
+ .menu-hidden {
728
+ display: none;
729
+ }
730
+ </style>
731
+
732
+ <div class="hamburger-menu" onclick="toggleMenu()">
733
+
734
+ </div>
735
+
736
+ <div id="menu-content" class="menu-content menu-hidden">
737
+ <h4 style="color: #0B3B0B; margin: 0 0 10px 0;">Navigation</h4>
738
  </div>
739
+
740
+ <script>
741
+ function toggleMenu() {
742
+ const menu = document.getElementById('menu-content');
743
+ menu.classList.toggle('menu-hidden');
744
+ }
745
+
746
+ // Close menu when clicking outside
747
+ document.addEventListener('click', function(event) {
748
+ const menu = document.getElementById('menu-content');
749
+ const hamburger = document.querySelector('.hamburger-menu');
750
+ if (!menu.contains(event.target) && !hamburger.contains(event.target)) {
751
+ menu.classList.add('menu-hidden');
752
+ }
753
+ });
754
+ </script>
755
  """, unsafe_allow_html=True)
756
 
757
+ # Navigation menu in main content (only show when menu should be visible)
758
+ if 'show_menu' not in st.session_state:
759
+ st.session_state.show_menu = False
 
760
 
761
+ # Menu toggle button
762
+ col1, col2, col3 = st.columns([1, 8, 1])
763
+ with col1:
764
+ if st.button("☰", key="menu_toggle", help="Navigation Menu"):
765
+ st.session_state.show_menu = not st.session_state.show_menu
766
  st.rerun()
767
+
768
+ # Show menu content if toggled
769
+ if st.session_state.show_menu:
770
+ with st.container():
771
+ st.markdown("#### 🧭 Navigation")
772
 
773
+ nav_col1, nav_col2 = st.columns(2)
 
 
774
 
775
+ with nav_col1:
776
+ if st.button("🎯 Improvements", key="nav_improvements", use_container_width=True):
777
+ st.session_state.current_step = 4
778
+ st.session_state.show_menu = False
779
+ st.rerun()
780
+
781
+ with nav_col2:
782
+ if st.button("💬 Chatbot", key="nav_chatbot", use_container_width=True):
783
+ st.session_state.current_step = 5
784
+ st.session_state.show_menu = False
785
+ st.rerun()
786
 
787
+ if st.button("🔄 Start Over", key="nav_start_over", use_container_width=True):
788
+ # Reset all session state
789
+ for key in list(st.session_state.keys()):
790
+ if key != 'session_initialized':
791
+ del st.session_state[key]
792
+ st.session_state.current_step = 1
793
+ st.rerun()
794
+
795
+ st.markdown("---")
796
 
797
  # Step-based content rendering
798
  if st.session_state.current_step == 1: