Modal.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. <h2 class="modal-card-title is-marginless">
  7. {{ title }}
  8. </h2>
  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>
  42. <style lang="scss" scoped>
  43. .modal-card {
  44. width: 800px;
  45. }
  46. p {
  47. font-size: 17px;
  48. }
  49. .modal-card-title {
  50. font-size: 27px;
  51. }
  52. </style>