Content.vue
171 lines
| 1 | <template> |
| 2 | <div class="am-cat__wrapper" :class="wrapperClass" role="main"> |
| 3 | <div ref="catHeader" class="am-cat__header"> |
| 4 | <slot name="header"></slot> |
| 5 | </div> |
| 6 | <div ref="catContainer" class="am-cat__main"> |
| 7 | <slot name="side"></slot> |
| 8 | <div ref="catForm" class="am-cat__form" :class="formClass" :style="cssVars"> |
| 9 | <div ref="catHeading" class="am-cat__heading" :class="headingClass"> |
| 10 | <slot name="heading"></slot> |
| 11 | </div> |
| 12 | |
| 13 | <div ref="catContent" class="am-cat__content" :class="contentClass"> |
| 14 | <slot name="content"></slot> |
| 15 | </div> |
| 16 | </div> |
| 17 | </div> |
| 18 | </div> |
| 19 | </template> |
| 20 | |
| 21 | <script setup> |
| 22 | import { inject, ref, onMounted, onBeforeUnmount, computed, nextTick } from 'vue' |
| 23 | import { useColorTransparency } from '../../../../assets/js/common/colorManipulation' |
| 24 | |
| 25 | defineProps({ |
| 26 | wrapperClass: { |
| 27 | type: String, |
| 28 | default: '', |
| 29 | }, |
| 30 | formClass: { |
| 31 | type: String, |
| 32 | default: '', |
| 33 | }, |
| 34 | headingClass: { |
| 35 | type: String, |
| 36 | default: '', |
| 37 | }, |
| 38 | contentClass: { |
| 39 | type: String, |
| 40 | default: '', |
| 41 | }, |
| 42 | }) |
| 43 | |
| 44 | let catHeader = ref(null) |
| 45 | let catHeaderWidth = ref(0) |
| 46 | |
| 47 | let catContainer = ref(null) |
| 48 | let catContainerWidth = ref(0) |
| 49 | |
| 50 | let catForm = ref(null) |
| 51 | let catFormWidth = ref(0) |
| 52 | |
| 53 | let catHeading = ref(null) |
| 54 | // let catHeadingWidth = ref(0) |
| 55 | |
| 56 | let catContent = ref(null) |
| 57 | |
| 58 | let scrollBlockHeight = ref(0) |
| 59 | |
| 60 | // * resize function |
| 61 | function resize() { |
| 62 | nextTick(() => { |
| 63 | if (catHeader.value) { |
| 64 | catHeaderWidth.value = catHeader.value.offsetWidth |
| 65 | } |
| 66 | |
| 67 | if (catContainer.value) { |
| 68 | catContainerWidth.value = catContainer.value.offsetWidth |
| 69 | } |
| 70 | |
| 71 | if (catForm.value) { |
| 72 | catFormWidth.value = catForm.value.offsetWidth |
| 73 | } |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | onMounted(() => { |
| 78 | // * window resize listener |
| 79 | window.addEventListener('resize', resize) |
| 80 | |
| 81 | nextTick(() => { |
| 82 | if (catForm.value && catHeading.value) { |
| 83 | let height = catForm.value.offsetHeight - catHeading.value.offsetHeight - 2 |
| 84 | scrollBlockHeight.value = height <= 656 ? 656 : height |
| 85 | } |
| 86 | |
| 87 | resize() |
| 88 | }) |
| 89 | }) |
| 90 | |
| 91 | onBeforeUnmount(() => { |
| 92 | window.removeEventListener('resize', resize) |
| 93 | }) |
| 94 | |
| 95 | defineExpose({ |
| 96 | catHeaderWidth, |
| 97 | catFormWidth, |
| 98 | catContainerWidth, |
| 99 | }) |
| 100 | |
| 101 | // * Colors |
| 102 | let amColors = inject('amColors') |
| 103 | |
| 104 | let cssVars = computed(() => { |
| 105 | return { |
| 106 | '--am-h-cat-content': `${scrollBlockHeight.value}px`, |
| 107 | '--am-c-scroll-op30': useColorTransparency(amColors.value.colorPrimary, 0.3), |
| 108 | '--am-c-scroll-op10': useColorTransparency(amColors.value.colorPrimary, 0.1), |
| 109 | } |
| 110 | }) |
| 111 | </script> |
| 112 | |
| 113 | <script> |
| 114 | export default { |
| 115 | name: 'MainContent', |
| 116 | } |
| 117 | </script> |
| 118 | |
| 119 | <style lang="scss"> |
| 120 | @mixin catalog-content { |
| 121 | .am-cat { |
| 122 | &__wrapper { |
| 123 | --am-c-cat-main-bgr: var(--am-c-main-bgr); |
| 124 | width: 100%; |
| 125 | background-color: var(--am-c-main-bgr); |
| 126 | } |
| 127 | |
| 128 | &__main { |
| 129 | max-width: 100%; |
| 130 | width: 100%; |
| 131 | display: flex; |
| 132 | flex-direction: row; |
| 133 | } |
| 134 | |
| 135 | &__form { |
| 136 | width: 100%; |
| 137 | } |
| 138 | |
| 139 | &__content { |
| 140 | max-height: var(--am-h-cat-content); |
| 141 | overflow-x: hidden; |
| 142 | |
| 143 | // Main Scroll styles |
| 144 | &::-webkit-scrollbar { |
| 145 | width: 6px; |
| 146 | } |
| 147 | |
| 148 | &::-webkit-scrollbar-thumb { |
| 149 | border-radius: 6px; |
| 150 | background: var(--am-c-scroll-op30); |
| 151 | } |
| 152 | |
| 153 | &::-webkit-scrollbar-track { |
| 154 | border-radius: 6px; |
| 155 | background: var(--am-c-scroll-op10); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // Public |
| 162 | .amelia-v2-booking #amelia-container { |
| 163 | @include catalog-content; |
| 164 | } |
| 165 | |
| 166 | // Admin |
| 167 | #amelia-app-backend-new #amelia-container { |
| 168 | @include catalog-content; |
| 169 | } |
| 170 | </style> |
| 171 |