adamelliotfields commited on
Commit
459aacb
1 Parent(s): bd8e953

Menu improvements

Browse files
Files changed (4) hide show
  1. app.css +7 -3
  2. app.js +6 -4
  3. app.py +50 -46
  4. partials/head.html +2 -2
app.css CHANGED
@@ -19,6 +19,10 @@
19
  --block-border-width: 1px;
20
  }
21
 
 
 
 
 
22
  .gallery {
23
  background-color: var(--bg);
24
  }
@@ -30,11 +34,11 @@
30
  }
31
  .gallery, .gallery > .grid-wrap {
32
  height: 100%;
33
- max-height: 574px;
34
  }
35
  @media (min-width: 640px) {
36
  .gallery, .gallery > .grid-wrap {
37
- height: 574px;
38
  max-height: none;
39
  }
40
  }
@@ -105,7 +109,7 @@
105
  border-width: 0px;
106
  }
107
  .tabitem {
108
- max-height: 698px;
109
  overflow-x: hidden;
110
  overflow-y: auto;
111
  padding: 0 0 8px;
 
19
  --block-border-width: 1px;
20
  }
21
 
22
+ #embeddings .token {
23
+ border-radius: 4px;
24
+ }
25
+
26
  .gallery {
27
  background-color: var(--bg);
28
  }
 
34
  }
35
  .gallery, .gallery > .grid-wrap {
36
  height: 100%;
37
+ max-height: 550px;
38
  }
39
  @media (min-width: 640px) {
40
  .gallery, .gallery > .grid-wrap {
41
+ height: 550px;
42
  max-height: none;
43
  }
44
  }
 
109
  border-width: 0px;
110
  }
111
  .tabitem {
112
+ max-height: 656px;
113
  overflow-x: hidden;
114
  overflow-y: auto;
115
  padding: 0 0 8px;
app.js CHANGED
@@ -2,13 +2,15 @@
2
  const menu = document.querySelector("#menu");
3
  const menuButton = menu.querySelector("button");
4
  const menuSpan = menuButton.querySelector("span:first-child");
 
5
 
6
- const updateMenuText = () => {
7
  const isOpen = menuButton.classList.contains("open");
8
- menuSpan.textContent = isOpen ? "Close menu" : "Open menu";
 
9
  };
10
 
11
- const observer = new MutationObserver(updateMenuText);
12
  observer.observe(menuButton, { attributes: true, attributeFilter: ["class"] });
13
- updateMenuText();
14
  }
 
2
  const menu = document.querySelector("#menu");
3
  const menuButton = menu.querySelector("button");
4
  const menuSpan = menuButton.querySelector("span:first-child");
5
+ const content = document.querySelector("#content");
6
 
7
+ const updateMenu = () => {
8
  const isOpen = menuButton.classList.contains("open");
9
+ menuSpan.textContent = isOpen ? "Hide menu" : "Show menu";
10
+ content.style.display = isOpen ? "none" : "flex";
11
  };
12
 
13
+ const observer = new MutationObserver(updateMenu);
14
  observer.observe(menuButton, { attributes: true, attributeFilter: ["class"] });
15
+ updateMenu();
16
  }
app.py CHANGED
@@ -87,7 +87,7 @@ with gr.Blocks(
87
  with gr.Accordion(
88
  elem_classes=["accordion"],
89
  elem_id="menu",
90
- label="Open menu",
91
  open=False,
92
  ):
93
  with gr.Tabs():
@@ -106,6 +106,7 @@ with gr.Blocks(
106
  filterable=False,
107
  value=Config.MODEL,
108
  label="Model",
 
109
  )
110
  scheduler = gr.Dropdown(
111
  choices=Config.SCHEDULERS,
@@ -120,14 +121,15 @@ with gr.Blocks(
120
  style = gr.Dropdown(
121
  value=Config.STYLE,
122
  label="Style",
123
- min_width=200,
124
  choices=[("None", None)] + [(s["name"], s["id"]) for s in styles],
125
  )
126
  embeddings = gr.Dropdown(
 
127
  label="Embeddings",
128
  choices=[(f"<{e}>", e) for e in Config.EMBEDDINGS],
129
  multiselect=True,
130
  value=[Config.EMBEDDING],
 
131
  )
132
 
133
  with gr.Row():
@@ -179,7 +181,6 @@ with gr.Blocks(
179
  value="448,576",
180
  filterable=False,
181
  label="Aspect Ratio",
182
- min_width=180,
183
  )
184
  scale = gr.Dropdown(
185
  choices=[(f"{s}x", s) for s in Config.SCALES],
@@ -253,49 +254,52 @@ with gr.Blocks(
253
  with gr.TabItem("ℹ️ Usage"):
254
  gr.Markdown(read_file("usage.md"), elem_classes=["markdown"])
255
 
256
- with gr.Group():
257
- output_images = gr.Gallery(
258
- elem_classes=["gallery"],
259
- show_share_button=False,
260
- interactive=False,
261
- show_label=False,
262
- object_fit="cover",
263
- label="Output",
264
- format="png",
265
- columns=2,
266
- )
267
- prompt = gr.Textbox(
268
- placeholder="corgi, beach, 8k",
269
- show_label=False,
270
- label="Prompt",
271
- value=None,
272
- lines=2,
273
- )
274
-
275
- with gr.Row():
276
- generate_btn = gr.Button("Generate", variant="primary")
277
- random_btn = gr.Button(
278
- elem_classes=["icon-button", "popover"],
279
- variant="secondary",
280
- elem_id="random",
281
- min_width=0,
282
- value="🎲",
283
- )
284
- refresh_btn = gr.Button(
285
- elem_classes=["icon-button", "popover"],
286
- variant="secondary",
287
- elem_id="refresh",
288
- min_width=0,
289
- value="🔄",
290
- )
291
- clear_btn = gr.ClearButton(
292
- elem_classes=["icon-button", "popover"],
293
- components=[output_images],
294
- variant="secondary",
295
- elem_id="clear",
296
- min_width=0,
297
- value="🗑️",
298
- )
 
 
 
299
 
300
  random_btn.click(random_fn, inputs=[], outputs=[prompt], show_api=False)
301
 
 
87
  with gr.Accordion(
88
  elem_classes=["accordion"],
89
  elem_id="menu",
90
+ label="Show menu",
91
  open=False,
92
  ):
93
  with gr.Tabs():
 
106
  filterable=False,
107
  value=Config.MODEL,
108
  label="Model",
109
+ min_width=240,
110
  )
111
  scheduler = gr.Dropdown(
112
  choices=Config.SCHEDULERS,
 
121
  style = gr.Dropdown(
122
  value=Config.STYLE,
123
  label="Style",
 
124
  choices=[("None", None)] + [(s["name"], s["id"]) for s in styles],
125
  )
126
  embeddings = gr.Dropdown(
127
+ elem_id="embeddings",
128
  label="Embeddings",
129
  choices=[(f"<{e}>", e) for e in Config.EMBEDDINGS],
130
  multiselect=True,
131
  value=[Config.EMBEDDING],
132
+ min_width=240,
133
  )
134
 
135
  with gr.Row():
 
181
  value="448,576",
182
  filterable=False,
183
  label="Aspect Ratio",
 
184
  )
185
  scale = gr.Dropdown(
186
  choices=[(f"{s}x", s) for s in Config.SCALES],
 
254
  with gr.TabItem("ℹ️ Usage"):
255
  gr.Markdown(read_file("usage.md"), elem_classes=["markdown"])
256
 
257
+ # Main content
258
+ with gr.Column(elem_id="content"):
259
+ with gr.Group():
260
+ output_images = gr.Gallery(
261
+ elem_classes=["gallery"],
262
+ show_share_button=False,
263
+ interactive=False,
264
+ show_label=False,
265
+ object_fit="cover",
266
+ label="Output",
267
+ format="png",
268
+ columns=2,
269
+ )
270
+ prompt = gr.Textbox(
271
+ placeholder="corgi, beach, 8k",
272
+ show_label=False,
273
+ label="Prompt",
274
+ value=None,
275
+ lines=2,
276
+ )
277
+
278
+ # Buttons
279
+ with gr.Row():
280
+ generate_btn = gr.Button("Generate", variant="primary")
281
+ random_btn = gr.Button(
282
+ elem_classes=["icon-button", "popover"],
283
+ variant="secondary",
284
+ elem_id="random",
285
+ min_width=0,
286
+ value="🎲",
287
+ )
288
+ refresh_btn = gr.Button(
289
+ elem_classes=["icon-button", "popover"],
290
+ variant="secondary",
291
+ elem_id="refresh",
292
+ min_width=0,
293
+ value="🔄",
294
+ )
295
+ clear_btn = gr.ClearButton(
296
+ elem_classes=["icon-button", "popover"],
297
+ components=[output_images],
298
+ variant="secondary",
299
+ elem_id="clear",
300
+ min_width=0,
301
+ value="🗑️",
302
+ )
303
 
304
  random_btn.click(random_fn, inputs=[], outputs=[prompt], show_api=False)
305
 
partials/head.html CHANGED
@@ -1,8 +1,8 @@
1
  <style>
2
  /* gradio styles go in head */
3
- @media (min-width: 1024px) {
4
  gradio-app > .gradio-container {
5
- max-width: 960px !important;
6
  }
7
  }
8
  </style>
 
1
  <style>
2
  /* gradio styles go in head */
3
+ @media (min-width: 1536px) {
4
  gradio-app > .gradio-container {
5
+ max-width: 1280px !important;
6
  }
7
  }
8
  </style>