feat: adds preview overlay for styles (#1762)
* feat: adds preview overlay for styles * fix: implement correct path resolution for all OS solves issues for Windows * fix: makes preview overlay also work with other languages * feat: scale down images to 258x200, fix aspect ratio in css reduces file size from 19,6MB to 3,4MB * fix: adjust z-index to correctly overlay gradio border pulse when generating images * update files * version --------- Co-authored-by: Manuel Schmid <9307310+mashb1t@users.noreply.github.com> Co-authored-by: Manuel Schmid <manuel.schmid@odt.net> Co-authored-by: lllyasviel <lyuminzhang@outlook.com>
@ -196,3 +196,18 @@
|
||||
pointer-events: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#stylePreviewOverlay {
|
||||
display: none;
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
border: solid 1px lightgrey;
|
||||
transform: translate(-140px, 20px);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border-radius: 5px;
|
||||
z-index: 100;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
version = '2.1.860'
|
||||
version = '2.1.861'
|
||||
|
@ -45,6 +45,9 @@ function processTextNode(node) {
|
||||
var tl = getTranslation(text);
|
||||
if (tl !== undefined) {
|
||||
node.textContent = tl;
|
||||
if (text && node.parentElement) {
|
||||
node.parentElement.setAttribute("data-original-text", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||
}
|
||||
});
|
||||
mutationObserver.observe(gradioApp(), {childList: true, subtree: true});
|
||||
initStylePreviewOverlay();
|
||||
});
|
||||
|
||||
/**
|
||||
@ -145,6 +146,39 @@ document.addEventListener('keydown', function(e) {
|
||||
}
|
||||
});
|
||||
|
||||
function initStylePreviewOverlay() {
|
||||
let overlayVisible = false;
|
||||
const samplesPath = document.querySelector("meta[name='samples-path']").getAttribute("content")
|
||||
const overlay = document.createElement('div');
|
||||
overlay.id = 'stylePreviewOverlay';
|
||||
document.body.appendChild(overlay);
|
||||
document.addEventListener('mouseover', function(e) {
|
||||
const label = e.target.closest('.style_selections label');
|
||||
if (!label) return;
|
||||
label.removeEventListener("mouseout", onMouseLeave);
|
||||
label.addEventListener("mouseout", onMouseLeave);
|
||||
overlayVisible = true;
|
||||
overlay.style.display = "block";
|
||||
const originalText = label.querySelector("span").getAttribute("data-original-text");
|
||||
const name = originalText || label.querySelector("span").textContent;
|
||||
overlay.style.backgroundImage = `url("${samplesPath.replace(
|
||||
"fooocus_v2",
|
||||
name.toLowerCase().replaceAll(" ", "_")
|
||||
)}")`;
|
||||
function onMouseLeave() {
|
||||
overlayVisible = false;
|
||||
overlay.style.display = "none";
|
||||
overlay.style.backgroundImage = "";
|
||||
label.removeEventListener("mouseout", onMouseLeave);
|
||||
}
|
||||
});
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
if(!overlayVisible) return;
|
||||
overlay.style.left = `${e.clientX}px`;
|
||||
overlay.style.top = `${e.clientY}px`;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* checks that a UI element is not in another hidden element or tab content
|
||||
*/
|
||||
|
@ -30,6 +30,7 @@ def javascript_html():
|
||||
edit_attention_js_path = webpath('javascript/edit-attention.js')
|
||||
viewer_js_path = webpath('javascript/viewer.js')
|
||||
image_viewer_js_path = webpath('javascript/imageviewer.js')
|
||||
samples_path = webpath(os.path.abspath('./sdxl_styles/samples/fooocus_v2.jpg'))
|
||||
head = f'<script type="text/javascript">{localization_js(args_manager.args.language)}</script>\n'
|
||||
head += f'<script type="text/javascript" src="{script_js_path}"></script>\n'
|
||||
head += f'<script type="text/javascript" src="{context_menus_js_path}"></script>\n'
|
||||
@ -38,6 +39,7 @@ def javascript_html():
|
||||
head += f'<script type="text/javascript" src="{edit_attention_js_path}"></script>\n'
|
||||
head += f'<script type="text/javascript" src="{viewer_js_path}"></script>\n'
|
||||
head += f'<script type="text/javascript" src="{image_viewer_js_path}"></script>\n'
|
||||
head += f'<meta name="samples-path" content="{samples_path}"></meta>\n'
|
||||
|
||||
if args_manager.args.theme:
|
||||
head += f'<script type="text/javascript">set_theme(\"{args_manager.args.theme}\");</script>\n'
|
||||
|
BIN
sdxl_styles/samples/Academia.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
sdxl_styles/samples/Baroque.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
sdxl_styles/samples/Caricature.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/Constructivism.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
sdxl_styles/samples/Cubism.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
sdxl_styles/samples/Dadaism.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
sdxl_styles/samples/Expressionism.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
sdxl_styles/samples/Fauvism.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
sdxl_styles/samples/Futurism.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
sdxl_styles/samples/Glitchcore.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
sdxl_styles/samples/Idyllic.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/Impressionism.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
sdxl_styles/samples/Medievalism.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
sdxl_styles/samples/Minimalism.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sdxl_styles/samples/Neoclassicism.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
sdxl_styles/samples/Rococo.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
sdxl_styles/samples/Sketchup.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
sdxl_styles/samples/Suprematism.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/Surrealism.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/Terragen.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
sdxl_styles/samples/abstract_expressionism.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
sdxl_styles/samples/action_figure.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
sdxl_styles/samples/adorable_3d_character.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
sdxl_styles/samples/adorable_kawaii.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/ads_advertising.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/ads_automotive.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sdxl_styles/samples/ads_corporate.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
sdxl_styles/samples/ads_fashion_editorial.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
sdxl_styles/samples/ads_food_photography.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/ads_gourmet_food_photography.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
sdxl_styles/samples/ads_luxury.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
sdxl_styles/samples/ads_real_estate.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/ads_retail.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
sdxl_styles/samples/art_deco.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
sdxl_styles/samples/art_nouveau.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
sdxl_styles/samples/artstyle_abstract.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
sdxl_styles/samples/artstyle_abstract_expressionism.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
sdxl_styles/samples/artstyle_art_deco.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
sdxl_styles/samples/artstyle_art_nouveau.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
sdxl_styles/samples/artstyle_constructivist.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
sdxl_styles/samples/artstyle_cubist.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/artstyle_expressionist.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
sdxl_styles/samples/artstyle_graffiti.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
sdxl_styles/samples/artstyle_hyperrealism.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/artstyle_impressionist.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
sdxl_styles/samples/artstyle_pointillism.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
sdxl_styles/samples/artstyle_pop_art.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
sdxl_styles/samples/artstyle_psychedelic.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
sdxl_styles/samples/artstyle_renaissance.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/artstyle_steampunk.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/artstyle_surrealist.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
sdxl_styles/samples/artstyle_typography.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
sdxl_styles/samples/artstyle_watercolor.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
sdxl_styles/samples/astral_aura.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
sdxl_styles/samples/avant_garde.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
sdxl_styles/samples/bauhaus_style_poster.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/blueprint_schematic_drawing.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sdxl_styles/samples/cel_shaded_art.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/character_design_sheet.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
sdxl_styles/samples/cinematic_diva.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
sdxl_styles/samples/classicism_art.jpg
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
sdxl_styles/samples/color_field_painting.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/colored_pencil_art.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
sdxl_styles/samples/conceptual_art.jpg
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
sdxl_styles/samples/dark_fantasy.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/dark_moody_atmosphere.jpg
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
sdxl_styles/samples/dmt_art_style.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
sdxl_styles/samples/doodle_art.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/double_exposure.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/dripping_paint_splatter_art.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
sdxl_styles/samples/faded_polaroid_photo.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/flat_2d_art.jpg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
sdxl_styles/samples/fooocus_cinematic.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/fooocus_enhance.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/fooocus_masterpiece.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/fooocus_negative.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/fooocus_photograph.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/fooocus_sharp.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/fooocus_v2.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
sdxl_styles/samples/fortnite_art_style.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
sdxl_styles/samples/futuristic_biomechanical.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/futuristic_biomechanical_cyberpunk.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/futuristic_cybernetic.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
sdxl_styles/samples/futuristic_cybernetic_robot.jpg
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
sdxl_styles/samples/futuristic_cyberpunk_cityscape.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
sdxl_styles/samples/futuristic_futuristic.jpg
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
sdxl_styles/samples/futuristic_retro_cyberpunk.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
sdxl_styles/samples/futuristic_retro_futurism.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
sdxl_styles/samples/futuristic_sci_fi.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
sdxl_styles/samples/futuristic_vaporwave.jpg
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
sdxl_styles/samples/game_bubble_bobble.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
sdxl_styles/samples/game_cyberpunk_game.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
sdxl_styles/samples/game_fighting_game.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
sdxl_styles/samples/game_gta.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
sdxl_styles/samples/game_mario.jpg
Normal file
After Width: | Height: | Size: 22 KiB |