Jonny001 commited on
Commit
ddadfd1
·
verified ·
1 Parent(s): 67519cb

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +10 -5
  2. app.py +147 -0
  3. theme_dropdown.py +56 -0
  4. themes/theme_schema@0.0.2.json.json +134 -0
README.md CHANGED
@@ -1,13 +1,18 @@
1
  ---
2
- title: PinkWorld Theme
3
- emoji: 👀
 
 
4
  colorFrom: pink
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.44.1
8
  app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ tags:
3
+ - gradio-theme
4
+ - track-1
5
+ title: PinkWorld_Theme
6
  colorFrom: pink
7
+ colorTo: pink
8
  sdk: gradio
9
+ sdk_version: 3.25.0
10
  app_file: app.py
11
  pinned: false
12
  license: apache-2.0
13
+ emoji: 🧩
14
+ short_description: Green color Theme for Gradio
15
  ---
16
 
17
+ ## Contributions
18
+ Thanks to [@HaleyCH](https://huggingface.co/HaleyCH) for adding this gradio theme!
app.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+
3
+ from theme_dropdown import create_theme_dropdown # noqa: F401
4
+
5
+ import gradio as gr
6
+
7
+ dropdown, js = create_theme_dropdown()
8
+
9
+ with gr.Blocks(theme='Jonny001/GreenEarth_Theme') as demo:
10
+ with gr.Row().style(equal_height=True):
11
+ with gr.Column(scale=10):
12
+ gr.Markdown(
13
+ """
14
+ # Theme preview: `GreenEarth_Theme`
15
+ To use this theme, set `theme='Jonny001/GreenEarth_Theme'` in `gr.Blocks()` or `gr.Interface()`.
16
+ You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
17
+ of this theme.
18
+ """
19
+ )
20
+ with gr.Column(scale=3):
21
+ with gr.Box():
22
+ dropdown.render()
23
+ toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
24
+
25
+ dropdown.change(None, dropdown, None, _js=js)
26
+ toggle_dark.click(
27
+ None,
28
+ _js="""
29
+ () => {
30
+ document.body.classList.toggle('dark');
31
+ document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
32
+ }
33
+ """,
34
+ )
35
+
36
+ name = gr.Textbox(
37
+ label="Name",
38
+ info="Full name, including middle name. No special characters.",
39
+ placeholder="John Doe",
40
+ value="John Doe",
41
+ interactive=True,
42
+ )
43
+
44
+ with gr.Row():
45
+ slider1 = gr.Slider(label="Slider 1")
46
+ slider2 = gr.Slider(label="Slider 2")
47
+ gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
48
+
49
+ with gr.Row():
50
+ with gr.Column(variant="panel", scale=1):
51
+ gr.Markdown("## Panel 1")
52
+ radio = gr.Radio(
53
+ ["A", "B", "C"],
54
+ label="Radio",
55
+ info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
56
+ )
57
+ drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
58
+ drop_2 = gr.Dropdown(
59
+ ["Option A", "Option B", "Option C"],
60
+ multiselect=True,
61
+ value=["Option A"],
62
+ label="Dropdown",
63
+ interactive=True,
64
+ )
65
+ check = gr.Checkbox(label="Go")
66
+ with gr.Column(variant="panel", scale=2):
67
+ img = gr.Image(
68
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg", label="Image"
69
+ ).style(height=320)
70
+ with gr.Row():
71
+ go_btn = gr.Button("Go", label="Primary Button", variant="primary")
72
+ clear_btn = gr.Button(
73
+ "Clear", label="Secondary Button", variant="secondary"
74
+ )
75
+
76
+ def go(*args):
77
+ time.sleep(3)
78
+ return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg"
79
+
80
+ go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
81
+
82
+ def clear():
83
+ time.sleep(0.2)
84
+ return None
85
+
86
+ clear_btn.click(clear, None, img)
87
+
88
+ with gr.Row():
89
+ btn1 = gr.Button("Button 1").style(size="sm")
90
+ btn2 = gr.UploadButton().style(size="sm")
91
+ stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
92
+ size="sm"
93
+ )
94
+
95
+ with gr.Row():
96
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
97
+ gr.JSON(
98
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
99
+ )
100
+ gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
101
+ gr.File()
102
+ with gr.Row():
103
+ gr.ColorPicker()
104
+ gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
105
+ gr.Gallery(
106
+ [
107
+ (
108
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
109
+ "lion",
110
+ ),
111
+ (
112
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
113
+ "logo",
114
+ ),
115
+ (
116
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
117
+ "tower",
118
+ ),
119
+ ]
120
+ ).style(height="200px", grid=2)
121
+
122
+ with gr.Row():
123
+ with gr.Column(scale=2):
124
+ chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
125
+ chat_btn = gr.Button("Add messages")
126
+
127
+ def chat(history):
128
+ time.sleep(2)
129
+ yield [["How are you?", "I am good."]]
130
+
131
+ chat_btn.click(
132
+ lambda history: history
133
+ + [["How are you?", "I am good."]]
134
+ + (time.sleep(2) or []),
135
+ chatbot,
136
+ chatbot,
137
+ )
138
+ with gr.Column(scale=1):
139
+ with gr.Accordion("Advanced Settings"):
140
+ gr.Markdown("Hello")
141
+ gr.Number(label="Chatbot control 1")
142
+ gr.Number(label="Chatbot control 2")
143
+ gr.Number(label="Chatbot control 3")
144
+
145
+
146
+ if __name__ == "__main__":
147
+ demo.queue().launch()
theme_dropdown.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pathlib
3
+
4
+ from gradio.themes.utils import ThemeAsset
5
+
6
+ def create_theme_dropdown():
7
+ import gradio as gr
8
+
9
+ asset_path = pathlib.Path(__file__).parent / "themes"
10
+ themes = []
11
+ for theme_asset in os.listdir(str(asset_path)):
12
+ themes.append(
13
+ (ThemeAsset(theme_asset), gr.Theme.load(str(asset_path / theme_asset)))
14
+ )
15
+
16
+ def make_else_if(theme_asset):
17
+ return f"""
18
+ else if (theme == '{str(theme_asset[0].version)}') {{
19
+ var theme_css = `{theme_asset[1]._get_theme_css()}`
20
+ }}"""
21
+
22
+ head, tail = themes[0], themes[1:]
23
+ if_statement = f"""
24
+ if (theme == "{str(head[0].version)}") {{
25
+ var theme_css = `{head[1]._get_theme_css()}`
26
+ }} {" ".join(make_else_if(t) for t in tail)}
27
+ """
28
+
29
+ latest_to_oldest = sorted([t[0] for t in themes], key=lambda asset: asset.version)[
30
+ ::-1
31
+ ]
32
+ latest_to_oldest = [str(t.version) for t in latest_to_oldest]
33
+
34
+ component = gr.Dropdown(
35
+ choices=latest_to_oldest,
36
+ value=latest_to_oldest[0],
37
+ render=False,
38
+ label="Select Version",
39
+ ).style(container=False)
40
+
41
+ return (
42
+ component,
43
+ f"""
44
+ (theme) => {{
45
+ if (!document.querySelector('.theme-css')) {{
46
+ var theme_elem = document.createElement('style');
47
+ theme_elem.classList.add('theme-css');
48
+ document.head.appendChild(theme_elem);
49
+ }} else {{
50
+ var theme_elem = document.querySelector('.theme-css');
51
+ }}
52
+ {if_statement}
53
+ theme_elem.innerHTML = theme_css;
54
+ }}
55
+ """,
56
+ )
themes/theme_schema@0.0.2.json.json ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "theme": {
3
+ "_font": [
4
+ {"__gradio_font__": true, "name": "Montserrat", "class": "google"},
5
+ {"__gradio_font__": true, "name": "ui-sans-serif", "class": "font"},
6
+ {"__gradio_font__": true, "name": "system-ui", "class": "font"},
7
+ {"__gradio_font__": true, "name": "sans-serif", "class": "font"}
8
+ ],
9
+ "_font_mono": [
10
+ {"__gradio_font__": true, "name": "IBM Plex Mono", "class": "google"},
11
+ {"__gradio_font__": true, "name": "ui-monospace", "class": "font"},
12
+ {"__gradio_font__": true, "name": "Consolas", "class": "font"},
13
+ {"__gradio_font__": true, "name": "monospace", "class": "font"}
14
+ ],
15
+ "_stylesheets": [
16
+ "https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap",
17
+ "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
18
+ ],
19
+ "background_fill_primary": "#330022",
20
+ "background_fill_primary_dark": "#330022",
21
+ "background_fill_secondary": "#330022",
22
+ "background_fill_secondary_dark": "#330022",
23
+ "block_background_fill": "#330022",
24
+ "block_background_fill_dark": "#330022",
25
+ "block_border_color": "#ff69b4",
26
+ "block_border_color_dark": "#ff69b4",
27
+ "block_border_width": "1px",
28
+ "block_info_text_color": "#ff1493",
29
+ "block_info_text_color_dark": "#ff1493",
30
+ "block_info_text_size": "*text_sm",
31
+ "block_info_text_weight": "400",
32
+ "block_label_background_fill": "#330022",
33
+ "block_label_background_fill_dark": "#330022",
34
+ "block_label_border_color": "#ff1493",
35
+ "block_label_border_color_dark": "#ff1493",
36
+ "block_label_border_width": "1px",
37
+ "block_label_margin": "0",
38
+ "block_label_padding": "*spacing_sm *spacing_lg",
39
+ "block_label_radius": "calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px) 0",
40
+ "block_label_right_radius": "0 calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px)",
41
+ "block_label_text_color": "#ff1493",
42
+ "block_label_text_color_dark": "#ff1493",
43
+ "block_label_text_size": "*text_sm",
44
+ "block_label_text_weight": "400",
45
+ "block_padding": "*spacing_xl calc(*spacing_xl + 2px)",
46
+ "block_radius": "*radius_lg",
47
+ "block_shadow": "none",
48
+ "block_title_background_fill": "#330022",
49
+ "block_title_background_fill_dark": "#330022",
50
+ "block_title_border_color": "#ff1493",
51
+ "block_title_border_color_dark": "#ff1493",
52
+ "block_title_border_width": "0px",
53
+ "block_title_padding": "0",
54
+ "block_title_radius": "none",
55
+ "block_title_text_color": "#ff1493",
56
+ "block_title_text_color_dark": "#ff1493",
57
+ "block_title_text_size": "*text_md",
58
+ "block_title_text_weight": "400",
59
+ "body_background_fill": "#330022",
60
+ "body_background_fill_dark": "#330022",
61
+ "body_text_color": "#ff1493",
62
+ "body_text_color_dark": "#ff1493",
63
+ "body_text_color_subdued": "#ff1493",
64
+ "body_text_color_subdued_dark": "#ff1493",
65
+ "body_text_size": "*text_md",
66
+ "body_text_weight": "400",
67
+ "border_color_accent": "#ff69b4",
68
+ "border_color_accent_dark": "#ff69b4",
69
+ "border_color_primary": "#ff1493",
70
+ "border_color_primary_dark": "#ff1493",
71
+ "button_border_width": "*input_border_width",
72
+ "button_border_width_dark": "*input_border_width",
73
+ "button_cancel_background_fill": "#ff1493",
74
+ "button_cancel_background_fill_dark": "#ff1493",
75
+ "button_cancel_background_fill_hover": "#ff69b4",
76
+ "button_cancel_background_fill_hover_dark": "#ff69b4",
77
+ "button_cancel_border_color": "#ff69b4",
78
+ "button_cancel_border_color_dark": "#ff69b4",
79
+ "button_cancel_border_color_hover": "#ff1493",
80
+ "button_cancel_border_color_hover_dark": "#ff1493",
81
+ "button_cancel_text_color": "*button_secondary_text_color",
82
+ "button_cancel_text_color_dark": "*button_secondary_text_color",
83
+ "button_cancel_text_color_hover": "*button_cancel_text_color",
84
+ "button_cancel_text_color_hover_dark": "*button_cancel_text_color",
85
+ "button_primary_background_fill": "#ff69b4",
86
+ "button_primary_background_fill_dark": "#ff69b4",
87
+ "button_primary_background_fill_hover": "#ff1493",
88
+ "button_primary_background_fill_hover_dark": "#ff1493",
89
+ "button_primary_border_color": "#ff69b4",
90
+ "button_primary_border_color_dark": "#ff69b4",
91
+ "button_primary_border_color_hover": "#ff1493",
92
+ "button_primary_border_color_hover_dark": "#ff1493",
93
+ "button_primary_text_color": "*secondary_900",
94
+ "button_primary_text_color_dark": "*secondary_900",
95
+ "button_primary_text_color_hover": "*secondary_950",
96
+ "button_primary_text_color_hover_dark": "*secondary_950",
97
+ "button_secondary_background_fill": "#ff69b4",
98
+ "button_secondary_background_fill_dark": "#ff69b4",
99
+ "button_secondary_background_fill_hover": "#ff1493",
100
+ "button_secondary_background_fill_hover_dark": "#ff1493",
101
+ "button_secondary_border_color": "#ff1493",
102
+ "button_secondary_border_color_dark": "#ff1493",
103
+ "button_secondary_border_color_hover": "#ff69b4",
104
+ "button_secondary_border_color_hover_dark": "#ff69b4",
105
+ "button_secondary_text_color": "*secondary_950",
106
+ "button_secondary_text_color_dark": "*secondary_950",
107
+ "button_secondary_text_color_hover": "*secondary_950",
108
+ "button_secondary_text_color_hover_dark": "*secondary_950",
109
+ "button_shadow": "none",
110
+ "button_shadow_active": "none",
111
+ "button_shadow_hover": "none",
112
+ "checkbox_background_color": "#ff69b4",
113
+ "checkbox_background_color_dark": "#ff69b4",
114
+ "checkbox_background_color_focus": "#ff1493",
115
+ "checkbox_background_color_focus_dark": "#ff1493",
116
+ "checkbox_background_color_hover": "#ff69b4",
117
+ "checkbox_background_color_hover_dark": "#ff69b4",
118
+ "checkbox_background_color_selected": "#ff1493",
119
+ "checkbox_background_color_selected_dark": "#ff1493",
120
+ "checkbox_border_color": "#ff69b4",
121
+ "checkbox_border_color_dark": "#ff69b4",
122
+ "checkbox_border_color_focus": "#ff1493",
123
+ "checkbox_border_color_focus_dark": "#ff1493",
124
+ "checkbox_border_color_hover": "#ff1493",
125
+ "checkbox_border_color_hover_dark": "#ff1493",
126
+ "checkbox_border_color_selected": "#ff1493",
127
+ "checkbox_border_color_selected_dark": "#ff1493",
128
+ "checkbox_border_radius": "*radius_sm",
129
+ "checkbox_border_width": "*input_border_width",
130
+ "checkbox_border_width_dark": "*input_border_width",
131
+ "checkbox_check": "url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e\")"
132
+ },
133
+ "version": "0.0.2"
134
+ }