Spaces:
Running
on
Zero
Running
on
Zero
File size: 5,796 Bytes
843171c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gradio App Embed</title>
<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/4.37.2/gradio.js"></script>
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.gradio-container {
width: 100%;
min-height: 600px;
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto;
padding: 20px;
box-sizing: border-box;
}
gradio-app {
width: 100%;
max-width: 1024px;
height: auto;
border: 1px solid #e0e0e0;
border-radius: 8px;
overflow: visible;
}
gradio-app::part(root) {
max-width: 100% !important;
}
gradio-app::part(root) h1,
gradio-app::part(root) h2,
gradio-app::part(root) h3 {
text-align: center;
display: block;
}
gradio-app::part(root) .gr-image {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 512px;
overflow: hidden;
}
gradio-app::part(root) .gr-image img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
gradio-app::part(root) footer {
display: none !important;
}
gradio-app::part(root) .gr-button-row {
justify-content: center;
}
gradio-app::part(root) .gr-form.gr-box {
max-width: 100% !important;
}
gradio-app::part(root) #style_selection {
width: 100%;
max-width: 300px;
margin: 0 auto;
}
gradio-app::part(root) .gr-form {
display: flex;
flex-direction: column;
align-items: center;
}
#mobile-dropdown {
display: none;
width: 100%;
max-width: 300px;
margin: 10px auto;
padding: 10px;
font-size: 16px;
}
@media (max-width: 768px) {
#mobile-dropdown {
display: block;
}
gradio-app::part(root) #style_selection {
display: none;
}
}
</style>
</head>
<body>
<div class="gradio-container">
<gradio-app src="https://app.skybrowse.co"></gradio-app>
</div>
<select id="mobile-dropdown"></select>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
const gradioApp = document.querySelector('gradio-app');
const container = document.querySelector('.gradio-container');
const mobileDropdown = document.getElementById('mobile-dropdown');
const adjustLayout = () => {
const shadowRoot = gradioApp.shadowRoot;
if (shadowRoot) {
const appContent = shadowRoot.querySelector('#root');
if (appContent) {
container.style.minHeight = `${window.innerHeight}px`;
appContent.style.minHeight = `${window.innerHeight}px`;
// Create mobile dropdown
const radioGroup = shadowRoot.querySelector('#style_selection');
if (radioGroup) {
const radioButtons = radioGroup.querySelectorAll('input[type="radio"]');
mobileDropdown.innerHTML = '';
radioButtons.forEach(radio => {
const option = document.createElement('option');
option.value = radio.value;
option.textContent = radio.nextElementSibling.textContent;
mobileDropdown.appendChild(option);
});
// Sync dropdown with radio buttons
mobileDropdown.addEventListener('change', (e) => {
const selectedRadio = radioGroup.querySelector(`input[value="${e.target.value}"]`);
if (selectedRadio) selectedRadio.click();
});
// Position the dropdown
const radioGroupRect = radioGroup.getBoundingClientRect();
mobileDropdown.style.position = 'absolute';
mobileDropdown.style.top = `${radioGroupRect.top}px`;
mobileDropdown.style.left = `${radioGroupRect.left}px`;
mobileDropdown.style.width = `${radioGroupRect.width}px`;
}
// Force layout recalculation
appContent.style.display = 'none';
appContent.offsetHeight; // Trigger reflow
appContent.style.display = '';
}
}
};
const observer = new MutationObserver((mutations) => {
adjustLayout();
});
gradioApp.addEventListener('load', () => {
observer.observe(gradioApp.shadowRoot, { childList: true, subtree: true });
adjustLayout();
});
window.addEventListener('resize', adjustLayout);
});
</script>
</body>
</html> |