Modal.vue 981 B

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