mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Make the char gallery more space-efficent
This commit is contained in:
parent
b16f097466
commit
b4fa7dcefc
@ -7,49 +7,51 @@ from modules.html_generator import image_to_base64
|
|||||||
|
|
||||||
def generate_html():
|
def generate_html():
|
||||||
css = """
|
css = """
|
||||||
.character-gallery table {
|
.character-gallery {
|
||||||
border-collapse: collapse;
|
margin: 1rem 0;
|
||||||
table-layout: fixed;
|
display: grid;
|
||||||
width: 100%;
|
grid-template-columns: repeat(4, 1fr);
|
||||||
}
|
grid-column-gap: 0.4rem;
|
||||||
|
grid-row-gap: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
.character-gallery th, .character-gallery td {
|
.character-container {
|
||||||
padding: 8px;
|
cursor: pointer;
|
||||||
}
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
.character-gallery img {
|
.character-container:hover {
|
||||||
width: 150px;
|
opacity: 1;
|
||||||
height: 200px;
|
}
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.character-gallery .placeholder {
|
.character-container .placeholder, .character-container img {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
background-color: gray;
|
background-color: gray;
|
||||||
}
|
object-fit: cover;
|
||||||
|
margin: 0 auto;
|
||||||
.character-gallery tr {
|
border-radius: 1rem;
|
||||||
cursor: pointer;
|
border: 3px solid white;
|
||||||
}
|
box-shadow: 5px 5px 2px 0px rgb(0 0 0 / 50%);
|
||||||
|
}
|
||||||
.character-gallery .image-td {
|
|
||||||
width: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.character-gallery .character-td {
|
|
||||||
text-align: center !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.character-name {
|
||||||
|
margin-top: 0.2rem;
|
||||||
|
display: block;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
table_html = f'<style>{css}</style><div class="character-gallery"><table>'
|
container_html = f'<style>{css}</style><div class="character-gallery">'
|
||||||
|
|
||||||
# Iterate through files in image folder
|
# Iterate through files in image folder
|
||||||
for file in Path("characters").glob("*"):
|
for file in Path("characters").glob("*"):
|
||||||
if file.name.endswith(".json"):
|
if file.name.endswith(".json"):
|
||||||
character = file.name.replace(".json", "")
|
character = file.name.replace(".json", "")
|
||||||
table_html += f'<tr onclick=\'document.getElementById("character-menu").children[1].children[1].value = "{character}"; document.getElementById("character-menu").children[1].children[1].dispatchEvent(new Event("change"));\'>'
|
container_html += f'<div class="character-container" onclick=\'document.getElementById("character-menu").children[1].children[1].value = "{character}"; document.getElementById("character-menu").children[1].children[1].dispatchEvent(new Event("change"));\'>'
|
||||||
image_html = "<div class='placeholder'></div>"
|
image_html = "<div class='placeholder'></div>"
|
||||||
|
|
||||||
for i in [
|
for i in [
|
||||||
@ -66,11 +68,11 @@ def generate_html():
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
table_html += f'<td class="image-td">{image_html}</td><td class="character-td">{character}</td>'
|
container_html += f'{image_html} <span class="character-name">{character}</span>'
|
||||||
table_html += "</tr>"
|
container_html += "</div>"
|
||||||
table_html += "</table></div>"
|
|
||||||
|
|
||||||
return table_html
|
container_html += "</div>"
|
||||||
|
return container_html
|
||||||
|
|
||||||
def ui():
|
def ui():
|
||||||
with gr.Accordion("Character gallery"):
|
with gr.Accordion("Character gallery"):
|
||||||
|
Loading…
Reference in New Issue
Block a user