Spaces:
Build error
Build error
Update app.py
Browse files767 unmodified lines768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846767 unmodified linestrust_buckets = ["Stability","Development","Relationship","Benefit","Vision","Competence",]# Map bucket names to icon filenamesicon_files = {"Stability": "Bucket_STABILITY.png","Development": "Bucket_DEVELOPMENT.png","Relationship": "Bucket_RELATIONSHIP.png","Benefit": "Bucket_BENEFIT.png","Vision": "Bucket_VISION.png","Competence": "Bucket_COMPETENCE.png",}# Function to encode local images as Base64def get_base64(file_path):try:with open(file_path, "rb") as f:return base64.b64encode(f.read()).decode()except FileNotFoundError:st.error(f"File not found: {file_path}")return ""# Generate HTML for dropdowndropdown_html = """<style>.custom-dropdown {width: 100%;max-width: 400px;margin: 10px auto;font-family: Arial, sans-serif;}.custom-dropdown option {display: flex;align-items: center;padding: 10px;font-size: 16px;}</style><div class="custom-dropdown"><select>"""for bucket in trust_buckets:if bucket in icon_files:icon_path = os.path.join(".", icon_files[bucket]) # Adjust path if icons are in a subdirectoryencoded_img = get_base64(icon_path)dropdown_html += f"""<option style="background-image: url('data:image/png;base64,{encoded_img}');background-repeat: no-repeat;background-size: 20px 20px;background-position: left center;padding-left: 40px;">{bucket}</option>"""else:dropdown_html += f"<option>{bucket}</option>"dropdown_html += """</select></div>"""st.subheader("Show My TrustBuilders®")search_query = st.text_input("Search by keyword", key="search_query")st.markdown(dropdown_html, unsafe_allow_html=True)767 unmodified lines768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838767 unmodified linestrust_buckets = [{"name": "Stability", "color": "rgb(7, 55, 99)"},{"name": "Development", "color": "rgb(241, 194, 50)"},{"name": "Relationship", "color": "rgb(204, 0, 0)"},{"name": "Benefit", "color": "rgb(56, 118, 29)"},{"name": "Vision", "color": "rgb(255, 153, 0)"},{"name": "Competence", "color": "rgb(111, 168, 220)"},]# Inject CSS styles for the scrollable dropdownst.markdown("""<style>.scrollable-dropdown {max-height: 200px;overflow-y: auto;border: 1px solid #ccc;border-radius: 5px;padding: 5px;background-color: #f9f9f9;}.dropdown-item {padding: 8px 12px;font-size: 16px;font-weight: bold;cursor: pointer;border-bottom: 1px solid #ddd;}.dropdown-item:hover {background-color: #e6f7ff;}.stability { color: rgb(7, 55, 99); }.development { color: rgb(241, 194, 50); }.relationship { color: rgb(204, 0, 0); }.benefit { color: rgb(56, 118, 29); }.vision { color: rgb(255, 153, 0); }.competence { color: rgb(111, 168, 220); }</style>""",unsafe_allow_html=True,)# Scrollable Dropdown with colored itemsst.markdown('<div class="scrollable-dropdown">', unsafe_allow_html=True)selected_bucket = Nonefor bucket in trust_buckets:# Display each item with its unique colorif st.button(bucket["name"], key=bucket["name"]):selected_bucket = bucket["name"]st.session_state["selected_bucket_color"] = bucket["color"]st.markdown("</div>", unsafe_allow_html=True)st.subheader("Show My TrustBuilders®")search_query = st.text_input("Search by keyword", key="search_query")if selected_bucket:st.markdown(f'<p style="font-size: 18px; color: {st.session_state.get("selected_bucket_color", "#000")};">'f"<strong>Selected Trust Bucket:</strong> {selected_bucket}</p>",unsafe_allow_html=True,)
app.py+52-60