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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -19
app.py CHANGED
@@ -771,7 +771,7 @@ def export_calculations_wrapper():
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,46 +836,51 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
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">
@@ -890,19 +895,23 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
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">
@@ -923,7 +932,7 @@ def calculate_feed(birds, weeks, days, bag_size, price_per_bag, email, country_c
923
 
924
 
925
  # ============================================================
926
- # CSS - COMPLETE FIX: NO FLOATER, FORCE LIGHT THEME
927
  # ============================================================
928
 
929
  CSS = """
@@ -948,7 +957,7 @@ html, body, .gradio-container, .gradio-container * {
948
  color: #0b3022 !important;
949
  }
950
 
951
- /* REMOVE GOOGLECALC FLOATER - Ultimate Fix */
952
  #huggingface-space-header,
953
  #huggingface-space-header *,
954
  .hf-header,
@@ -1096,8 +1105,12 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
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%);
1103
  border: 2px solid #00a86b;
@@ -1110,10 +1123,13 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1110
  .buy-number { color: #00a86b !important; font-size: clamp(50px, 15vw, 76px); font-weight: 900; line-height: .9; }
1111
  .buy-unit { color: #0b3022 !important; font-size: 18px; font-weight: 900; letter-spacing: .06em; }
1112
  .buy-note { margin-top: 6px; color: #5a6e65 !important; font-size: 11px; }
 
1113
  .result-context { text-align: center; margin: 10px 2px 4px; color: #5a6e65 !important; font-size: 12px; }
1114
  .result-context strong { color: #0b3022 !important; }
 
 
1115
  .plain-answer {
1116
- background: #fff;
1117
  border-left: 4px solid #ffb800;
1118
  border-radius: 8px;
1119
  padding: 10px 12px;
@@ -1124,6 +1140,7 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1124
  }
1125
  .plain-answer strong { color: #0b3022 !important; }
1126
 
 
1127
  .metric-grid {
1128
  display: grid;
1129
  grid-template-columns: repeat(2, 1fr);
@@ -1136,13 +1153,15 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1136
  border-radius: 10px;
1137
  padding: 10px 8px;
1138
  }
1139
- .metric-icon { display: block; color: #00a86b !important; font-size: 16px; font-weight: 900; }
1140
  .metric-label { display: block; color: #5a6e65 !important; font-size: 10px; margin: 2px 0 3px; }
1141
- .metric-card strong { display: block; color: #0b3022 !important; font-size: 15px; line-height: 1.2; }
1142
 
1143
  .result-section { margin: 12px 0; }
1144
  .section-title { color: #0b3022 !important; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
1145
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
 
 
1146
  .feed-table {
1147
  width: 100%;
1148
  min-width: 280px;
@@ -1166,6 +1185,7 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1166
  .feed-table .muted { color: #5a6e65 !important; font-size: 9px; }
1167
  .feed-table .total-row td { background: #eaf8f1 !important; font-weight: 900 !important; }
1168
 
 
1169
  .cost-card {
1170
  background: #fff7db !important;
1171
  border: 1px solid #EBC34A;
@@ -1177,6 +1197,7 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1177
  .cost-main { color: #0b3022 !important; font-size: clamp(24px, 7vw, 34px); line-height: 1.1; font-weight: 900; }
1178
  .cost-note { color: #5a6e65 !important; font-size: 10px; margin-top: 4px; }
1179
 
 
1180
  .performance-grid {
1181
  background: #fff;
1182
  border: 1px solid #d6e0db;
@@ -1193,8 +1214,9 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1193
  }
1194
  .performance-grid > div:first-child { border-top: 0; }
1195
  .performance-grid span { color: #5a6e65 !important; }
1196
- .performance-grid strong { color: #00a86b !important; white-space: nowrap; }
1197
 
 
1198
  .share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
1199
  .share-btn {
1200
  display: block;
@@ -1228,6 +1250,7 @@ body, .gradio-container, .gradio-container .block, .gradio-container .gr-group {
1228
  margin-top: 12px;
1229
  }
1230
 
 
1231
  .benchmark-card {
1232
  background: #ffffff !important;
1233
  border: 1px solid #d6e0db;
@@ -1383,7 +1406,7 @@ with gr.Blocks(title=APP_NAME, analytics_enabled=False) as demo:
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>
 
771
 
772
 
773
  # ============================================================
774
+ # FEED CALCULATION - COLORFUL 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
+ <!-- BUY CARD - Mint Green -->
840
  <div class="buy-card">
841
+ <div class="eyebrow">🎯 YOUR FEED RESULT</div>
842
  <div class="buy-label">BUY</div>
843
  <div class="buy-number">{rounded_bags}</div>
844
  <div class="buy-unit">BAGS</div>
845
  <div class="buy-note">Recommended amount, rounded up to the next whole bag.</div>
846
  </div>
847
 
848
+ <!-- Context -->
849
  <div class="result-context">
850
  <strong>{birds:,} {breed} broilers</strong> Β· {age_text} ({total_days} days)
851
  </div>
852
 
853
+ <!-- Plain Answer - Yellow Highlight -->
854
  <div class="plain-answer">
855
  You need <strong>{total_feed_kg:,.1f} kg</strong> of feed, equal to about
856
  <strong>{total_bags:.1f} bags</strong> of {bag_size:g} kg feed.
857
  </div>
858
 
859
+ <!-- METRIC GRID - Colorful Cards -->
860
  <div class="metric-grid">
861
+ <div class="metric-card" style="border-left: 4px solid #00A86B;">
862
  <div class="metric-icon">βš–οΈ</div>
863
  <div class="metric-label">Feed needed</div>
864
+ <strong style="color: #00A86B;">{total_feed_kg:,.1f} kg</strong>
865
  </div>
866
+ <div class="metric-card" style="border-left: 4px solid #FFB800;">
867
  <div class="metric-icon">βœ“</div>
868
  <div class="metric-label">Exact amount</div>
869
+ <strong style="color: #FFB800;">{total_bags:.1f} bags</strong>
870
  </div>
871
+ <div class="metric-card" style="border-left: 4px solid #EA4335;">
872
  <div class="metric-icon">₦</div>
873
  <div class="metric-label">Estimated cost</div>
874
+ <strong style="color: #EA4335;">{currency_symbol}{total_cost:,.0f}</strong>
875
  </div>
876
+ <div class="metric-card" style="border-left: 4px solid #1E4620;">
877
  <div class="metric-icon">πŸ“…</div>
878
  <div class="metric-label">Growing period</div>
879
+ <strong style="color: #1E4620;">{total_days} days</strong>
880
  </div>
881
  </div>
882
 
883
+ <!-- FEED BREAKDOWN -->
884
  <div class="result-section">
885
  <div class="section-title">🌾 Feed Breakdown</div>
886
  <div class="table-wrap">
 
895
  </div>
896
  </div>
897
 
898
+ <!-- FEED COST - Yellow Card -->
899
  <div class="cost-card">
900
  <div class="section-title">πŸ’° Feed Cost Estimate</div>
901
  <div class="cost-main">{currency_symbol}{total_cost:,.0f}</div>
902
  <div class="cost-note">Based on {rounded_bags} bags Γ— {currency_symbol}{price_per_bag:,.0f} per bag.</div>
903
  </div>
904
 
905
+ <!-- PERFORMANCE - Green Card -->
906
  <div class="result-section performance-section">
907
  <div class="section-title">πŸ“ˆ Expected Performance</div>
908
  <div class="performance-grid">
909
+ <div><span>Body weight per bird</span><strong style="color: #00A86B;">{expected_weight:.3f} kg</strong></div>
910
+ <div><span>Flock live weight</span><strong style="color: #1E4620;">{flock_weight:,.1f} kg</strong></div>
911
  </div>
912
  </div>
913
 
914
+ <!-- SHARE -->
915
  <div class="result-section share-section">
916
  <div class="section-title">πŸ“€ Share Result</div>
917
  <div class="share-grid">
 
932
 
933
 
934
  # ============================================================
935
+ # CSS - COMPLETE FIX: LIGHT THEME + COLORFUL RESULTS
936
  # ============================================================
937
 
938
  CSS = """
 
957
  color: #0b3022 !important;
958
  }
959
 
960
+ /* REMOVE GOOGLECALC FLOATER */
961
  #huggingface-space-header,
962
  #huggingface-space-header *,
963
  .hf-header,
 
1105
  }
1106
  .calculate-btn button:hover { background: #008F5A !important; }
1107
 
1108
+ /* ============================================================
1109
+ COLORFUL RESULTS
1110
+ ============================================================ */
1111
  .results-shell { width: 100%; box-sizing: border-box; color: #0b3022; }
1112
+
1113
+ /* BUY CARD - Mint Green */
1114
  .buy-card {
1115
  background: linear-gradient(145deg, #F1FBF6 0%, #FFFFFF 100%);
1116
  border: 2px solid #00a86b;
 
1123
  .buy-number { color: #00a86b !important; font-size: clamp(50px, 15vw, 76px); font-weight: 900; line-height: .9; }
1124
  .buy-unit { color: #0b3022 !important; font-size: 18px; font-weight: 900; letter-spacing: .06em; }
1125
  .buy-note { margin-top: 6px; color: #5a6e65 !important; font-size: 11px; }
1126
+
1127
  .result-context { text-align: center; margin: 10px 2px 4px; color: #5a6e65 !important; font-size: 12px; }
1128
  .result-context strong { color: #0b3022 !important; }
1129
+
1130
+ /* Plain Answer - Yellow Highlight */
1131
  .plain-answer {
1132
+ background: #fff7db !important;
1133
  border-left: 4px solid #ffb800;
1134
  border-radius: 8px;
1135
  padding: 10px 12px;
 
1140
  }
1141
  .plain-answer strong { color: #0b3022 !important; }
1142
 
1143
+ /* Metric Cards - Colorful */
1144
  .metric-grid {
1145
  display: grid;
1146
  grid-template-columns: repeat(2, 1fr);
 
1153
  border-radius: 10px;
1154
  padding: 10px 8px;
1155
  }
1156
+ .metric-icon { display: block; color: #0b3022 !important; font-size: 16px; font-weight: 900; }
1157
  .metric-label { display: block; color: #5a6e65 !important; font-size: 10px; margin: 2px 0 3px; }
1158
+ .metric-card strong { display: block; font-size: 15px; line-height: 1.2; }
1159
 
1160
  .result-section { margin: 12px 0; }
1161
  .section-title { color: #0b3022 !important; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
1162
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
1163
+
1164
+ /* Feed Table - Mint Green Header */
1165
  .feed-table {
1166
  width: 100%;
1167
  min-width: 280px;
 
1185
  .feed-table .muted { color: #5a6e65 !important; font-size: 9px; }
1186
  .feed-table .total-row td { background: #eaf8f1 !important; font-weight: 900 !important; }
1187
 
1188
+ /* Cost Card - Yellow */
1189
  .cost-card {
1190
  background: #fff7db !important;
1191
  border: 1px solid #EBC34A;
 
1197
  .cost-main { color: #0b3022 !important; font-size: clamp(24px, 7vw, 34px); line-height: 1.1; font-weight: 900; }
1198
  .cost-note { color: #5a6e65 !important; font-size: 10px; margin-top: 4px; }
1199
 
1200
+ /* Performance - Green */
1201
  .performance-grid {
1202
  background: #fff;
1203
  border: 1px solid #d6e0db;
 
1214
  }
1215
  .performance-grid > div:first-child { border-top: 0; }
1216
  .performance-grid span { color: #5a6e65 !important; }
1217
+ .performance-grid strong { white-space: nowrap; }
1218
 
1219
+ /* Share Buttons */
1220
  .share-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
1221
  .share-btn {
1222
  display: block;
 
1250
  margin-top: 12px;
1251
  }
1252
 
1253
+ /* Benchmark / Question Cards */
1254
  .benchmark-card {
1255
  background: #ffffff !important;
1256
  border: 1px solid #d6e0db;
 
1406
  value="""
1407
  <div class="results-shell">
1408
  <div class="buy-card">
1409
+ <div class="eyebrow">🎯 YOUR FEED RESULT</div>
1410
  <div class="buy-label">BUY</div>
1411
  <div class="buy-number">β€”</div>
1412
  <div class="buy-unit">BAGS</div>