Skip to content

Commit

Permalink
Show/hide the extensions block using javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Mar 15, 2023
1 parent 348596f commit c1959c2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions css/chat.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
document.getElementById("main").childNodes[0].style = "max-width: 800px; margin-left: auto; margin-right: auto";
document.getElementById("extensions").style = "max-width: 800px; margin-left: auto; margin-right: auto";
2 changes: 1 addition & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ svg {
ol li p, ul li p {
display: inline-block;
}
#main, #settings, #extensions, #chat-settings {
#main, #settings, #chat-settings {
border: 0;
}

15 changes: 15 additions & 0 deletions css/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
document.getElementById("main").parentNode.childNodes[0].style = "border: none; background-color: #8080802b; margin-bottom: 40px";
document.getElementById("main").parentNode.style = "padding: 0; margin: 0";
document.getElementById("main").parentNode.parentNode.parentNode.style = "padding: 0";

// Get references to the elements
let main = document.getElementById('main');
let main_parent = main.parentNode;
let extensions = document.getElementById('extensions');

// Add an event listener to the main element
main_parent.addEventListener('click', function(e) {
// Check if the main element is visible
if (main.offsetHeight > 0 && main.offsetWidth > 0) {
extensions.style.visibility = 'visible';
} else {
extensions.style.visibility = 'hidden';
}
});
2 changes: 1 addition & 1 deletion modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_extensions_block():
extension.params[param] = shared.settings[_id]

# Creating the extension ui elements
with gr.Box(elem_id="#extensions"):
with gr.Box(elem_id="extensions"):
gr.Markdown("Extensions")
for extension, name in iterator():
if hasattr(extension, "ui"):
Expand Down
2 changes: 1 addition & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_settings_menus(default_preset):
shared.gradio['display'] = gr.Chatbot(value=shared.history['visible']).style(color_map=("#326efd", "#212528"))
shared.gradio['textbox'] = gr.Textbox(label='Input')
with gr.Row():
shared.gradio['Stop'] = gr.Button('Stop')
shared.gradio['Stop'] = gr.Button('Stop', elem_id="stop")
shared.gradio['Generate'] = gr.Button('Generate')
with gr.Row():
shared.gradio['Impersonate'] = gr.Button('Impersonate')
Expand Down

0 comments on commit c1959c2

Please sign in to comment.