Add Negative Prompt field

This commit is contained in:
Danny McGee
2024-02-28 04:26:54 -05:00
parent ca68a64ab3
commit ac9d6901b3
3 changed files with 96 additions and 34 deletions
+26 -5
View File
@@ -73,8 +73,9 @@
border-radius: 0.5rem; border-radius: 0.5rem;
} }
.config-prompt { .config-prompts {
display: flex; display: flex;
flex-direction: column;
gap: 0.5rem; gap: 0.5rem;
} }
@@ -118,10 +119,6 @@
color: #FFFF; color: #FFFF;
} }
&.prompt {
width: 512px;
}
&.seed { &.seed {
width: 96px; width: 96px;
appearance: textfield; appearance: textfield;
@@ -134,8 +131,32 @@
} }
} }
.prompt {
flex: 1 0 0;
}
.config-field-group { .config-field-group {
display: flex;
align-items: center;
gap: 0.5rem;
position: relative; position: relative;
.pre-icon {
&.red {
color: rgb(220, 53, 69);
font-size: 1.333rem;
}
&.green {
color: rgb(25, 135, 84);
font-size: 1.15rem;
}
}
}
.config-row {
display: flex;
width: 768px;
gap: 0.5rem;
} }
.seed-refresh { .seed-refresh {
+62 -29
View File
@@ -29,6 +29,7 @@ export class AppElement extends LitElement {
@state() loading = true; @state() loading = true;
@state() prompt = ""; @state() prompt = "";
@state() negPrompt = "";
@state() seed = randomSeed(); @state() seed = randomSeed();
protected override createRenderRoot = () => this; protected override createRenderRoot = () => this;
@@ -41,10 +42,16 @@ export class AppElement extends LitElement {
} }
protected override willUpdate(changes: PropertyValues<this>): void { protected override willUpdate(changes: PropertyValues<this>): void {
if (changes.has("prompt") || changes.has("seed") || changes.has("imageCaptureUrl")) { if (
changes.has("prompt")
|| changes.has("negPrompt")
|| changes.has("seed")
|| changes.has("imageCaptureUrl")
) {
// TODO: Send parameters to model // TODO: Send parameters to model
console.log("changes:", { console.log("changes:", {
prompt: this.prompt, prompt: this.prompt,
negPrompt: this.negPrompt,
seed: this.seed, seed: this.seed,
imageCaptureUrl: this.imageCaptureUrl, imageCaptureUrl: this.imageCaptureUrl,
}); });
@@ -91,6 +98,10 @@ export class AppElement extends LitElement {
this.prompt = (event.target as HTMLInputElement).value; this.prompt = (event.target as HTMLInputElement).value;
} }
updateNegPrompt(event: Event): void {
this.negPrompt = (event.target as HTMLInputElement).value;
}
refreshSeed(): void { refreshSeed(): void {
this.seed = randomSeed(); this.seed = randomSeed();
} }
@@ -164,39 +175,61 @@ export class AppElement extends LitElement {
<div class="image-capture placeholder"></div> <div class="image-capture placeholder"></div>
`} `}
<div class="config config-prompt h-center v-end" <div class="config config-prompts h-center v-end"
@keydown=${this.stopTextInputBubbling} @keydown=${this.stopTextInputBubbling}
@keyup=${this.stopTextInputBubbling} @keyup=${this.stopTextInputBubbling}
> >
<input <div class="config-field-group prompt">
class="config-field prompt" <sts-icon class="pre-icon green" icon="check"></sts-icon>
type="text"
aria-label="Prompt"
placeholder="Enter a prompt to customize the output"
.value=${this.prompt}
@change=${this.updatePrompt}
@keydown=${(event: KeyboardEvent) => {
if (event.key === "Enter") {
event.preventDefault();
this.updatePrompt(event);
}
}}
/>
<div class="config-field-group">
<input <input
class="config-field seed" class="config-field prompt"
type="number" type="text"
aria-label="Seed" aria-label="Affirmative Prompt"
.value=${this.seed.toString()} placeholder="Enter an affirmative prompt to customize the output"
min="1" .value=${this.prompt}
max="99999" @change=${this.updatePrompt}
@keydown=${(event: KeyboardEvent) => {
if (event.key === "Enter") {
event.preventDefault();
this.updatePrompt(event);
}
}}
/> />
<button </div>
class="seed-refresh" <div class="config-row">
@click=${this.refreshSeed} <div class="config-field-group prompt">
> <sts-icon class="pre-icon red" icon="xmark"></sts-icon>
<sts-icon icon="rotate"></sts-icon> <input
</button> class="config-field prompt"
type="text"
aria-label="Negative Prompt"
placeholder="Enter a negative prompt to customize the output"
.value=${this.negPrompt}
@change=${this.updateNegPrompt}
@keydown=${(event: KeyboardEvent) => {
if (event.key === "Enter") {
event.preventDefault();
this.updateNegPrompt(event);
}
}}
/>
</div>
<div class="config-field-group">
<input
class="config-field seed"
type="number"
aria-label="Seed"
.value=${this.seed.toString()}
min="1"
max="99999"
/>
<button
class="seed-refresh"
@click=${this.refreshSeed}
>
<sts-icon icon="rotate"></sts-icon>
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
+8
View File
@@ -24,6 +24,10 @@ import fasFloppyDisk from "@fortawesome/fontawesome-pro/svgs/solid/floppy-disk.s
import farSkeleton from "@fortawesome/fontawesome-pro/svgs/regular/skeleton.svg?raw"; import farSkeleton from "@fortawesome/fontawesome-pro/svgs/regular/skeleton.svg?raw";
import farBone from "@fortawesome/fontawesome-pro/svgs/regular/bone.svg?raw"; import farBone from "@fortawesome/fontawesome-pro/svgs/regular/bone.svg?raw";
import fasBrightness from "@fortawesome/fontawesome-pro/svgs/solid/brightness.svg?raw"; import fasBrightness from "@fortawesome/fontawesome-pro/svgs/solid/brightness.svg?raw";
import fasCheck from "@fortawesome/fontawesome-pro/svgs/solid/check.svg?raw";
import fasXmark from "@fortawesome/fontawesome-pro/svgs/solid/xmark.svg?raw";
import fasCircleCheck from "@fortawesome/fontawesome-pro/svgs/solid/circle-check.svg?raw";
import fasCircleXmark from "@fortawesome/fontawesome-pro/svgs/solid/circle-xmark.svg?raw";
import styles from "./icon.element.scss?inline"; import styles from "./icon.element.scss?inline";
@@ -53,7 +57,10 @@ function renderSvg(iconId: string) {
"bone": () => farBone, "bone": () => farBone,
"bwd-fast": () => fasBwdFast, "bwd-fast": () => fasBwdFast,
"bwd-step": () => fasBwdStep, "bwd-step": () => fasBwdStep,
"check": () => fasCheck,
"circle-check": () => fasCircleCheck,
"circle-question": () => fasCircleQuestion, "circle-question": () => fasCircleQuestion,
"circle-xmark": () => fasCircleXmark,
"caret-right": () => fasCaretRight, "caret-right": () => fasCaretRight,
"crosshairs": () => farCrosshairs, "crosshairs": () => farCrosshairs,
"cube": () => farCube, "cube": () => farCube,
@@ -70,6 +77,7 @@ function renderSvg(iconId: string) {
"skeleton": () => farSkeleton, "skeleton": () => farSkeleton,
"up-down-left-right": () => farUpDownLeftRight, "up-down-left-right": () => farUpDownLeftRight,
"video": () => farVideo, "video": () => farVideo,
"xmark": () => fasXmark,
_: () => null, _: () => null,
}); });