File size: 2,114 Bytes
a5078bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<script lang="ts">
  import { nanoid } from "nanoid";
  import { createEventDispatcher } from "svelte";
  import type { PromptType } from "../types";
  import Prompt from "./Prompt.svelte";
  import Plus from "./Icons/Plus.svelte";
  export let classNames = "";
  export let promptsList: PromptType[] = [];
  export let min: number;
  export let max: number;
  export let step: number;

  function removeConcept(conceptToRemove: PromptType) {
    promptsList = promptsList.filter(
      (concept) => concept.id !== conceptToRemove.id
    );
  }
  function addPrompt(negative = false) {
    promptsList = [
      ...promptsList,
      {
        id: nanoid(),
        prompt: "",
        scale: 1,
        negative: negative,
      },
    ];
  }
  const dispatch = createEventDispatcher();
  // $: promptsList,
  //   dispatch("change", promptsList),
  //   dispatch("input", promptsList);
</script>

<div class="flex items-center gap-1 flex-wrap {classNames}">
  {#each promptsList as prompt}
    <Prompt
      {min}
      {max}
      {step}
      bind:prompt
      on:remove={() => removeConcept(prompt)}
      on:add={() => addPrompt()}
    />
  {/each}
  <div class="flex flex-col gap-1">
    <button
      title="Add Concept"
      class="flex items-center text-base text-black hover-text-cyan-500 dark:text-white"
      on:click={() => addPrompt(false)}
      ><Plus />
      <h2 class="text-xs font-normal px-1">Add Prompt</h2>
    </button>
  </div>
</div>

<style scoped>
  .flex {
    display: flex;
  }
  .items-center {
    align-items: center;
  }
  .gap-1 {
    gap: 0.25rem;
  }
  .flex-wrap {
    flex-wrap: wrap;
  }
  .flex-col {
    flex-direction: column;
  }
  .text-base {
    font-size: 1rem;
    line-height: 1.5rem;
  }
  .text-black {
    color: #000;
  }
  .hover-text-cyan-500:hover {
    color: #06b6d4;
  }
  @media (prefers-color-scheme: dark) {
    .dark\:text-white {
      color: #fff;
    }
  }

  .text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
  }
  .font-normal {
    font-weight: 400;
  }
  .px-1 {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
</style>