Wajahat698 commited on
Commit
d4ce59e
·
verified ·
1 Parent(s): 4040a8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -60
app.py CHANGED
@@ -768,79 +768,71 @@ def side():
768
 
769
 
770
  trust_buckets = [
771
- "Stability",
772
- "Development",
773
- "Relationship",
774
- "Benefit",
775
- "Vision",
776
- "Competence",
777
  ]
778
 
779
- # Map bucket names to icon filenames
780
- icon_files = {
781
- "Stability": "Bucket_STABILITY.png",
782
- "Development": "Bucket_DEVELOPMENT.png",
783
- "Relationship": "Bucket_RELATIONSHIP.png",
784
- "Benefit": "Bucket_BENEFIT.png",
785
- "Vision": "Bucket_VISION.png",
786
- "Competence": "Bucket_COMPETENCE.png",
787
- }
788
-
789
- # Function to encode local images as Base64
790
- def get_base64(file_path):
791
- try:
792
- with open(file_path, "rb") as f:
793
- return base64.b64encode(f.read()).decode()
794
- except FileNotFoundError:
795
- st.error(f"File not found: {file_path}")
796
- return ""
797
-
798
- # Generate HTML for dropdown
799
- dropdown_html = """
800
- <style>
801
- .custom-dropdown {
802
- width: 100%;
803
- max-width: 400px;
804
- margin: 10px auto;
805
- font-family: Arial, sans-serif;
806
  }
807
- .custom-dropdown option {
808
- display: flex;
809
- align-items: center;
810
- padding: 10px;
811
  font-size: 16px;
 
 
 
812
  }
813
- </style>
814
- <div class="custom-dropdown">
815
- <select>
816
- """
 
 
 
 
 
 
 
 
 
817
 
 
 
 
818
  for bucket in trust_buckets:
819
- if bucket in icon_files:
820
- icon_path = os.path.join(".", icon_files[bucket]) # Adjust path if icons are in a subdirectory
821
- encoded_img = get_base64(icon_path)
822
- dropdown_html += f"""
823
- <option style="background-image: url('data:image/png;base64,{encoded_img}');
824
- background-repeat: no-repeat;
825
- background-size: 20px 20px;
826
- background-position: left center;
827
- padding-left: 40px;">
828
- {bucket}
829
- </option>
830
- """
831
- else:
832
- dropdown_html += f"<option>{bucket}</option>"
833
 
834
- dropdown_html += """
835
- </select>
836
- </div>
837
- """
838
 
839
 
840
 
841
  st.subheader("Show My TrustBuilders®")
842
  search_query = st.text_input("Search by keyword", key="search_query")
843
- st.markdown(dropdown_html, unsafe_allow_html=True)
 
 
 
 
 
 
844
 
845
 
846
 
 
768
 
769
 
770
  trust_buckets = [
771
+ {"name": "Stability", "color": "rgb(7, 55, 99)"},
772
+ {"name": "Development", "color": "rgb(241, 194, 50)"},
773
+ {"name": "Relationship", "color": "rgb(204, 0, 0)"},
774
+ {"name": "Benefit", "color": "rgb(56, 118, 29)"},
775
+ {"name": "Vision", "color": "rgb(255, 153, 0)"},
776
+ {"name": "Competence", "color": "rgb(111, 168, 220)"},
777
  ]
778
 
779
+ # Inject CSS styles for the scrollable dropdown
780
+ st.markdown(
781
+ """
782
+ <style>
783
+ .scrollable-dropdown {
784
+ max-height: 200px;
785
+ overflow-y: auto;
786
+ border: 1px solid #ccc;
787
+ border-radius: 5px;
788
+ padding: 5px;
789
+ background-color: #f9f9f9;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  }
791
+ .dropdown-item {
792
+ padding: 8px 12px;
 
 
793
  font-size: 16px;
794
+ font-weight: bold;
795
+ cursor: pointer;
796
+ border-bottom: 1px solid #ddd;
797
  }
798
+ .dropdown-item:hover {
799
+ background-color: #e6f7ff;
800
+ }
801
+ .stability { color: rgb(7, 55, 99); }
802
+ .development { color: rgb(241, 194, 50); }
803
+ .relationship { color: rgb(204, 0, 0); }
804
+ .benefit { color: rgb(56, 118, 29); }
805
+ .vision { color: rgb(255, 153, 0); }
806
+ .competence { color: rgb(111, 168, 220); }
807
+ </style>
808
+ """,
809
+ unsafe_allow_html=True,
810
+ )
811
 
812
+ # Scrollable Dropdown with colored items
813
+ st.markdown('<div class="scrollable-dropdown">', unsafe_allow_html=True)
814
+ selected_bucket = None
815
  for bucket in trust_buckets:
816
+ # Display each item with its unique color
817
+ if st.button(bucket["name"], key=bucket["name"]):
818
+ selected_bucket = bucket["name"]
819
+ st.session_state["selected_bucket_color"] = bucket["color"]
 
 
 
 
 
 
 
 
 
 
820
 
821
+ st.markdown("</div>", unsafe_allow_html=True)
822
+
823
+
 
824
 
825
 
826
 
827
  st.subheader("Show My TrustBuilders®")
828
  search_query = st.text_input("Search by keyword", key="search_query")
829
+ if selected_bucket:
830
+ st.markdown(
831
+ f'<p style="font-size: 18px; color: {st.session_state.get("selected_bucket_color", "#000")};">'
832
+ f"<strong>Selected Trust Bucket:</strong> {selected_bucket}</p>",
833
+ unsafe_allow_html=True,
834
+ )
835
+
836
 
837
 
838