Anne31415 commited on
Commit
5efe4f5
·
1 Parent(s): c66ac46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -30,17 +30,17 @@ def cloud_button(label, key=None, color=None):
30
  num_circles = max(3, min(12, len(label) // 4)) # Adjust the number of circles based on text length
31
  circle_size = 60
32
 
33
- # Generate circles on both sides of the text
34
  circles_html = ''.join([
35
- f'<div class="circle {color_class}" style="margin-right: -{circle_size // 2}px;"></div>' for _ in range(num_circles//2)
36
- ] + [
37
- f'<div class="circle {color_class}" style="margin-left: -{circle_size // 2}px;"></div>' for _ in range(num_circles//2)
38
  ])
39
 
40
  cloud_button_html = f"""
41
  <div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
42
- {circles_html}
43
- <div class="text">{label}</div>
 
 
44
  </div>
45
  <style>
46
  .cloud {{
@@ -48,24 +48,29 @@ def cloud_button(label, key=None, color=None):
48
  display: inline-flex;
49
  align-items: center;
50
  }}
 
 
 
 
 
 
 
51
  .text {{
52
  position: relative;
53
  font-weight: bold;
54
- padding: 10px 20px;
55
- z-index: 2; # Higher z-index to place text on top of circles
56
- background-color: transparent;
57
  }}
58
  .circle {{
59
  background-color: #9BBEFF;
60
  border-radius: 50%;
61
  width: {circle_size}px;
62
  height: {circle_size}px;
63
- position: relative;
64
- z-index: 1; # Lower z-index to place circles below text
65
  }}
66
- .color-1 .circle {{ background-color: #FFA07A; }}
67
- .color-2 .circle {{ background-color: #FF7F50; }}
68
- .color-3 .circle {{ background-color: #FF6347; }}
69
  </style>
70
  <script>
71
  document.getElementById("{button_id}").onclick = function() {{
@@ -79,9 +84,6 @@ cloud_button("Short Text", color="1")
79
  cloud_button("This is a longer piece of text", color="2")
80
  cloud_button("This is an even longer piece of text to test the cloud button", color="3")
81
 
82
-
83
-
84
-
85
  def load_pdf(file_path):
86
  pdf_reader = PdfReader(file_path)
87
  text = ""
 
30
  num_circles = max(3, min(12, len(label) // 4)) # Adjust the number of circles based on text length
31
  circle_size = 60
32
 
33
+ # Generate circles
34
  circles_html = ''.join([
35
+ f'<div class="circle {color_class}"></div>' for _ in range(num_circles)
 
 
36
  ])
37
 
38
  cloud_button_html = f"""
39
  <div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
40
+ <div class="wrapper {color_class}">
41
+ {circles_html}
42
+ <div class="text">{label}</div>
43
+ </div>
44
  </div>
45
  <style>
46
  .cloud {{
 
48
  display: inline-flex;
49
  align-items: center;
50
  }}
51
+ .wrapper {{
52
+ display: flex;
53
+ align-items: center;
54
+ background-color: #9BBEFF;
55
+ border-radius: 30px; # Adjust as needed
56
+ padding: 10px 20px;
57
+ }}
58
  .text {{
59
  position: relative;
60
  font-weight: bold;
61
+ z-index: 2;
 
 
62
  }}
63
  .circle {{
64
  background-color: #9BBEFF;
65
  border-radius: 50%;
66
  width: {circle_size}px;
67
  height: {circle_size}px;
68
+ margin: 0 -{circle_size // 4}px; # Adjust negative margin for overlap
69
+ z-index: 1;
70
  }}
71
+ .color-1 .wrapper, .color-1 .circle {{ background-color: #FFA07A; }}
72
+ .color-2 .wrapper, .color-2 .circle {{ background-color: #FF7F50; }}
73
+ .color-3 .wrapper, .color-3 .circle {{ background-color: #FF6347; }}
74
  </style>
75
  <script>
76
  document.getElementById("{button_id}").onclick = function() {{
 
84
  cloud_button("This is a longer piece of text", color="2")
85
  cloud_button("This is an even longer piece of text to test the cloud button", color="3")
86
 
 
 
 
87
  def load_pdf(file_path):
88
  pdf_reader = PdfReader(file_path)
89
  text = ""