Anne31415 commited on
Commit
3b9357b
·
1 Parent(s): 35a5f8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -23
app.py CHANGED
@@ -24,40 +24,25 @@ repo.git_pull() # Pull the latest changes (if any)
24
  pdf_file_path = "Private_Book/KOMBI_all2.pdf" # Replace with your PDF file path
25
 
26
 
27
- # Define a Streamlit component to display cloud-shaped text
28
- def cloud_text(text_content):
29
- cloud_html = f"""
30
- <div style="position: relative; background-color: #FFA07A; border-radius: 20px; padding: 10px; width: fit-content;">
31
- <div style="position: relative; z-index: 2;">{text_content}</div>
32
- <div style="position: absolute; top: -5px; left: 10px; width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-bottom: 20px solid #FFA07A;"></div>
33
- </div>
34
- """
35
- st.markdown(cloud_html, unsafe_allow_html=True)
36
-
37
- # Example usage
38
- text1 = "This is a short text."
39
- text2 = "This is a longer piece of text to test the cloud shape."
40
-
41
- cloud_text(text1)
42
- cloud_text(text2)
43
-
44
-
45
-
46
  def cloud_button(label, key=None, color=None):
47
  button_id = f"cloud-button-{key or label}"
48
  color_class = f"color-{color}" if color else ""
49
  num_circles = max(3, min(12, len(label) // 4))
50
  circle_size = 60
51
 
 
52
  circles_html = ''.join([
53
- f'<div class="circle {color_class}"></div>' for _ in range(num_circles)
 
 
 
 
54
  ])
55
 
56
  cloud_button_html = f"""
57
  <div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
58
  <div class="wrapper {color_class}">
59
  {circles_html}
60
- <div class="text">{label}</div>
61
  </div>
62
  </div>
63
  <style>
@@ -78,14 +63,17 @@ def cloud_button(label, key=None, color=None):
78
  position: relative;
79
  font-weight: bold;
80
  z-index: 2;
 
81
  }}
82
  .circle {{
83
  background-color: #FF6347;
84
  border-radius: 50%;
85
  width: {circle_size}px;
86
  height: {circle_size}px;
87
- position: absolute;
88
- z-index: 1;
 
 
89
  }}
90
  .color-1 .circle {{ background-color: #FFA07A; }}
91
  .color-2 .circle {{ background-color: #FF7F50; }}
 
24
  pdf_file_path = "Private_Book/KOMBI_all2.pdf" # Replace with your PDF file path
25
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  def cloud_button(label, key=None, color=None):
28
  button_id = f"cloud-button-{key or label}"
29
  color_class = f"color-{color}" if color else ""
30
  num_circles = max(3, min(12, len(label) // 4))
31
  circle_size = 60
32
 
33
+ # Create circles for left, middle, and right
34
  circles_html = ''.join([
35
+ f'<div class="circle left {color_class}"></div>' for _ in range(num_circles // 2)
36
+ ])
37
+ circles_html += f'<div class="text">{label}</div>'
38
+ circles_html += ''.join([
39
+ f'<div class="circle right {color_class}"></div>' for _ in range(num_circles // 2)
40
  ])
41
 
42
  cloud_button_html = f"""
43
  <div class="cloud" id="{button_id}" style="margin-bottom: 20px;">
44
  <div class="wrapper {color_class}">
45
  {circles_html}
 
46
  </div>
47
  </div>
48
  <style>
 
63
  position: relative;
64
  font-weight: bold;
65
  z-index: 2;
66
+ margin: 0 10px; /* Adjust the margin as needed */
67
  }}
68
  .circle {{
69
  background-color: #FF6347;
70
  border-radius: 50%;
71
  width: {circle_size}px;
72
  height: {circle_size}px;
73
+ position: relative;
74
+ }}
75
+ .circle.left, .circle.right {{
76
+ margin: 0 5px; /* Adjust the margin as needed */
77
  }}
78
  .color-1 .circle {{ background-color: #FFA07A; }}
79
  .color-2 .circle {{ background-color: #FF7F50; }}