Spaces:
Sleeping
Sleeping
Update refApp.py
Browse files
refApp.py
CHANGED
|
@@ -14,45 +14,36 @@ st.markdown("""
|
|
| 14 |
<style>
|
| 15 |
/* Cible le bouton spécifique que vous avez identifié */
|
| 16 |
button[data-testid="stBaseButton-headerNoPadding"]::after {
|
| 17 |
-
content: " Menu";
|
| 18 |
-
margin-left: 8px;
|
| 19 |
-
font-size: 0.9em;
|
| 20 |
-
vertical-align: middle;
|
| 21 |
-
color: inherit;
|
| 22 |
-
font-weight: normal;
|
| 23 |
-
display: inline-flex;
|
| 24 |
align-items: center;
|
| 25 |
}
|
| 26 |
div[data-testid="stCodeBlock"] pre,
|
| 27 |
-
pre.st-emotion-cache-1nqbjoj
|
| 28 |
-
{
|
| 29 |
-
|
| 30 |
max-height: 520px !important;
|
| 31 |
overflow-y: auto !important;
|
| 32 |
font-size: 0.875em !important;
|
| 33 |
-
|
| 34 |
-
display: block !important;
|
| 35 |
visibility: visible !important;
|
| 36 |
opacity: 1 !important;
|
| 37 |
}
|
| 38 |
-
|
| 39 |
-
/* Cible le div conteneur direct à l'intérieur de stCodeBlock s'il existe et gère le scroll */
|
| 40 |
div[data-testid="stCodeBlock"] > div:first-child {
|
| 41 |
-
|
| 42 |
-
max-height: 520px !important; /* Correspond à la valeur du pre ci-dessus */
|
| 43 |
overflow-y: auto !important;
|
| 44 |
-
|
| 45 |
visibility: visible !important;
|
| 46 |
opacity: 1 !important;
|
| 47 |
}
|
| 48 |
-
|
| 49 |
-
/* Si le div interne au <pre> doit gérer le scroll */
|
| 50 |
pre.st-emotion-cache-1nqbjoj > div[style*="background-color: transparent;"] {
|
| 51 |
-
height: auto !important;
|
| 52 |
-
max-height: 100% !important;
|
| 53 |
overflow-y: auto !important;
|
| 54 |
}
|
| 55 |
-
/* === NOUVELLES RÈGLES POUR L'ICÔNE DE COPIE DE ST.CODE === */
|
| 56 |
button[data-testid="stCodeCopyButton"] {
|
| 57 |
opacity: 0.85 !important;
|
| 58 |
visibility: visible !important;
|
|
@@ -61,240 +52,48 @@ st.markdown("""
|
|
| 61 |
border-radius: 4px !important;
|
| 62 |
padding: 3px 5px !important;
|
| 63 |
transition: opacity 0.15s ease-in-out, background-color 0.15s ease-in-out;
|
| 64 |
-
/* top: 2px !important; */
|
| 65 |
-
/* right: 2px !important; */
|
| 66 |
}
|
| 67 |
-
|
| 68 |
button[data-testid="stCodeCopyButton"]:hover {
|
| 69 |
opacity: 1 !important;
|
| 70 |
background-color: #e6e8eb !important;
|
| 71 |
border-color: #b0b0b0 !important;
|
| 72 |
}
|
| 73 |
-
|
| 74 |
button[data-testid="stCodeCopyButton"] svg {
|
| 75 |
-
transform: scale(1.2);
|
| 76 |
vertical-align: middle;
|
| 77 |
}
|
| 78 |
-
|
| 79 |
-
/* === SOLUTION POUR COMPRESSION LATERALE DE LA SIDEBAR === */
|
| 80 |
-
/* Force le contenu principal à se comprimer au lieu d'être décalé */
|
| 81 |
section[data-testid="stSidebar"] {
|
| 82 |
width: 31.5rem !important;
|
| 83 |
min-width: 31.5rem !important;
|
| 84 |
max-width: 31.5rem !important;
|
| 85 |
}
|
| 86 |
-
|
| 87 |
-
/* RÉDUIRE LA SIDEBAR QUAND FERMÉE */
|
| 88 |
section[data-testid="stSidebar"][aria-expanded="false"] {
|
| 89 |
width: 0rem !important;
|
| 90 |
min-width: 0rem !important;
|
| 91 |
max-width: 0rem !important;
|
| 92 |
overflow: hidden !important;
|
| 93 |
}
|
| 94 |
-
|
| 95 |
-
/* Ajustement du conteneur principal pour la compression */
|
| 96 |
-
.main .block-container {
|
| 97 |
-
max-width: calc(100vw - 31.5rem) !important;
|
| 98 |
-
width: calc(100vw - 31.5rem) !important;
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
/* Quand la sidebar est fermée, reprendre toute la largeur */
|
| 102 |
-
section[data-testid="stSidebar"][aria-expanded="false"] ~ .main .block-container,
|
| 103 |
-
section[data-testid="stSidebar"]:not([aria-expanded="true"]) ~ .main .block-container {
|
| 104 |
-
max-width: 100vw !important;
|
| 105 |
-
width: 100vw !important;
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
/* Alternative pour cibler via l'état collapsed */
|
| 109 |
-
.main .block-container {
|
| 110 |
-
transition: width 0.3s ease, max-width 0.3s ease !important;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
/* PADDING SPECIFIQUE POUR INTERPRO1_LIGHT */
|
| 114 |
[data-testid="stMainBlockContainer"] {
|
| 115 |
padding-top: 3rem !important;
|
| 116 |
}
|
| 117 |
-
|
| 118 |
.css-1d391kg, .css-18e3th9 {
|
| 119 |
padding-top: 3rem !important;
|
| 120 |
}
|
| 121 |
-
|
| 122 |
-
/* REDUCTION SPECIFIQUE POUR LA PAGE D'ACCUEIL UNIQUEMENT */
|
| 123 |
h1[data-testid="stHeading"]:first-of-type {
|
| 124 |
margin-top: -2rem !important;
|
| 125 |
padding-top: 0rem !important;
|
| 126 |
}
|
| 127 |
-
|
| 128 |
h1:contains("Bienvenue dans votre laboratoire") {
|
| 129 |
margin-top: -2rem !important;
|
| 130 |
padding-top: 0rem !important;
|
| 131 |
}
|
| 132 |
-
|
| 133 |
-
/* Responsive: sur petits écrans, garder le comportement normal */
|
| 134 |
@media (max-width: 768px) {
|
| 135 |
.main .block-container {
|
| 136 |
max-width: 100vw !important;
|
| 137 |
width: 100vw !important;
|
| 138 |
}
|
| 139 |
}
|
| 140 |
-
|
| 141 |
-
/* === RÈGLES SPÉCIFIQUES POUR st.code() QUI CAUSE LE PROBLÈME === */
|
| 142 |
-
/* Forcer la compression sur TOUS les blocs de code */
|
| 143 |
-
[data-testid="stCodeBlock"],
|
| 144 |
-
div[data-testid="stCodeBlock"],
|
| 145 |
-
.stCodeBlock {
|
| 146 |
-
max-width: 100vw !important;
|
| 147 |
-
width: 100vw !important;
|
| 148 |
-
box-sizing: border-box !important;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
/* Quand sidebar ouverte, compresser les blocs de code */
|
| 152 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main [data-testid="stCodeBlock"],
|
| 153 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main div[data-testid="stCodeBlock"],
|
| 154 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main .stCodeBlock {
|
| 155 |
-
max-width: calc(100vw - 31.5rem) !important;
|
| 156 |
-
width: calc(100vw - 31.5rem) !important;
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
-
/* Forcer sur les éléments internes du code block */
|
| 160 |
-
[data-testid="stCodeBlock"] > div,
|
| 161 |
-
[data-testid="stCodeBlock"] pre,
|
| 162 |
-
[data-testid="stCodeBlock"] code {
|
| 163 |
-
max-width: 100% !important;
|
| 164 |
-
width: 100% !important;
|
| 165 |
-
box-sizing: border-box !important;
|
| 166 |
-
overflow-x: auto !important;
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
/* Quand sidebar ouverte, aussi sur les éléments internes */
|
| 170 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main [data-testid="stCodeBlock"] > div,
|
| 171 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main [data-testid="stCodeBlock"] pre,
|
| 172 |
-
section[data-testid="stSidebar"][aria-expanded="true"] ~ .main [data-testid="stCodeBlock"] code {
|
| 173 |
-
max-width: calc(100vw - 31.5rem) !important;
|
| 174 |
-
width: calc(100vw - 31.5rem) !important;
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
</style>
|
| 178 |
-
<script>
|
| 179 |
-
// Force la détection de l'état de la sidebar
|
| 180 |
-
function checkSidebarState() {
|
| 181 |
-
const sidebar = document.querySelector('section[data-testid="stSidebar"]');
|
| 182 |
-
const mainContent = document.querySelector('.main .block-container');
|
| 183 |
-
|
| 184 |
-
if (sidebar && mainContent) {
|
| 185 |
-
const isExpanded = sidebar.getAttribute('aria-expanded') === 'true';
|
| 186 |
-
|
| 187 |
-
if (isExpanded) {
|
| 188 |
-
mainContent.style.maxWidth = 'calc(100vw - 31.5rem)';
|
| 189 |
-
mainContent.style.width = 'calc(100vw - 31.5rem)';
|
| 190 |
-
} else {
|
| 191 |
-
mainContent.style.maxWidth = '100vw';
|
| 192 |
-
mainContent.style.width = '100vw';
|
| 193 |
-
}
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
// FORCE SPÉCIAL POUR st.code() - Le vrai problème
|
| 197 |
-
const codeBlocks = document.querySelectorAll('[data-testid="stCodeBlock"], div[data-testid="stCodeBlock"], .stCodeBlock');
|
| 198 |
-
codeBlocks.forEach(block => {
|
| 199 |
-
if (sidebar && sidebar.getAttribute('aria-expanded') === 'true') {
|
| 200 |
-
// Sidebar ouverte - compresser
|
| 201 |
-
block.style.maxWidth = 'calc(100vw - 31.5rem)';
|
| 202 |
-
block.style.width = 'calc(100vw - 31.5rem)';
|
| 203 |
-
block.style.boxSizing = 'border-box';
|
| 204 |
-
|
| 205 |
-
// Forcer aussi sur les éléments internes
|
| 206 |
-
const innerElements = block.querySelectorAll('div, pre, code');
|
| 207 |
-
innerElements.forEach(inner => {
|
| 208 |
-
inner.style.maxWidth = '100%';
|
| 209 |
-
inner.style.width = '100%';
|
| 210 |
-
inner.style.overflowX = 'auto';
|
| 211 |
-
});
|
| 212 |
-
} else {
|
| 213 |
-
// Sidebar fermée - pleine largeur
|
| 214 |
-
block.style.maxWidth = '100vw';
|
| 215 |
-
block.style.width = '100vw';
|
| 216 |
-
|
| 217 |
-
const innerElements = block.querySelectorAll('div, pre, code');
|
| 218 |
-
innerElements.forEach(inner => {
|
| 219 |
-
inner.style.maxWidth = '100%';
|
| 220 |
-
inner.style.width = '100%';
|
| 221 |
-
});
|
| 222 |
-
}
|
| 223 |
-
});
|
| 224 |
-
}
|
| 225 |
-
|
| 226 |
-
// Observer les changements
|
| 227 |
-
const observer = new MutationObserver(checkSidebarState);
|
| 228 |
-
|
| 229 |
-
// Démarrer l'observation quand le DOM est prêt
|
| 230 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 231 |
-
const sidebar = document.querySelector('section[data-testid="stSidebar"]');
|
| 232 |
-
if (sidebar) {
|
| 233 |
-
observer.observe(sidebar, { attributes: true, attributeFilter: ['aria-expanded'] });
|
| 234 |
-
}
|
| 235 |
-
checkSidebarState(); // Check initial state
|
| 236 |
-
});
|
| 237 |
-
|
| 238 |
-
// Observer pour changements DOM (génération de contenu)
|
| 239 |
-
const contentObserver = new MutationObserver(function(mutations) {
|
| 240 |
-
mutations.forEach(function(mutation) {
|
| 241 |
-
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
| 242 |
-
// Du nouveau contenu a été ajouté, re-vérifier l'état
|
| 243 |
-
setTimeout(checkSidebarState, 100);
|
| 244 |
-
}
|
| 245 |
-
});
|
| 246 |
-
});
|
| 247 |
-
|
| 248 |
-
// Observer le conteneur principal pour changements
|
| 249 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 250 |
-
const main = document.querySelector('.main');
|
| 251 |
-
if (main) {
|
| 252 |
-
contentObserver.observe(main, { childList: true, subtree: true });
|
| 253 |
-
}
|
| 254 |
-
});
|
| 255 |
-
|
| 256 |
-
// Fallback: check périodique
|
| 257 |
-
setInterval(checkSidebarState, 500);
|
| 258 |
-
|
| 259 |
-
// Disable Enter key form submission
|
| 260 |
-
function disableEnterSubmit() {
|
| 261 |
-
const forms = document.querySelectorAll('form[data-testid="stForm"]');
|
| 262 |
-
forms.forEach(form => {
|
| 263 |
-
const inputs = form.querySelectorAll('input[type="text"], textarea');
|
| 264 |
-
inputs.forEach(input => {
|
| 265 |
-
input.addEventListener('keydown', function(event) {
|
| 266 |
-
if (event.key === 'Enter' && !event.shiftKey) {
|
| 267 |
-
event.preventDefault();
|
| 268 |
-
return false;
|
| 269 |
-
}
|
| 270 |
-
});
|
| 271 |
-
});
|
| 272 |
-
});
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
// Apply on DOM ready and on content changes
|
| 276 |
-
document.addEventListener('DOMContentLoaded', disableEnterSubmit);
|
| 277 |
-
|
| 278 |
-
// Observer for new forms being added dynamically
|
| 279 |
-
const formObserver = new MutationObserver(function(mutations) {
|
| 280 |
-
mutations.forEach(function(mutation) {
|
| 281 |
-
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
|
| 282 |
-
setTimeout(disableEnterSubmit, 100);
|
| 283 |
-
}
|
| 284 |
-
});
|
| 285 |
-
});
|
| 286 |
-
|
| 287 |
-
// Start observing
|
| 288 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 289 |
-
const body = document.querySelector('body');
|
| 290 |
-
if (body) {
|
| 291 |
-
formObserver.observe(body, { childList: true, subtree: true });
|
| 292 |
-
}
|
| 293 |
-
});
|
| 294 |
-
|
| 295 |
-
// Apply periodically as fallback
|
| 296 |
-
setInterval(disableEnterSubmit, 1000);
|
| 297 |
-
</script>
|
| 298 |
""", unsafe_allow_html=True)
|
| 299 |
|
| 300 |
# --- Initial Data Structure & Constants ---
|
|
|
|
| 14 |
<style>
|
| 15 |
/* Cible le bouton spécifique que vous avez identifié */
|
| 16 |
button[data-testid="stBaseButton-headerNoPadding"]::after {
|
| 17 |
+
content: " Menu";
|
| 18 |
+
margin-left: 8px;
|
| 19 |
+
font-size: 0.9em;
|
| 20 |
+
vertical-align: middle;
|
| 21 |
+
color: inherit;
|
| 22 |
+
font-weight: normal;
|
| 23 |
+
display: inline-flex;
|
| 24 |
align-items: center;
|
| 25 |
}
|
| 26 |
div[data-testid="stCodeBlock"] pre,
|
| 27 |
+
pre.st-emotion-cache-1nqbjoj {
|
|
|
|
|
|
|
| 28 |
max-height: 520px !important;
|
| 29 |
overflow-y: auto !important;
|
| 30 |
font-size: 0.875em !important;
|
| 31 |
+
display: block !important;
|
|
|
|
| 32 |
visibility: visible !important;
|
| 33 |
opacity: 1 !important;
|
| 34 |
}
|
|
|
|
|
|
|
| 35 |
div[data-testid="stCodeBlock"] > div:first-child {
|
| 36 |
+
max-height: 520px !important;
|
|
|
|
| 37 |
overflow-y: auto !important;
|
| 38 |
+
display: block !important;
|
| 39 |
visibility: visible !important;
|
| 40 |
opacity: 1 !important;
|
| 41 |
}
|
|
|
|
|
|
|
| 42 |
pre.st-emotion-cache-1nqbjoj > div[style*="background-color: transparent;"] {
|
| 43 |
+
height: auto !important;
|
| 44 |
+
max-height: 100% !important;
|
| 45 |
overflow-y: auto !important;
|
| 46 |
}
|
|
|
|
| 47 |
button[data-testid="stCodeCopyButton"] {
|
| 48 |
opacity: 0.85 !important;
|
| 49 |
visibility: visible !important;
|
|
|
|
| 52 |
border-radius: 4px !important;
|
| 53 |
padding: 3px 5px !important;
|
| 54 |
transition: opacity 0.15s ease-in-out, background-color 0.15s ease-in-out;
|
|
|
|
|
|
|
| 55 |
}
|
|
|
|
| 56 |
button[data-testid="stCodeCopyButton"]:hover {
|
| 57 |
opacity: 1 !important;
|
| 58 |
background-color: #e6e8eb !important;
|
| 59 |
border-color: #b0b0b0 !important;
|
| 60 |
}
|
|
|
|
| 61 |
button[data-testid="stCodeCopyButton"] svg {
|
| 62 |
+
transform: scale(1.2);
|
| 63 |
vertical-align: middle;
|
| 64 |
}
|
|
|
|
|
|
|
|
|
|
| 65 |
section[data-testid="stSidebar"] {
|
| 66 |
width: 31.5rem !important;
|
| 67 |
min-width: 31.5rem !important;
|
| 68 |
max-width: 31.5rem !important;
|
| 69 |
}
|
|
|
|
|
|
|
| 70 |
section[data-testid="stSidebar"][aria-expanded="false"] {
|
| 71 |
width: 0rem !important;
|
| 72 |
min-width: 0rem !important;
|
| 73 |
max-width: 0rem !important;
|
| 74 |
overflow: hidden !important;
|
| 75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
[data-testid="stMainBlockContainer"] {
|
| 77 |
padding-top: 3rem !important;
|
| 78 |
}
|
|
|
|
| 79 |
.css-1d391kg, .css-18e3th9 {
|
| 80 |
padding-top: 3rem !important;
|
| 81 |
}
|
|
|
|
|
|
|
| 82 |
h1[data-testid="stHeading"]:first-of-type {
|
| 83 |
margin-top: -2rem !important;
|
| 84 |
padding-top: 0rem !important;
|
| 85 |
}
|
|
|
|
| 86 |
h1:contains("Bienvenue dans votre laboratoire") {
|
| 87 |
margin-top: -2rem !important;
|
| 88 |
padding-top: 0rem !important;
|
| 89 |
}
|
|
|
|
|
|
|
| 90 |
@media (max-width: 768px) {
|
| 91 |
.main .block-container {
|
| 92 |
max-width: 100vw !important;
|
| 93 |
width: 100vw !important;
|
| 94 |
}
|
| 95 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
""", unsafe_allow_html=True)
|
| 98 |
|
| 99 |
# --- Initial Data Structure & Constants ---
|