Modal.vue 943 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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, $1 => $1.toUpperCase())
  33. .replace(/ /g, "");
  34. },
  35. ...mapActions("modals", ["closeCurrentModal"])
  36. },
  37. mounted() {
  38. this.type = this.toCamelCase(this.title);
  39. }
  40. };
  41. </script>