js02vel commited on
Commit
f91adf8
·
verified ·
1 Parent(s): f8b215b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +80 -49
src/streamlit_app.py CHANGED
@@ -1,104 +1,132 @@
1
  import streamlit as st
2
 
3
  # 1. Basic Configuration
4
- st.set_page_config(page_title="FitPlan AI", page_icon="💪")
5
 
6
- # 2. CSS with High-Priority Selectors
7
- # This forces the background image and ensures font visibility
8
  st.markdown("""
9
  <style>
10
  /* Full Page Background */
11
  [data-testid="stAppViewContainer"] {
12
- background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
13
  url("https://images.unsplash.com/photo-1517836357463-d25dfeac3438?q=80&w=2070&auto=format&fit=crop");
14
  background-size: cover;
15
  background-position: center;
16
  background-attachment: fixed;
17
  }
18
 
19
- /* Transparent Header */
20
- [data-testid="stHeader"] {
21
- background: rgba(0,0,0,0);
22
  }
23
 
24
- /* Making the Form readable against the dark background */
25
  div[data-testid="stForm"] {
26
- background-color: rgba(255, 255, 255, 0.95) !important;
27
- padding: 2rem !important;
28
- border-radius: 15px !important;
29
- border: 2px solid #3b82f6 !important;
 
30
  }
31
 
32
- /* --- FONT COLORS (FORCED VISIBILITY) --- */
33
- /* Main Title White (Outside Form) */
34
- .title-text {
35
  color: #FFFFFF !important;
36
- text-shadow: 2px 2px 4px #000000;
37
- font-size: 3rem;
38
- font-weight: bold;
39
  text-align: center;
 
 
 
40
  }
41
 
42
- /* Form Labels (Dark Blue) */
43
- label, p, .stMarkdown {
44
- color: #1e293b !important;
45
- font-weight: 600 !important;
 
 
 
 
 
46
  }
47
 
48
- /* Section Headers inside form (Orange) */
49
  .form-header {
50
  color: #f97316 !important;
51
- font-weight: 800;
52
- margin-bottom: 0px;
 
 
53
  }
54
 
55
- /* Force metric values to be visible */
56
- [data-testid="stMetricValue"] {
57
- color: #2563eb !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
  </style>
60
  """, unsafe_allow_html=True)
61
 
62
  # --------------------------------------------------
63
- # UI Elements
64
  # --------------------------------------------------
65
- st.markdown('<p class="title-text">💪 FitPlan AI</p>', unsafe_allow_html=True)
66
- st.markdown("<p style='text-align:center; color:white;'>Your personalized gym companion.</p>", unsafe_allow_html=True)
67
 
68
- with st.form("fitness_form"):
 
 
 
69
  st.markdown('<p class="form-header">🧍‍♂️ 1. PERSONAL INFORMATION</p>', unsafe_allow_html=True)
70
 
71
- name = st.text_input("Full Name *", placeholder="Enter your name")
72
 
73
  col1, col2 = st.columns(2)
74
  with col1:
75
- height = st.number_input("Height (cm) *", min_value=0.0, step=1.0)
76
  with col2:
77
- weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1)
78
 
79
- st.markdown("---")
80
  st.markdown('<p class="form-header">🏋️ 2. FITNESS DETAILS</p>', unsafe_allow_html=True)
81
 
82
  goal = st.selectbox("Fitness Goal", ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"])
83
 
84
  equipment = st.multiselect("Available Equipment",
85
- ["Dumbbells", "Resistance Band", "Yoga Mat", "Kettlebell", "No Equipment"],
86
  default=["No Equipment"])
87
 
88
  level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"], horizontal=True)
89
 
 
90
  submit = st.form_submit_button("GENERATE MY PLAN")
91
 
92
  # --------------------------------------------------
93
- # Calculations & Logic
94
  # --------------------------------------------------
95
  if submit:
96
- if not name.strip() or height <= 0 or weight <= 0:
97
- st.error("🚨 Please fill in all required fields accurately.")
98
  else:
99
- # BMI Logic
100
- h_m = height / 100
101
- bmi = round(weight / (h_m ** 2), 2)
102
 
103
  if bmi < 18.5:
104
  cat, color = "Underweight", "blue"
@@ -109,11 +137,14 @@ if submit:
109
  else:
110
  cat, color = "Obese", "red"
111
 
112
- # Result Display
113
- st.success(f"✅ Success! Data processed for {name}.")
 
114
 
115
- res1, res2 = st.columns(2)
116
- res1.metric("BMI Score", bmi)
117
- res2.markdown(f"### Status: :{color}[{cat}]")
 
 
118
 
119
- st.info(f"**Goal:** {goal} | **Level:** {level}")
 
1
  import streamlit as st
2
 
3
  # 1. Basic Configuration
4
+ st.set_page_config(page_title="FitPlan AI", page_icon="💪", layout="centered")
5
 
6
+ # 2. Enhanced CSS
 
7
  st.markdown("""
8
  <style>
9
  /* Full Page Background */
10
  [data-testid="stAppViewContainer"] {
11
+ background: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.75)),
12
  url("https://images.unsplash.com/photo-1517836357463-d25dfeac3438?q=80&w=2070&auto=format&fit=crop");
13
  background-size: cover;
14
  background-position: center;
15
  background-attachment: fixed;
16
  }
17
 
18
+ /* Hide the "Press Enter to submit form" hint globally */
19
+ [data-testid="InputInstructions"] {
20
+ display: none !important;
21
  }
22
 
23
+ /* Form Container Polish */
24
  div[data-testid="stForm"] {
25
+ background-color: rgba(255, 255, 255, 0.98) !important;
26
+ padding: 3rem !important;
27
+ border-radius: 20px !important;
28
+ border: none !important;
29
+ box-shadow: 0 15px 35px rgba(0,0,0,0.5);
30
  }
31
 
32
+ /* --- FONT SIZE UPDATES --- */
33
+ /* Main Title (FitPlan AI) */
34
+ .main-title {
35
  color: #FFFFFF !important;
36
+ font-size: 60px !important;
37
+ font-weight: 850 !important;
 
38
  text-align: center;
39
+ margin-bottom: 0px;
40
+ text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
41
+ font-family: 'Helvetica Neue', sans-serif;
42
  }
43
 
44
+ /* Subtitle (Your personalized gym companion) */
45
+ .sub-title {
46
+ color: #E0E0E0 !important;
47
+ font-size: 24px !important;
48
+ text-align: center;
49
+ margin-top: -10px;
50
+ margin-bottom: 40px;
51
+ font-style: italic;
52
+ text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
53
  }
54
 
55
+ /* Form Section Headers (Orange) */
56
  .form-header {
57
  color: #f97316 !important;
58
+ font-size: 22px !important;
59
+ font-weight: bold !important;
60
+ text-transform: uppercase;
61
+ letter-spacing: 1px;
62
  }
63
 
64
+ /* Labels for inputs */
65
+ label p {
66
+ font-size: 18px !important;
67
+ color: #1e293b !important;
68
+ font-weight: 600 !important;
69
+ }
70
+
71
+ /* Button Styling */
72
+ .stButton > button {
73
+ width: 100%;
74
+ background: linear-gradient(90deg, #f97316, #ea580c) !important;
75
+ color: white !important;
76
+ font-size: 20px !important;
77
+ font-weight: bold !important;
78
+ height: 3.5rem !important;
79
+ border-radius: 12px !important;
80
+ border: none !important;
81
+ margin-top: 20px;
82
  }
83
  </style>
84
  """, unsafe_allow_html=True)
85
 
86
  # --------------------------------------------------
87
+ # UI Header Section
88
  # --------------------------------------------------
89
+ st.markdown('<p class="main-title">💪 FitPlan AI</p>', unsafe_allow_html=True)
90
+ st.markdown('<p class="sub-title">Your personalized gym companion</p>', unsafe_allow_html=True)
91
 
92
+ # --------------------------------------------------
93
+ # Fitness Profile Form
94
+ # --------------------------------------------------
95
+ with st.form("fitness_form", clear_on_submit=False):
96
  st.markdown('<p class="form-header">🧍‍♂️ 1. PERSONAL INFORMATION</p>', unsafe_allow_html=True)
97
 
98
+ name = st.text_input("Full Name *", placeholder="Enter your full name")
99
 
100
  col1, col2 = st.columns(2)
101
  with col1:
102
+ height = st.number_input("Height (cm) *", min_value=0.0, step=1.0, value=0.0)
103
  with col2:
104
+ weight = st.number_input("Weight (kg) *", min_value=0.0, step=0.1, value=0.0)
105
 
106
+ st.markdown("<br>", unsafe_allow_html=True)
107
  st.markdown('<p class="form-header">🏋️ 2. FITNESS DETAILS</p>', unsafe_allow_html=True)
108
 
109
  goal = st.selectbox("Fitness Goal", ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"])
110
 
111
  equipment = st.multiselect("Available Equipment",
112
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "Kettlebell", "Pull-up Bar", "No Equipment"],
113
  default=["No Equipment"])
114
 
115
  level = st.radio("Fitness Level", ["Beginner", "Intermediate", "Advanced"], horizontal=True)
116
 
117
+ # Submission Button
118
  submit = st.form_submit_button("GENERATE MY PLAN")
119
 
120
  # --------------------------------------------------
121
+ # Logic & Calculation
122
  # --------------------------------------------------
123
  if submit:
124
+ if not name.strip() or height <= 50 or weight <= 10:
125
+ st.error("🚨 Please provide a valid name, height, and weight.")
126
  else:
127
+ # BMI Calculation
128
+ height_m = height / 100
129
+ bmi = round(weight / (height_m ** 2), 2)
130
 
131
  if bmi < 18.5:
132
  cat, color = "Underweight", "blue"
 
137
  else:
138
  cat, color = "Obese", "red"
139
 
140
+ # Results Display
141
+ st.balloons()
142
+ st.success(f"✅ Profile created for {name}")
143
 
144
+ c1, c2 = st.columns(2)
145
+ with c1:
146
+ st.metric("Calculated BMI", bmi)
147
+ with c2:
148
+ st.markdown(f"### Status: :{color}[{cat}]")
149
 
150
+ st.info(f"**Goal:** {goal} | **Experience:** {level}")