js02vel commited on
Commit
2e65e3d
Β·
verified Β·
1 Parent(s): 8552652

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +75 -126
src/streamlit_app.py CHANGED
@@ -10,30 +10,69 @@ st.set_page_config(
10
  )
11
 
12
  # --------------------------------------------------
13
- # Custom Styling (HF Compatible)
14
  # --------------------------------------------------
15
  st.markdown("""
16
  <style>
 
 
17
  .stApp {
18
- background: linear-gradient(135deg, #e3f2fd, #f8fbff);
19
  }
20
 
 
21
  .block-container {
22
- background-color: white;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  padding: 2rem;
24
- border-radius: 15px;
25
- max-width: 850px;
26
  }
27
 
 
28
  .stButton > button {
29
  width: 100%;
30
- height: 3em;
31
- border-radius: 8px;
32
- background-color: #FF4B4B;
33
- color: white;
34
- font-size: 16px;
 
35
  border: none;
36
  }
 
37
  </style>
38
  """, unsafe_allow_html=True)
39
 
@@ -42,37 +81,28 @@ st.markdown("""
42
  # --------------------------------------------------
43
  st.title("πŸ’ͺ FitPlan AI")
44
  st.subheader("Milestone 1: Fitness Profile & BMI Analysis")
45
- st.write("Fill in your details to generate your BMI profile.")
46
 
47
  # --------------------------------------------------
48
  # Fitness Profile Form
49
  # --------------------------------------------------
50
  with st.form("fitness_form"):
51
 
52
- st.header("1️⃣ Personal Information")
 
53
 
54
  name = st.text_input("Full Name *")
55
 
56
  col1, col2 = st.columns(2)
57
  with col1:
58
- height = st.number_input(
59
- "Height (cm) *",
60
- min_value=0.0,
61
- step=0.1,
62
- format="%.2f"
63
- )
64
-
65
  with col2:
66
- weight = st.number_input(
67
- "Weight (kg) *",
68
- min_value=0.0,
69
- step=0.1,
70
- format="%.2f"
71
- )
72
 
73
  st.divider()
74
 
75
- st.header("2️⃣ Fitness Details")
 
76
 
77
  goal = st.selectbox(
78
  "Fitness Goal",
@@ -93,136 +123,55 @@ with st.form("fitness_form"):
93
  submit = st.form_submit_button("Generate Profile")
94
 
95
  # --------------------------------------------------
96
- # Processing Logic
97
  # --------------------------------------------------
98
  if submit:
99
 
100
- # -------- Input Validation --------
101
  if not name.strip():
102
  st.error("⚠ Please enter your name.")
103
-
104
- elif height <= 0:
105
- st.error("⚠ Height must be greater than 0 cm.")
106
-
107
- elif weight <= 0:
108
- st.error("⚠ Weight must be greater than 0 kg.")
109
-
110
  else:
111
  # -------- BMI Calculation --------
112
- height_m = height / 100 # Convert cm to meters
113
- bmi = weight / (height_m ** 2)
114
- bmi = round(bmi, 2)
115
 
116
  # -------- BMI Classification --------
117
  if bmi < 18.5:
118
  category = "Underweight"
119
  color = "blue"
 
120
  elif 18.5 <= bmi < 24.9:
121
  category = "Normal"
122
  color = "green"
 
123
  elif 25 <= bmi < 29.9:
124
  category = "Overweight"
125
  color = "orange"
 
126
  else:
127
  category = "Obese"
128
  color = "red"
 
129
 
130
- # -------- Display Results --------
131
- st.success(f"βœ… Profile successfully created for {name}!")
132
 
133
  colA, colB = st.columns(2)
134
-
135
  with colA:
136
  st.metric("Your BMI", bmi)
137
-
138
  with colB:
139
  st.markdown(f"**BMI Category:** :{color}[{category}]")
140
 
 
 
 
 
 
141
  st.info(f"🎯 Goal: {goal} | πŸ“ˆ Level: {level}")
142
 
143
  if equipment:
144
- st.write("πŸ‹ Available Equipment:", ", ".join(equipment))
145
  else:
146
- st.write("πŸ‹ Available Equipment: None selected")
147
- st.markdown("""
148
- <style>
149
-
150
- /* Full page background */
151
- .stApp {
152
- background-color: #f4f7fb;
153
- }
154
-
155
- /* Main container */
156
- .block-container {
157
- background-color: #ffffff;
158
- padding: 2.5rem;
159
- border-radius: 16px;
160
- max-width: 900px;
161
- }
162
-
163
- /* Headings */
164
- h1, h2, h3 {
165
- color: #0f172a !important;
166
- }
167
-
168
- /* Labels */
169
- label {
170
- color: #1e293b !important;
171
- font-weight: 600;
172
- }
173
-
174
- /* Text inputs & number inputs */
175
- input, textarea {
176
- background-color: #ffffff !important;
177
- color: #0f172a !important;
178
- border-radius: 10px !important;
179
- border: 1px solid #cbd5e1 !important;
180
- }
181
-
182
- /* Selectbox & Multiselect */
183
- div[data-baseweb="select"] {
184
- background-color: #ffffff !important;
185
- color: #0f172a !important;
186
- border-radius: 10px;
187
- }
188
-
189
- /* Dropdown text */
190
- div[data-baseweb="select"] span {
191
- color: #0f172a !important;
192
- }
193
-
194
- /* Number input buttons (+ / -) */
195
- button[aria-label="Increment"],
196
- button[aria-label="Decrement"] {
197
- color: #0f172a !important;
198
- }
199
-
200
- /* Radio & checkbox text */
201
- span {
202
- color: #0f172a !important;
203
- }
204
-
205
- /* Form card */
206
- div[data-testid="stForm"] {
207
- background-color: #f8fafc;
208
- padding: 2rem;
209
- border-radius: 14px;
210
- box-shadow: 0 10px 25px rgba(0,0,0,0.08);
211
- }
212
-
213
- /* Main action button */
214
- .stButton > button {
215
- width: 100%;
216
- height: 3.2em;
217
- border-radius: 10px;
218
- background: linear-gradient(90deg, #2563eb, #1d4ed8);
219
- color: white !important;
220
- font-size: 17px;
221
- font-weight: 600;
222
- border: none;
223
- }
224
-
225
- </style>
226
- """, unsafe_allow_html=True)
227
-
228
-
 
10
  )
11
 
12
  # --------------------------------------------------
13
+ # Custom CSS (HF Compatible + Visible UI)
14
  # --------------------------------------------------
15
  st.markdown("""
16
  <style>
17
+
18
+ /* Page background */
19
  .stApp {
20
+ background-color: #f4f7fb;
21
  }
22
 
23
+ /* Main container */
24
  .block-container {
25
+ background-color: #ffffff;
26
+ padding: 2.5rem;
27
+ border-radius: 18px;
28
+ max-width: 900px;
29
+ }
30
+
31
+ /* Headings */
32
+ h1, h2, h3 {
33
+ color: #0f172a !important;
34
+ }
35
+
36
+ /* Labels */
37
+ label {
38
+ color: #1e293b !important;
39
+ font-weight: 600;
40
+ }
41
+
42
+ /* Inputs */
43
+ input, textarea {
44
+ background-color: #ffffff !important;
45
+ color: #0f172a !important;
46
+ border-radius: 10px !important;
47
+ border: 1px solid #cbd5e1 !important;
48
+ }
49
+
50
+ /* Selectbox & Multiselect */
51
+ div[data-baseweb="select"] {
52
+ background-color: #ffffff !important;
53
+ border-radius: 10px;
54
+ }
55
+
56
+ /* Form card */
57
+ div[data-testid="stForm"] {
58
+ background-color: #f8fafc;
59
  padding: 2rem;
60
+ border-radius: 14px;
61
+ box-shadow: 0 10px 25px rgba(0,0,0,0.08);
62
  }
63
 
64
+ /* Main button */
65
  .stButton > button {
66
  width: 100%;
67
+ height: 3.2em;
68
+ border-radius: 10px;
69
+ background: linear-gradient(90deg, #2563eb, #1d4ed8);
70
+ color: white !important;
71
+ font-size: 17px;
72
+ font-weight: 600;
73
  border: none;
74
  }
75
+
76
  </style>
77
  """, unsafe_allow_html=True)
78
 
 
81
  # --------------------------------------------------
82
  st.title("πŸ’ͺ FitPlan AI")
83
  st.subheader("Milestone 1: Fitness Profile & BMI Analysis")
84
+ st.write("Enter your details to calculate BMI and generate your fitness profile.")
85
 
86
  # --------------------------------------------------
87
  # Fitness Profile Form
88
  # --------------------------------------------------
89
  with st.form("fitness_form"):
90
 
91
+ # -------- Section 1 --------
92
+ st.header("πŸ§β€β™‚οΈ 1. Personal Information")
93
 
94
  name = st.text_input("Full Name *")
95
 
96
  col1, col2 = st.columns(2)
97
  with col1:
98
+ height = st.number_input("Height (cm) *", min_value=0.0, step=0.1)
 
 
 
 
 
 
99
  with col2:
100
+ weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1)
 
 
 
 
 
101
 
102
  st.divider()
103
 
104
+ # -------- Section 2 --------
105
+ st.header("πŸ‹οΈ 2. Fitness Details")
106
 
107
  goal = st.selectbox(
108
  "Fitness Goal",
 
123
  submit = st.form_submit_button("Generate Profile")
124
 
125
  # --------------------------------------------------
126
+ # Processing & Output
127
  # --------------------------------------------------
128
  if submit:
129
 
130
+ # -------- Validation --------
131
  if not name.strip():
132
  st.error("⚠ Please enter your name.")
133
+ elif height <= 0 or weight <= 0:
134
+ st.error("⚠ Height and weight must be greater than zero.")
 
 
 
 
 
135
  else:
136
  # -------- BMI Calculation --------
137
+ height_m = height / 100
138
+ bmi = round(weight / (height_m ** 2), 2)
 
139
 
140
  # -------- BMI Classification --------
141
  if bmi < 18.5:
142
  category = "Underweight"
143
  color = "blue"
144
+ progress = bmi / 18.5
145
  elif 18.5 <= bmi < 24.9:
146
  category = "Normal"
147
  color = "green"
148
+ progress = bmi / 24.9
149
  elif 25 <= bmi < 29.9:
150
  category = "Overweight"
151
  color = "orange"
152
+ progress = bmi / 29.9
153
  else:
154
  category = "Obese"
155
  color = "red"
156
+ progress = 1.0
157
 
158
+ # -------- Results Section --------
159
+ st.success(f"βœ… Profile created successfully for **{name}**")
160
 
161
  colA, colB = st.columns(2)
 
162
  with colA:
163
  st.metric("Your BMI", bmi)
 
164
  with colB:
165
  st.markdown(f"**BMI Category:** :{color}[{category}]")
166
 
167
+ # -------- BMI Progress Bar --------
168
+ st.markdown("### πŸ“Š BMI Progress Indicator")
169
+ st.progress(min(progress, 1.0))
170
+
171
+ # -------- Summary --------
172
  st.info(f"🎯 Goal: {goal} | πŸ“ˆ Level: {level}")
173
 
174
  if equipment:
175
+ st.write("🧰 Equipment:", ", ".join(equipment))
176
  else:
177
+ st.write("🧰 Equipment: No equipment selected")