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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from textwrap import dedent
|
| 2 |
+
|
| 3 |
+
def get_dvnc_layout_css() -> str:
|
| 4 |
+
return dedent(r'''
|
| 5 |
+
:root {
|
| 6 |
+
--dvnc-page-max: min(1880px, calc(100vw - 32px));
|
| 7 |
+
--dvnc-content-max: min(1840px, calc(100vw - 48px));
|
| 8 |
+
--dvnc-route-gap: 22px;
|
| 9 |
+
--dvnc-summary-col: clamp(280px, 18vw, 360px);
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
html, body, .gradio-container {
|
| 13 |
+
overflow-x: hidden !important;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.gradio-container {
|
| 17 |
+
max-width: var(--dvnc-page-max) !important;
|
| 18 |
+
width: 100% !important;
|
| 19 |
+
margin: 0 auto !important;
|
| 20 |
+
padding: 16px !important;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
#dvnc-shell {
|
| 24 |
+
width: 100% !important;
|
| 25 |
+
max-width: var(--dvnc-content-max) !important;
|
| 26 |
+
margin: 0 auto !important;
|
| 27 |
+
padding: 20px 20px 28px !important;
|
| 28 |
+
box-sizing: border-box !important;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
#dvnc-shell > .gradio-row,
|
| 32 |
+
#dvnc-shell .gradio-row {
|
| 33 |
+
width: 100% !important;
|
| 34 |
+
max-width: 100% !important;
|
| 35 |
+
flex-wrap: nowrap !important;
|
| 36 |
+
align-items: stretch !important;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
#dvnc-shell .gradio-column,
|
| 40 |
+
#dvnc-shell .gr-block,
|
| 41 |
+
#dvnc-shell .gr-box,
|
| 42 |
+
#dvnc-shell .gr-panel {
|
| 43 |
+
min-width: 0 !important;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
#dvnc-shell .gradio-column.scale-0,
|
| 47 |
+
#dvnc-shell .gradio-column.scale-1,
|
| 48 |
+
#dvnc-shell .gradio-column.scale-2,
|
| 49 |
+
#dvnc-shell .gradio-column.scale-3,
|
| 50 |
+
#dvnc-shell .gradio-column.scale-4,
|
| 51 |
+
#dvnc-shell .gradio-column.scale-5,
|
| 52 |
+
#dvnc-shell .gradio-column.scale-6,
|
| 53 |
+
#dvnc-shell .gradio-column.scale-7,
|
| 54 |
+
#dvnc-shell .gradio-column.scale-8,
|
| 55 |
+
#dvnc-shell .gradio-column.scale-9,
|
| 56 |
+
#dvnc-shell .gradio-column.scale-10,
|
| 57 |
+
#dvnc-shell [class*='scale-'] {
|
| 58 |
+
min-width: 0 !important;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
#dvnc-shell .stretch,
|
| 62 |
+
#dvnc-shell [style*='flex-grow'] {
|
| 63 |
+
min-width: 0 !important;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
#dvnc-shell .prose,
|
| 67 |
+
#dvnc-shell .markdown,
|
| 68 |
+
#dvnc-shell .gr-markdown,
|
| 69 |
+
#dvnc-shell .gr-html,
|
| 70 |
+
#dvnc-shell .gradio-html {
|
| 71 |
+
max-width: 100% !important;
|
| 72 |
+
width: 100% !important;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
#dvnc-shell .gr-html > div,
|
| 76 |
+
#dvnc-shell .gradio-html > div,
|
| 77 |
+
#dvnc-shell .gr-markdown > div {
|
| 78 |
+
max-width: 100% !important;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
#dvnc-shell #dvnc-agent-route-cards,
|
| 82 |
+
#dvnc-shell #dvnc-agent-route-cards.dvnc-agent-route-shell {
|
| 83 |
+
width: 100% !important;
|
| 84 |
+
max-width: none !important;
|
| 85 |
+
margin: 0 !important;
|
| 86 |
+
padding-inline: 0 !important;
|
| 87 |
+
box-sizing: border-box !important;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-route-grid {
|
| 91 |
+
width: 100% !important;
|
| 92 |
+
max-width: none !important;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-row {
|
| 96 |
+
grid-template-columns: minmax(260px, var(--dvnc-summary-col)) minmax(0, 1fr) !important;
|
| 97 |
+
gap: var(--dvnc-route-gap) !important;
|
| 98 |
+
width: 100% !important;
|
| 99 |
+
max-width: 100% !important;
|
| 100 |
+
align-items: stretch !important;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-summary-panel {
|
| 104 |
+
min-height: 100% !important;
|
| 105 |
+
height: 100% !important;
|
| 106 |
+
align-self: stretch !important;
|
| 107 |
+
position: sticky;
|
| 108 |
+
top: 18px;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-cards {
|
| 112 |
+
display: grid !important;
|
| 113 |
+
grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
|
| 114 |
+
gap: 16px !important;
|
| 115 |
+
width: 100% !important;
|
| 116 |
+
max-width: 100% !important;
|
| 117 |
+
align-items: stretch !important;
|
| 118 |
+
justify-content: stretch !important;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-card,
|
| 122 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-card-inner,
|
| 123 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-face {
|
| 124 |
+
width: 100% !important;
|
| 125 |
+
max-width: 100% !important;
|
| 126 |
+
box-sizing: border-box !important;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-face {
|
| 130 |
+
min-height: 320px !important;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-top,
|
| 134 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-meta,
|
| 135 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-actions {
|
| 136 |
+
gap: 10px !important;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-badge,
|
| 140 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-score,
|
| 141 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-face h4,
|
| 142 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-face p,
|
| 143 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-route-btn,
|
| 144 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-copy p,
|
| 145 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-topline span {
|
| 146 |
+
white-space: normal !important;
|
| 147 |
+
overflow-wrap: anywhere !important;
|
| 148 |
+
word-break: break-word !important;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#dvnc-shell .panel,
|
| 152 |
+
#dvnc-shell .chat-panel,
|
| 153 |
+
#dvnc-shell .querybox,
|
| 154 |
+
#dvnc-shell .gr-block,
|
| 155 |
+
#dvnc-shell .gr-box {
|
| 156 |
+
width: 100% !important;
|
| 157 |
+
max-width: 100% !important;
|
| 158 |
+
box-sizing: border-box !important;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
@media (max-width: 1560px) {
|
| 162 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-row {
|
| 163 |
+
grid-template-columns: minmax(250px, 320px) minmax(0, 1fr) !important;
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
@media (max-width: 1360px) {
|
| 168 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-cards {
|
| 169 |
+
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
@media (max-width: 1080px) {
|
| 174 |
+
#dvnc-shell > .gradio-row,
|
| 175 |
+
#dvnc-shell .gradio-row {
|
| 176 |
+
flex-wrap: wrap !important;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-row {
|
| 180 |
+
grid-template-columns: 1fr !important;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-summary-panel {
|
| 184 |
+
position: static;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
#dvnc-shell #dvnc-agent-route-cards .dvnc-agent-cards {
|
| 188 |
+
grid-template-columns: 1fr !important;
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
''')
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def get_dvnc_layout_readme() -> str:
|
| 195 |
+
return dedent('''
|
| 196 |
+
# DVNC UI layout patch
|
| 197 |
+
|
| 198 |
+
Import this file from `dvnc_ai_v2_hf/app.py` and append `get_dvnc_layout_css()` to your main CSS string.
|
| 199 |
+
|
| 200 |
+
Example:
|
| 201 |
+
|
| 202 |
+
```python
|
| 203 |
+
from dvnc_ai_v2_hf.dvnc_ui_layout import get_dvnc_layout_css
|
| 204 |
+
|
| 205 |
+
CSS = BASE_CSS + "\\n" + get_dvnc_layout_css()
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
This patch fixes the common Gradio/HTML layout issue where the custom route-card HTML remains constrained by an inner left-aligned container instead of expanding to full available width.
|
| 209 |
+
''')
|