Ifeanyi commited on
Commit
fa013f7
·
verified ·
1 Parent(s): 4f329a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +194 -74
app.py CHANGED
@@ -27,82 +27,202 @@ def arithmetic(num1, num2, operation):
27
  return res[0]
28
 
29
  custom_css = """
30
- /* Define color variables for light mode */
31
  :root {
32
- --background-color-light: #ffffff;
33
- --text-color-light: #000000;
34
- --input-background-light: #f0f0f0;
35
- --input-text-light: #000000;
36
- --button-background-light: #4CAF50;
37
- --button-text-light: #ffffff;
38
- }
39
-
40
- /* Define color variables for dark mode */
41
- @media (prefers-color-scheme: dark) {
42
- :root {
43
- --background-color-dark: #121212;
44
- --text-color-dark: #ffffff;
45
- --input-background-dark: #1e1e1e;
46
- --input-text-dark: #ffffff;
47
- --button-background-dark: #2a5298;
48
- --button-text-dark: #ffffff;
49
- }
50
- }
51
-
52
- /* Apply background and text colors based on the current mode */
53
  body {
54
- background-color: var(--background-color-light);
55
- color: var(--text-color-light);
56
- }
57
-
58
- @media (prefers-color-scheme: dark) {
59
- body {
60
- background-color: var(--background-color-dark);
61
- color: var(--text-color-dark);
62
- }
63
- }
64
-
65
- /* Style the input fields */
66
- input, textarea {
67
- background-color: var(--input-background-light);
68
- color: var(--input-text-light);
69
- border: 1px solid #ccc;
70
- padding: 10px;
71
- border-radius: 5px;
72
- width: 100%;
73
- box-sizing: border-box;
74
- }
75
-
76
- @media (prefers-color-scheme: dark) {
77
- input, textarea {
78
- background-color: var(--input-background-dark);
79
- color: var(--input-text-dark);
80
- border: 1px solid #444;
81
- }
82
- }
83
-
84
- /* Style the buttons */
85
- button {
86
- background-color: var(--button-background-light);
87
- color: var(--button-text-light);
88
- border: none;
89
- padding: 10px 20px;
90
- border-radius: 5px;
91
- cursor: pointer;
92
- transition: background-color 0.3s ease;
93
- }
94
-
95
- @media (prefers-color-scheme: dark) {
96
- button {
97
- background-color: var(--button-background-dark);
98
- color: var(--button-text-dark);
99
- }
100
- button:hover {
101
- background-color: #1e3c72;
102
- }
103
- }
104
- /* Hide footer display */
105
- footer {display: none !important;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  """
107
  with gr.Blocks(
108
  title="R-Powered Calculator",
 
27
  return res[0]
28
 
29
  custom_css = """
30
+ /* Define color variables for the dark theme */
31
  :root {
32
+ --background-color: #121212;
33
+ --surface-color: #1e1e1e;
34
+ --primary-color: #3a6ea5;
35
+ --accent-color: #6d9eeb;
36
+ --text-primary: #ffffff;
37
+ --text-secondary: #b0b0b0;
38
+ --border-color: #2c2c2c;
39
+ --input-background: #2a2a2a;
40
+ --button-gradient-start: #4568dc;
41
+ --button-gradient-end: #0f4c81;
42
+ --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
43
+ }
44
+
45
+ /* Global styles for the Gradio app */
 
 
 
 
 
 
 
46
  body {
47
+ background-color: var(--background-color) !important;
48
+ color: var(--text-primary) !important;
49
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
50
+ }
51
+
52
+ /* Override Gradio's container styles */
53
+ .gradio-container {
54
+ max-width: 800px !important;
55
+ margin: 0 auto !important;
56
+ background-color: var(--background-color) !important;
57
+ }
58
+
59
+ /* Header styling */
60
+ h1, h2, h3, h4, h5, h6 {
61
+ color: var(--text-primary) !important;
62
+ font-weight: 600 !important;
63
+ }
64
+
65
+ /* Make the main title stand out */
66
+ h1 strong {
67
+ background: linear-gradient(135deg, #4568dc, #6d9eeb);
68
+ -webkit-background-clip: text;
69
+ -webkit-text-fill-color: transparent;
70
+ background-clip: text;
71
+ }
72
+
73
+ /* Style the blocks and rows */
74
+ .block, .gr-box, .gr-form, .gr-panel {
75
+ background-color: var(--surface-color) !important;
76
+ border-radius: 8px !important;
77
+ border: 1px solid var(--border-color) !important;
78
+ box-shadow: var(--box-shadow) !important;
79
+ padding: 16px !important;
80
+ margin-bottom: 20px !important;
81
+ }
82
+
83
+ /* Style labels */
84
+ label, .gr-label {
85
+ color: var(--text-primary) !important;
86
+ font-weight: 500 !important;
87
+ margin-bottom: 8px !important;
88
+ }
89
+
90
+ /* Style number inputs */
91
+ input[type="number"], .gr-text-input, .gr-input {
92
+ background-color: var(--input-background) !important;
93
+ color: var(--text-primary) !important;
94
+ border: 1px solid var(--border-color) !important;
95
+ border-radius: 6px !important;
96
+ padding: 12px 16px !important;
97
+ font-size: 16px !important;
98
+ transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
99
+ }
100
+
101
+ input[type="number"]:focus, .gr-text-input:focus, .gr-input:focus {
102
+ border-color: var(--accent-color) !important;
103
+ box-shadow: 0 0 0 2px rgba(109, 158, 235, 0.2) !important;
104
+ outline: none !important;
105
+ }
106
+
107
+ /* Style radio buttons */
108
+ .gr-radio-group label {
109
+ color: var(--text-secondary) !important;
110
+ }
111
+
112
+ .gr-radio {
113
+ accent-color: var(--accent-color) !important;
114
+ }
115
+
116
+ .gr-checkbox-label, .gr-radio-label {
117
+ color: var(--text-secondary) !important;
118
+ }
119
+
120
+ /* Override radio button containers */
121
+ .gr-radio-group, .gr-form {
122
+ background-color: var(--surface-color) !important;
123
+ padding: 12px !important;
124
+ border-radius: 8px !important;
125
+ border: 1px solid var(--border-color) !important;
126
+ }
127
+
128
+ /* Style button with gradient */
129
+ button, .gr-button {
130
+ background: linear-gradient(135deg, var(--button-gradient-start), var(--button-gradient-end)) !important;
131
+ color: white !important;
132
+ border: none !important;
133
+ padding: 12px 24px !important;
134
+ border-radius: 6px !important;
135
+ cursor: pointer !important;
136
+ font-weight: 600 !important;
137
+ letter-spacing: 0.5px !important;
138
+ transition: all 0.3s ease !important;
139
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2) !important;
140
+ text-transform: uppercase !important;
141
+ font-size: 14px !important;
142
+ width: auto !important;
143
+ display: inline-block !important;
144
+ }
145
+
146
+ button:hover, .gr-button:hover {
147
+ background: linear-gradient(135deg, #5273e3, #1a5fa0) !important;
148
+ box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3) !important;
149
+ transform: translateY(-1px) !important;
150
+ }
151
+
152
+ button:active, .gr-button:active {
153
+ transform: translateY(1px) !important;
154
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
155
+ }
156
+
157
+ /* Result section styling */
158
+ .gr-output-box {
159
+ background-color: var(--surface-color) !important;
160
+ border: 1px solid var(--border-color) !important;
161
+ border-radius: 8px !important;
162
+ padding: 16px !important;
163
+ }
164
+
165
+ /* Result number styling */
166
+ .gr-number-output {
167
+ font-size: 24px !important;
168
+ font-weight: 700 !important;
169
+ color: var(--accent-color) !important;
170
+ text-align: center !important;
171
+ }
172
+
173
+ /* For the result header */
174
+ h3 strong {
175
+ color: var(--accent-color) !important;
176
+ }
177
+
178
+ /* Add a subtle border to all rows */
179
+ .gr-row {
180
+ margin-bottom: 20px !important;
181
+ }
182
+
183
+ /* Remove footer */
184
+ footer {
185
+ display: none !important;
186
+ }
187
+
188
+ /* Fix any dark text on dark background issues */
189
+ .dark {
190
+ color: var(--text-primary) !important;
191
+ }
192
+
193
+ /* Additional spacing for the operation radio buttons */
194
+ #operation {
195
+ margin-top: 10px !important;
196
+ margin-bottom: 20px !important;
197
+ }
198
+
199
+ /* Add a subtle gradient background to the app container */
200
+ .gradio-app {
201
+ background: linear-gradient(160deg, #121212 0%, #1a1f2c 100%) !important;
202
+ min-height: 100vh !important;
203
+ }
204
+
205
+ /* Ensure number inputs don't have spinner arrows in Firefox */
206
+ input[type=number] {
207
+ -moz-appearance: textfield !important;
208
+ }
209
+
210
+ /* Remove spinner arrows from number inputs in other browsers */
211
+ input::-webkit-outer-spin-button,
212
+ input::-webkit-inner-spin-button {
213
+ -webkit-appearance: none !important;
214
+ margin: 0 !important;
215
+ }
216
+
217
+ /* Make the result stand out more */
218
+ #result {
219
+ font-size: 28px !important;
220
+ padding: 16px !important;
221
+ text-align: center !important;
222
+ background-color: rgba(58, 110, 165, 0.1) !important;
223
+ border-radius: 8px !important;
224
+ margin-top: 10px !important;
225
+ }
226
  """
227
  with gr.Blocks(
228
  title="R-Powered Calculator",