Modal.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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" v-on:click="closeCurrentModal()"></button>
  8. </header>
  9. <section class="modal-card-body">
  10. <slot name="body"></slot>
  11. </section>
  12. <!-- v-if="_slotContents['footer'] != null" -->
  13. <footer class="modal-card-foot">
  14. <slot name="footer"></slot>
  15. </footer>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import { mapActions } from "vuex";
  21. export default {
  22. props: {
  23. title: { type: String }
  24. },
  25. methods: {
  26. toCamelCase: str => {
  27. return str
  28. .toLowerCase()
  29. .replace(/[-_]+/g, " ")
  30. .replace(/[^\w\s]/g, "")
  31. .replace(/ (.)/g, function($1) {
  32. return $1.toUpperCase();
  33. })
  34. .replace(/ /g, "");
  35. },
  36. ...mapActions("modals", ["closeCurrentModal"])
  37. },
  38. mounted: function() {
  39. this.type = this.toCamelCase(this.title);
  40. }
  41. };
  42. </script>