VyLala commited on
Commit
454da64
·
verified ·
1 Parent(s): 7922f77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -110
app.py CHANGED
@@ -19,26 +19,6 @@ with open("mtdna_tool_explainer_updated.html", "r", encoding="utf-8") as f:
19
  flow_chart = f.read()
20
 
21
  ### NEW: CSS for NPS modal overlay
22
- # custom_css = """
23
- # #nps-overlay {
24
- # position: fixed;
25
- # top: 0; left: 0;
26
- # width: 100%; height: 100%;
27
- # background: rgba(0,0,0,0.6);
28
- # z-index: 9999;
29
- # display: none; /* hidden by default */
30
- # justify-content: center;
31
- # align-items: center;
32
- # }
33
- # #nps-box {
34
- # background: white;
35
- # padding: 20px;
36
- # border-radius: 12px;
37
- # width: 400px;
38
- # max-width: 90%;
39
- # text-align: center;
40
- # }
41
- # """
42
  custom_css = """
43
  #nps-overlay {
44
  position: fixed;
@@ -46,45 +26,17 @@ custom_css = """
46
  width: 100%; height: 100%;
47
  background: rgba(0,0,0,0.6);
48
  z-index: 9999;
49
- display: none;
50
- flex-direction: column;
51
  justify-content: center;
52
  align-items: center;
53
- backdrop-filter: blur(5px);
54
  }
55
  #nps-box {
56
- position: relative;
57
  background: white;
58
  padding: 20px;
59
  border-radius: 12px;
60
  width: 400px;
61
  max-width: 90%;
62
  text-align: center;
63
- box-shadow: 0px 5px 20px rgba(0,0,0,0.3);
64
- }
65
- #nps-close {
66
- position: absolute;
67
- top: 8px;
68
- right: 8px;
69
- cursor: pointer;
70
- font-size: 18px;
71
- font-weight: bold;
72
- color: #666;
73
- }
74
- #nps-close:hover {
75
- color: black;
76
- }
77
- .nps-btn {
78
- border: 1px solid #ccc;
79
- background: #f9f9f9;
80
- padding: 6px 10px;
81
- cursor: pointer;
82
- border-radius: 6px;
83
- }
84
- .nps-btn.selected {
85
- background: #007bff;
86
- color: white;
87
- border-color: #007bff;
88
  }
89
  """
90
 
@@ -123,39 +75,12 @@ with gr.Blocks() as interface:
123
 
124
  status = gr.Markdown(visible=False)
125
 
126
- # with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
127
- # with gr.Column(elem_id="nps-box"):
128
- # gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
129
- # nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Your NPS Score (0-10)")
130
- # nps_text = gr.Textbox(label="Any feedback?", lines=3)
131
- # with gr.Row():
132
- # nps_submit = gr.Button("Submit")
133
- # nps_close = gr.Button("X", elem_id="nps-close")
134
- with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
135
  with gr.Column(elem_id="nps-box"):
136
- gr.HTML('<span id="nps-close">✕</span>')
137
  gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
138
-
139
- gr.HTML("""
140
- <div id="nps-numbers" style="display:flex; gap:8px; flex-wrap:wrap; justify-content:center;">
141
- <button class="nps-btn" data-score="0">0</button>
142
- <button class="nps-btn" data-score="1">1</button>
143
- <button class="nps-btn" data-score="2">2</button>
144
- <button class="nps-btn" data-score="3">3</button>
145
- <button class="nps-btn" data-score="4">4</button>
146
- <button class="nps-btn" data-score="5">5</button>
147
- <button class="nps-btn" data-score="6">6</button>
148
- <button class="nps-btn" data-score="7">7</button>
149
- <button class="nps-btn" data-score="8">8</button>
150
- <button class="nps-btn" data-score="9">9</button>
151
- <button class="nps-btn" data-score="10">10</button>
152
- </div>
153
- """)
154
-
155
- selected_score = gr.Textbox(label="selected_score", visible=False)
156
  nps_submit = gr.Button("Submit")
157
- nps_message = gr.Markdown(visible=True)
158
-
159
 
160
  with gr.Group(visible=False) as results_group:
161
  # with gr.Accordion("Open to See the Result", open=False) as results:
@@ -1198,7 +1123,7 @@ with gr.Blocks() as interface:
1198
  inputs=[raw_text, q1, q2, contact],
1199
  outputs=[feedback_status]
1200
  )
1201
- nps_submit.click(fn=submit_nps, inputs=[user_email, selected_score], outputs=[nps_message])
1202
 
1203
 
1204
  gr.HTML("""
@@ -1285,36 +1210,6 @@ with gr.Blocks() as interface:
1285
  with gr.Tab("PRICING"):
1286
  gr.HTML(value=pricing_html)
1287
 
1288
- interface.load(
1289
- js="""
1290
- () => {
1291
- setTimeout(() => {
1292
- const overlay = document.getElementById('nps-overlay');
1293
- const closeBtn = document.getElementById('nps-close');
1294
- const buttons = document.querySelectorAll('.nps-btn');
1295
- const hiddenInput = document.querySelector('textarea[aria-label="selected_score"]');
1296
-
1297
- if (closeBtn) {
1298
- closeBtn.onclick = () => {
1299
- overlay.style.display = 'none';
1300
- };
1301
- }
1302
-
1303
- buttons.forEach(btn => {
1304
- btn.onclick = () => {
1305
- buttons.forEach(b => b.classList.remove('selected'));
1306
- btn.classList.add('selected');
1307
- if (hiddenInput) {
1308
- hiddenInput.value = btn.getAttribute('data-score');
1309
- hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
1310
- }
1311
- };
1312
- });
1313
- }, 500);
1314
- }
1315
- """
1316
- )
1317
-
1318
 
1319
 
1320
 
 
19
  flow_chart = f.read()
20
 
21
  ### NEW: CSS for NPS modal overlay
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  custom_css = """
23
  #nps-overlay {
24
  position: fixed;
 
26
  width: 100%; height: 100%;
27
  background: rgba(0,0,0,0.6);
28
  z-index: 9999;
29
+ display: none; /* hidden by default */
 
30
  justify-content: center;
31
  align-items: center;
 
32
  }
33
  #nps-box {
 
34
  background: white;
35
  padding: 20px;
36
  border-radius: 12px;
37
  width: 400px;
38
  max-width: 90%;
39
  text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
  """
42
 
 
75
 
76
  status = gr.Markdown(visible=False)
77
 
78
+ with gr.Group(visible=False, elem_id="nps-overlay", interactive=True) as nps_modal:
 
 
 
 
 
 
 
 
79
  with gr.Column(elem_id="nps-box"):
 
80
  gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
81
+ nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Select score: 0-10 (0-6: not likely or low; 7-8: neutral; 9-10: likely or highly)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  nps_submit = gr.Button("Submit")
83
+ nps_output = gr.Textbox(label="",visible=True)
 
84
 
85
  with gr.Group(visible=False) as results_group:
86
  # with gr.Accordion("Open to See the Result", open=False) as results:
 
1123
  inputs=[raw_text, q1, q2, contact],
1124
  outputs=[feedback_status]
1125
  )
1126
+ nps_submit.click(fn=submit_nps, inputs=[user_email, selected_score], outputs=[nps_output])
1127
 
1128
 
1129
  gr.HTML("""
 
1210
  with gr.Tab("PRICING"):
1211
  gr.HTML(value=pricing_html)
1212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1213
 
1214
 
1215