js02vel commited on
Commit
074cc6d
Β·
verified Β·
1 Parent(s): 7d9664c

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +122 -84
src/streamlit_app.py CHANGED
@@ -10,130 +10,168 @@ st.set_page_config(
10
  )
11
 
12
  # --------------------------------------------------
13
- # Custom CSS (Ensuring High Visibility)
14
  # --------------------------------------------------
15
  st.markdown("""
16
  <style>
17
- /* Force a clean, light background for the whole app */
18
- .stApp {
19
- background-color: #F0F2F6;
20
- }
21
-
22
- /* Card-style container for the form */
23
- div[data-testid="stForm"] {
24
- background-color: #FFFFFF !important;
25
- padding: 30px !important;
26
- border-radius: 15px !important;
27
- border: 1px solid #E0E0E0 !important;
28
- box-shadow: 0 4px 12px rgba(0,0,0,0.05);
29
- }
30
-
31
- /* Force all text labels and headers to be Dark Blue/Black */
32
- h1, h2, h3, p, label, .stMarkdown {
33
- color: #1A1C25 !important;
34
- }
35
-
36
- /* Style the Input boxes for clarity */
37
- input {
38
- color: #1A1C25 !important;
39
- background-color: #F8F9FA !important;
40
- }
41
-
42
- /* Button styling */
43
- .stButton > button {
44
- width: 100%;
45
- background: linear-gradient(90deg, #2563eb, #1d4ed8);
46
- color: white !important;
47
- font-weight: bold;
48
- border: none;
49
- padding: 10px;
50
- border-radius: 8px;
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  </style>
53
  """, unsafe_allow_html=True)
54
 
55
  # --------------------------------------------------
56
- # Header
57
  # --------------------------------------------------
58
  st.title("πŸ’ͺ FitPlan AI")
59
- st.markdown("### Milestone 1: Fitness Profile & BMI Analysis")
60
- st.write("Complete your profile below to calculate your health metrics.")
61
 
62
  # --------------------------------------------------
63
  # Fitness Profile Form
64
  # --------------------------------------------------
65
  with st.form("fitness_form"):
66
- st.markdown("#### πŸ§β€β™‚οΈ 1. Personal Information")
67
-
68
- name = st.text_input("Full Name *", placeholder="e.g. John Doe")
 
 
69
 
70
  col1, col2 = st.columns(2)
71
  with col1:
72
- # Added min_value logic to prevent negatives
73
- height = st.number_input("Height (cm) *", min_value=0.0, step=1.0, format="%.1f")
74
  with col2:
75
- weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1, format="%.1f")
 
 
76
 
77
- st.markdown("---")
 
78
 
79
- st.markdown("#### πŸ‹οΈ 2. Fitness Details")
80
-
81
  goal = st.selectbox(
82
  "Fitness Goal",
83
  ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
84
  )
85
 
86
  equipment = st.multiselect(
87
- "Available Equipment (Select all that apply)",
88
- ["Dumbbells", "Resistance Band", "Yoga Mat", "Kettlebell", "Pull-up Bar", "No Equipment"],
89
- default=["No Equipment"]
90
  )
91
 
92
  level = st.radio(
93
  "Fitness Level",
94
- ["Beginner", "Intermediate", "Advanced"],
95
- horizontal=True
96
  )
97
 
98
  submit = st.form_submit_button("Generate Profile")
99
 
100
  # --------------------------------------------------
101
- # Logic & Output
102
  # --------------------------------------------------
103
  if submit:
104
- # Validation checks
 
105
  if not name.strip():
106
- st.error("🚨 Name is required.")
107
- elif height <= 50 or weight <= 10: # Realistic safety checks
108
- st.error("🚨 Please enter valid height and weight values.")
109
  else:
110
- # BMI Calculation
111
  height_m = height / 100
112
- bmi = weight / (height_m ** 2)
113
- bmi_display = round(bmi, 2)
114
 
115
- # Precise BMI Classification
116
  if bmi < 18.5:
117
- category, color, progress = "Underweight", "blue", 0.25
118
- elif 18.5 <= bmi < 25.0:
119
- category, color, progress = "Normal", "green", 0.50
120
- elif 25.0 <= bmi < 30.0:
121
- category, color, progress = "Overweight", "orange", 0.75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  else:
123
- category, color, progress = "Obese", "red", 1.0
124
-
125
- # Results Display
126
- st.success(f"βœ… Profile generated for {name}")
127
-
128
- m_col1, m_col2 = st.columns(2)
129
- with m_col1:
130
- st.metric("Your BMI", f"{bmi_display}")
131
- with m_col2:
132
- # Using bold colored markdown for high visibility
133
- st.markdown(f"**Status:** :{color}[{category}]")
134
-
135
- st.markdown("### πŸ“Š BMI Visual Indicator")
136
- st.progress(progress)
137
-
138
- # Summary Box
139
- st.info(f"**Profile Summary:**\n\n* **Goal:** {goal}\n* **Experience:** {level}\n* **Equipment:** {', '.join(equipment) if equipment else 'None'}")
 
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
 
79
  # --------------------------------------------------
80
+ # Title Section
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",
109
  ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
110
  )
111
 
112
  equipment = st.multiselect(
113
+ "Available Equipment",
114
+ ["Dumbbells", "Resistance Band", "Yoga Mat",
115
+ "Kettlebell", "Pull-up Bar", "No Equipment"]
116
  )
117
 
118
  level = st.radio(
119
  "Fitness Level",
120
+ ["Beginner", "Intermediate", "Advanced"]
 
121
  )
122
 
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")