Modal.vue 935 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <div class='modal is-active'>
  3. <div class='modal-background'></div>
  4. <div class='modal-card'>
  5. <header class='modal-card-head'>
  6. <p class='modal-card-title'>{{ title }}</p>
  7. <button class='delete' @click='$parent.$parent.modals[this.type] = !$parent.$parent.modals[this.type]'></button>
  8. </header>
  9. <section class='modal-card-body'>
  10. <slot name='body'></slot>
  11. </section>
  12. <footer class='modal-card-foot' v-if='_slotContents["footer"] != null'>
  13. <slot name='footer'></slot>
  14. </footer>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. title: { type: String }
  22. },
  23. methods: {
  24. toCamelCase: str => {
  25. return str.toLowerCase()
  26. .replace(/[-_]+/g, ' ')
  27. .replace(/[^\w\s]/g, '')
  28. .replace(/ (.)/g, function($1) { return $1.toUpperCase(); })
  29. .replace(/ /g, '');
  30. }
  31. },
  32. ready: function () {
  33. this.type = this.toCamelCase(this.title);
  34. }
  35. }
  36. </script>