Skip to content

Commit

Permalink
πŸ› fix(format): Fix format button and preview sticky position
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Sep 4, 2023
1 parent a2698af commit c320ec2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
19 changes: 13 additions & 6 deletions javascript/main.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/script/formatPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ export const Converter = {
*/
addPromptButton(type: string): void {
console.debug('🀯 [formatPrompt] inject', type);
const generateButton: HTMLElement | null = gradioApp().querySelector(`#${type}_generate`);
const actionsColumn: HTMLElement | null = gradioApp().querySelector(`#${type}_style_create`);
const nai2local: HTMLElement | null = gradioApp().querySelector(`#${type}_formatconvert`);
if (!generateButton || !actionsColumn || nai2local) return;
const actionsColumn: HTMLElement | null = gradioApp().querySelector(
`#${type}_tools > div.form`,
);
const formatBtn: HTMLElement | null = gradioApp().querySelector(`#${type}_formatconvert`);
if (!actionsColumn || formatBtn) return;
const convertButton: HTMLElement = Converter.createButton(`${type}_formatconvert`, 'πŸͺ„', () =>
Converter.onClickConvert(type));
actionsColumn.parentNode?.append(convertButton);
actionsColumn.append(convertButton);
},

/**
Expand Down Expand Up @@ -221,7 +222,7 @@ export const Converter = {
button.type = 'button';
button.innerHTML = innerHTML;
button.title = 'Format prompt~πŸͺ„';
button.className = 'lg secondary gradio-button tool svelte-1ipelgc';
button.className = 'lg secondary gradio-button tool svelte-cmf5ev';
button.addEventListener('click', onClick);
return button;
},
Expand Down
12 changes: 10 additions & 2 deletions src/script/replaceIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ import {
clipboardList,
cornerRightUp,
dices,
fileArchive,
folderClosed,
image,
laptop2,
panelRight,
penSquare,
pencilRuler,
pipette,
play,
refreshCcw,
ruler,
save,
settings,
trash,
Expand All @@ -35,6 +39,10 @@ const replaceIcon = (button: HTMLButtonElement, emoji: string[], svg: string) =>
export default () => {
console.time('🀯 [svgIcon] replace');
for (const button of document.querySelectorAll('button')) {
replaceIcon(button, ['πŸ–ŒοΈ'], penSquare);
replaceIcon(button, ['πŸ—ƒοΈ'], fileArchive);
replaceIcon(button, ['πŸ–ΌοΈ'], pipette);
replaceIcon(button, ['🎨️'], image);
replaceIcon(button, ['πŸ“‚'], folderClosed);
replaceIcon(button, ['πŸ”„', 'πŸ”', '♻️'], refreshCcw);
replaceIcon(button, ['↙️'], arrowDownLeft);
Expand All @@ -54,7 +62,7 @@ export default () => {
replaceIcon(button, ['πŸ’₯'], play);
replaceIcon(button, ['πŸ“·'], webcam);
replaceIcon(button, ['πŸ“'], laptop2);
replaceIcon(button, ['πŸ“'], ruler);
replaceIcon(button, ['πŸ“'], pencilRuler);
}
console.timeEnd('🀯 [svgIcon] replace');
};
6 changes: 6 additions & 0 deletions src/styles/components/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ export default (token: Theme) => {
align-items: flex-start;
justify-content: flex-start;
}
#img2img_results,
#txt2img_results,
#extras_results {
top: 80px !important;
}
`;
};

0 comments on commit c320ec2

Please sign in to comment.