Refactor streak modal to overlay native React component on transparent celebration canvas iframe

This commit is contained in:
2026-07-10 13:30:33 +05:30
parent 79dde09304
commit c0642ad6f3
3 changed files with 160 additions and 31 deletions

View File

@@ -0,0 +1,47 @@
import os
import re
def port_html():
source_path = r"C:\Users\naman\OneDrive\Desktop\pragativeer-v2\pragativeer-celebration_1.html"
dest_path = r"C:\Users\naman\OneDrive\Desktop\pragativeer-v2\public\streak-animation.html"
with open(source_path, 'r', encoding='utf-8') as f:
html = f.read()
# 1. Inject CSS to make background transparent and hide stage layout
hide_css = """
body {
background: transparent !important;
}
body.sad {
background: transparent !important;
}
body::after {
display: none !important;
}
#stage, .hint {
display: none !important;
}
"""
# Insert hide_css inside <style>
style_tag = "</style>"
html = html.replace(style_tag, hide_css + "\n</style>", 1)
# 2. Replace parseTarget to read from URL search params
parse_target_replacement = """
const parseTarget=()=>{
const params = new URLSearchParams(window.location.search);
const s = params.get('streak');
const v=parseFloat(s);
return isFinite(v)?v:0;
};
"""
html = re.sub(r"const parseTarget=\(\)=>\{.*?\};", parse_target_replacement, html, flags=re.DOTALL)
with open(dest_path, 'w', encoding='utf-8') as f:
f.write(html)
print("Ported successfully to public/streak-animation.html")
if __name__ == "__main__":
port_html()