From b4fa7dcefce7d5af5483a001df0c3a37558f5979 Mon Sep 17 00:00:00 2001 From: conanak99 Date: Mon, 27 Feb 2023 21:52:43 +0800 Subject: [PATCH 1/4] Make the char gallery more space-efficent --- extensions/gallery/script.py | 74 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 68e2c1a3..5e0da084 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -7,49 +7,51 @@ from modules.html_generator import image_to_base64 def generate_html(): css = """ - .character-gallery table { - border-collapse: collapse; - table-layout: fixed; - width: 100%; - } + .character-gallery { + margin: 1rem 0; + display: grid; + grid-template-columns: repeat(4, 1fr); + grid-column-gap: 0.4rem; + grid-row-gap: 1.2rem; + } - .character-gallery th, .character-gallery td { - padding: 8px; - } + .character-container { + cursor: pointer; + text-align: center; + position: relative; + opacity: 0.75; + } - .character-gallery img { - width: 150px; - height: 200px; - object-fit: cover; - } + .character-container:hover { + opacity: 1; + } - .character-gallery .placeholder { - width: 150px; - height: 200px; - background-color: gray; - } - - .character-gallery tr { - cursor: pointer; - } - - .character-gallery .image-td { - width: 150px; - } - - .character-gallery .character-td { - text-align: center !important; - } + .character-container .placeholder, .character-container img { + width: 150px; + height: 200px; + background-color: gray; + object-fit: cover; + margin: 0 auto; + border-radius: 1rem; + border: 3px solid white; + box-shadow: 5px 5px 2px 0px rgb(0 0 0 / 50%); + } + .character-name { + margin-top: 0.2rem; + display: block; + font-size: 1.2rem; + font-weight: 600; + } """ - table_html = f'" + container_html += f'{image_html} {character}' + container_html += "" - return table_html + container_html += "" + return container_html def ui(): with gr.Accordion("Character gallery"): From 44fd6bce34ed27b1b842201056d1187a89d68a97 Mon Sep 17 00:00:00 2001 From: conanak99 Date: Mon, 27 Feb 2023 22:26:19 +0800 Subject: [PATCH 2/4] make the grid responsive --- extensions/gallery/script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 5e0da084..3743dd04 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -10,7 +10,7 @@ def generate_html(): .character-gallery { margin: 1rem 0; display: grid; - grid-template-columns: repeat(4, 1fr); + grid-template-columns: repeat(4, minmax(150px, 1fr)); grid-column-gap: 0.4rem; grid-row-gap: 1.2rem; } From b5e31c8fef2e7f32f6e459ad830f0530d8ce7d14 Mon Sep 17 00:00:00 2001 From: conanak99 Date: Mon, 27 Feb 2023 22:30:52 +0800 Subject: [PATCH 3/4] fix responsive issue --- extensions/gallery/script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 3743dd04..91c79c8c 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -10,7 +10,7 @@ def generate_html(): .character-gallery { margin: 1rem 0; display: grid; - grid-template-columns: repeat(4, minmax(150px, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); grid-column-gap: 0.4rem; grid-row-gap: 1.2rem; } From 9c7fe2ec5d956b6ae9e083cf2931ff563301b0ed Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 27 Feb 2023 11:46:15 -0300 Subject: [PATCH 4/4] Handle overflows in character names --- extensions/gallery/script.py | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/gallery/script.py b/extensions/gallery/script.py index 91c79c8c..a1ec5481 100644 --- a/extensions/gallery/script.py +++ b/extensions/gallery/script.py @@ -42,6 +42,7 @@ def generate_html(): display: block; font-size: 1.2rem; font-weight: 600; + overflow-wrap: anywhere; } """