ModalWindow.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class='modal_window__overlay' :class='{"modal_window--show": showModal}' @click.self='hideModal'>
  3. <div class='modal_window' :class='{"modal_window--show": showModal}' v-on:hideModal='hideModal'>
  4. <slot></slot>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'ModalWindow',
  11. props: ['name'],
  12. methods: {
  13. hideModal () {
  14. this.$store.commit('hideModal', this.name);
  15. }
  16. },
  17. computed: {
  18. showModal () {
  19. return this.$store.state.modals[this.name];
  20. }
  21. }
  22. }
  23. </script>
  24. <style lang='scss' scoped>
  25. @import '../assets/scss/variables.scss';
  26. .modal_window__overlay {
  27. width: 100%;
  28. height: 100%;
  29. background-color: rgba(0, 0, 0, 0.5);
  30. display: flex;
  31. align-items: center;
  32. justify-content: center;
  33. position: fixed;
  34. z-index: 2;
  35. top: 0;
  36. left: 0;
  37. opacity: 0;
  38. pointer-events: none;
  39. transition: opacity 0.3s;
  40. @at-root #{&}--show {
  41. opacity: 1;
  42. pointer-events: all;
  43. transition: opacity 0.3s;
  44. }
  45. }
  46. .modal_window {
  47. width: 20rem;
  48. background-color: #fff;
  49. margin-top: -3rem;
  50. opacity: 0;
  51. border: 0.125rem solid $color__gray--darkest;
  52. pointer-events: none;
  53. transition: margin-top 0.3s, opacity 0.3s;
  54. @at-root #{&}--show {
  55. margin-top: 0;
  56. opacity: 1;
  57. pointer-events: all;
  58. transition: all 0.3s;
  59. }
  60. }
  61. </style>