milwright commited on
Commit
65790b5
Β·
1 Parent(s): a571c3e

Improve UI for mobile and fix multiple display issues

Browse files
Files changed (2) hide show
  1. app.py +7 -7
  2. ui/custom.css +134 -13
app.py CHANGED
@@ -634,10 +634,10 @@ with main_tab2:
634
  # Display previous results if available
635
  if not st.session_state.previous_results:
636
  st.markdown("""
637
- <div class="previous-results-container" style="text-align: center; padding: 40px 20px;">
638
- <div style="font-size: 48px; margin-bottom: 20px; color: #757575;">πŸ“„</div>
639
- <h3 style="color: #212121; margin-bottom: 10px;">No Previous Results</h3>
640
- <p style="color: #616161;">Process a document to see your results history saved here.</p>
641
  </div>
642
  """, unsafe_allow_html=True)
643
  else:
@@ -1669,7 +1669,7 @@ with main_tab1:
1669
  with columns1[i]:
1670
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1671
  try:
1672
- st.image(str(img_path), caption=img_path.name, width=300)
1673
  except Exception:
1674
  st.info(f"Example: {img_path.name}")
1675
  else:
@@ -1682,7 +1682,7 @@ with main_tab1:
1682
  with columns2[i]:
1683
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1684
  try:
1685
- st.image(str(img_path), caption=img_path.name, width=300)
1686
  except Exception:
1687
  st.info(f"Example: {img_path.name}")
1688
  else:
@@ -1695,7 +1695,7 @@ with main_tab1:
1695
  with columns[i % len(columns)]:
1696
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1697
  try:
1698
- st.image(str(img_path), caption=img_path.name, width=300)
1699
  except Exception:
1700
  st.info(f"Example: {img_path.name}")
1701
  else:
 
634
  # Display previous results if available
635
  if not st.session_state.previous_results:
636
  st.markdown("""
637
+ <div class="previous-results-container" style="text-align: center; padding: 40px 20px; background-color: #f8f9fa; border-radius: 8px;">
638
+ <div style="font-size: 48px; margin-bottom: 20px; color: #000000;">πŸ“„</div>
639
+ <h3 style="color: #000000; margin-bottom: 10px; font-weight: 600;">No Previous Results</h3>
640
+ <p style="color: #000000; font-size: 16px;">Process a document to see your results history saved here.</p>
641
  </div>
642
  """, unsafe_allow_html=True)
643
  else:
 
1669
  with columns1[i]:
1670
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1671
  try:
1672
+ st.image(str(img_path), caption=img_path.name, use_column_width=True)
1673
  except Exception:
1674
  st.info(f"Example: {img_path.name}")
1675
  else:
 
1682
  with columns2[i]:
1683
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1684
  try:
1685
+ st.image(str(img_path), caption=img_path.name, use_column_width=True)
1686
  except Exception:
1687
  st.info(f"Example: {img_path.name}")
1688
  else:
 
1695
  with columns[i % len(columns)]:
1696
  if img_path.suffix.lower() in ['.jpg', '.jpeg', '.png', '.tif']:
1697
  try:
1698
+ st.image(str(img_path), caption=img_path.name, use_column_width=True)
1699
  except Exception:
1700
  st.info(f"Example: {img_path.name}")
1701
  else:
ui/custom.css CHANGED
@@ -11,6 +11,8 @@
11
  /* Result card styling */
12
  .previous-results-container {
13
  margin-bottom: 20px;
 
 
14
  }
15
 
16
  .result-card {
@@ -150,44 +152,76 @@
150
  /* Fix for fullscreen and expander buttons in image containers */
151
  .stImage button[title="View fullscreen"] {
152
  position: absolute !important;
153
- top: 5px !important;
154
- right: 5px !important;
155
  z-index: 1000 !important;
156
  visibility: visible !important;
157
  opacity: 1 !important;
158
  display: flex !important;
159
  align-items: center !important;
160
  justify-content: center !important;
161
- background-color: rgba(255, 255, 255, 0.8) !important;
 
 
 
 
162
  }
163
 
164
  /* Fix fullscreen button styling */
165
  button[title="View fullscreen"],
166
  button.streamlit-expanderHeader {
167
  z-index: 999 !important;
168
- background-color: rgba(255, 255, 255, 0.8) !important;
169
  visibility: visible !important;
170
  opacity: 1 !important;
171
  display: flex !important;
172
  align-items: center !important;
173
  justify-content: center !important;
174
- width: 32px !important;
175
- height: 32px !important;
176
  border-radius: 4px !important;
177
  position: absolute !important;
178
- top: 5px !important;
179
- right: 5px !important;
180
- border: 1px solid rgba(0, 0, 0, 0.1) !important;
181
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
 
182
  }
183
 
184
- /* Make text visible in Previous Results tab */
 
 
 
 
 
 
185
  .previous-results-container h3,
186
  .previous-results-container p,
187
  .previous-results-container .result-filename,
188
  .previous-results-container .result-date,
189
- .previous-results-container .result-tag {
190
- color: #212121 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  }
192
 
193
  /* Additional image fixes for all containers */
@@ -202,6 +236,7 @@ button.streamlit-expanderHeader {
202
  }
203
 
204
  /* Responsive design rules */
 
205
  @media (max-width: 768px) {
206
  .stExpander img,
207
  .document-content img,
@@ -211,4 +246,90 @@ button.streamlit-expanderHeader {
211
  .streamlit-expanderContent img {
212
  max-width: 95% !important;
213
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
 
11
  /* Result card styling */
12
  .previous-results-container {
13
  margin-bottom: 20px;
14
+ color: #000000 !important;
15
+ background-color: #ffffff !important;
16
  }
17
 
18
  .result-card {
 
152
  /* Fix for fullscreen and expander buttons in image containers */
153
  .stImage button[title="View fullscreen"] {
154
  position: absolute !important;
155
+ top: 8px !important;
156
+ right: 8px !important;
157
  z-index: 1000 !important;
158
  visibility: visible !important;
159
  opacity: 1 !important;
160
  display: flex !important;
161
  align-items: center !important;
162
  justify-content: center !important;
163
+ background-color: rgba(0, 0, 0, 0.7) !important;
164
+ color: white !important;
165
+ width: 36px !important;
166
+ height: 36px !important;
167
+ border-radius: 4px !important;
168
  }
169
 
170
  /* Fix fullscreen button styling */
171
  button[title="View fullscreen"],
172
  button.streamlit-expanderHeader {
173
  z-index: 999 !important;
174
+ background-color: rgba(0, 0, 0, 0.7) !important;
175
  visibility: visible !important;
176
  opacity: 1 !important;
177
  display: flex !important;
178
  align-items: center !important;
179
  justify-content: center !important;
180
+ width: 36px !important;
181
+ height: 36px !important;
182
  border-radius: 4px !important;
183
  position: absolute !important;
184
+ top: 8px !important;
185
+ right: 8px !important;
186
+ border: 1px solid rgba(255, 255, 255, 0.3) !important;
187
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
188
+ color: white !important;
189
  }
190
 
191
+ button[title="View fullscreen"]:hover,
192
+ button.streamlit-expanderHeader:hover {
193
+ background-color: rgba(0, 0, 0, 0.9) !important;
194
+ border: 1px solid rgba(255, 255, 255, 0.5) !important;
195
+ }
196
+
197
+ /* Make text visible in Previous Results tab - ensure high contrast */
198
  .previous-results-container h3,
199
  .previous-results-container p,
200
  .previous-results-container .result-filename,
201
  .previous-results-container .result-date,
202
+ .previous-results-container .result-tag,
203
+ .stMarkdown h3,
204
+ .stMarkdown p,
205
+ .caption {
206
+ color: #000000 !important;
207
+ text-shadow: none !important;
208
+ }
209
+
210
+ /* No Results state styling */
211
+ .previous-results-container[style*="text-align: center"] {
212
+ background-color: #f8f9fa !important;
213
+ border-radius: 8px !important;
214
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
215
+ }
216
+
217
+ .previous-results-container[style*="text-align: center"] h3 {
218
+ color: #000000 !important;
219
+ font-weight: 600 !important;
220
+ }
221
+
222
+ .previous-results-container[style*="text-align: center"] p {
223
+ color: #000000 !important;
224
+ font-size: 16px !important;
225
  }
226
 
227
  /* Additional image fixes for all containers */
 
236
  }
237
 
238
  /* Responsive design rules */
239
+ /* Specific rules for mobile/small screens */
240
  @media (max-width: 768px) {
241
  .stExpander img,
242
  .document-content img,
 
246
  .streamlit-expanderContent img {
247
  max-width: 95% !important;
248
  }
249
+
250
+ /* Improve responsive layout for example documents */
251
+ .stImage,
252
+ .css-6qob1r,
253
+ .css-zq5wmm,
254
+ .css-fg4pbf,
255
+ [data-testid="column"] {
256
+ margin-bottom: 20px !important;
257
+ padding: 0 10px !important;
258
+ }
259
+
260
+ .stImage img {
261
+ width: 100% !important;
262
+ max-width: 100% !important;
263
+ height: auto !important;
264
+ object-fit: contain !important;
265
+ }
266
+
267
+ .stColumnContainer,
268
+ .css-jjjwqm,
269
+ .css-fg4pbf,
270
+ [data-testid="column"] {
271
+ gap: 20px !important;
272
+ margin-bottom: 20px !important;
273
+ }
274
+ }
275
+
276
+ /* Modern Streamlit styling - better responsive behavior */
277
+ .block-container {
278
+ padding-top: 2rem !important;
279
+ padding-bottom: 2rem !important;
280
+ }
281
+
282
+ /* Specific rules for very small screens (mobile) */
283
+ @media (max-width: 640px) {
284
+ /* Force single column on very small screens */
285
+ .row-widget.stHorizontal > div {
286
+ flex-direction: column !important;
287
+ width: 100% !important;
288
+ }
289
+
290
+ [data-testid="column"] {
291
+ width: 100% !important;
292
+ flex: 1 1 100% !important;
293
+ padding: 0 !important;
294
+ }
295
+
296
+ /* Make images more visible on small screens */
297
+ .row-widget.stImage img,
298
+ [data-testid="stImage"] > img {
299
+ max-width: 100% !important;
300
+ width: 100% !important;
301
+ margin-bottom: 15px !important;
302
+ }
303
+ }
304
+
305
+ /* Fix image display in grid layout */
306
+ .row-widget.stImage,
307
+ .css-z5fcl4 {
308
+ text-align: center !important;
309
+ margin-bottom: 15px !important;
310
+ padding: 0 !important;
311
+ }
312
+
313
+ .row-widget.stImage img,
314
+ .css-z5fcl4 img {
315
+ max-height: 250px !important;
316
+ object-fit: contain !important;
317
+ border-radius: 4px !important;
318
+ border: 1px solid rgba(0, 0, 0, 0.1) !important;
319
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
320
+ }
321
+
322
+ /* Better caption styling for images */
323
+ .css-z5fcl4 .caption,
324
+ .caption,
325
+ [data-testid="caption"],
326
+ .css-1b0udgb,
327
+ .css-183lzff {
328
+ margin-top: 5px !important;
329
+ color: #000000 !important;
330
+ font-weight: 500 !important;
331
+ text-align: center !important;
332
+ font-size: 0.9rem !important;
333
+ width: 100% !important;
334
+ display: block !important;
335
  }