File size: 3,710 Bytes
2700b48
d6ca4b2
fd55c28
cceef21
d6ca4b2
 
fd55c28
d6ca4b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd55c28
d6ca4b2
 
 
 
 
 
 
 
fd55c28
d6ca4b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd55c28
 
 
a0917fd
 
 
 
fd55c28
 
 
 
 
a0917fd
 
d6ca4b2
fd55c28
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#from future import annotations
from typing import Iterable
import gradio as gr
#gr.themes.builder()
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes

class Modern(Base):
    def __init__(
        self,
        *,
        primary_hue: colors.Color | str = colors.neutral,
        secondary_hue: colors.Color | str = colors.neutral,
        neutral_hue: colors.Color | str = colors.neutral,
        spacing_size: sizes.Size | str = sizes.spacing_md,
        radius_size: sizes.Size | str = sizes.radius_md,
        text_size: sizes.Size | str = sizes.text_lg,
        font: fonts.Font | str | Iterable[fonts.Font | str] = (
            "ui-sans-serif",
            "system-ui",
            "Segoe UI",
            "Roboto",
        ),
        font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
            "ui-monospace",
            "SFMono-Regular",
            "Consolas",
        ),
    ):
        super().__init__(
            primary_hue=primary_hue,
            secondary_hue=secondary_hue,
            neutral_hue=neutral_hue,
            spacing_size=spacing_size,
            radius_size=radius_size,
            text_size=text_size,
            font=font,
            font_mono=font_mono,
        )
        self.name = ("Modern",)

    def set(self):
        super().set(
            # Base styles
            background_fill_primary="#0F0F0F",
            background_fill_primary_dark="#0F0F0F",
            background_fill_secondary="#0F0F0F",
            background_fill_secondary_dark="#0F0F0F",
            body_text_color="white",
            body_text_color_dark="white",
            body_text_color_subdued="#999",
            body_text_color_subdued_dark="#999",
            border_color_primary="#333",
            border_color_primary_dark="#333",
            spacing_size=sizes.spacing_md,

            # Blocks
            block_radius="0 0 0 0",
            block_border_width="1px",
            block_border_color="#333",
            block_background_fill="#151515",
            block_padding="*spacing_lg",
            block_margin="*spacing_md 0",

            # Buttons
            button_primary_background_fill="#111",
            button_primary_background_fill_hover="#222",
            button_primary_text_color="white",
            button_secondary_background_fill="transparent",
            button_secondary_border_color="#666",
            button_secondary_text_color="#fff",
            button_secondary_border_width="1px",
            button_radius="6px",
            button_transition="0.2s",

            # Inputs
            input_background_fill="#181818",
            input_border_color="#444",
            input_text_color="white",
            input_padding="*spacing_md",
            input_radius="6px",
            input_border_width="1px",

            # Textarea
            textarea_background_fill="#181818",
            textarea_border_color="#444",
            textarea_text_color="white",
            textarea_padding="*spacing_md",
            textarea_radius="6px",
            textarea_border_width="1px",

            # Layout
            layout_gap="*spacing_lg",
            block_label_padding="*spacing_sm *spacing_lg",
            block_label_radius="6px",
            block_label_border_width="1px",
            block_label_border_color="#333",
            block_label_background_fill="#151515",
        )


def your_function(text):
    print(text)
    range = text 
    return range


# Assuming SimpleModern is your custom theme class
demo = gr.Interface(
    fn=your_function,
    inputs=gr.Textbox(),
    outputs=gr.Textbox(),
    theme=Modern(),
    title="Test App",
)

demo.launch()