mishig HF staff commited on
Commit
8b608ba
1 Parent(s): c0104ce

Auto resizing input elt

Browse files
Files changed (1) hide show
  1. src/routes/+page.svelte +22 -9
src/routes/+page.svelte CHANGED
@@ -289,6 +289,9 @@
289
  }
290
 
291
  function onKeyDown(e: KeyboardEvent) {
 
 
 
292
  if (e.code === 'Enter') {
293
  e.preventDefault();
294
  submitRequest();
@@ -379,15 +382,18 @@
379
  <div id="board-container" bind:this={canvasContainerEl} />
380
  {#if canvas}
381
  <div>
382
- <div class="flex gap-x-2 mt-3 items-center justify-center {isLoading ? 'animate-pulse' : ''}">
383
- <input
384
- type="text"
385
- class="border-2 py-1"
386
- placeholder="Add prompt"
387
- maxlength="200"
388
- on:keydown={onKeyDown}
389
- bind:value={txt}
390
- />
 
 
 
391
  <button
392
  on:click={submitRequest}
393
  class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1.5 px-4"
@@ -432,3 +438,10 @@ The model is licensed with a [CreativeML Open RAIL-M](https://huggingface.co/spa
432
  ### Biases and content acknowledgment
433
  Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the [LAION-5B dataset](https://laion.ai/blog/laion-5b/), which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)
434
  </article>
 
 
 
 
 
 
 
 
289
  }
290
 
291
  function onKeyDown(e: KeyboardEvent) {
292
+ if(isLoading){
293
+ return e.preventDefault();
294
+ }
295
  if (e.code === 'Enter') {
296
  e.preventDefault();
297
  submitRequest();
 
382
  <div id="board-container" bind:this={canvasContainerEl} />
383
  {#if canvas}
384
  <div>
385
+ <div class="flex gap-x-2 mt-3 items-start justify-center {isLoading ? 'animate-pulse' : ''}">
386
+ <span
387
+ class="overflow-auto resize-y py-2 px-3 min-h-[42px] max-h-[500px] !w-[181px] whitespace-pre-wrap inline-block border border-gray-200 rounded-lg shadow-inner outline-none"
388
+ role="textbox"
389
+ contenteditable
390
+ style="--placeholder: 'Add prompt'"
391
+ spellcheck="false"
392
+ dir="auto"
393
+ maxlength="200"
394
+ bind:textContent={txt}
395
+ on:keydown={onKeyDown}
396
+ />
397
  <button
398
  on:click={submitRequest}
399
  class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-1.5 px-4"
 
438
  ### Biases and content acknowledgment
439
  Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the [LAION-5B dataset](https://laion.ai/blog/laion-5b/), which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)
440
  </article>
441
+
442
+ <style>
443
+ span[contenteditable]:empty::before {
444
+ content: var(--placeholder);
445
+ color: rgba(156, 163, 175);
446
+ }
447
+ </style>