Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1976,22 +1976,32 @@ function refresh() {
|
|
| 1976 |
}
|
| 1977 |
"""
|
| 1978 |
custom_css = """
|
| 1979 |
-
|
| 1980 |
-
/*
|
| 1981 |
-
|
| 1982 |
-
|
| 1983 |
-
|
| 1984 |
-
|
| 1985 |
-
}
|
| 1986 |
-
</style>
|
| 1987 |
"""
|
| 1988 |
|
| 1989 |
-
|
| 1990 |
-
|
| 1991 |
-
|
| 1992 |
-
|
| 1993 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1994 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1995 |
with gr.Blocks(js=js_func) as demo:
|
| 1996 |
with gr.Column():
|
| 1997 |
gr.Markdown(
|
|
@@ -2008,14 +2018,12 @@ with gr.Blocks(js=js_func) as demo:
|
|
| 2008 |
with gr.Column():
|
| 2009 |
with gr.Row():
|
| 2010 |
|
| 2011 |
-
gr.HTML(custom_css)
|
| 2012 |
# Define buttons with specific elem_id for targeting
|
| 2013 |
-
vw_customers_btn = gr.Button("VW Owners"
|
| 2014 |
-
vw_prospects_btn = gr.Button("VW Prospects"
|
| 2015 |
|
| 2016 |
-
|
| 2017 |
-
vw_customers_btn.click(set_vw_owners)
|
| 2018 |
-
vw_prospects_btn.click(set_vw_prospects)
|
| 2019 |
|
| 2020 |
with gr.Row():
|
| 2021 |
with gr.Column():
|
|
|
|
| 1976 |
}
|
| 1977 |
"""
|
| 1978 |
custom_css = """
|
| 1979 |
+
.highlighted {
|
| 1980 |
+
background-color: #4CAF50; /* Green color when clicked */
|
| 1981 |
+
color: white;
|
| 1982 |
+
}
|
| 1983 |
+
.gr-button {
|
| 1984 |
+
margin: 10px;
|
| 1985 |
+
}
|
|
|
|
| 1986 |
"""
|
| 1987 |
|
| 1988 |
+
# JavaScript to handle button clicks
|
| 1989 |
+
custom_js = """
|
| 1990 |
+
function highlightButton(event) {
|
| 1991 |
+
// Remove 'highlighted' class from all buttons
|
| 1992 |
+
var buttons = document.querySelectorAll('.gr-button');
|
| 1993 |
+
buttons.forEach(function(button) {
|
| 1994 |
+
button.classList.remove('highlighted');
|
| 1995 |
+
});
|
| 1996 |
+
// Add 'highlighted' class to the clicked button
|
| 1997 |
+
event.target.classList.add('highlighted');
|
| 1998 |
+
}
|
| 1999 |
|
| 2000 |
+
// Attach the highlightButton function to button clicks
|
| 2001 |
+
document.querySelectorAll('.gr-button').forEach(function(button) {
|
| 2002 |
+
button.addEventListener('click', highlightButton);
|
| 2003 |
+
});
|
| 2004 |
+
"""
|
| 2005 |
with gr.Blocks(js=js_func) as demo:
|
| 2006 |
with gr.Column():
|
| 2007 |
gr.Markdown(
|
|
|
|
| 2018 |
with gr.Column():
|
| 2019 |
with gr.Row():
|
| 2020 |
|
| 2021 |
+
gr.HTML(f"<style>{custom_css}</style><script>{custom_js}</script>")
|
| 2022 |
# Define buttons with specific elem_id for targeting
|
| 2023 |
+
vw_customers_btn = gr.Button("VW Owners")
|
| 2024 |
+
vw_prospects_btn = gr.Button("VW Prospects")
|
| 2025 |
|
| 2026 |
+
|
|
|
|
|
|
|
| 2027 |
|
| 2028 |
with gr.Row():
|
| 2029 |
with gr.Column():
|