Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,18 +29,18 @@ def cloud_button(label, key=None, color=None):
|
|
29 |
num_circles = max(3, min(12, len(label) // 4))
|
30 |
circle_size = 60
|
31 |
|
32 |
-
# Calculate the
|
33 |
-
|
34 |
|
35 |
circles_html = ''.join([
|
36 |
-
f'<div class="circle {color_class}" style="margin
|
37 |
])
|
38 |
|
39 |
cloud_button_html = f"""
|
40 |
<div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
|
41 |
<div class="wrapper {color_class}">
|
42 |
-
{circles_html}
|
43 |
<div class="text">{label}</div>
|
|
|
44 |
</div>
|
45 |
</div>
|
46 |
<style>
|
@@ -48,31 +48,31 @@ def cloud_button(label, key=None, color=None):
|
|
48 |
position: relative;
|
49 |
display: inline-flex;
|
50 |
align-items: center;
|
|
|
51 |
}}
|
52 |
.wrapper {{
|
53 |
display: flex;
|
54 |
align-items: center;
|
55 |
justify-content: center;
|
56 |
background-color: transparent;
|
57 |
-
|
58 |
-
padding: 10px 20px;
|
59 |
-
overflow: hidden; # Hide overflowed circles
|
60 |
}}
|
61 |
.text {{
|
62 |
position: relative;
|
63 |
font-weight: bold;
|
64 |
z-index: 2;
|
|
|
|
|
|
|
65 |
}}
|
66 |
.circle {{
|
67 |
-
background-color: #
|
68 |
border-radius: 50%;
|
69 |
width: {circle_size}px;
|
70 |
height: {circle_size}px;
|
|
|
71 |
z-index: 1;
|
72 |
}}
|
73 |
-
.color-1 .wrapper, .color-1 .circle {{ background-color: #FFA07A; }}
|
74 |
-
.color-2 .wrapper, .color-2 .circle {{ background-color: #FF7F50; }}
|
75 |
-
.color-3 .wrapper, .color-3 .circle {{ background-color: #FF6347; }}
|
76 |
</style>
|
77 |
<script>
|
78 |
document.getElementById("{button_id}").onclick = function() {{
|
@@ -82,10 +82,12 @@ def cloud_button(label, key=None, color=None):
|
|
82 |
"""
|
83 |
st.markdown(cloud_button_html, unsafe_allow_html=True)
|
84 |
|
|
|
85 |
cloud_button("Short Text", color="1")
|
86 |
cloud_button("This is a longer piece of text", color="2")
|
87 |
cloud_button("This is an even longer piece of text to test the cloud button", color="3")
|
88 |
|
|
|
89 |
def load_pdf(file_path):
|
90 |
pdf_reader = PdfReader(file_path)
|
91 |
text = ""
|
|
|
29 |
num_circles = max(3, min(12, len(label) // 4))
|
30 |
circle_size = 60
|
31 |
|
32 |
+
# Calculate the overlap based on the circle size
|
33 |
+
overlap = circle_size * 0.4
|
34 |
|
35 |
circles_html = ''.join([
|
36 |
+
f'<div class="circle {color_class}" style="margin: 0 -{overlap}px;"></div>' for _ in range(num_circles)
|
37 |
])
|
38 |
|
39 |
cloud_button_html = f"""
|
40 |
<div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
|
41 |
<div class="wrapper {color_class}">
|
|
|
42 |
<div class="text">{label}</div>
|
43 |
+
{circles_html}
|
44 |
</div>
|
45 |
</div>
|
46 |
<style>
|
|
|
48 |
position: relative;
|
49 |
display: inline-flex;
|
50 |
align-items: center;
|
51 |
+
justify-content: center;
|
52 |
}}
|
53 |
.wrapper {{
|
54 |
display: flex;
|
55 |
align-items: center;
|
56 |
justify-content: center;
|
57 |
background-color: transparent;
|
58 |
+
position: relative;
|
|
|
|
|
59 |
}}
|
60 |
.text {{
|
61 |
position: relative;
|
62 |
font-weight: bold;
|
63 |
z-index: 2;
|
64 |
+
background-color: white; # Set the background color of the text
|
65 |
+
padding: 10px 20px;
|
66 |
+
border-radius: 30px;
|
67 |
}}
|
68 |
.circle {{
|
69 |
+
background-color: #FF6347; # Set the background color of the circles
|
70 |
border-radius: 50%;
|
71 |
width: {circle_size}px;
|
72 |
height: {circle_size}px;
|
73 |
+
position: absolute;
|
74 |
z-index: 1;
|
75 |
}}
|
|
|
|
|
|
|
76 |
</style>
|
77 |
<script>
|
78 |
document.getElementById("{button_id}").onclick = function() {{
|
|
|
82 |
"""
|
83 |
st.markdown(cloud_button_html, unsafe_allow_html=True)
|
84 |
|
85 |
+
# Example usage
|
86 |
cloud_button("Short Text", color="1")
|
87 |
cloud_button("This is a longer piece of text", color="2")
|
88 |
cloud_button("This is an even longer piece of text to test the cloud button", color="3")
|
89 |
|
90 |
+
|
91 |
def load_pdf(file_path):
|
92 |
pdf_reader = PdfReader(file_path)
|
93 |
text = ""
|