hajar-bettiche-07 commited on
Commit
420be92
·
1 Parent(s): 0551b23

another version of UI

Browse files
Files changed (1) hide show
  1. app.py +87 -154
app.py CHANGED
@@ -36,7 +36,7 @@ with gr.Blocks(
36
  padding: 0 !important;
37
  margin: 0 !important;
38
  background: white !important;
39
- font-family: 'Segoe UI', system-ui, sans-serif !important;
40
  }
41
 
42
  /* Supprimer TOUS les gaps et marges */
@@ -53,297 +53,233 @@ with gr.Blocks(
53
  padding-bottom: 0 !important;
54
  }
55
 
56
- /* Header Section - Style image */
57
  .header-section {
58
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
59
- padding: 80px 0 60px 0 !important;
60
  margin: 0 !important;
61
  text-align: center;
62
  }
63
 
64
  .header-content {
65
- max-width: 800px;
66
  margin: 0 auto;
67
  padding: 0 20px;
68
  }
69
 
70
  .header-text h1 {
71
  color: white;
72
- font-size: 3.5rem;
73
  font-weight: 700;
74
- margin: 0 0 16px 0;
75
  letter-spacing: -0.5px;
76
  line-height: 1.1;
77
  }
78
 
79
  .header-text p {
80
  color: rgba(255, 255, 255, 0.9);
81
- font-size: 1.4rem;
82
  margin: 0;
83
  font-weight: 400;
84
  line-height: 1.4;
85
  }
86
 
87
- /* Features Section - Style image */
88
  .features-section {
89
  background: white;
90
- padding: 60px 0 !important;
91
  margin: 0 !important;
92
  }
93
 
94
  .features-grid {
95
  display: grid;
96
- grid-template-columns: repeat(2, 1fr);
97
- gap: 30px;
98
- max-width: 1000px;
99
  margin: 0 auto;
100
  padding: 0 20px;
101
  }
102
 
103
  .feature-item {
104
  text-align: center;
105
- padding: 0 20px;
106
  }
107
 
108
  .feature-item h3 {
109
- font-size: 1.5rem;
110
  font-weight: 600;
111
  color: #2d3748;
112
- margin: 0 0 12px 0;
113
  line-height: 1.3;
114
  }
115
 
116
  .feature-item p {
117
- font-size: 1.1rem;
118
  color: #718096;
119
- line-height: 1.5;
120
  margin: 0;
121
  }
122
 
123
- /* Divider Line */
124
- .divider {
125
- height: 1px;
126
- background: linear-gradient(90deg, transparent 0%, #e2e8f0 50%, transparent 100%);
127
- margin: 40px auto;
128
- max-width: 1000px;
129
- }
130
-
131
- /* Search Section - Style image */
132
  .search-section {
133
  background: white;
134
- padding: 40px 0 80px 0 !important;
135
  margin: 0 !important;
136
  text-align: center;
137
  }
138
 
139
  .search-content {
140
- max-width: 800px;
141
  margin: 0 auto;
142
  padding: 0 20px;
143
  }
144
 
145
  .search-title {
146
- margin-bottom: 30px;
147
  }
148
 
149
  .search-title h2 {
150
- font-size: 2.2rem;
151
  font-weight: 600;
152
  color: #2d3748;
153
- margin: 0 0 16px 0;
154
  line-height: 1.2;
155
  }
156
 
157
  .search-subtitle {
158
- font-size: 1.2rem;
159
  color: #718096;
160
- line-height: 1.5;
161
  margin: 0;
162
  }
163
 
164
- /* Search Input - Style image */
165
  .search-inputs {
166
- max-width: 600px;
167
  margin: 0 auto !important;
168
  padding: 0 20px !important;
169
  }
170
 
171
  .search-box-container {
172
  display: flex;
173
- gap: 12px;
174
- margin-bottom: 20px;
175
  align-items: center;
176
  }
177
 
178
  .search-box-container input {
179
  flex: 1;
180
- padding: 16px 20px !important;
181
- border: 2px solid #e2e8f0 !important;
182
- border-radius: 12px !important;
183
- font-size: 1rem !important;
184
  background: white !important;
185
  color: #2d3748 !important;
186
- transition: all 0.3s ease !important;
187
  }
188
 
189
  .search-box-container input:focus {
190
  border-color: #667eea !important;
191
  outline: none !important;
192
- box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
193
  }
194
 
195
  .search-box-container input::placeholder {
196
- color: #a0aec0 !important;
197
  }
198
 
199
  .search-button {
200
- padding: 16px 32px !important;
201
  background: #667eea !important;
202
  color: white !important;
203
  border: none !important;
204
- border-radius: 12px !important;
205
- font-size: 1rem !important;
206
- font-weight: 600 !important;
207
  cursor: pointer !important;
208
- transition: all 0.3s ease !important;
209
- min-width: 120px !important;
210
  }
211
 
212
  .search-button:hover {
213
  background: #5a6fd8 !important;
214
- transform: translateY(-1px);
215
  }
216
 
217
  .status-message {
218
- max-width: 600px;
219
  margin: 0 auto !important;
220
  text-align: center;
 
221
  }
222
 
223
- /* Chat Section - Style image */
224
  .chat-section-wrapper {
225
- background: #f7fafc;
226
- padding: 60px 0 80px 0 !important;
227
  margin: 0 !important;
228
- border-top: 1px solid #e2e8f0;
229
  }
230
 
231
  .chat-section {
232
- max-width: 800px !important;
233
  margin: 0 auto !important;
234
  padding: 0 20px !important;
235
  }
236
 
237
  .chat-header {
238
  text-align: center;
239
- margin-bottom: 40px;
240
  }
241
 
242
  .chat-header h3 {
243
- font-size: 1.8rem;
244
- font-weight: 600;
245
- color: #2d3748;
246
- margin: 0 0 12px 0;
247
- }
248
-
249
- .chat-header p {
250
- font-size: 1.1rem;
251
- color: #718096;
252
- margin: 0;
253
  }
254
 
255
- /* Chat Interface Styling */
256
  .chat-interface {
257
  background: white;
258
- border: 1px solid #e2e8f0;
259
- border-radius: 16px;
260
  overflow: hidden;
261
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
262
  }
263
 
264
  /* Chatbot Styling */
265
  .gradio-chatbot {
266
  border: none !important;
267
  background: white !important;
268
- min-height: 400px !important;
269
- max-height: 500px !important;
270
- }
271
-
272
- .gradio-chatbot .message {
273
- border: none !important;
274
- padding: 16px 20px !important;
275
- margin: 8px 16px !important;
276
- border-radius: 12px !important;
277
- }
278
-
279
- .gradio-chatbot .user-message {
280
- background: #667eea !important;
281
- color: white !important;
282
- margin-left: 60px !important;
283
  }
284
 
285
- .gradio-chatbot .bot-message {
286
- background: #f7fafc !important;
287
- color: #2d3748 !important;
288
- margin-right: 60px !important;
289
- border: 1px solid #e2e8f0 !important;
290
- }
291
-
292
- /* Textbox Styling */
293
  .gradio-textbox {
294
- border: 1px solid #e2e8f0 !important;
295
- border-radius: 12px !important;
296
- padding: 16px 20px !important;
297
- font-size: 1rem !important;
298
  background: white !important;
299
  }
300
 
301
- .gradio-textbox:focus {
302
- border-color: #667eea !important;
303
- box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
304
- }
305
-
306
  /* Button Styling */
307
  .gradio-button {
308
  background: #667eea !important;
309
  color: white !important;
310
  border: none !important;
311
- border-radius: 12px !important;
312
- padding: 12px 24px !important;
313
- font-weight: 600 !important;
 
314
  }
315
 
316
  .gradio-button:hover {
317
  background: #5a6fd8 !important;
318
  }
319
 
320
- /* Hide elements until book is selected */
321
- .hidden-section {
322
- display: none !important;
323
- }
324
-
325
- /* Responsive Design */
326
- @media (max-width: 768px) {
327
- .header-text h1 {
328
- font-size: 2.5rem;
329
- }
330
-
331
- .header-text p {
332
- font-size: 1.2rem;
333
- }
334
-
335
- .features-grid {
336
- grid-template-columns: 1fr;
337
- gap: 40px;
338
- }
339
-
340
- .search-box-container {
341
- flex-direction: column;
342
- }
343
-
344
- .search-button {
345
- width: 100%;
346
- }
347
  }
348
 
349
  /* Force remove all gaps */
@@ -351,10 +287,15 @@ with gr.Blocks(
351
  margin: 0 !important;
352
  padding: 0 !important;
353
  }
 
 
 
 
 
354
  """
355
  ) as demo:
356
 
357
- # Header Section
358
  gr.HTML("""
359
  <div class="header-section">
360
  <div class="header-content">
@@ -366,7 +307,7 @@ with gr.Blocks(
366
  </div>
367
  """)
368
 
369
- # Features Section
370
  gr.HTML("""
371
  <div class="features-section">
372
  <div class="features-grid">
@@ -378,20 +319,11 @@ with gr.Blocks(
378
  <h3>Instant Answers</h3>
379
  <p>Get immediate AI-powered responses about any book</p>
380
  </div>
381
- <div class="feature-item">
382
- <h3>Save Time</h3>
383
- <p>No need to re-read - get quick summaries and insights</p>
384
- </div>
385
- <div class="feature-item">
386
- <h3>Learn More</h3>
387
- <p>Discover hidden meanings and literary analysis</p>
388
- </div>
389
  </div>
390
- <div class="divider"></div>
391
  </div>
392
  """)
393
 
394
- # Search Section
395
  gr.HTML("""
396
  <div class="search-section">
397
  <div class="search-content">
@@ -407,16 +339,16 @@ with gr.Blocks(
407
  with gr.Group(elem_classes="search-inputs"):
408
  with gr.Row(elem_classes="search-box-container"):
409
  book_box = gr.Textbox(
410
- placeholder="Enter book title (e.g., The Great Gatsby)...",
411
  show_label=False,
412
  container=False,
413
- scale=6
414
  )
415
- search_btn = gr.Button("Search", elem_classes="search-button", scale=2)
416
 
417
  status_text = gr.HTML("", visible=False)
418
 
419
- # Chat Section (hidden initially)
420
  with gr.Group(visible=False) as chat_section:
421
  gr.HTML("""
422
  <div class="chat-section-wrapper">
@@ -426,20 +358,21 @@ with gr.Blocks(
426
  </div>
427
  """)
428
 
429
- # Chat Interface with custom styling
430
  chat = gr.ChatInterface(
431
  fn=echo,
432
  type="messages",
433
  chatbot=gr.Chatbot(
434
- height=400,
435
  type="messages",
436
  show_label=False,
437
- container=False
 
438
  ),
439
  textbox=gr.Textbox(
440
  placeholder="Type your question here...",
441
  container=False,
442
- scale=7
443
  ),
444
  submit_btn="Send",
445
  title=""
 
36
  padding: 0 !important;
37
  margin: 0 !important;
38
  background: white !important;
39
+ font-family: system-ui, -apple-system, sans-serif !important;
40
  }
41
 
42
  /* Supprimer TOUS les gaps et marges */
 
53
  padding-bottom: 0 !important;
54
  }
55
 
56
+ /* Header Section - EXACTEMENT COMME L'IMAGE */
57
  .header-section {
58
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
59
+ padding: 60px 0 40px 0 !important;
60
  margin: 0 !important;
61
  text-align: center;
62
  }
63
 
64
  .header-content {
65
+ max-width: 600px;
66
  margin: 0 auto;
67
  padding: 0 20px;
68
  }
69
 
70
  .header-text h1 {
71
  color: white;
72
+ font-size: 2.5rem;
73
  font-weight: 700;
74
+ margin: 0 0 8px 0;
75
  letter-spacing: -0.5px;
76
  line-height: 1.1;
77
  }
78
 
79
  .header-text p {
80
  color: rgba(255, 255, 255, 0.9);
81
+ font-size: 1.1rem;
82
  margin: 0;
83
  font-weight: 400;
84
  line-height: 1.4;
85
  }
86
 
87
+ /* Features Section - STYLE EXACT DE L'IMAGE */
88
  .features-section {
89
  background: white;
90
+ padding: 40px 0 30px 0 !important;
91
  margin: 0 !important;
92
  }
93
 
94
  .features-grid {
95
  display: grid;
96
+ grid-template-columns: 1fr;
97
+ gap: 20px;
98
+ max-width: 500px;
99
  margin: 0 auto;
100
  padding: 0 20px;
101
  }
102
 
103
  .feature-item {
104
  text-align: center;
105
+ padding: 0;
106
  }
107
 
108
  .feature-item h3 {
109
+ font-size: 1.3rem;
110
  font-weight: 600;
111
  color: #2d3748;
112
+ margin: 0 0 8px 0;
113
  line-height: 1.3;
114
  }
115
 
116
  .feature-item p {
117
+ font-size: 1rem;
118
  color: #718096;
119
+ line-height: 1.4;
120
  margin: 0;
121
  }
122
 
123
+ /* Search Section - STYLE EXACT */
 
 
 
 
 
 
 
 
124
  .search-section {
125
  background: white;
126
+ padding: 30px 0 40px 0 !important;
127
  margin: 0 !important;
128
  text-align: center;
129
  }
130
 
131
  .search-content {
132
+ max-width: 500px;
133
  margin: 0 auto;
134
  padding: 0 20px;
135
  }
136
 
137
  .search-title {
138
+ margin-bottom: 20px;
139
  }
140
 
141
  .search-title h2 {
142
+ font-size: 1.5rem;
143
  font-weight: 600;
144
  color: #2d3748;
145
+ margin: 0 0 12px 0;
146
  line-height: 1.2;
147
  }
148
 
149
  .search-subtitle {
150
+ font-size: 1rem;
151
  color: #718096;
152
+ line-height: 1.4;
153
  margin: 0;
154
  }
155
 
156
+ /* Search Input - STYLE EXACT */
157
  .search-inputs {
158
+ max-width: 500px;
159
  margin: 0 auto !important;
160
  padding: 0 20px !important;
161
  }
162
 
163
  .search-box-container {
164
  display: flex;
165
+ gap: 10px;
166
+ margin-bottom: 15px;
167
  align-items: center;
168
  }
169
 
170
  .search-box-container input {
171
  flex: 1;
172
+ padding: 12px 16px !important;
173
+ border: 1px solid #d1d5db !important;
174
+ border-radius: 8px !important;
175
+ font-size: 0.95rem !important;
176
  background: white !important;
177
  color: #2d3748 !important;
 
178
  }
179
 
180
  .search-box-container input:focus {
181
  border-color: #667eea !important;
182
  outline: none !important;
 
183
  }
184
 
185
  .search-box-container input::placeholder {
186
+ color: #9ca3af !important;
187
  }
188
 
189
  .search-button {
190
+ padding: 12px 24px !important;
191
  background: #667eea !important;
192
  color: white !important;
193
  border: none !important;
194
+ border-radius: 8px !important;
195
+ font-size: 0.95rem !important;
196
+ font-weight: 500 !important;
197
  cursor: pointer !important;
198
+ min-width: 80px !important;
 
199
  }
200
 
201
  .search-button:hover {
202
  background: #5a6fd8 !important;
 
203
  }
204
 
205
  .status-message {
206
+ max-width: 500px;
207
  margin: 0 auto !important;
208
  text-align: center;
209
+ font-size: 0.9rem;
210
  }
211
 
212
+ /* Chat Section - STYLE EXACT COMME L'IMAGE */
213
  .chat-section-wrapper {
214
+ background: #f8fafc;
215
+ padding: 40px 0 60px 0 !important;
216
  margin: 0 !important;
217
+ border-top: 1px solid #e5e7eb;
218
  }
219
 
220
  .chat-section {
221
+ max-width: 500px !important;
222
  margin: 0 auto !important;
223
  padding: 0 20px !important;
224
  }
225
 
226
  .chat-header {
227
  text-align: center;
228
+ margin-bottom: 30px;
229
  }
230
 
231
  .chat-header h3 {
232
+ font-size: 1.2rem;
233
+ font-weight: 500;
234
+ color: #6b7280;
235
+ margin: 0 0 20px 0;
236
+ font-style: italic;
 
 
 
 
 
237
  }
238
 
239
+ /* Chat Interface Styling - TRÈS SIMPLE */
240
  .chat-interface {
241
  background: white;
242
+ border: 1px solid #e5e7eb;
243
+ border-radius: 12px;
244
  overflow: hidden;
 
245
  }
246
 
247
  /* Chatbot Styling */
248
  .gradio-chatbot {
249
  border: none !important;
250
  background: white !important;
251
+ min-height: 200px !important;
252
+ max-height: 300px !important;
253
+ box-shadow: none !important;
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
 
256
+ /* Textbox Styling - BOUTON "Send" */
 
 
 
 
 
 
 
257
  .gradio-textbox {
258
+ border: 1px solid #e5e7eb !important;
259
+ border-radius: 8px !important;
260
+ padding: 12px 16px !important;
261
+ font-size: 0.95rem !important;
262
  background: white !important;
263
  }
264
 
 
 
 
 
 
265
  /* Button Styling */
266
  .gradio-button {
267
  background: #667eea !important;
268
  color: white !important;
269
  border: none !important;
270
+ border-radius: 8px !important;
271
+ padding: 12px 20px !important;
272
+ font-weight: 500 !important;
273
+ margin-left: 8px !important;
274
  }
275
 
276
  .gradio-button:hover {
277
  background: #5a6fd8 !important;
278
  }
279
 
280
+ /* Container for chat input */
281
+ .gradio-row {
282
+ gap: 8px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
 
285
  /* Force remove all gaps */
 
287
  margin: 0 !important;
288
  padding: 0 !important;
289
  }
290
+
291
+ /* Hide the submit button label if it exists */
292
+ .submit-button {
293
+ display: none !important;
294
+ }
295
  """
296
  ) as demo:
297
 
298
+ # Header Section - EXACTEMENT COMME L'IMAGE
299
  gr.HTML("""
300
  <div class="header-section">
301
  <div class="header-content">
 
307
  </div>
308
  """)
309
 
310
+ # Features Section - EXACTEMENT COMME L'IMAGE
311
  gr.HTML("""
312
  <div class="features-section">
313
  <div class="features-grid">
 
319
  <h3>Instant Answers</h3>
320
  <p>Get immediate AI-powered responses about any book</p>
321
  </div>
 
 
 
 
 
 
 
 
322
  </div>
 
323
  </div>
324
  """)
325
 
326
+ # Search Section - EXACTEMENT COMME L'IMAGE
327
  gr.HTML("""
328
  <div class="search-section">
329
  <div class="search-content">
 
339
  with gr.Group(elem_classes="search-inputs"):
340
  with gr.Row(elem_classes="search-box-container"):
341
  book_box = gr.Textbox(
342
+ placeholder="Enter book title...",
343
  show_label=False,
344
  container=False,
345
+ scale=7
346
  )
347
+ search_btn = gr.Button("Search", elem_classes="search-button", scale=3)
348
 
349
  status_text = gr.HTML("", visible=False)
350
 
351
+ # Chat Section (hidden initially) - EXACTEMENT COMME L'IMAGE
352
  with gr.Group(visible=False) as chat_section:
353
  gr.HTML("""
354
  <div class="chat-section-wrapper">
 
358
  </div>
359
  """)
360
 
361
+ # Chat Interface - SIMPLE COMME L'IMAGE
362
  chat = gr.ChatInterface(
363
  fn=echo,
364
  type="messages",
365
  chatbot=gr.Chatbot(
366
+ height=200,
367
  type="messages",
368
  show_label=False,
369
+ container=False,
370
+ show_copy_button=False
371
  ),
372
  textbox=gr.Textbox(
373
  placeholder="Type your question here...",
374
  container=False,
375
+ scale=8
376
  ),
377
  submit_btn="Send",
378
  title=""