Roseco-crs commited on
Commit
ec58da7
·
1 Parent(s): 592c318

Make the app responsive by injecting a mobile friendly CSS

Browse files
Files changed (1) hide show
  1. app.py +26 -13
app.py CHANGED
@@ -2,6 +2,7 @@ from ailab_crs import NLP_tasks_crs, Prompt_engineering_crs
2
  import gradio as gr
3
  from googletrans import LANGUAGES
4
 
 
5
  # CSS to hide the entire footer, including "Made with Gradio", settings, and API info
6
  hide_footer_css = """
7
  <style>
@@ -10,17 +11,29 @@ footer, footer * {
10
  }
11
  </style>
12
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  nlp_tasks = NLP_tasks_crs()
15
  supported_langs = list(LANGUAGES.values())
16
 
17
- def hide_footer():
18
- return """
19
- footer {visibility: hidden;}
20
- #footer {display: none !important;}
21
- """
22
 
23
  with gr.Blocks() as demo:
 
 
 
 
24
  gr.Markdown("# 🧠 NaanhAI 💡")
25
 
26
  # Inject the CSS at the top
@@ -35,14 +48,14 @@ with gr.Blocks() as demo:
35
  style = gr.Textbox(label="Choose Your Style", value="polite")
36
 
37
  with gr.Row(scale=5):
38
- with gr.Column(scale=1, min_width=1):
39
- btn = gr.Button("Q&A")
40
- with gr.Column(scale=2, min_width=1):
41
- btn1 = gr.Button("Translator")
42
- with gr.Column(scale=2, min_width=1):
43
- btn2 = gr.Button("Summarizer")
44
- with gr.Column(scale=2, min_width=1):
45
- btn3 = gr.Button("Translator_Summarizer")
46
 
47
  answer = gr.Textbox(label="AI Answer", lines=2)
48
 
 
2
  import gradio as gr
3
  from googletrans import LANGUAGES
4
 
5
+
6
  # CSS to hide the entire footer, including "Made with Gradio", settings, and API info
7
  hide_footer_css = """
8
  <style>
 
11
  }
12
  </style>
13
  """
14
+
15
+ # Mobile-friendly CSS
16
+ mobile_css = """
17
+ <style>
18
+ /* Make all inputs, textboxes, and buttons full width on small screens */
19
+ @media (max-width: 768px) {
20
+ input, textarea, button, .gr-textbox, .gr-button {
21
+ width: 100% !important;
22
+ margin: 5px 0 !important;
23
+ }
24
+ }
25
+ </style>
26
+ """
27
 
28
  nlp_tasks = NLP_tasks_crs()
29
  supported_langs = list(LANGUAGES.values())
30
 
 
 
 
 
 
31
 
32
  with gr.Blocks() as demo:
33
+ # Inject the mobile CSS
34
+ gr.HTML(mobile_css)
35
+
36
+ # App title
37
  gr.Markdown("# 🧠 NaanhAI 💡")
38
 
39
  # Inject the CSS at the top
 
48
  style = gr.Textbox(label="Choose Your Style", value="polite")
49
 
50
  with gr.Row(scale=5):
51
+ # with gr.Column(scale=1, min_width=1):
52
+ btn = gr.Button("Q&A")
53
+ # with gr.Column(scale=2, min_width=1):
54
+ btn1 = gr.Button("Translator")
55
+ # with gr.Column(scale=2, min_width=1):
56
+ btn2 = gr.Button("Summarizer")
57
+ # with gr.Column(scale=2, min_width=1):
58
+ btn3 = gr.Button("Translator_Summarizer")
59
 
60
  answer = gr.Textbox(label="AI Answer", lines=2)
61