|
| 1 | +<script setup> |
| 2 | +/** Services */ |
| 3 | +import { getAdvByName, getRandomAdv } from "@/services/constants/advertising" |
| 4 | +
|
| 5 | +/** Store */ |
| 6 | +import { useModalsStore } from "~/store/modals" |
| 7 | +const modalsStore = useModalsStore() |
| 8 | +
|
| 9 | +const props = defineProps({ |
| 10 | + advName: { |
| 11 | + type: String, |
| 12 | + required: false, |
| 13 | + }, |
| 14 | + orientation: { |
| 15 | + type: String, |
| 16 | + default: 'vertical', |
| 17 | + }, |
| 18 | +}) |
| 19 | +
|
| 20 | +const adv = ref({}) |
| 21 | +const isDisplayed = ref(true) |
| 22 | +
|
| 23 | +const handleClick = () => { |
| 24 | + if (adv.value.link) { |
| 25 | + window.open(adv.value.link, '_blank') |
| 26 | + } else if (adv.value.modal) { |
| 27 | + modalsStore.open(adv.value.modal) |
| 28 | + } |
| 29 | +} |
| 30 | +
|
| 31 | +onMounted(() => { |
| 32 | + if (props.advName) { |
| 33 | + adv.value = getAdvByName(props.advName) |
| 34 | + } else { |
| 35 | + adv.value = getRandomAdv() |
| 36 | + } |
| 37 | +}) |
| 38 | +</script> |
| 39 | + |
| 40 | +<template> |
| 41 | + <Flex v-if="adv.name" @click="handleClick()" :class="[$style.wrapper, orientation === 'horizontal' && $style.wrapper_horizontal, !isDisplayed && $style.not_display]"> |
| 42 | + <Flex v-if="orientation === 'vertical'" direction="column" gap="12" :class="$style.ad_vertical"> |
| 43 | + <Flex direction="column" gap="8"> |
| 44 | + <Flex align="center" gap="6"> |
| 45 | + <Icon v-if="adv.icon" :name="adv.icon" size="14" color="brand" /> |
| 46 | + <Text size="13" weight="600" color="primary"> {{ adv.header }} </Text> |
| 47 | + </Flex> |
| 48 | + |
| 49 | + <Text size="13" weight="600" color="tertiary" height="140"> {{ adv.body }} </Text> |
| 50 | + </Flex> |
| 51 | + |
| 52 | + <Flex align="center" justify="between"> |
| 53 | + <Text size="13" weight="600" color="brand" :class="$style.footer"> {{ adv.footer }} </Text> |
| 54 | + |
| 55 | + <Icon @click.prevent.stop="isDisplayed = false" name="close" size="16" color="secondary" :class="$style.close_icon" /> |
| 56 | + </Flex> |
| 57 | + </Flex> |
| 58 | + <Flex |
| 59 | + v-else-if="orientation === 'horizontal'" |
| 60 | + align="center" |
| 61 | + justify="between" |
| 62 | + gap="12" |
| 63 | + wide |
| 64 | + :class="$style.ad_horizontal" |
| 65 | + > |
| 66 | + <Flex align="center" gap="12"> |
| 67 | + <Flex align="center" gap="6"> |
| 68 | + <Icon v-if="adv.icon" :name="adv.icon" size="14" color="brand" /> |
| 69 | + <Text size="13" weight="600" color="primary"> {{ adv.header }} </Text> |
| 70 | + </Flex> |
| 71 | + |
| 72 | + <Text size="13" weight="600" color="tertiary" height="140"> {{ adv.body }} </Text> |
| 73 | + </Flex> |
| 74 | + |
| 75 | + <Flex align="center" gap="8"> |
| 76 | + <Text size="13" weight="600" color="brand"> {{ adv.footer }} </Text> |
| 77 | + |
| 78 | + <Icon @click.prevent.stop="isDisplayed = false" name="close" size="16" color="secondary" :class="$style.close_icon" /> |
| 79 | + </Flex> |
| 80 | + </Flex> |
| 81 | + </Flex> |
| 82 | +</template> |
| 83 | + |
| 84 | +<style module> |
| 85 | +.wrapper { |
| 86 | + width: 100%; |
| 87 | + |
| 88 | + cursor: pointer; |
| 89 | +} |
| 90 | +
|
| 91 | +.wrapper_horizontal { |
| 92 | + width: 100%; |
| 93 | + padding: 8px 24px 0px 24px; |
| 94 | +} |
| 95 | +
|
| 96 | +.not_display { |
| 97 | + display: none; |
| 98 | +} |
| 99 | +
|
| 100 | +.ad_vertical { |
| 101 | + position: relative; |
| 102 | +
|
| 103 | + border-radius: 12px; |
| 104 | + box-shadow: inset 0 0 0 2px var(--op-10); |
| 105 | +
|
| 106 | + padding: 16px; |
| 107 | +
|
| 108 | + transition: all 0.2s ease; |
| 109 | +
|
| 110 | + &:hover { |
| 111 | + background: var(--op-3); |
| 112 | +
|
| 113 | + .close_icon { |
| 114 | + display: block; |
| 115 | + } |
| 116 | + } |
| 117 | +
|
| 118 | + & .footer { |
| 119 | + padding: 2px; |
| 120 | + } |
| 121 | + & .close_icon { |
| 122 | + display: none; |
| 123 | + padding: 2px; |
| 124 | +
|
| 125 | + border-radius: 12px; |
| 126 | +
|
| 127 | + transition: all 0.2s ease; |
| 128 | +
|
| 129 | + &:hover { |
| 130 | + background: var(--op-10); |
| 131 | + transform: scale(1.1); |
| 132 | + } |
| 133 | + } |
| 134 | +} |
| 135 | +
|
| 136 | +.ad_horizontal { |
| 137 | + position: relative; |
| 138 | + width: 100%; |
| 139 | +
|
| 140 | + border-radius: 12px; |
| 141 | + box-shadow: inset 0 0 0 2px var(--op-10); |
| 142 | +
|
| 143 | + padding: 8px 16px; |
| 144 | +
|
| 145 | + transition: all 0.2s ease; |
| 146 | +
|
| 147 | + &:hover { |
| 148 | + background: var(--op-3); |
| 149 | +
|
| 150 | + .close_icon { |
| 151 | + display: block; |
| 152 | + } |
| 153 | + } |
| 154 | +
|
| 155 | + & .close_icon { |
| 156 | + display: none; |
| 157 | + padding: 2px; |
| 158 | +
|
| 159 | + border-radius: 12px; |
| 160 | +
|
| 161 | + transition: all 0.2s ease; |
| 162 | +
|
| 163 | + &:hover { |
| 164 | + background: var(--op-10); |
| 165 | + transform: scale(1.1); |
| 166 | + } |
| 167 | + } |
| 168 | +} |
| 169 | +
|
| 170 | +@media (max-width: 500px) { |
| 171 | + .wrapper_horizontal { |
| 172 | + padding: 12px; |
| 173 | + } |
| 174 | +} |
| 175 | +</style> |
0 commit comments