File size: 751 Bytes
0914710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<template>
  <dl class="grid md:pt-1 md:pb-1" v-for="item in props.stringArray" v-bind:key="item">
    <div class="flex flex-col bg-blue-100 text-center m-1">
      <button
        class="text-xs font-thin"
        @click="emitPrompt(item)"
      >
        {{ item }}
      </button>
    </div>
  </dl>
</template>

<script setup lang="ts">
const props = defineProps<{
  stringArray: Array<string>,
  stringPrefix: string
}>()
console.log(props)
const emit = defineEmits(['set-prompt'])

const concatStringIf = (a: string, b: string, separator: string) => {
  return a ? a.concat(separator, b) : b
}

const emitPrompt = (s: string) => {
  const updatedString = concatStringIf(props.stringPrefix, s, ' ')
  emit("set-prompt", updatedString)
}
</script>