Modal.vue 971 B

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