Use new Wine slots, remove all duplicate code.
This commit is contained in:
		| @@ -1,33 +1,41 @@ | |||||||
| <template> | <template> | ||||||
|   <div class="requested-wine"> |   <Wine :wine="wine"> | ||||||
|     <img |     <template v-slot:top> | ||||||
|       v-if="wine.image" |       <div class="flex justify-end"> | ||||||
|       :src="wine.image" |         <div class="requested-count cursor-pointer" @click="request"> | ||||||
|       class="wine-image" |           <span>{{ requestedElement.count }}</span> | ||||||
|       :class="{ 'fullscreen': fullscreen }" |           <i class="icon icon--heart">{{ locallyRequested ? "💜" : "🤍" }}</i> | ||||||
|     /> |         </div> | ||||||
|     <img v-else class="wine-placeholder" alt="Wine image" /> |       </div> | ||||||
|     <h3 v-if="wine.name">{{ wine.name }}</h3> |     </template> | ||||||
|     <h3 v-else>(no name)</h3> |  | ||||||
|     <p class="requested-amount">Foreslått: <strong>{{requestedElement.count}}</strong></p> |  | ||||||
|  |  | ||||||
|     <button class="vin-button" @click="request(wine)" v-if="!locallyRequested">Foreslå denne</button> |     <template v-slot:default> | ||||||
|     <a |       <button @click="deleteWine(wine)" v-if="showDeleteButton == true" class="vin-button small danger"> | ||||||
|     v-if="wine.vivinoLink" |  | ||||||
|     :href="wine.vivinoLink" |  | ||||||
|     class="wine-link"> |  | ||||||
|       Les mer |  | ||||||
|     </a> |  | ||||||
|     <button @click="deleteWine(wine)" v-if="showDeleteButton == true" class="vin-button danger"> |  | ||||||
|         Slett vinen |         Slett vinen | ||||||
|       </button> |       </button> | ||||||
|     </div> |     </template> | ||||||
|  |  | ||||||
|  |     <template v-slot:bottom> | ||||||
|  |       <a aria-role="button" tabindex="0" class="link float-left" @click="request" | ||||||
|  |          :class="{ 'active': locallyRequested }"> | ||||||
|  |         Anbefal | ||||||
|  |       </a> | ||||||
|  |  | ||||||
|  |       <a aria-role="button" tabindex="0" class="link float-left" @click="request" | ||||||
|  |          :class="{ 'active': locallyRequested }"> | ||||||
|  |       </a> | ||||||
|  |     </template> | ||||||
|  |   </Wine> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import { deleteRequestedWine, requestNewWine } from "@/api"; | import { deleteRequestedWine, requestNewWine } from "@/api"; | ||||||
|  | import Wine from "@/ui/Wine"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|  |   components: { | ||||||
|  |     Wine | ||||||
|  |   }, | ||||||
|   data(){ |   data(){ | ||||||
|     return { |     return { | ||||||
|       wine: this.requestedElement.wine, |       wine: this.requestedElement.wine, | ||||||
| @@ -66,61 +74,23 @@ export default { | |||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
| @import "../styles/global.scss"; | .requested-count { | ||||||
|  |   display: inline-block; | ||||||
|  |   margin-top: -0.5rem; | ||||||
|  |   background-color: rgb(244,244,244); | ||||||
|  |   border-radius: 1.1rem; | ||||||
|  |   font-size: 1.1rem; | ||||||
|  |   padding-left: 1rem; | ||||||
|  |   padding-right: 1rem; | ||||||
|    |    | ||||||
| .requested-wine{ |   span { | ||||||
|   -webkit-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65); |     padding: 0.6rem 0; | ||||||
|   -moz-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65); |     padding-right: 0.25rem; | ||||||
|   box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65); |     display: inline-block; | ||||||
|   text-align: center; |  | ||||||
|   display: grid; |  | ||||||
|   grid-template-areas: "top top" |  | ||||||
|                        "middle-left middle-right-top" |  | ||||||
|                        "middle-left middle-right-bot" |  | ||||||
|                        "bottom-top bottom-top" |  | ||||||
|                        "bottom-bot bottom-bot"; |  | ||||||
|   grid-gap: 1em; |  | ||||||
|   justify-items: center; |  | ||||||
|   align-items: center; |  | ||||||
|   width: 100%; |  | ||||||
|    |  | ||||||
|   h3{ |  | ||||||
|     grid-area: top; |  | ||||||
|     word-break: keep-all; |  | ||||||
|     width: 90%; |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   img{ |   .icon { | ||||||
|     height: 13em; |     font-style: unset; | ||||||
|     grid-area: middle-left; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   .requested-amount{ |  | ||||||
|     grid-area: middle-right-top; |  | ||||||
|     width: 90%; |  | ||||||
|     word-break: keep-all; |  | ||||||
|   } |  | ||||||
|    |  | ||||||
|   .wine-link{ |  | ||||||
|     grid-area: middle-right-bot; |  | ||||||
|     color: #333333; |  | ||||||
|     font-family: Arial; |  | ||||||
|     text-decoration: none; |  | ||||||
|     font-weight: bold; |  | ||||||
|     border-bottom: 1px solid $link-color; |  | ||||||
|     height: 1em; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   .vin-button{ |  | ||||||
|     grid-area: bottom-top; |  | ||||||
|     margin-bottom: 1em; |  | ||||||
|  |  | ||||||
|     &.danger{ |  | ||||||
|       grid-area: bottom-bot; |  | ||||||
|       background-color: $light-red; |  | ||||||
|       color: $red; |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| </style> | </style> | ||||||
		Reference in New Issue
	
	Block a user