Upload folder using huggingface_hub
Browse files- app.py +10 -9
- custom.html +22 -0
- src/demo/app.py +10 -9
- src/demo/custom.html +22 -0
app.py
CHANGED
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field, asdict
|
|
5 |
from typing import Literal
|
6 |
from gradio_propertysheet import PropertySheet
|
7 |
|
|
|
8 |
# --- 1. Dataclass Definitions ---
|
9 |
|
10 |
# Dataclasses for the Original Sidebar Demo
|
@@ -65,13 +66,13 @@ model_settings_map_py = {"SDXL 1.0": DPM_Settings(), "Stable Diffusion 1.5": Eul
|
|
65 |
# --- 3. CSS and JavaScript Loading ---
|
66 |
|
67 |
# Load external CSS file if it exists
|
68 |
-
script_path = Path(__file__).resolve()
|
69 |
-
script_dir = script_path.parent
|
70 |
-
css_path = script_dir / "custom.css"
|
71 |
-
flyout_css = ""
|
72 |
-
if css_path.exists():
|
73 |
-
|
74 |
-
|
75 |
|
76 |
# JavaScript for positioning the flyout panel
|
77 |
head_script = f"""
|
@@ -97,10 +98,10 @@ head_script = f"""
|
|
97 |
}}, 50);
|
98 |
}}
|
99 |
</script>
|
100 |
-
"""
|
101 |
|
102 |
# --- 4. Gradio App Build ---
|
103 |
-
with gr.Blocks(css
|
104 |
gr.Markdown("# PropertySheet Component Demos")
|
105 |
|
106 |
with gr.Tabs():
|
|
|
5 |
from typing import Literal
|
6 |
from gradio_propertysheet import PropertySheet
|
7 |
|
8 |
+
|
9 |
# --- 1. Dataclass Definitions ---
|
10 |
|
11 |
# Dataclasses for the Original Sidebar Demo
|
|
|
66 |
# --- 3. CSS and JavaScript Loading ---
|
67 |
|
68 |
# Load external CSS file if it exists
|
69 |
+
# script_path = Path(__file__).resolve()
|
70 |
+
# script_dir = script_path.parent
|
71 |
+
# css_path = script_dir / "custom.css"
|
72 |
+
# flyout_css = ""
|
73 |
+
# if css_path.exists():
|
74 |
+
# with open(css_path, "r", encoding="utf8") as file:
|
75 |
+
# flyout_css = file.read()
|
76 |
|
77 |
# JavaScript for positioning the flyout panel
|
78 |
head_script = f"""
|
|
|
98 |
}}, 50);
|
99 |
}}
|
100 |
</script>
|
101 |
+
# """
|
102 |
|
103 |
# --- 4. Gradio App Build ---
|
104 |
+
with gr.Blocks(css_paths=["demo/custom.css"], head=head_script, head_paths=["demo/custom.html"], title="PropertySheet Demos") as demo:
|
105 |
gr.Markdown("# PropertySheet Component Demos")
|
106 |
|
107 |
with gr.Tabs():
|
custom.html
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
function position_flyout(anchorId) {{
|
3 |
+
setTimeout(() => {{
|
4 |
+
const anchorRow = document.getElementById(anchorId).closest('.fake-input-container');
|
5 |
+
const flyoutElem = document.getElementById('flyout_panel');
|
6 |
+
|
7 |
+
if (anchorRow && flyoutElem && flyoutElem.style.display !== 'none') {{
|
8 |
+
const anchorRect = anchorRow.getBoundingClientRect();
|
9 |
+
const containerRect = anchorRow.closest('.flyout-context-area').getBoundingClientRect();
|
10 |
+
|
11 |
+
const flyoutWidth = flyoutElem.offsetWidth;
|
12 |
+
const flyoutHeight = flyoutElem.offsetHeight;
|
13 |
+
|
14 |
+
const topPosition = (anchorRect.top - containerRect.top) + (anchorRect.height / 2) - (flyoutHeight / 2);
|
15 |
+
const leftPosition = (anchorRect.left - containerRect.left) + (anchorRect.width / 2) - (flyoutWidth / 2);
|
16 |
+
|
17 |
+
flyoutElem.style.top = `${{topPosition}}px`;
|
18 |
+
flyoutElem.style.left = `${{leftPosition}}px`;
|
19 |
+
}}
|
20 |
+
}}, 50);
|
21 |
+
}};
|
22 |
+
</script>
|
src/demo/app.py
CHANGED
@@ -5,6 +5,7 @@ from dataclasses import dataclass, field, asdict
|
|
5 |
from typing import Literal
|
6 |
from gradio_propertysheet import PropertySheet
|
7 |
|
|
|
8 |
# --- 1. Dataclass Definitions ---
|
9 |
|
10 |
# Dataclasses for the Original Sidebar Demo
|
@@ -65,13 +66,13 @@ model_settings_map_py = {"SDXL 1.0": DPM_Settings(), "Stable Diffusion 1.5": Eul
|
|
65 |
# --- 3. CSS and JavaScript Loading ---
|
66 |
|
67 |
# Load external CSS file if it exists
|
68 |
-
script_path = Path(__file__).resolve()
|
69 |
-
script_dir = script_path.parent
|
70 |
-
css_path = script_dir / "custom.css"
|
71 |
-
flyout_css = ""
|
72 |
-
if css_path.exists():
|
73 |
-
|
74 |
-
|
75 |
|
76 |
# JavaScript for positioning the flyout panel
|
77 |
head_script = f"""
|
@@ -97,10 +98,10 @@ head_script = f"""
|
|
97 |
}}, 50);
|
98 |
}}
|
99 |
</script>
|
100 |
-
"""
|
101 |
|
102 |
# --- 4. Gradio App Build ---
|
103 |
-
with gr.Blocks(css
|
104 |
gr.Markdown("# PropertySheet Component Demos")
|
105 |
|
106 |
with gr.Tabs():
|
|
|
5 |
from typing import Literal
|
6 |
from gradio_propertysheet import PropertySheet
|
7 |
|
8 |
+
|
9 |
# --- 1. Dataclass Definitions ---
|
10 |
|
11 |
# Dataclasses for the Original Sidebar Demo
|
|
|
66 |
# --- 3. CSS and JavaScript Loading ---
|
67 |
|
68 |
# Load external CSS file if it exists
|
69 |
+
# script_path = Path(__file__).resolve()
|
70 |
+
# script_dir = script_path.parent
|
71 |
+
# css_path = script_dir / "custom.css"
|
72 |
+
# flyout_css = ""
|
73 |
+
# if css_path.exists():
|
74 |
+
# with open(css_path, "r", encoding="utf8") as file:
|
75 |
+
# flyout_css = file.read()
|
76 |
|
77 |
# JavaScript for positioning the flyout panel
|
78 |
head_script = f"""
|
|
|
98 |
}}, 50);
|
99 |
}}
|
100 |
</script>
|
101 |
+
# """
|
102 |
|
103 |
# --- 4. Gradio App Build ---
|
104 |
+
with gr.Blocks(css_paths=["demo/custom.css"], head=head_script, head_paths=["demo/custom.html"], title="PropertySheet Demos") as demo:
|
105 |
gr.Markdown("# PropertySheet Component Demos")
|
106 |
|
107 |
with gr.Tabs():
|
src/demo/custom.html
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script>
|
2 |
+
function position_flyout(anchorId) {{
|
3 |
+
setTimeout(() => {{
|
4 |
+
const anchorRow = document.getElementById(anchorId).closest('.fake-input-container');
|
5 |
+
const flyoutElem = document.getElementById('flyout_panel');
|
6 |
+
|
7 |
+
if (anchorRow && flyoutElem && flyoutElem.style.display !== 'none') {{
|
8 |
+
const anchorRect = anchorRow.getBoundingClientRect();
|
9 |
+
const containerRect = anchorRow.closest('.flyout-context-area').getBoundingClientRect();
|
10 |
+
|
11 |
+
const flyoutWidth = flyoutElem.offsetWidth;
|
12 |
+
const flyoutHeight = flyoutElem.offsetHeight;
|
13 |
+
|
14 |
+
const topPosition = (anchorRect.top - containerRect.top) + (anchorRect.height / 2) - (flyoutHeight / 2);
|
15 |
+
const leftPosition = (anchorRect.left - containerRect.left) + (anchorRect.width / 2) - (flyoutWidth / 2);
|
16 |
+
|
17 |
+
flyoutElem.style.top = `${{topPosition}}px`;
|
18 |
+
flyoutElem.style.left = `${{leftPosition}}px`;
|
19 |
+
}}
|
20 |
+
}}, 50);
|
21 |
+
}};
|
22 |
+
</script>
|