GoogleCalc commited on
Commit
8e40d3d
Β·
verified Β·
1 Parent(s): 1c94841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -34
app.py CHANGED
@@ -771,7 +771,7 @@ def export_calculations_wrapper():
771
 
772
 
773
  # ============================================================
774
- # FEED CALCULATION
775
  # ============================================================
776
 
777
  def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_code, breed, request: gr.Request):
@@ -836,47 +836,47 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
836
  html = f"""
837
  <div class="results-shell">
838
 
839
- <section class="buy-card">
840
  <div class="eyebrow">YOUR FEED RESULT</div>
841
  <div class="buy-label">BUY</div>
842
  <div class="buy-number">{rounded_bags}</div>
843
  <div class="buy-unit">BAGS</div>
844
  <div class="buy-note">Recommended amount, rounded up to the next whole bag.</div>
845
- </section>
846
 
847
  <div class="result-context">
848
  <strong>{birds:,} {breed} broilers</strong> Β· {age_text} ({total_days} days)
849
  </div>
850
 
851
- <p class="plain-answer">
852
  You need <strong>{total_feed_kg:,.1f} kg</strong> of feed, equal to about
853
  <strong>{total_bags:.1f} bags</strong> of {bag_size:g} kg feed.
854
- </p>
855
 
856
  <div class="metric-grid">
857
  <div class="metric-card">
858
- <span class="metric-icon">βš–οΈ</span>
859
- <span class="metric-label">Feed needed</span>
860
  <strong>{total_feed_kg:,.1f} kg</strong>
861
  </div>
862
  <div class="metric-card">
863
- <span class="metric-icon">βœ“</span>
864
- <span class="metric-label">Exact amount</span>
865
  <strong>{total_bags:.1f} bags</strong>
866
  </div>
867
  <div class="metric-card">
868
- <span class="metric-icon">₦</span>
869
- <span class="metric-label">Estimated cost</span>
870
  <strong>{currency_symbol}{total_cost:,.0f}</strong>
871
  </div>
872
  <div class="metric-card">
873
- <span class="metric-icon">πŸ“…</span>
874
- <span class="metric-label">Growing period</span>
875
  <strong>{total_days} days</strong>
876
  </div>
877
  </div>
878
 
879
- <section class="result-section">
880
  <div class="section-title">🌾 Feed Breakdown</div>
881
  <div class="table-wrap">
882
  <table class="feed-table">
@@ -888,23 +888,22 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
888
  </tbody>
889
  </table>
890
  </div>
891
- </section>
892
 
893
- <section class="cost-card">
894
  <div class="section-title">πŸ’° Feed Cost Estimate</div>
895
  <div class="cost-main">{currency_symbol}{total_cost:,.0f}</div>
896
  <div class="cost-note">Based on {rounded_bags} bags Γ— {currency_symbol}{price_per_bag:,.0f} per bag.</div>
897
- </section>
898
 
899
- <section class="result-section performance-section">
900
  <div class="section-title">πŸ“ˆ Expected Performance</div>
901
  <div class="performance-grid">
902
  <div><span>Body weight per bird</span><strong>{expected_weight:.3f} kg</strong></div>
903
- <div><span>Flock live weight</span><strong>{flock_weight:,.1f} kg</strong></div>
904
  </div>
905
- </section>
906
 
907
- <section class="result-section share-section">
908
  <div class="section-title">πŸ“€ Share Result</div>
909
  <div class="share-grid">
910
  <a class="share-btn whatsapp" href="{share_links['whatsapp']}" target="_blank">WhatsApp</a>
@@ -912,7 +911,7 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
912
  <a class="share-btn facebook" href="{share_links['facebook']}" target="_blank">Facebook</a>
913
  <a class="share-btn twitter" href="{share_links['twitter']}" target="_blank">X</a>
914
  </div>
915
- </section>
916
 
917
  <div class="result-disclaimer">
918
  ⚠️ This is an estimate based on the selected {breed} benchmark. Actual feed use can vary with feed quality, management, environment and bird performance.
@@ -929,7 +928,7 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
929
 
930
  CSS = """
931
  /* ============================================================
932
- FORCE LIGHT THEME - NO DARK MODE
933
  ============================================================ */
934
  :root {
935
  color-scheme: light !important;
@@ -940,11 +939,6 @@ CSS = """
940
  --brand-accent-yellow: #ffb800;
941
  --ui-border-muted: #d6e0db;
942
  --text-helper: #5a6e65;
943
- --mint: #00a86b;
944
- --mint-dark: #0b3022;
945
- --mint-soft: #eaf8f1;
946
- --yellow: #ffb800;
947
- --yellow-soft: #fff7db;
948
  }
949
 
950
  /* Force light on everything */
@@ -954,7 +948,7 @@ html, body, .gradio-container, .gradio-container * {
954
  color: #0b3022 !important;
955
  }
956
 
957
- /* Remove Hugging Face Space header/GoogleCalc floater */
958
  #huggingface-space-header,
959
  #huggingface-space-header *,
960
  .hf-header,
@@ -966,7 +960,17 @@ html, body, .gradio-container, .gradio-container * {
966
  .space-header,
967
  .space-header *,
968
  .duplicated-from-banner,
969
- .duplicated-from-banner * {
 
 
 
 
 
 
 
 
 
 
970
  display: none !important;
971
  opacity: 0 !important;
972
  height: 0 !important;
@@ -977,12 +981,16 @@ html, body, .gradio-container, .gradio-container * {
977
  border: 0 !important;
978
  pointer-events: none !important;
979
  visibility: hidden !important;
 
 
 
980
  }
981
 
982
  /* Kill any dark mode */
983
  .dark, .dark *,
984
  [data-theme="dark"], [data-theme="dark"] *,
985
- .dark-mode, .dark-mode * {
 
986
  background-color: #f4f7f5 !important;
987
  color: #0b3022 !important;
988
  color-scheme: light !important;
@@ -1088,7 +1096,7 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1088
  }
1089
  .calculate-btn button:hover { background: #008F5A !important; }
1090
 
1091
- /* RESULTS */
1092
  .results-shell { width: 100%; box-sizing: border-box; color: #0b3022; }
1093
  .buy-card {
1094
  background: linear-gradient(145deg, #F1FBF6 0%, #FFFFFF 100%);
@@ -1374,13 +1382,13 @@ with gr.Blocks(title=APP_NAME, analytics_enabled=False) as demo:
1374
  result = gr.HTML(
1375
  value="""
1376
  <div class="results-shell">
1377
- <section class="buy-card">
1378
  <div class="eyebrow">YOUR FEED RESULT</div>
1379
  <div class="buy-label">BUY</div>
1380
  <div class="buy-number">β€”</div>
1381
  <div class="buy-unit">BAGS</div>
1382
  <div class="buy-note">Enter your flock details above to calculate.</div>
1383
- </section>
1384
  </div>
1385
  """,
1386
  elem_classes=["answer-box"],
 
771
 
772
 
773
  # ============================================================
774
+ # FEED CALCULATION - CLEAN FORMATTED RESULTS
775
  # ============================================================
776
 
777
  def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_code, breed, request: gr.Request):
 
836
  html = f"""
837
  <div class="results-shell">
838
 
839
+ <div class="buy-card">
840
  <div class="eyebrow">YOUR FEED RESULT</div>
841
  <div class="buy-label">BUY</div>
842
  <div class="buy-number">{rounded_bags}</div>
843
  <div class="buy-unit">BAGS</div>
844
  <div class="buy-note">Recommended amount, rounded up to the next whole bag.</div>
845
+ </div>
846
 
847
  <div class="result-context">
848
  <strong>{birds:,} {breed} broilers</strong> Β· {age_text} ({total_days} days)
849
  </div>
850
 
851
+ <div class="plain-answer">
852
  You need <strong>{total_feed_kg:,.1f} kg</strong> of feed, equal to about
853
  <strong>{total_bags:.1f} bags</strong> of {bag_size:g} kg feed.
854
+ </div>
855
 
856
  <div class="metric-grid">
857
  <div class="metric-card">
858
+ <div class="metric-icon">βš–οΈ</div>
859
+ <div class="metric-label">Feed needed</div>
860
  <strong>{total_feed_kg:,.1f} kg</strong>
861
  </div>
862
  <div class="metric-card">
863
+ <div class="metric-icon">βœ“</div>
864
+ <div class="metric-label">Exact amount</div>
865
  <strong>{total_bags:.1f} bags</strong>
866
  </div>
867
  <div class="metric-card">
868
+ <div class="metric-icon">₦</div>
869
+ <div class="metric-label">Estimated cost</div>
870
  <strong>{currency_symbol}{total_cost:,.0f}</strong>
871
  </div>
872
  <div class="metric-card">
873
+ <div class="metric-icon">πŸ“…</div>
874
+ <div class="metric-label">Growing period</div>
875
  <strong>{total_days} days</strong>
876
  </div>
877
  </div>
878
 
879
+ <div class="result-section">
880
  <div class="section-title">🌾 Feed Breakdown</div>
881
  <div class="table-wrap">
882
  <table class="feed-table">
 
888
  </tbody>
889
  </table>
890
  </div>
891
+ </div>
892
 
893
+ <div class="cost-card">
894
  <div class="section-title">πŸ’° Feed Cost Estimate</div>
895
  <div class="cost-main">{currency_symbol}{total_cost:,.0f}</div>
896
  <div class="cost-note">Based on {rounded_bags} bags Γ— {currency_symbol}{price_per_bag:,.0f} per bag.</div>
897
+ </div>
898
 
899
+ <div class="result-section performance-section">
900
  <div class="section-title">πŸ“ˆ Expected Performance</div>
901
  <div class="performance-grid">
902
  <div><span>Body weight per bird</span><strong>{expected_weight:.3f} kg</strong></div>
 
903
  </div>
904
+ </div>
905
 
906
+ <div class="result-section share-section">
907
  <div class="section-title">πŸ“€ Share Result</div>
908
  <div class="share-grid">
909
  <a class="share-btn whatsapp" href="{share_links['whatsapp']}" target="_blank">WhatsApp</a>
 
911
  <a class="share-btn facebook" href="{share_links['facebook']}" target="_blank">Facebook</a>
912
  <a class="share-btn twitter" href="{share_links['twitter']}" target="_blank">X</a>
913
  </div>
914
+ </div>
915
 
916
  <div class="result-disclaimer">
917
  ⚠️ This is an estimate based on the selected {breed} benchmark. Actual feed use can vary with feed quality, management, environment and bird performance.
 
928
 
929
  CSS = """
930
  /* ============================================================
931
+ FORCE LIGHT THEME - NO DARK MODE - NO FLOATER
932
  ============================================================ */
933
  :root {
934
  color-scheme: light !important;
 
939
  --brand-accent-yellow: #ffb800;
940
  --ui-border-muted: #d6e0db;
941
  --text-helper: #5a6e65;
 
 
 
 
 
942
  }
943
 
944
  /* Force light on everything */
 
948
  color: #0b3022 !important;
949
  }
950
 
951
+ /* REMOVE GOOGLECALC FLOATER - Ultimate Fix */
952
  #huggingface-space-header,
953
  #huggingface-space-header *,
954
  .hf-header,
 
960
  .space-header,
961
  .space-header *,
962
  .duplicated-from-banner,
963
+ .duplicated-from-banner *,
964
+ .flex.items-center.gap-2,
965
+ .flex.items-center.gap-2 *,
966
+ .absolute.top-4.left-4,
967
+ .absolute.top-4.left-4 *,
968
+ [class*="duplicated"],
969
+ [class*="Duplicated"],
970
+ [class*="origin"],
971
+ [class*="Origin"],
972
+ .p-2.rounded-lg.border,
973
+ .p-2.rounded-lg.border * {
974
  display: none !important;
975
  opacity: 0 !important;
976
  height: 0 !important;
 
981
  border: 0 !important;
982
  pointer-events: none !important;
983
  visibility: hidden !important;
984
+ position: absolute !important;
985
+ clip: rect(0,0,0,0) !important;
986
+ overflow: hidden !important;
987
  }
988
 
989
  /* Kill any dark mode */
990
  .dark, .dark *,
991
  [data-theme="dark"], [data-theme="dark"] *,
992
+ .dark-mode, .dark-mode *,
993
+ [class*="dark"] {
994
  background-color: #f4f7f5 !important;
995
  color: #0b3022 !important;
996
  color-scheme: light !important;
 
1096
  }
1097
  .calculate-btn button:hover { background: #008F5A !important; }
1098
 
1099
+ /* RESULTS - Clean Formatting */
1100
  .results-shell { width: 100%; box-sizing: border-box; color: #0b3022; }
1101
  .buy-card {
1102
  background: linear-gradient(145deg, #F1FBF6 0%, #FFFFFF 100%);
 
1382
  result = gr.HTML(
1383
  value="""
1384
  <div class="results-shell">
1385
+ <div class="buy-card">
1386
  <div class="eyebrow">YOUR FEED RESULT</div>
1387
  <div class="buy-label">BUY</div>
1388
  <div class="buy-number">β€”</div>
1389
  <div class="buy-unit">BAGS</div>
1390
  <div class="buy-note">Enter your flock details above to calculate.</div>
1391
+ </div>
1392
  </div>
1393
  """,
1394
  elem_classes=["answer-box"],