Spaces:
Running on Zero
Running on Zero
UI: inject slider styles via JS MutationObserver — bypasses CSS specificity entirely
Browse files
app.py
CHANGED
|
@@ -873,6 +873,70 @@ CSS = """
|
|
| 873 |
|
| 874 |
|
| 875 |
with gr.Blocks(delete_cache=(3600, 10800)) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 876 |
gr.Markdown(model_title())
|
| 877 |
gr.Markdown("Run Wan 2.2 in just 4-8 steps, fp8 quantization & AoT compilation - compatible with 🧨 diffusers and ZeroGPU")
|
| 878 |
|
|
|
|
| 873 |
|
| 874 |
|
| 875 |
with gr.Blocks(delete_cache=(3600, 10800)) as demo:
|
| 876 |
+
gr.HTML(
|
| 877 |
+
"""<script>
|
| 878 |
+
(function() {
|
| 879 |
+
function styleSlider() {
|
| 880 |
+
var inp = document.querySelector('#duration-slider input[data-testid="range-input"]')
|
| 881 |
+
|| document.querySelector('#duration-slider input[type="range"]');
|
| 882 |
+
if (!inp) return false;
|
| 883 |
+
/* thumb */
|
| 884 |
+
inp.style.setProperty('--thumb-bg', 'linear-gradient(135deg, #00e5c8, #6c5ce7)', '');
|
| 885 |
+
inp.style.setProperty('--thumb-shadow', '0 0 8px rgba(0, 229, 200, 0.5)', '');
|
| 886 |
+
/* inject a style tag scoped to this input */
|
| 887 |
+
var id = 'slider-theme-styles';
|
| 888 |
+
if (!document.getElementById(id)) {
|
| 889 |
+
var s = document.createElement('style');
|
| 890 |
+
s.id = id;
|
| 891 |
+
s.textContent = `
|
| 892 |
+
#duration-slider input[type="range"]::-webkit-slider-thumb {
|
| 893 |
+
-webkit-appearance: none !important;
|
| 894 |
+
appearance: none !important;
|
| 895 |
+
width: 18px !important;
|
| 896 |
+
height: 18px !important;
|
| 897 |
+
border-radius: 50% !important;
|
| 898 |
+
background: linear-gradient(135deg, #00e5c8, #6c5ce7) !important;
|
| 899 |
+
border: 2px solid rgba(255,255,255,0.3) !important;
|
| 900 |
+
box-shadow: 0 0 8px rgba(0, 229, 200, 0.5) !important;
|
| 901 |
+
cursor: pointer !important;
|
| 902 |
+
margin-top: -6px !important;
|
| 903 |
+
}
|
| 904 |
+
#duration-slider input[type="range"]::-webkit-slider-runnable-track {
|
| 905 |
+
background: linear-gradient(90deg, #00d4aa, #6c5ce7) !important;
|
| 906 |
+
height: 6px !important;
|
| 907 |
+
border-radius: 3px !important;
|
| 908 |
+
}
|
| 909 |
+
#duration-slider input[type="range"]::-moz-range-thumb {
|
| 910 |
+
width: 18px !important;
|
| 911 |
+
height: 18px !important;
|
| 912 |
+
border-radius: 50% !important;
|
| 913 |
+
background: linear-gradient(135deg, #00e5c8, #6c5ce7) !important;
|
| 914 |
+
border: 2px solid rgba(255,255,255,0.3) !important;
|
| 915 |
+
box-shadow: 0 0 8px rgba(0, 229, 200, 0.5) !important;
|
| 916 |
+
cursor: pointer !important;
|
| 917 |
+
}
|
| 918 |
+
#duration-slider input[type="range"]::-moz-range-track {
|
| 919 |
+
background: linear-gradient(90deg, #00d4aa, #6c5ce7) !important;
|
| 920 |
+
height: 6px !important;
|
| 921 |
+
border-radius: 3px !important;
|
| 922 |
+
}
|
| 923 |
+
`;
|
| 924 |
+
document.head.appendChild(s);
|
| 925 |
+
}
|
| 926 |
+
return true;
|
| 927 |
+
}
|
| 928 |
+
/* try immediately, then retry with observer until Gradio renders */
|
| 929 |
+
if (!styleSlider()) {
|
| 930 |
+
var obs = new MutationObserver(function() {
|
| 931 |
+
if (styleSlider()) obs.disconnect();
|
| 932 |
+
});
|
| 933 |
+
obs.observe(document.body, {childList: true, subtree: true});
|
| 934 |
+
setTimeout(function() { obs.disconnect(); }, 15000);
|
| 935 |
+
}
|
| 936 |
+
})();
|
| 937 |
+
</script>""",
|
| 938 |
+
visible=False,
|
| 939 |
+
)
|
| 940 |
gr.Markdown(model_title())
|
| 941 |
gr.Markdown("Run Wan 2.2 in just 4-8 steps, fp8 quantization & AoT compilation - compatible with 🧨 diffusers and ZeroGPU")
|
| 942 |
|