Spaces:
Sleeping
Sleeping
File size: 3,913 Bytes
510595a 4779692 46cf077 4779692 46cf077 4779692 46cf077 4779692 46cf077 3ecfa56 46cf077 3ecfa56 4779692 46cf077 4779692 3ecfa56 4779692 46cf077 4779692 510595a 4779692 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | import streamlit as st
# -----------------------------
# PAGE CONFIG
# -----------------------------
st.set_page_config(
page_title="Temperature Converter",
page_icon="🌡️",
layout="centered"
)
# -----------------------------
# NEON + ANIMATED UI (ONLY ADDITION)
# -----------------------------
st.markdown("""
<style>
/* ---------------- BACKGROUND ---------------- */
.stApp {
background: linear-gradient(-45deg, #0f172a, #1e293b, #0b1220, #1e3a8a);
background-size: 400% 400%;
animation: gradientMove 10s ease infinite;
color: white;
text-align: center; /* ✅ CENTER EVERYTHING */
}
@keyframes gradientMove {
0% {background-position: 0% 50%;}
50% {background-position: 100% 50%;}
100% {background-position: 0% 50%;}
}
/* ---------------- TITLE ---------------- */
h1 {
text-align: center;
color: white;
text-shadow:
0 0 10px #38bdf8,
0 0 20px #0ea5e9,
0 0 40px #3b82f6;
}
/* ---------------- INPUT BOXES ---------------- */
div[data-testid="stNumberInput"],
div[data-testid="stRadio"] {
background: rgba(255,255,255,0.06);
padding: 15px;
border-radius: 15px;
margin-bottom: 15px;
backdrop-filter: blur(10px);
box-shadow: 0 0 15px rgba(59,130,246,0.25);
}
/* ---------------- BUTTON ---------------- */
.stButton>button {
width: 100%;
background: linear-gradient(90deg, #06b6d4, #3b82f6);
color: white;
border-radius: 12px;
height: 3em;
font-size: 16px;
border: none;
box-shadow: 0 0 15px rgba(59,130,246,0.6);
transition: 0.3s;
}
.stButton>button:hover {
transform: scale(1.03);
box-shadow: 0 0 25px rgba(59,130,246,0.9);
}
/* ---------------- SUCCESS / OUTPUT BOX ---------------- */
div[data-testid="stSuccess"] {
background: rgba(0, 255, 120, 0.08); /* light green glow */
border: 2px solid white; /* white border */
border-radius: 15px;
padding: 20px;
color: #00ff99 !important; /* GREEN TEXT */
font-size: 20px;
font-weight: bold;
box-shadow: 0 0 20px rgba(255,255,255,0.6);
text-align: center;
}
/* Make success text green */
div[data-testid="stSuccess"] * {
color: #00ff99 !important;
}
</style>
""", unsafe_allow_html=True)
# -----------------------------
# YOUR ORIGINAL CODE (UNCHANGED)
# -----------------------------
# Title and Description
st.title("Temperature Conversion App")
st.markdown("Convert temperatures between Celsius, Fahrenheit, and Kelvin.")
# Input Temperature
temp_input = st.number_input("Enter the temperature to convert:", format="%.2f")
# Conversion Option
conversion_type = st.radio(
"Select conversion type:",
(
"Celsius to Fahrenheit",
"Fahrenheit to Celsius",
"Celsius to Kelvin",
"Kelvin to Celsius",
"Fahrenheit to Kelvin",
"Kelvin to Fahrenheit",
),
)
# Conversion Logic
if conversion_type == "Celsius to Fahrenheit":
converted_temp = (temp_input * 9/5) + 32
st.write(f"{temp_input:.2f}°C is equal to {converted_temp:.2f}°F.")
elif conversion_type == "Fahrenheit to Celsius":
converted_temp = (temp_input - 32) * 5/9
st.write(f"{temp_input:.2f}°F is equal to {converted_temp:.2f}°C.")
elif conversion_type == "Celsius to Kelvin":
converted_temp = temp_input + 273.15
st.write(f"{temp_input:.2f}°C is equal to {converted_temp:.2f} K.")
elif conversion_type == "Kelvin to Celsius":
converted_temp = temp_input - 273.15
st.write(f"{temp_input:.2f} K is equal to {converted_temp:.2f}°C.")
elif conversion_type == "Fahrenheit to Kelvin":
converted_temp = (temp_input - 32) * 5/9 + 273.15
st.write(f"{temp_input:.2f}°F is equal to {converted_temp:.2f} K.")
elif conversion_type == "Kelvin to Fahrenheit":
converted_temp = (temp_input - 273.15) * 9/5 + 32
st.write(f"{temp_input:.2f} K is equal to {converted_temp:.2f}°F.") |