Header.vue
161 lines
| 1 | <template> |
| 2 | <div class="am-cat__header-inner"> |
| 3 | <div class="am-cat__back-btn"> |
| 4 | <AmButton |
| 5 | v-if="props.backBtnVisibility" |
| 6 | :prefix="arrowLeft" |
| 7 | category="secondary" |
| 8 | :type="btnType" |
| 9 | :size="btnSize" |
| 10 | @click="goBack" |
| 11 | > |
| 12 | {{props.btnString}} |
| 13 | </AmButton> |
| 14 | </div> |
| 15 | <div |
| 16 | v-if="props.cartBtnVisibility" |
| 17 | class="am-cat__cart-btn" |
| 18 | > |
| 19 | <span class="am-cat__cart-number"> |
| 20 | {{props.cartItemsNumber}} |
| 21 | </span> |
| 22 | <AmButton |
| 23 | category="secondary" |
| 24 | :type="btnType" |
| 25 | :size="btnSize" |
| 26 | :round="true" |
| 27 | :icon-only="true" |
| 28 | :icon="iconCart" |
| 29 | @click="goToCart" |
| 30 | > |
| 31 | </AmButton> |
| 32 | </div> |
| 33 | </div> |
| 34 | </template> |
| 35 | |
| 36 | <script setup> |
| 37 | import AmButton from '../../../_components/button/AmButton.vue' |
| 38 | import IconComponent from '../../../_components/icons/IconComponent.vue' |
| 39 | |
| 40 | import { |
| 41 | defineComponent |
| 42 | } from "vue" |
| 43 | import {useStore} from "vuex"; |
| 44 | // * import composable |
| 45 | import { |
| 46 | useRemoveLastCartItem, |
| 47 | } from '../../../../assets/js/public/cart' |
| 48 | |
| 49 | let props = defineProps({ |
| 50 | btnString: { |
| 51 | type: String, |
| 52 | default: '' |
| 53 | }, |
| 54 | btnType: { |
| 55 | type: String, |
| 56 | default: 'plain' |
| 57 | }, |
| 58 | btnSize: { |
| 59 | type: String, |
| 60 | default: 'mini' |
| 61 | }, |
| 62 | backBtnVisibility: { |
| 63 | type: Boolean, |
| 64 | default: true |
| 65 | }, |
| 66 | cartBtnVisibility: { |
| 67 | type: Boolean, |
| 68 | default: false |
| 69 | }, |
| 70 | cartItemsNumber: { |
| 71 | type: Number, |
| 72 | default: 0 |
| 73 | } |
| 74 | }) |
| 75 | |
| 76 | let arrowLeft = defineComponent({ |
| 77 | components: {IconComponent}, |
| 78 | template: `<IconComponent icon="arrow-left"></IconComponent>` |
| 79 | }) |
| 80 | |
| 81 | let iconCart = defineComponent({ |
| 82 | components: {IconComponent}, |
| 83 | template: `<IconComponent icon="cart"/>` |
| 84 | }) |
| 85 | |
| 86 | let emits = defineEmits(['goBack', 'goToCart']) |
| 87 | |
| 88 | function goBack() { |
| 89 | emits('goBack') |
| 90 | } |
| 91 | |
| 92 | const store = useStore() |
| 93 | |
| 94 | function goToCart() { |
| 95 | useRemoveLastCartItem(store) |
| 96 | |
| 97 | emits('goToCart') |
| 98 | } |
| 99 | </script> |
| 100 | |
| 101 | <script> |
| 102 | export default { |
| 103 | name: "MainHeader" |
| 104 | } |
| 105 | </script> |
| 106 | |
| 107 | <style lang="scss"> |
| 108 | @mixin catalog-header { |
| 109 | .am-cat { |
| 110 | &__header { |
| 111 | &-inner { |
| 112 | display: flex; |
| 113 | align-items: center; |
| 114 | justify-content: space-between; |
| 115 | width: 100%; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | &__back-btn { |
| 120 | width: 100%; |
| 121 | } |
| 122 | |
| 123 | &__cart { |
| 124 | &-btn { |
| 125 | position: relative; |
| 126 | |
| 127 | .am-icon-cart { |
| 128 | font-size: 24px; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | &-number { |
| 133 | position: absolute; |
| 134 | top: -6px; |
| 135 | left: -6px; |
| 136 | width: 18px; |
| 137 | height: 18px; |
| 138 | display: flex; |
| 139 | align-items: center; |
| 140 | justify-content: center; |
| 141 | font-size: 12px; |
| 142 | line-height: 1; |
| 143 | border-radius: 50%; |
| 144 | background-color: var(--am-c-error); |
| 145 | color: var(--am-c-cat-main-bgr); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // Public |
| 152 | .amelia-v2-booking #amelia-container { |
| 153 | @include catalog-header; |
| 154 | } |
| 155 | |
| 156 | // Admin |
| 157 | #amelia-app-backend-new #amelia-container { |
| 158 | @include catalog-header; |
| 159 | } |
| 160 | </style> |
| 161 |