ModalWindow.vue 1.3 KB

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