Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,27 +29,24 @@ import streamlit as st
|
|
29 |
|
30 |
import streamlit as st
|
31 |
|
|
|
|
|
32 |
def cloud_button(label, key=None, color=None):
|
33 |
button_id = f"cloud-button-{key or label}"
|
34 |
color_class = f"color-{color}" if color else ""
|
35 |
num_circles = max(3, min(12, len(label) // 4)) # Adjust the number of circles based on text length
|
36 |
|
37 |
-
# Calculate the overlap and spacing for the circles
|
38 |
-
circle_diameter = 60
|
39 |
-
overlap = 0.4 # 40% overlap
|
40 |
-
spacing = circle_diameter * (1 - overlap)
|
41 |
-
|
42 |
# Generate circles on both sides of the text
|
43 |
circles_html = ''.join([
|
44 |
-
f'<div class="circle {color_class}" style="margin-right: -
|
45 |
] + [
|
46 |
-
f'<div class="circle {color_class}" style="margin-left: -
|
47 |
])
|
48 |
|
49 |
cloud_button_html = f"""
|
50 |
-
<div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
|
51 |
{circles_html}
|
52 |
-
<
|
53 |
</div>
|
54 |
<style>
|
55 |
.cloud {{
|
@@ -61,7 +58,10 @@ def cloud_button(label, key=None, color=None):
|
|
61 |
font-size: 16px;
|
62 |
white-space: nowrap;
|
63 |
}}
|
64 |
-
.
|
|
|
|
|
|
|
65 |
position: relative;
|
66 |
display: inline-flex;
|
67 |
align-items: center;
|
@@ -69,23 +69,16 @@ def cloud_button(label, key=None, color=None):
|
|
69 |
font-weight: bold;
|
70 |
padding: 10px 20px;
|
71 |
z-index: 2;
|
72 |
-
|
73 |
-
border-radius: 30px;
|
74 |
}}
|
75 |
.circle {{
|
|
|
76 |
border-radius: 50%;
|
77 |
-
width:
|
78 |
-
height:
|
79 |
position: relative;
|
80 |
z-index: 1;
|
81 |
}}
|
82 |
-
.cloud:hover .text {{
|
83 |
-
background-color: #008CBA;
|
84 |
-
color: white;
|
85 |
-
}}
|
86 |
-
.color-1 .text, .color-1 .circle {{ background-color: #FFA07A; }}
|
87 |
-
.color-2 .text, .color-2 .circle {{ background-color: #FF7F50; }}
|
88 |
-
.color-3 .text, .color-3 .circle {{ background-color: #FF6347; }}
|
89 |
</style>
|
90 |
<script>
|
91 |
document.getElementById("{button_id}").onclick = function() {{
|
@@ -95,6 +88,11 @@ def cloud_button(label, key=None, color=None):
|
|
95 |
"""
|
96 |
st.markdown(cloud_button_html, unsafe_allow_html=True)
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
|
100 |
|
@@ -166,9 +164,7 @@ def main():
|
|
166 |
# Main content
|
167 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
168 |
|
169 |
-
|
170 |
-
cloud_button("This is a longer piece of text", color="2")
|
171 |
-
cloud_button("This is an even longer piece of text to test the cloud button", color="3")
|
172 |
|
173 |
|
174 |
pdf_path = "path_to_your_pdf_file.pdf" # Update this to the path of your PDF file
|
|
|
29 |
|
30 |
import streamlit as st
|
31 |
|
32 |
+
import streamlit as st
|
33 |
+
|
34 |
def cloud_button(label, key=None, color=None):
|
35 |
button_id = f"cloud-button-{key or label}"
|
36 |
color_class = f"color-{color}" if color else ""
|
37 |
num_circles = max(3, min(12, len(label) // 4)) # Adjust the number of circles based on text length
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
# Generate circles on both sides of the text
|
40 |
circles_html = ''.join([
|
41 |
+
f'<div class="circle {color_class}" style="margin-right: -15px;"></div>' for _ in range(num_circles//2)
|
42 |
] + [
|
43 |
+
f'<div class="circle {color_class}" style="margin-left: -15px;"></div>' for _ in range(num_circles//2)
|
44 |
])
|
45 |
|
46 |
cloud_button_html = f"""
|
47 |
+
<div class="cloud {color_class}" id="{button_id}" style="margin-bottom: 20px; display: inline-block;">
|
48 |
{circles_html}
|
49 |
+
<div class="rectangle {color_class}">{label}</div>
|
50 |
</div>
|
51 |
<style>
|
52 |
.cloud {{
|
|
|
58 |
font-size: 16px;
|
59 |
white-space: nowrap;
|
60 |
}}
|
61 |
+
.rectangle {{
|
62 |
+
min-width: 120px;
|
63 |
+
height: auto;
|
64 |
+
border-radius: 30px;
|
65 |
position: relative;
|
66 |
display: inline-flex;
|
67 |
align-items: center;
|
|
|
69 |
font-weight: bold;
|
70 |
padding: 10px 20px;
|
71 |
z-index: 2;
|
72 |
+
background-color: #9BBEFF;
|
|
|
73 |
}}
|
74 |
.circle {{
|
75 |
+
background-color: #9BBEFF;
|
76 |
border-radius: 50%;
|
77 |
+
width: 30px;
|
78 |
+
height: 30px;
|
79 |
position: relative;
|
80 |
z-index: 1;
|
81 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
</style>
|
83 |
<script>
|
84 |
document.getElementById("{button_id}").onclick = function() {{
|
|
|
88 |
"""
|
89 |
st.markdown(cloud_button_html, unsafe_allow_html=True)
|
90 |
|
91 |
+
# Examples
|
92 |
+
cloud_button("Short Text", color="1")
|
93 |
+
cloud_button("This is a longer piece of text", color="2")
|
94 |
+
cloud_button("This is an even longer piece of text to test the cloud button", color="3")
|
95 |
+
|
96 |
|
97 |
|
98 |
|
|
|
164 |
# Main content
|
165 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
166 |
|
167 |
+
|
|
|
|
|
168 |
|
169 |
|
170 |
pdf_path = "path_to_your_pdf_file.pdf" # Update this to the path of your PDF file
|