Anne31415 commited on
Commit
1110c74
·
1 Parent(s): 29fa4c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -31,10 +31,14 @@ def estimate_num_circles(text, character_width=7, circle_diameter=30):
31
  def cloud_button(label, key=None, color=None):
32
  button_id = f"cloud-button-{key or label}"
33
  color_class = f"color-{color}" if color else ""
34
- num_circles = estimate_num_circles(label)
35
 
36
- # Generate circles
37
- circles_html = ''.join([f'<div class="circle" style="left: {-i * 30}px;"></div>' for i in range(num_circles)])
 
 
 
 
38
 
39
  cloud_button_html = f"""
40
  <div class="cloud {color_class}" id="{button_id}" style="margin-bottom: 20px;">
@@ -50,7 +54,6 @@ def cloud_button(label, key=None, color=None):
50
  user-select: none;
51
  font-size: 16px;
52
  white-space: nowrap;
53
- background-color: #f8f9fa;
54
  }}
55
  .rectangle {{
56
  min-width: 120px;
@@ -66,29 +69,27 @@ def cloud_button(label, key=None, color=None):
66
  transition: background-color 0.4s;
67
  }}
68
  .circle {{
69
- background-color: #f8f9fa;
70
  border-radius: 50%;
71
  width: 30px;
72
  height: 30px;
73
- position: absolute;
74
  z-index: 1;
75
- top: 50%;
76
- transform: translateY(-50%);
77
  }}
78
  .cloud:hover .rectangle {{
79
  background-color: #008CBA;
80
  color: white;
81
  }}
82
- .color-1 .rectangle {{ background-color: #FFA07A; }}
83
- .color-2 .rectangle {{ background-color: #FF7F50; }}
84
- .color-3 .rectangle {{ background-color: #FF6347; }}
85
- .color-4 .rectangle {{ background-color: #FF4500; }}
86
- .color-5 .rectangle {{ background-color: #FF8C00; }}
87
- .color-6 .rectangle {{ background-color: #FFD700; }}
88
  </style>
89
  <script>
90
  document.getElementById("{button_id}").onclick = function() {{
91
- // Add your JavaScript code here
92
  }};
93
  </script>
94
  """
 
31
  def cloud_button(label, key=None, color=None):
32
  button_id = f"cloud-button-{key or label}"
33
  color_class = f"color-{color}" if color else ""
34
+ num_circles = max(3, min(12, len(label) // 4)) # Adjust the number of circles based on text length
35
 
36
+ # Generate circles on both sides of the text
37
+ circles_html = ''.join([
38
+ f'<div class="circle" style="margin-right: -10px;"></div>' for _ in range(num_circles//2)
39
+ ] + [
40
+ f'<div class="circle" style="margin-left: -10px;"></div>' for _ in range(num_circles//2)
41
+ ])
42
 
43
  cloud_button_html = f"""
44
  <div class="cloud {color_class}" id="{button_id}" style="margin-bottom: 20px;">
 
54
  user-select: none;
55
  font-size: 16px;
56
  white-space: nowrap;
 
57
  }}
58
  .rectangle {{
59
  min-width: 120px;
 
69
  transition: background-color 0.4s;
70
  }}
71
  .circle {{
72
+ background-color: inherit;
73
  border-radius: 50%;
74
  width: 30px;
75
  height: 30px;
76
+ position: relative;
77
  z-index: 1;
 
 
78
  }}
79
  .cloud:hover .rectangle {{
80
  background-color: #008CBA;
81
  color: white;
82
  }}
83
+ .color-1 .rectangle, .color-1 .circle {{ background-color: #FFA07A; }}
84
+ .color-2 .rectangle, .color-2 .circle {{ background-color: #FF7F50; }}
85
+ .color-3 .rectangle, .color-3 .circle {{ background-color: #FF6347; }}
86
+ .color-4 .rectangle, .color-4 .circle {{ background-color: #FF4500; }}
87
+ .color-5 .rectangle, .color-5 .circle {{ background-color: #FF8C00; }}
88
+ .color-6 .rectangle, .color-6 .circle {{ background-color: #FFD700; }}
89
  </style>
90
  <script>
91
  document.getElementById("{button_id}").onclick = function() {{
92
+ // Your existing JavaScript code for handling button click
93
  }};
94
  </script>
95
  """