Skip to content

Commit c1959c2

Browse files
committed
Show/hide the extensions block using javascript
1 parent 348596f commit c1959c2

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

css/chat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
document.getElementById("main").childNodes[0].style = "max-width: 800px; margin-left: auto; margin-right: auto";
2+
document.getElementById("extensions").style = "max-width: 800px; margin-left: auto; margin-right: auto";

css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ svg {
3333
ol li p, ul li p {
3434
display: inline-block;
3535
}
36-
#main, #settings, #extensions, #chat-settings {
36+
#main, #settings, #chat-settings {
3737
border: 0;
3838
}
3939

css/main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
document.getElementById("main").parentNode.childNodes[0].style = "border: none; background-color: #8080802b; margin-bottom: 40px";
22
document.getElementById("main").parentNode.style = "padding: 0; margin: 0";
33
document.getElementById("main").parentNode.parentNode.parentNode.style = "padding: 0";
4+
5+
// Get references to the elements
6+
let main = document.getElementById('main');
7+
let main_parent = main.parentNode;
8+
let extensions = document.getElementById('extensions');
9+
10+
// Add an event listener to the main element
11+
main_parent.addEventListener('click', function(e) {
12+
// Check if the main element is visible
13+
if (main.offsetHeight > 0 && main.offsetWidth > 0) {
14+
extensions.style.visibility = 'visible';
15+
} else {
16+
extensions.style.visibility = 'hidden';
17+
}
18+
});

modules/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def create_extensions_block():
4242
extension.params[param] = shared.settings[_id]
4343

4444
# Creating the extension ui elements
45-
with gr.Box(elem_id="#extensions"):
45+
with gr.Box(elem_id="extensions"):
4646
gr.Markdown("Extensions")
4747
for extension, name in iterator():
4848
if hasattr(extension, "ui"):

server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def create_settings_menus(default_preset):
215215
shared.gradio['display'] = gr.Chatbot(value=shared.history['visible']).style(color_map=("#326efd", "#212528"))
216216
shared.gradio['textbox'] = gr.Textbox(label='Input')
217217
with gr.Row():
218-
shared.gradio['Stop'] = gr.Button('Stop')
218+
shared.gradio['Stop'] = gr.Button('Stop', elem_id="stop")
219219
shared.gradio['Generate'] = gr.Button('Generate')
220220
with gr.Row():
221221
shared.gradio['Impersonate'] = gr.Button('Impersonate')

0 commit comments

Comments
 (0)