devjas1 commited on
Commit
9f156ed
·
1 Parent(s): 5076875

(FEAT): Revamp custom CSS for improved accessibility and aesthetics in Streamlit app

Browse files
Files changed (1) hide show
  1. app.py +56 -114
app.py CHANGED
@@ -50,164 +50,106 @@ st.set_page_config(
50
  # ==Custom CSS Page + Element Styling==
51
  st.markdown("""
52
  <style>
53
- /* Modern, slightly darker custom CSS for Streamlit app */
54
- /* Optimized for accessibility, consistency, and tech-forward aesthetics */
55
-
56
- /* Scoped global styles */
57
- :where(html, body, .stApp) {
58
- background-color: #111827; /* Tailwind gray-900, dark and sleek */
59
- color: #fff; /* Tailwind slate-100, high contrast */
60
- font-family: 'roboto', 'ui-monospace', 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
61
- font-size: 16px; /* Base font size for accessibility */
62
- line-height: 1.4;
63
  }
64
 
65
- /* Tabs content area */
 
 
66
  div[data-testid="stTabs"] > div[role="tablist"] + div {
67
  min-height: 400px;
68
- background: #1f2937; /* Tailwind gray-800, slightly lighter for depth */
69
- border-radius: 8px;
70
  padding: 20px;
 
71
  }
72
 
73
- /* Confidence box */
74
  .confbox {
75
  font-size: 0.9rem;
76
  padding: 10px 12px;
77
- border: 1px solid #374151; /* Tailwind gray-700 */
78
- border-radius: 6px;
79
- background: #1e293b; /* Tailwind slate-800 */
80
- color: #d1d5db; /* Tailwind gray-300 */
81
  }
82
 
83
- /* Key-value rows */
84
  .kv-row {
85
  display: flex;
86
  justify-content: space-between;
87
  gap: 16px;
88
  padding: 4px 0;
89
- border-bottom: 1px solid #374151; /* Tailwind gray-700 */
90
- }
91
- .kv-key {
92
- opacity: 0.8;
93
- font-size: 0.9rem;
94
- white-space: nowrap;
95
- }
96
- .kv-val {
97
- font-family: 'Fira Code', monospace;
98
- font-size: 0.9rem;
99
- color: #e5e7eb; /* Tailwind gray-200 */
100
- overflow-wrap: break-word;
101
- }
102
-
103
- /* Markdown headings */
104
- :where(h5, .stMarkdown h5) {
105
- margin-top: 0.5rem;
106
- color: #f1f5f9; /* Tailwind slate-100 */
107
- font-weight: 500;
108
  }
 
 
109
 
110
- /* Expander styles */
111
- div.stExpander > details > summary {
112
- display: flex;
113
- align-items: center;
114
- justify-content: space-between;
115
- cursor: pointer;
116
- border: 1px solid #374151; /* Tailwind gray-700 */
117
- border-radius: 6px;
118
- padding: 6px 10px;
119
- margin: 0;
120
- background: #1e293b; /* Tailwind slate-800 */
121
- font-weight: 600;
122
- font-size: 0.95rem;
123
- color: #d1d5db; /* Tailwind gray-300 */
124
- }
125
-
126
- /* Remove default disclosure markers */
127
  div.stExpander > details > summary::-webkit-details-marker,
128
- div.stExpander > details > summary::marker {
129
- display: none;
130
- }
131
-
132
- /* Hide Streamlit's custom arrow icon */
133
- div[data-testid="stExpander"] summary svg {
134
- display: none !important;
135
- }
136
 
137
- /* Expander hover state */
138
- div.stExpander > details[open] > summary {
139
- background: #374151; /* Tailwind gray-700 */
140
- }
141
 
142
- /* Expander badge */
143
  div.stExpander > details > summary::after {
144
- content: " ↓ ";
145
  font-size: 1.2rem;
146
- font-weight: 1000;
147
- letter-spacing: 0.5 ;
148
  padding: 3px 10px;
149
- border: 1px solid #4b5563;
150
  border-radius: 999px;
151
- background: #374151; /* Tailwind gray-600 */
152
- color: #e5e7eb; /* Tailwind gray-200 */
 
153
  }
154
 
155
- /* Success/results expander */
156
- .expander-marker + div[data-testid="stExpander"] summary {
157
- border-left-color: #059669; /* Tailwind emerald-600 */
158
- background: #1e293b; /* Tailwind slate-800 */
159
- }
160
  .expander-marker + div[data-testid="stExpander"] summary::after {
161
  content: "RESULTS";
162
- background: #047857; /* Tailwind emerald-700 */
163
- color: #d1fae5; /* Tailwind emerald-100 */
164
- }
165
-
166
- [data-testid="stExpanderDetails"] {
167
- padding-top: 10px;
168
- }
169
-
170
- /* Technical expander */
171
- div.stExpander:has(summary:contains("Technical")) > details > summary {
172
- border-left-color: #ea580c; /* Tailwind orange-600 */
173
- background: #1e293b; /* Tailwind slate-800 */
174
  }
175
  div.stExpander:has(summary:contains("Technical")) > details > summary::after {
176
  content: "ADVANCED";
177
- background: #c2410c; /* Tailwind orange-700 */
178
- color: #ffedd5; /* Tailwind orange-100 */
179
  }
180
-
181
- /* Sidebar metrics */
182
- div[data-testid="stMetricValue"] {
183
- font-size: 0.95rem !important;
184
- color: #f1f5f9; /* Tailwind slate-100 */
185
- }
186
- div[data-testid="stMetricLabel"] {
187
- font-size: 0.85rem !important;
188
- opacity: 0.8;
189
- color: #d1d5db; /* Tailwind gray-300 */
190
  }
191
 
192
- /* Sidebar text */
193
- section[data-testid="stSidebar"]{
194
  font-size: 0.95rem !important;
195
  line-height: 1.25;
196
- color: #fff; /* Tailwind gray-200 */
197
  }
198
 
199
- /* Diagnostics metrics */
200
- div[data-testid="stMetricValue"] {
201
- font-size: 0.95rem !important;
202
- color: #f1f5f9; /* Tailwind slate-100 */
 
 
 
 
203
  }
204
- div[data-testid="stMetricLabel"] {
205
- font-size: 0.85rem !important;
206
- color: #d1d5db; /* Tailwind gray-300 */
 
207
  }
208
  </style>
209
- """, unsafe_allow_html=True)
210
 
 
211
 
212
  # ==CONSTANTS==
213
  TARGET_LEN = 500
 
50
  # ==Custom CSS Page + Element Styling==
51
  st.markdown("""
52
  <style>
53
+ /* ====== Base Styles ====== */
54
+ .confbox,
55
+ .kv-key,
56
+ .kv-val,
57
+ div[data-testid="stMetricValue"],
58
+ div[data-testid="stMetricLabel"],
59
+ section[data-testid="stSidebar"] {
60
+ font-family: 'Inter', sans-serif;
61
+ color: #e2e8f0; /* slate-200 */
 
62
  }
63
 
64
+ .kv-val { font-family: 'Fira Code', monospace; }
65
+
66
+ /* ====== Tabs Content ====== */
67
  div[data-testid="stTabs"] > div[role="tablist"] + div {
68
  min-height: 400px;
69
+ background: #1e293b; /* slate-800 */
70
+ border-radius: 10px;
71
  padding: 20px;
72
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
73
  }
74
 
75
+ /* ====== Confidence Box ====== */
76
  .confbox {
77
  font-size: 0.9rem;
78
  padding: 10px 12px;
79
+ border: 1px solid #2d3748; /* slate-700 */
80
+ border-radius: 10px;
81
+ background: #1e293b; /* slate-800 */
 
82
  }
83
 
84
+ /* ====== Key-Value Rows ====== */
85
  .kv-row {
86
  display: flex;
87
  justify-content: space-between;
88
  gap: 16px;
89
  padding: 4px 0;
90
+ border-bottom: 1px solid #2d3748; /* slate-700 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
+ .kv-key { opacity: 0.8; font-size: 0.9rem; white-space: nowrap; }
93
+ .kv-val { font-size: 0.9rem; overflow-wrap: break-word; }
94
 
95
+ /* ====== Expanders ====== */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  div.stExpander > details > summary::-webkit-details-marker,
97
+ div.stExpander > details > summary::marker,
98
+ div[data-testid="stExpander"] summary svg { display: none !important; }
 
 
 
 
 
 
99
 
100
+ div.stExpander > details[open] > summary { background: #2d3748; /* slate-700 */ }
 
 
 
101
 
 
102
  div.stExpander > details > summary::after {
 
103
  font-size: 1.2rem;
104
+ font-weight: 700;
105
+ letter-spacing: 0.5px;
106
  padding: 3px 10px;
 
107
  border-radius: 999px;
108
+ border: 1px solid #0ea5e9; /* sky-500 */
109
+ background: #2d3748;
110
+ color: #e2e8f0;
111
  }
112
 
113
+ /* Specialized Expanders */
 
 
 
 
114
  .expander-marker + div[data-testid="stExpander"] summary::after {
115
  content: "RESULTS";
116
+ background: #2dd4bf; /* teal-400 */
117
+ color: #0f172a; /* slate-900 */
 
 
 
 
 
 
 
 
 
 
118
  }
119
  div.stExpander:has(summary:contains("Technical")) > details > summary::after {
120
  content: "ADVANCED";
121
+ background: #ea580c; /* orange-600 */
122
+ border-color: #f97316; /* orange-500 */
123
  }
124
+ [data-testid="stExpanderDetails"] {
125
+ padding-top: 10px;
126
+ background: #0f172a; /* slate-900 */
 
 
 
 
 
 
 
127
  }
128
 
129
+ /* ====== Sidebar ====== */
130
+ section[data-testid="stSidebar"] {
131
  font-size: 0.95rem !important;
132
  line-height: 1.25;
133
+ background: #1e293b; /* slate-800 */
134
  }
135
 
136
+ /* Metric labels/values */
137
+ div[data-testid="stMetricValue"] { font-size: 0.95rem !important; }
138
+ div[data-testid="stMetricLabel"] { font-size: 0.85rem !important; opacity: 0.8; }
139
+
140
+ /* ====== Interactivity ====== */
141
+ button:hover, a:hover, [role="button"]:hover {
142
+ background: #2dd4bf; /* teal-400 */
143
+ color: #0f172a; /* slate-900 */
144
  }
145
+ :focus {
146
+ outline: 2px solid #67e8f9; /* cyan-300 */
147
+ outline-offset: 2px;
148
+ border-radius: 8px;
149
  }
150
  </style>
 
151
 
152
+ """, unsafe_allow_html=True)
153
 
154
  # ==CONSTANTS==
155
  TARGET_LEN = 500