Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ html_content = """
|
|
| 30 |
margin: 0;
|
| 31 |
padding: 20px;
|
| 32 |
user-select: none;
|
| 33 |
-
overflow-y: auto;
|
| 34 |
}
|
| 35 |
|
| 36 |
h1 { margin-bottom: 10px; font-weight: 900; }
|
|
@@ -40,6 +40,7 @@ html_content = """
|
|
| 40 |
gap: 30px;
|
| 41 |
flex-wrap: wrap;
|
| 42 |
justify-content: center;
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
.preview-area {
|
|
@@ -760,22 +761,26 @@ html_content = """
|
|
| 760 |
"""
|
| 761 |
|
| 762 |
def create_app():
|
| 763 |
-
#
|
| 764 |
-
# Это решает все конфликты CSS и JS.
|
| 765 |
encoded_html = base64.b64encode(html_content.encode('utf-8')).decode('utf-8')
|
| 766 |
-
iframe_html = f'<iframe src="data:text/html;base64,{encoded_html}" style="width:100%; height:100vh; border:none; display:block;"></iframe>'
|
| 767 |
|
| 768 |
-
#
|
| 769 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
global_css = """
|
| 771 |
<style>
|
| 772 |
-
footer {
|
| 773 |
-
|
| 774 |
-
|
| 775 |
</style>
|
| 776 |
"""
|
| 777 |
|
| 778 |
-
# Убрали аргумент css=, чтобы не вызывать ошибку версии
|
| 779 |
with gr.Blocks(title="Swaga Icon Maker") as demo:
|
| 780 |
gr.HTML(global_css)
|
| 781 |
gr.HTML(iframe_html)
|
|
|
|
| 30 |
margin: 0;
|
| 31 |
padding: 20px;
|
| 32 |
user-select: none;
|
| 33 |
+
overflow-y: auto; /* Скролл внутри iframe, если контент не влазит */
|
| 34 |
}
|
| 35 |
|
| 36 |
h1 { margin-bottom: 10px; font-weight: 900; }
|
|
|
|
| 40 |
gap: 30px;
|
| 41 |
flex-wrap: wrap;
|
| 42 |
justify-content: center;
|
| 43 |
+
padding-bottom: 50px; /* Отступ снизу для удобства */
|
| 44 |
}
|
| 45 |
|
| 46 |
.preview-area {
|
|
|
|
| 761 |
"""
|
| 762 |
|
| 763 |
def create_app():
|
| 764 |
+
# Кодируем HTML в base64
|
|
|
|
| 765 |
encoded_html = base64.b64encode(html_content.encode('utf-8')).decode('utf-8')
|
|
|
|
| 766 |
|
| 767 |
+
# КЛЮЧЕВОЕ ИЗМЕНЕНИЕ: position: fixed.
|
| 768 |
+
# Это вырывает iframe из потока документа Gradio, предотвращая бесконечное расширение.
|
| 769 |
+
# top: 0, left: 0, width: 100%, height: 100% заставляет его занять всё окно браузера.
|
| 770 |
+
iframe_html = f'''
|
| 771 |
+
<iframe src="data:text/html;base64,{encoded_html}"
|
| 772 |
+
style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: 9999;">
|
| 773 |
+
</iframe>'''
|
| 774 |
+
|
| 775 |
+
# Стили для подавления самого интерфейса Gradio под нашим iframe
|
| 776 |
global_css = """
|
| 777 |
<style>
|
| 778 |
+
footer {display: none !important;}
|
| 779 |
+
body {overflow: hidden !important;}
|
| 780 |
+
.gradio-container {min-height: 0 !important; overflow: hidden !important;}
|
| 781 |
</style>
|
| 782 |
"""
|
| 783 |
|
|
|
|
| 784 |
with gr.Blocks(title="Swaga Icon Maker") as demo:
|
| 785 |
gr.HTML(global_css)
|
| 786 |
gr.HTML(iframe_html)
|