shaheerawan3 commited on
Commit
ca682bd
ยท
verified ยท
1 Parent(s): 40d45d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -28
app.py CHANGED
@@ -1,70 +1,89 @@
1
  import streamlit as st
2
  import datetime
3
 
4
- # Simple styling without complex animation
5
  st.markdown("""
6
  <style>
7
  body {
8
- margin: 0;
9
- padding: 0;
10
- background-color: #f0f0f0;
11
  font-family: 'Arial', sans-serif;
12
- height: 100vh;
13
  display: flex;
14
  justify-content: center;
15
  align-items: center;
 
 
16
  }
17
 
18
  .card {
19
- background-color: white;
20
- border-radius: 10px;
21
- padding: 30px;
22
- width: 350px;
23
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
 
24
  text-align: center;
25
- transition: all 0.3s ease;
26
  }
27
 
28
- .card:hover {
29
- transform: scale(1.05);
30
- box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
 
 
 
 
 
 
31
  }
32
 
33
- button {
34
  background-color: #2575fc;
35
  color: white;
36
  border: none;
37
- padding: 10px 20px;
38
- border-radius: 5px;
39
- font-size: 16px;
40
  cursor: pointer;
41
- margin-top: 20px;
42
  }
43
 
44
- button:hover {
45
  background-color: #6a11cb;
46
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </style>
48
  """, unsafe_allow_html=True)
49
 
50
  def main():
 
51
  st.title("Age Calculation App")
 
52
 
53
- # Create input fields for DOB and current date
54
- dob = st.date_input("Date of Birth", min_value=datetime.date(1900, 1, 1), max_value=datetime.date.today())
55
- current_date = st.date_input("Current Date")
56
 
57
- # Simple card UI
58
  with st.container():
59
  st.markdown("""
60
  <div class="card">
61
- <h3>Age Calculation</h3>
62
- <p>Enter your Date of Birth and today's date to calculate your age.</p>
63
  </div>
64
  """, unsafe_allow_html=True)
65
 
66
- # Generate age details on button click
67
- if st.button("Calculate Age"):
68
  # Calculate years
69
  years = current_date.year - dob.year
70
  if (current_date.month, current_date.day) < (dob.month, dob.day):
@@ -86,7 +105,7 @@ def main():
86
  last_day_of_prev_month = (current_date.replace(day=1) - datetime.timedelta(days=1)).day
87
  days = last_day_of_prev_month - dob.day + current_date.day
88
 
89
- # Display age results
90
  st.write(f"Your date of birth is {dob.strftime('%Y-%m-%d')} and today's date is {current_date.strftime('%Y-%m-%d')}.")
91
  st.write(f"Your age is {years} years, {months} months, and {days} days.")
92
 
 
1
  import streamlit as st
2
  import datetime
3
 
4
+ # Custom Styling
5
  st.markdown("""
6
  <style>
7
  body {
8
+ background-color: #f1f5f8;
 
 
9
  font-family: 'Arial', sans-serif;
 
10
  display: flex;
11
  justify-content: center;
12
  align-items: center;
13
+ height: 100vh;
14
+ margin: 0;
15
  }
16
 
17
  .card {
18
+ background-color: #ffffff;
19
+ border-radius: 15px;
20
+ padding: 40px;
 
21
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
22
+ width: 400px;
23
  text-align: center;
 
24
  }
25
 
26
+ .card h3 {
27
+ font-size: 24px;
28
+ color: #2575fc;
29
+ margin-bottom: 20px;
30
+ }
31
+
32
+ .card p {
33
+ font-size: 16px;
34
+ color: #333;
35
  }
36
 
37
+ .card button {
38
  background-color: #2575fc;
39
  color: white;
40
  border: none;
41
+ padding: 15px 30px;
42
+ border-radius: 8px;
43
+ font-size: 18px;
44
  cursor: pointer;
45
+ transition: background-color 0.3s;
46
  }
47
 
48
+ .card button:hover {
49
  background-color: #6a11cb;
50
  }
51
+
52
+ .stButton>button {
53
+ font-size: 18px;
54
+ }
55
+
56
+ .stDateInput>div {
57
+ margin-bottom: 20px;
58
+ }
59
+
60
+ .stTextInput>div {
61
+ margin-bottom: 20px;
62
+ }
63
+
64
  </style>
65
  """, unsafe_allow_html=True)
66
 
67
  def main():
68
+ # Title and App Description
69
  st.title("Age Calculation App")
70
+ st.markdown("<h2 style='color:#2575fc;'>Calculate Your Age</h2>", unsafe_allow_html=True)
71
 
72
+ # Create input fields with icons
73
+ dob = st.date_input("๐Ÿ“… Select Date of Birth", min_value=datetime.date(1900, 1, 1), max_value=datetime.date.today())
74
+ current_date = st.date_input("๐Ÿ“† Select Current Date", max_value=datetime.date.today())
75
 
76
+ # Simple Card UI
77
  with st.container():
78
  st.markdown("""
79
  <div class="card">
80
+ <h3>Age Calculator</h3>
81
+ <p>Enter your Date of Birth and the current date to calculate your age in years, months, and days.</p>
82
  </div>
83
  """, unsafe_allow_html=True)
84
 
85
+ # Calculate and display age on button click
86
+ if st.button("๐Ÿ” Calculate Age"):
87
  # Calculate years
88
  years = current_date.year - dob.year
89
  if (current_date.month, current_date.day) < (dob.month, dob.day):
 
105
  last_day_of_prev_month = (current_date.replace(day=1) - datetime.timedelta(days=1)).day
106
  days = last_day_of_prev_month - dob.day + current_date.day
107
 
108
+ # Display age details
109
  st.write(f"Your date of birth is {dob.strftime('%Y-%m-%d')} and today's date is {current_date.strftime('%Y-%m-%d')}.")
110
  st.write(f"Your age is {years} years, {months} months, and {days} days.")
111