MenuButton.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class='menu_button'>
  3. <div class='menu_button__overlay' :class='{ "menu_button__overlay--show": show }' @click='setShow(false)'></div>
  4. <div class='menu_button__icon' @click='setShow(true)'>
  5. <slot ></slot>
  6. </div>
  7. <div class='menu_button__options' :class='{ "menu_button__options--show": show }'>
  8. <div
  9. class='menu_button__option'
  10. v-for='(option, $index) in options'
  11. @click='emit(option)'
  12. :style="{ 'border-bottom' : $index === options.length-1 ? 'none' : 'solid thin rgb(245, 245, 245)' }"
  13. >
  14. {{option}}
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'MenuButton',
  22. props: ['options'],
  23. data () {
  24. return {
  25. show: false
  26. }
  27. },
  28. methods: {
  29. setShow (val) {
  30. this.show = val
  31. },
  32. emit (option) {
  33. this.$emit(option)
  34. this.setShow(false)
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang='scss' scoped>
  40. @import '../assets/scss/variables.scss';
  41. .menu_button {
  42. position: relative;
  43. @at-root #{&}__overlay {
  44. position: fixed;
  45. width: 100%;
  46. height: 100%;
  47. left: 0;
  48. top: 0;
  49. z-index: 2;
  50. pointer-events: none;
  51. @at-root #{&}--show {
  52. pointer-events: all;
  53. }
  54. }
  55. @at-root #{&}__options {
  56. position: absolute;
  57. background-color: #fff;
  58. width: 10rem;
  59. border-radius: 0.125rem;
  60. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.03), 0 3px 6px rgba(0, 0, 0, 0.06);
  61. z-index: 3;
  62. border: 0.125rem solid $color__gray--darker;
  63. pointer-events: none;
  64. transform: perspective( 600 ) rotateX( 15deg );
  65. -webkit-transform: perspective( 600 ) rotateX( 15deg );
  66. opacity: 0;
  67. margin-top: -1rem;
  68. transition: all 0.25s;
  69. top: 0.25rem;
  70. left: 0;
  71. @at-root #{&}--show {
  72. opacity: 1;
  73. transform: perspective( 0 ) rotateX( 0 );
  74. -webkit-transform: perspective( 0 ) rotateX( 0 );
  75. margin-top: 0;
  76. pointer-events: all;
  77. }
  78. }
  79. @at-root #{&}__option {
  80. padding: 0.5rem;
  81. font-size: 0.9rem;
  82. cursor: default;
  83. transition: all 0.2s;
  84. &:hover { background-color: $color__lightgray--primary; }
  85. &:active { background-color: $color__lightgray--darker; }
  86. }
  87. }
  88. </style>