You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

button-multi.vue 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template lang="pug">
  2. .form--step.button-multi
  3. header.f-row
  4. p {{selected.length}} | {{selected.length == opts.length}}
  5. p
  6. span(v-for="sel in selected") {{ sel }}&nbsp;
  7. main.f-col(v-for="(op, i) in opts" :class="[{ 'selected': selected.length == i }, `step-${i}`, 'step']")
  8. button(v-for="val in op" @click="selectOption(i, val)") {{ val }}
  9. main(v-if="opts.length == selected.length").selected
  10. button(@click="next") next
  11. </template>
  12. <script setup>
  13. import { defineProps, defineEmits, ref } from 'vue'
  14. const emit = defineEmits(['selected', 'next'])
  15. const props = defineProps({
  16. opts: {
  17. required: true,
  18. type: Array,
  19. default: () => [
  20. ['up', 'down'],
  21. ['left', 'right'],
  22. ],
  23. },
  24. })
  25. const selected = ref([])
  26. const selectOption = (step, optionVal) => {
  27. selected.value[step] = optionVal
  28. emit('selected', selected.value)
  29. }
  30. const next = () => {
  31. emit('next', selected.value)
  32. selected.value = []
  33. }
  34. </script>
  35. <style lang="postcss">
  36. // prettier-ignore
  37. @import '@/sss/theme.sss'
  38. .button-multi
  39. color: white
  40. .step
  41. flex-wrap: wrap
  42. display: none
  43. &.selected
  44. display: block
  45. button
  46. padding: 1em
  47. border: 2px teal solid
  48. border-radius: 4px
  49. &.selected
  50. border: 2px teal dotted
  51. </style>