AmOptionTemplate1.vue
177 lines
| 1 | <template> |
| 2 | <span class="am-oitf__wrapper"> |
| 3 | <span class="am-oitf"> |
| 4 | <span v-if="!props.iconString" class="am-oitf__img"> |
| 5 | <span |
| 6 | class="am-oitf__img-placeholder" |
| 7 | :style="{ |
| 8 | backgroundImage: `url(${props.imageThumb})`, |
| 9 | backgroundColor: props.imageThumb |
| 10 | ? 'var(--am-c-option-bgr)' |
| 11 | : 'var(--am-c-option-img-bgr)', |
| 12 | }" |
| 13 | > |
| 14 | <span v-if="!props.imageThumb"> |
| 15 | {{ imagePlaceholder() }} |
| 16 | </span> |
| 17 | </span> |
| 18 | </span> |
| 19 | <span |
| 20 | v-if="props.iconString" |
| 21 | class="am-oitf__icon" |
| 22 | :class="`am-icon-${props.iconString}`" |
| 23 | ></span> |
| 24 | <span class="am-oitf__data"> |
| 25 | <span class="am-oitf__data-label"> |
| 26 | {{ props.label }} |
| 27 | </span> |
| 28 | <span v-if="props.price" class="am-oitf__data-price"> |
| 29 | {{ `${(props.price > 0 ? '+' : '-') + useFormattedPrice(props.price)}` }} |
| 30 | </span> |
| 31 | <span v-if="!props.price && props.priceString" class="am-oitf__data-price-string"> |
| 32 | {{ `${props.priceString}` }} |
| 33 | </span> |
| 34 | </span> |
| 35 | </span> |
| 36 | </span> |
| 37 | </template> |
| 38 | |
| 39 | <script setup> |
| 40 | import { useFormattedPrice } from '../../../../assets/js/common/formatting' |
| 41 | |
| 42 | /** |
| 43 | * Component Props |
| 44 | */ |
| 45 | let props = defineProps({ |
| 46 | identifier: { |
| 47 | type: [String, Number], |
| 48 | required: true, |
| 49 | }, |
| 50 | imageThumb: { |
| 51 | type: String, |
| 52 | default: '', |
| 53 | }, |
| 54 | label: { |
| 55 | type: [String, Number], |
| 56 | required: true, |
| 57 | }, |
| 58 | description: { |
| 59 | type: String, |
| 60 | default: '', |
| 61 | }, |
| 62 | price: { |
| 63 | type: [String, Number], |
| 64 | default: '', |
| 65 | }, |
| 66 | iconString: { |
| 67 | type: String, |
| 68 | default: '', |
| 69 | }, |
| 70 | priceString: { |
| 71 | type: String, |
| 72 | default: '', |
| 73 | }, |
| 74 | }) |
| 75 | |
| 76 | function imagePlaceholder() { |
| 77 | if (props.label) { |
| 78 | let shortLabel = '' |
| 79 | props.label.split(' ').forEach((item) => { |
| 80 | shortLabel += item.charAt(0).toUpperCase() |
| 81 | }) |
| 82 | |
| 83 | return shortLabel |
| 84 | } |
| 85 | } |
| 86 | </script> |
| 87 | |
| 88 | <script> |
| 89 | export default { |
| 90 | inheritAttrs: false, |
| 91 | } |
| 92 | </script> |
| 93 | |
| 94 | <style lang="scss"> |
| 95 | // am - Amelia |
| 96 | // oitf - option inner template first |
| 97 | .am-oitf { |
| 98 | width: 100%; |
| 99 | display: flex; |
| 100 | align-items: center; |
| 101 | |
| 102 | * { |
| 103 | font-family: var(--am-font-family); |
| 104 | } |
| 105 | |
| 106 | &__wrapper { |
| 107 | display: flex; |
| 108 | } |
| 109 | |
| 110 | &__icon { |
| 111 | font-size: 24px; |
| 112 | color: var(--am-c-select-option-text); |
| 113 | } |
| 114 | |
| 115 | &__img { |
| 116 | display: flex; |
| 117 | flex-shrink: 0; |
| 118 | width: 36px; |
| 119 | height: 36px; |
| 120 | margin-right: 8px; |
| 121 | |
| 122 | &-placeholder { |
| 123 | position: relative; |
| 124 | display: block; |
| 125 | width: 100%; |
| 126 | height: 100%; |
| 127 | background-color: var(--am-c-option-img-bgr); |
| 128 | border-radius: 50%; |
| 129 | background-size: cover; |
| 130 | background-repeat: no-repeat; |
| 131 | background-position: center; |
| 132 | |
| 133 | span { |
| 134 | display: block; |
| 135 | position: absolute; |
| 136 | top: 50%; |
| 137 | left: 50%; |
| 138 | transform: translate(-50%, -50%); |
| 139 | font-size: 15px; |
| 140 | font-weight: 500; |
| 141 | line-height: 1; |
| 142 | color: var(--am-c-option-img-text); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | &__data { |
| 148 | display: flex; |
| 149 | align-items: center; |
| 150 | justify-content: space-between; |
| 151 | width: 100%; |
| 152 | |
| 153 | &-label { |
| 154 | font-size: 15px; |
| 155 | font-weight: 500; |
| 156 | line-height: 1.333333; |
| 157 | color: var(--am-c-select-option-text); |
| 158 | white-space: nowrap; |
| 159 | overflow: hidden; |
| 160 | text-overflow: ellipsis; |
| 161 | } |
| 162 | |
| 163 | &-price { |
| 164 | display: flex; |
| 165 | flex-shrink: 0; |
| 166 | align-self: center; |
| 167 | justify-content: center; |
| 168 | min-width: 70px; |
| 169 | font-size: 16px; |
| 170 | font-weight: 500; |
| 171 | line-height: 1.25; |
| 172 | color: var(--am-c-option-selected); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | </style> |
| 177 |