Anne31415 commited on
Commit
df5dc0d
·
1 Parent(s): 04d331c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -29,8 +29,11 @@ def cloud_button(label, key=None, color=None):
29
  num_circles = max(3, min(12, len(label) // 4))
30
  circle_size = 60
31
 
 
 
 
32
  circles_html = ''.join([
33
- f'<div class="circle {color_class}"></div>' for _ in range(num_circles)
34
  ])
35
 
36
  cloud_button_html = f"""
@@ -49,9 +52,11 @@ def cloud_button(label, key=None, color=None):
49
  .wrapper {{
50
  display: flex;
51
  align-items: center;
 
52
  background-color: transparent;
53
  border-radius: 30px;
54
  padding: 10px 20px;
 
55
  }}
56
  .text {{
57
  position: relative;
@@ -59,14 +64,10 @@ def cloud_button(label, key=None, color=None):
59
  z-index: 2;
60
  }}
61
  .circle {{
62
- background-color: transparent;
63
  border-radius: 50%;
64
  width: {circle_size}px;
65
  height: {circle_size}px;
66
- margin: 0 -{circle_size // 4}px;
67
- position: absolute;
68
- top: 50%;
69
- transform: translateY(-50%);
70
  z-index: 1;
71
  }}
72
  .color-1 .wrapper, .color-1 .circle {{ background-color: #FFA07A; }}
@@ -81,8 +82,6 @@ def cloud_button(label, key=None, color=None):
81
  """
82
  st.markdown(cloud_button_html, unsafe_allow_html=True)
83
 
84
-
85
-
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")
 
29
  num_circles = max(3, min(12, len(label) // 4))
30
  circle_size = 60
31
 
32
+ # Calculate the spacing between circles based on the number of circles
33
+ spacing = circle_size // (num_circles + 1)
34
+
35
  circles_html = ''.join([
36
+ f'<div class="circle {color_class}" style="margin-left: -{spacing}px;"></div>' for _ in range(num_circles)
37
  ])
38
 
39
  cloud_button_html = f"""
 
52
  .wrapper {{
53
  display: flex;
54
  align-items: center;
55
+ justify-content: center;
56
  background-color: transparent;
57
  border-radius: 30px;
58
  padding: 10px 20px;
59
+ overflow: hidden; # Hide overflowed circles
60
  }}
61
  .text {{
62
  position: relative;
 
64
  z-index: 2;
65
  }}
66
  .circle {{
67
+ background-color: #9BBEFF;
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; }}
 
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")