Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -74,6 +74,11 @@ custom_css = """
|
|
74 |
#nps-close:hover {
|
75 |
color: black;
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
77 |
"""
|
78 |
|
79 |
|
@@ -118,54 +123,28 @@ with gr.Blocks() as interface:
|
|
118 |
# with gr.Row():
|
119 |
# nps_submit = gr.Button("Submit")
|
120 |
# nps_close = gr.Button("X", elem_id="nps-close")
|
121 |
-
nps_html = """
|
122 |
-
<div id="nps-container" style="text-align:center;">
|
123 |
-
<style>
|
124 |
-
.nps-btn {
|
125 |
-
display: inline-block;
|
126 |
-
width: 40px;
|
127 |
-
height: 40px;
|
128 |
-
line-height: 40px;
|
129 |
-
margin: 4px;
|
130 |
-
border-radius: 6px;
|
131 |
-
color: white;
|
132 |
-
font-weight: bold;
|
133 |
-
cursor: pointer;
|
134 |
-
user-select: none;
|
135 |
-
}
|
136 |
-
.nps-red { background-color: #d9534f; }
|
137 |
-
.nps-yellow { background-color: #f0ad4e; }
|
138 |
-
.nps-green { background-color: #5cb85c; }
|
139 |
-
.nps-btn:hover { opacity: 0.8; }
|
140 |
-
#nps-labels { margin-top: 8px; font-size: 14px; color: #555; }
|
141 |
-
</style>
|
142 |
-
<div>
|
143 |
-
<span class="nps-btn nps-red" data-score="0">0</span>
|
144 |
-
<span class="nps-btn nps-red" data-score="1">1</span>
|
145 |
-
<span class="nps-btn nps-red" data-score="2">2</span>
|
146 |
-
<span class="nps-btn nps-red" data-score="3">3</span>
|
147 |
-
<span class="nps-btn nps-red" data-score="4">4</span>
|
148 |
-
<span class="nps-btn nps-red" data-score="5">5</span>
|
149 |
-
<span class="nps-btn nps-red" data-score="6">6</span>
|
150 |
-
<span class="nps-btn nps-yellow" data-score="7">7</span>
|
151 |
-
<span class="nps-btn nps-yellow" data-score="8">8</span>
|
152 |
-
<span class="nps-btn nps-green" data-score="9">9</span>
|
153 |
-
<span class="nps-btn nps-green" data-score="10">10</span>
|
154 |
-
</div>
|
155 |
-
<div id="nps-labels">
|
156 |
-
<span style="float:left;">Not at all likely</span>
|
157 |
-
<span>Neutral</span>
|
158 |
-
<span style="float:right;">Extremely likely</span>
|
159 |
-
</div>
|
160 |
-
</div>
|
161 |
-
"""
|
162 |
-
|
163 |
with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
|
164 |
with gr.Column(elem_id="nps-box", interactive=True):
|
165 |
gr.HTML('<span id="nps-close">✕</span>')
|
166 |
gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
nps_submit = gr.Button("Submit")
|
170 |
|
171 |
|
@@ -467,7 +446,13 @@ with gr.Blocks() as interface:
|
|
467 |
worksheet.update_cell(i, recent_time_col + 1, new_timestamp)
|
468 |
if nps_score is not None:
|
469 |
print("this is nps score:", nps_score)
|
470 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
print(f"✅ Updated existing user row for: {email}")
|
472 |
return
|
473 |
|
@@ -1293,21 +1278,26 @@ with gr.Blocks() as interface:
|
|
1293 |
|
1294 |
with gr.Tab("PRICING"):
|
1295 |
gr.HTML(value=pricing_html)
|
|
|
1296 |
interface.load(js="""
|
1297 |
() => {
|
1298 |
-
// Close
|
1299 |
-
document.getElementById('nps-close')
|
1300 |
-
|
1301 |
-
|
|
|
|
|
|
|
|
|
1302 |
|
1303 |
-
//
|
1304 |
-
document.querySelectorAll('
|
1305 |
-
btn.addEventListener('click',
|
1306 |
-
const score =
|
1307 |
-
const
|
1308 |
-
if (
|
1309 |
-
|
1310 |
-
|
1311 |
}
|
1312 |
});
|
1313 |
});
|
|
|
74 |
#nps-close:hover {
|
75 |
color: black;
|
76 |
}
|
77 |
+
#nps-box button:active {
|
78 |
+
transform: scale(0.95);
|
79 |
+
background-color: #ddd;
|
80 |
+
}
|
81 |
+
|
82 |
"""
|
83 |
|
84 |
|
|
|
123 |
# with gr.Row():
|
124 |
# nps_submit = gr.Button("Submit")
|
125 |
# nps_close = gr.Button("X", elem_id="nps-close")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
|
127 |
with gr.Column(elem_id="nps-box", interactive=True):
|
128 |
gr.HTML('<span id="nps-close">✕</span>')
|
129 |
gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
|
130 |
+
|
131 |
+
gr.HTML("""
|
132 |
+
<div id="nps-numbers" style="display:flex; gap:8px; flex-wrap:wrap; justify-content:center;">
|
133 |
+
<button class="nps-btn" data-score="0">0</button>
|
134 |
+
<button class="nps-btn" data-score="1">1</button>
|
135 |
+
<button class="nps-btn" data-score="2">2</button>
|
136 |
+
<button class="nps-btn" data-score="3">3</button>
|
137 |
+
<button class="nps-btn" data-score="4">4</button>
|
138 |
+
<button class="nps-btn" data-score="5">5</button>
|
139 |
+
<button class="nps-btn" data-score="6">6</button>
|
140 |
+
<button class="nps-btn" data-score="7">7</button>
|
141 |
+
<button class="nps-btn" data-score="8">8</button>
|
142 |
+
<button class="nps-btn" data-score="9">9</button>
|
143 |
+
<button class="nps-btn" data-score="10">10</button>
|
144 |
+
</div>
|
145 |
+
""")
|
146 |
+
|
147 |
+
selected_score = gr.Textbox(label="selected_score", visible=False)
|
148 |
nps_submit = gr.Button("Submit")
|
149 |
|
150 |
|
|
|
446 |
worksheet.update_cell(i, recent_time_col + 1, new_timestamp)
|
447 |
if nps_score is not None:
|
448 |
print("this is nps score:", nps_score)
|
449 |
+
old_nps = row[nps_col].strip() if len(row) > nps_col else ""
|
450 |
+
if old_nps:
|
451 |
+
new_nps = f"{old_nps}, {nps_score}"
|
452 |
+
else:
|
453 |
+
new_nps = str(nps_score)
|
454 |
+
worksheet.update_cell(i, nps_col + 1, new_nps)
|
455 |
+
|
456 |
print(f"✅ Updated existing user row for: {email}")
|
457 |
return
|
458 |
|
|
|
1278 |
|
1279 |
with gr.Tab("PRICING"):
|
1280 |
gr.HTML(value=pricing_html)
|
1281 |
+
|
1282 |
interface.load(js="""
|
1283 |
() => {
|
1284 |
+
// Close button functionality
|
1285 |
+
const closeBtn = document.getElementById('nps-close');
|
1286 |
+
if (closeBtn) {
|
1287 |
+
closeBtn.addEventListener('click', () => {
|
1288 |
+
const overlay = document.getElementById('nps-overlay');
|
1289 |
+
if (overlay) overlay.style.display = 'none';
|
1290 |
+
});
|
1291 |
+
}
|
1292 |
|
1293 |
+
// Handle score button clicks
|
1294 |
+
document.querySelectorAll('.nps-btn').forEach(btn => {
|
1295 |
+
btn.addEventListener('click', () => {
|
1296 |
+
const score = btn.getAttribute('data-score');
|
1297 |
+
const hiddenInput = document.querySelector('textarea[aria-label="selected_score"]');
|
1298 |
+
if (hiddenInput) {
|
1299 |
+
hiddenInput.value = score;
|
1300 |
+
hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
|
1301 |
}
|
1302 |
});
|
1303 |
});
|