milwright commited on
Commit
ef270a4
·
1 Parent(s): c902f0b

Improve UI layout for better space usage and usability

Browse files

- Reduce excessive whitespace and margins
- Add CSS classes for more compact layout
- Improve button positioning and make Process button more prominent
- Better organize the document preview and results sections

Files changed (2) hide show
  1. app.py +20 -8
  2. ui/custom.css +46 -1
app.py CHANGED
@@ -493,17 +493,23 @@ with main_tab3:
493
 
494
  # Main tab content
495
  with main_tab1:
496
- # Create two columns for the main interface
497
- col1, col2 = st.columns([1, 1])
 
 
 
498
 
499
  # File upload column
500
  with col1:
501
- st.subheader("Upload Document")
502
-
503
- # File uploader
504
- uploaded_file = st.file_uploader("Choose an image or PDF file",
505
- type=["pdf", "png", "jpg", "jpeg"],
506
- help="Select a document to process with OCR")
 
 
 
507
 
508
  # Show preprocessing summary if options are selected
509
  if uploaded_file is not None and any(preprocessing_options.values()):
@@ -541,10 +547,12 @@ with main_tab1:
541
  st.write(f"**File:** {uploaded_file.name} ({file_size_mb:.2f} MB)")
542
 
543
  # Process button
 
544
  process_button = st.button("Process Document",
545
  type="primary",
546
  use_container_width=True,
547
  help="Start OCR processing with the selected options")
 
548
 
549
  # Preview column
550
  with col2:
@@ -624,6 +632,7 @@ with main_tab1:
624
  # Results section - spans full width
625
  if 'process_button' in locals() and process_button:
626
  # Horizontal line to separate input and results
 
627
  st.markdown("---")
628
  st.subheader("Processing Results")
629
 
@@ -734,6 +743,8 @@ with main_tab1:
734
  else:
735
  st.markdown(f"**{k}:** {v}")
736
 
 
 
737
  # Download button
738
  with st.expander("Export Content"):
739
  # Generate HTML content for download with proper CSS styling
@@ -940,6 +951,7 @@ with main_tab1:
940
  # Show sample examples when no file is uploaded
941
  elif uploaded_file is None:
942
  # Show info about supported formats
 
943
  st.info("📝 Upload a document to get started. Supported formats: JPG, PNG, PDF")
944
 
945
  # Show example usage
 
493
 
494
  # Main tab content
495
  with main_tab1:
496
+ # Create a more compact layout using custom CSS
497
+ st.markdown('<div class="compact-layout">', unsafe_allow_html=True)
498
+
499
+ # Create two columns for the main interface with a better ratio
500
+ col1, col2 = st.columns([1, 1.2])
501
 
502
  # File upload column
503
  with col1:
504
+ with st.container():
505
+ st.markdown('<div class="upload-section">', unsafe_allow_html=True)
506
+ st.subheader("Upload Document")
507
+
508
+ # File uploader
509
+ uploaded_file = st.file_uploader("Choose an image or PDF file",
510
+ type=["pdf", "png", "jpg", "jpeg"],
511
+ help="Select a document to process with OCR")
512
+ st.markdown('</div>', unsafe_allow_html=True)
513
 
514
  # Show preprocessing summary if options are selected
515
  if uploaded_file is not None and any(preprocessing_options.values()):
 
547
  st.write(f"**File:** {uploaded_file.name} ({file_size_mb:.2f} MB)")
548
 
549
  # Process button
550
+ st.markdown('<div class="process-button">', unsafe_allow_html=True)
551
  process_button = st.button("Process Document",
552
  type="primary",
553
  use_container_width=True,
554
  help="Start OCR processing with the selected options")
555
+ st.markdown('</div>', unsafe_allow_html=True)
556
 
557
  # Preview column
558
  with col2:
 
632
  # Results section - spans full width
633
  if 'process_button' in locals() and process_button:
634
  # Horizontal line to separate input and results
635
+ st.markdown('<div class="processing-results">', unsafe_allow_html=True)
636
  st.markdown("---")
637
  st.subheader("Processing Results")
638
 
 
743
  else:
744
  st.markdown(f"**{k}:** {v}")
745
 
746
+ st.markdown('</div>', unsafe_allow_html=True) # Close processing-results div
747
+
748
  # Download button
749
  with st.expander("Export Content"):
750
  # Generate HTML content for download with proper CSS styling
 
951
  # Show sample examples when no file is uploaded
952
  elif uploaded_file is None:
953
  # Show info about supported formats
954
+ st.markdown('</div>', unsafe_allow_html=True) # Close compact-layout div
955
  st.info("📝 Upload a document to get started. Supported formats: JPG, PNG, PDF")
956
 
957
  # Show example usage
ui/custom.css CHANGED
@@ -216,12 +216,26 @@
216
  .stButton > button {
217
  background-color: var(--color-blue-600);
218
  color: white;
 
 
219
  }
220
 
221
  .stButton > button:hover {
222
  background-color: var(--color-blue-700);
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  /* Sidebars */
226
  [data-testid="stSidebar"] {
227
  background-color: var(--color-gray-900);
@@ -275,7 +289,7 @@
275
  padding: 1.5rem;
276
  border-radius: 0.5rem;
277
  border: 1px solid var(--color-gray-700);
278
- margin-bottom: 1.5rem;
279
  }
280
 
281
  /* Upload container */
@@ -302,6 +316,37 @@
302
  background-color: var(--color-blue-600);
303
  }
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  /* Workflow steps */
306
  .workflow-step {
307
  background-color: var(--color-gray-800);
 
216
  .stButton > button {
217
  background-color: var(--color-blue-600);
218
  color: white;
219
+ margin-top: 10px;
220
+ margin-bottom: 10px;
221
  }
222
 
223
  .stButton > button:hover {
224
  background-color: var(--color-blue-700);
225
  }
226
 
227
+ /* Process button specific styling */
228
+ .process-button button {
229
+ margin-top: 10px;
230
+ position: relative;
231
+ width: 100%;
232
+ }
233
+
234
+ /* Processing results section */
235
+ .processing-results {
236
+ margin-top: 20px;
237
+ }
238
+
239
  /* Sidebars */
240
  [data-testid="stSidebar"] {
241
  background-color: var(--color-gray-900);
 
289
  padding: 1.5rem;
290
  border-radius: 0.5rem;
291
  border: 1px solid var(--color-gray-700);
292
+ margin-bottom: 1rem;
293
  }
294
 
295
  /* Upload container */
 
316
  background-color: var(--color-blue-600);
317
  }
318
 
319
+ /* Custom layout improvements */
320
+ .compact-layout {
321
+ margin-top: 0;
322
+ margin-bottom: 0;
323
+ padding-top: 0;
324
+ padding-bottom: 0;
325
+ }
326
+
327
+ .upload-section {
328
+ margin-bottom: 10px;
329
+ }
330
+
331
+ .preview-section {
332
+ margin-top: 0;
333
+ margin-bottom: 10px;
334
+ }
335
+
336
+ /* Two column layout for better space usage */
337
+ .two-column-container {
338
+ display: flex;
339
+ gap: 20px;
340
+ }
341
+
342
+ .left-panel {
343
+ flex: 1;
344
+ }
345
+
346
+ .right-panel {
347
+ flex: 2;
348
+ }
349
+
350
  /* Workflow steps */
351
  .workflow-step {
352
  background-color: var(--color-gray-800);