NeoPy commited on
Commit
d6ca4b2
·
verified ·
1 Parent(s): a0917fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -26
app.py CHANGED
@@ -1,32 +1,101 @@
 
 
1
  import gradio as gr
2
- from gradio.themes.default import Default
 
 
3
 
4
- class SimpleModern(Default):
5
- def __init__(self):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  super().__init__(
7
- primary_hue="blue",
8
- secondary_hue="gray",
9
- neutral_hue="white",
10
- font=("Helvetica", "Arial", "sans-serif"),
11
- font_mono=("Courier New", "Courier", "monospace"),
12
- spacing_size="md",
13
- radius_size="md",
14
- text_size="md",
15
  )
16
- self.name = "SimpleModern"
17
- self.set(
18
- background_fill_primary="#f5f5f5",
19
- background_fill_secondary="#ffffff",
20
- block_background_fill="#ffffff",
21
- block_border_color="#e0e0e0",
22
- block_shadow="none",
23
- button_primary_background_fill="#007bff",
24
- button_primary_text_color="#ffffff",
25
- input_background_fill="#ffffff",
26
- input_border_color="#ced4da",
27
- input_text_color="#495057",
28
- link_text_color="#007bff",
29
- body_text_color="#212529",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  )
31
 
32
 
@@ -41,7 +110,7 @@ demo = gr.Interface(
41
  fn=your_function,
42
  inputs=gr.Textbox(),
43
  outputs=gr.Textbox(),
44
- theme=SimpleModern(),
45
  title="Test App",
46
  )
47
 
 
1
+ from future import annotations
2
+ from typing import Iterable
3
  import gradio as gr
4
+ gr.themes.builder()
5
+ from gradio.themes.base import Base
6
+ from gradio.themes.utils import colors, fonts, sizes
7
 
8
+ class Modern(Base):
9
+ def __init__(
10
+ self,
11
+ *,
12
+ primary_hue: colors.Color | str = colors.neutral,
13
+ secondary_hue: colors.Color | str = colors.neutral,
14
+ neutral_hue: colors.Color | str = colors.neutral,
15
+ spacing_size: sizes.Size | str = sizes.spacing_md,
16
+ radius_size: sizes.Size | str = sizes.radius_md,
17
+ text_size: sizes.Size | str = sizes.text_lg,
18
+ font: fonts.Font | str | Iterable[fonts.Font | str] = (
19
+ "ui-sans-serif",
20
+ "system-ui",
21
+ "Segoe UI",
22
+ "Roboto",
23
+ ),
24
+ font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
25
+ "ui-monospace",
26
+ "SFMono-Regular",
27
+ "Consolas",
28
+ ),
29
+ ):
30
  super().__init__(
31
+ primary_hue=primary_hue,
32
+ secondary_hue=secondary_hue,
33
+ neutral_hue=neutral_hue,
34
+ spacing_size=spacing_size,
35
+ radius_size=radius_size,
36
+ text_size=text_size,
37
+ font=font,
38
+ font_mono=font_mono,
39
  )
40
+ self.name = ("Modern",)
41
+
42
+ def set(self):
43
+ super().set(
44
+ # Base styles
45
+ background_fill_primary="#0F0F0F",
46
+ background_fill_primary_dark="#0F0F0F",
47
+ background_fill_secondary="#0F0F0F",
48
+ background_fill_secondary_dark="#0F0F0F",
49
+ body_text_color="white",
50
+ body_text_color_dark="white",
51
+ body_text_color_subdued="#999",
52
+ body_text_color_subdued_dark="#999",
53
+ border_color_primary="#333",
54
+ border_color_primary_dark="#333",
55
+ spacing_size=sizes.spacing_md,
56
+
57
+ # Blocks
58
+ block_radius="0 0 0 0",
59
+ block_border_width="1px",
60
+ block_border_color="#333",
61
+ block_background_fill="#151515",
62
+ block_padding="*spacing_lg",
63
+ block_margin="*spacing_md 0",
64
+
65
+ # Buttons
66
+ button_primary_background_fill="#111",
67
+ button_primary_background_fill_hover="#222",
68
+ button_primary_text_color="white",
69
+ button_secondary_background_fill="transparent",
70
+ button_secondary_border_color="#666",
71
+ button_secondary_text_color="#fff",
72
+ button_secondary_border_width="1px",
73
+ button_radius="6px",
74
+ button_transition="0.2s",
75
+
76
+ # Inputs
77
+ input_background_fill="#181818",
78
+ input_border_color="#444",
79
+ input_text_color="white",
80
+ input_padding="*spacing_md",
81
+ input_radius="6px",
82
+ input_border_width="1px",
83
+
84
+ # Textarea
85
+ textarea_background_fill="#181818",
86
+ textarea_border_color="#444",
87
+ textarea_text_color="white",
88
+ textarea_padding="*spacing_md",
89
+ textarea_radius="6px",
90
+ textarea_border_width="1px",
91
+
92
+ # Layout
93
+ layout_gap="*spacing_lg",
94
+ block_label_padding="*spacing_sm *spacing_lg",
95
+ block_label_radius="6px",
96
+ block_label_border_width="1px",
97
+ block_label_border_color="#333",
98
+ block_label_background_fill="#151515",
99
  )
100
 
101
 
 
110
  fn=your_function,
111
  inputs=gr.Textbox(),
112
  outputs=gr.Textbox(),
113
+ theme=Modern(),
114
  title="Test App",
115
  )
116