File size: 2,729 Bytes
4b21bf5
96f69e3
4b21bf5
0917013
 
 
 
4b21bf5
b1d3b94
0917013
 
 
b1d3b94
0917013
b1d3b94
 
0917013
b1d3b94
 
 
 
 
0917013
 
 
 
b1d3b94
0917013
 
 
 
b1d3b94
 
 
0917013
 
 
 
 
 
b1d3b94
 
0917013
b1d3b94
0917013
 
b1d3b94
 
0917013
 
 
b1d3b94
0917013
 
 
 
 
4b21bf5
96f69e3
 
 
 
 
 
 
 
 
 
 
 
 
0917013
 
 
bf53cb5
b1d3b94
0917013
 
4b21bf5
 
 
 
 
 
 
0917013
4b21bf5
0917013
4b21bf5
 
 
0917013
4b21bf5
0917013
4b21bf5
 
 
0917013
96f69e3
 
0917013
 
 
 
4b21bf5
0917013
96f69e3
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
import streamlit as st
import re

st.set_page_config(
    page_title="Text Case Converter",
    layout="centered",
)

# ---------- Cool Tech Theme ----------
st.markdown("""
<style>
body {
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
}
.main { background: transparent; }

.card {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    border-radius: 22px;
    padding: 28px;
    box-shadow: 0 0 25px rgba(0,255,255,0.25);
    max-width: 720px;
    margin: auto;
}
h1, p, label, h3 {
    color: #e5f9ff !important;
    text-align: center;
}
textarea {
    border-radius: 14px !important;
    background: #020617 !important;
    color: #e5f9ff !important;
    border: 1px solid #0ea5e9 !important;
}
.stButton>button {
    width: 100%;
    height: 45px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(90deg, #0ea5e9, #22d3ee);
    color: #020617;
    font-weight: bold;
    transition: 0.25s ease;
}
.stButton>button:hover {
    transform: scale(1.06);
    box-shadow: 0 0 15px #22d3ee;
}
.footer {
    text-align: center;
    color: #94a3b8;
    margin-top: 15px;
    font-size: 13px;
}
</style>
""", unsafe_allow_html=True)

# ---------- Helper Function ----------
def paragraph_style(text):
    sentences = re.split(r'(?<=[.!?])\s*', text.strip())
    fixed = []
    for s in sentences:
        s = s.strip()
        if not s:
            continue
        if not s.endswith(('.', '!', '?')):
            s += '.'
        fixed.append(s.capitalize())
    return " ".join(fixed)

# ---------- UI ----------
st.markdown("<div class='card'>", unsafe_allow_html=True)

st.markdown("<h1>Text Case Converter</h1>", unsafe_allow_html=True)
st.markdown("<p>Change your text instantly</p>", unsafe_allow_html=True)

text = st.text_area("", placeholder="Type or paste your text here...", height=180)

st.markdown("### Choose Conversion")

col1, col2, col3 = st.columns(3)

with col1:
    if st.button("UPPERCASE"):
        st.session_state["out"] = text.upper()
    if st.button("lowercase"):
        st.session_state["out"] = text.lower()

with col2:
    if st.button("Title Case"):
        st.session_state["out"] = text.title()
    if st.button("Sentence Case"):
        st.session_state["out"] = text.capitalize()

with col3:
    if st.button("Toggle Case"):
        st.session_state["out"] = text.swapcase()
    if st.button("Paragraph Style"):
        st.session_state["out"] = paragraph_style(text)

if "out" in st.session_state:
    st.markdown("### Output")
    st.text_area("", st.session_state["out"], height=150)

st.markdown("</div>", unsafe_allow_html=True)
st.markdown("<div class='footer'>Made with ❤️ using Streamlit</div>", unsafe_allow_html=True)