All wines simplified. Refactor script and template.
This commit is contained in:
		| @@ -1,26 +1,32 @@ | |||||||
| <template> | <template> | ||||||
|   <div class="outer"> |  | ||||||
|   <div class="container"> |   <div class="container"> | ||||||
|       <h1 class="title">Alle viner</h1> |     <h1 class="">Alle viner</h1> | ||||||
|       <div class="wines-container"> |  | ||||||
|         <Wine :wine="wine" v-for="wine in wines" :key="wine" :fullscreen="true" :inlineSlot="true"> |     <div id="wines-container"> | ||||||
|  |       <Wine :wine="wine" v-for="(wine, _, index) in wines" :key="wine._id"> | ||||||
|         <div class="winners-container"> |         <div class="winners-container"> | ||||||
|             <div class="color-wins" :class="{ 'big': fullscreen }" |  | ||||||
|               v-if="wine.blue || wine.red || wine.green || wine.yellow"> |  | ||||||
|           <span class="label">Vinnende lodd:</span> |           <span class="label">Vinnende lodd:</span> | ||||||
|               <span class="color-win blue">{{wine.blue == undefined ? 0 : wine.blue}}</span> |           <div class="flex row"> | ||||||
|               <span class="color-win red">{{wine.red == undefined ? 0 : wine.red}}</span> |             <span class="raffle-element blue-raffle">{{ wine.blue == null ? 0 : wine.blue }}</span> | ||||||
|               <span class="color-win green">{{wine.green == undefined ? 0 : wine.green}}</span> |             <span class="raffle-element red-raffle">{{ wine.red == null ? 0 : wine.red }}</span> | ||||||
|               <span class="color-win yellow">{{wine.yellow == undefined ? 0 : wine.yellow}}</span> |             <span class="raffle-element green-raffle">{{ wine.green == null ? 0 : wine.green }}</span> | ||||||
|  |             <span class="raffle-element yellow-raffle">{{ wine.yellow == null ? 0 : wine.yellow }}</span> | ||||||
|           </div> |           </div> | ||||||
|             <div class="name-wins" v-if="wine.winners"> |  | ||||||
|  |           <div class="name-wins"> | ||||||
|             <span class="label">Vunnet av:</span> |             <span class="label">Vunnet av:</span> | ||||||
|               <span class="names" v-for="winner in wine.winners">- {{ winner }}</span> |             <ul class="names"> | ||||||
|               </span> |               <li v-for="(winner, index) in wine.winners"> | ||||||
|  |                 <router-link class="vin-link" :to="`/highscore/` + winner">{{ winner }}</router-link> | ||||||
|  |                  -  | ||||||
|  |                 <router-link class="vin-link" :to="winDateUrl(wine.dates[index])">{{ dateString(wine.dates[index]) }}</router-link> | ||||||
|  |               </li> | ||||||
|  |             </ul> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|       </Wine> |       </Wine> | ||||||
|       </div> |  | ||||||
|     </div> |     </div> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| @@ -30,6 +36,7 @@ import { page, event } from "vue-analytics"; | |||||||
| import Banner from "@/ui/Banner"; | import Banner from "@/ui/Banner"; | ||||||
| import Wine from "@/ui/Wine"; | import Wine from "@/ui/Wine"; | ||||||
| import { overallWineStatistics } from "@/api"; | import { overallWineStatistics } from "@/api"; | ||||||
|  | import { dateString } from "@/utils"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   components: { |   components: { | ||||||
| @@ -41,133 +48,97 @@ export default { | |||||||
|       wines: [] |       wines: [] | ||||||
|     }; |     }; | ||||||
|   }, |   }, | ||||||
|  |   methods: { | ||||||
|  |     winDateUrl(date) { | ||||||
|  |       const timestamp = new Date(date).getTime(); | ||||||
|  |       return `/history/${timestamp}` | ||||||
|  |     }, | ||||||
|  |     dateString: dateString | ||||||
|  |   }, | ||||||
|   async mounted() { |   async mounted() { | ||||||
|     const wines = await overallWineStatistics(); |     this.wines = await overallWineStatistics(); | ||||||
|     this.wines = wines.sort((a, b) => |  | ||||||
|       a.rating > b.rating ? -1 : 1 |  | ||||||
|     ); |  | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
| @import "./src/styles/media-queries"; | @import "./src/styles/media-queries"; | ||||||
|  | @import "./src/styles/variables"; | ||||||
|  |  | ||||||
|  | .container { | ||||||
|  |   width: 90vw; | ||||||
|  |   margin: 3rem auto; | ||||||
|  |   margin-bottom: 0; | ||||||
|  |   padding-bottom: 4rem; | ||||||
|  | } | ||||||
|  |  | ||||||
| h1 { | h1 { | ||||||
|  |   font-size: 3rem; | ||||||
|  |   font-family: "knowit"; | ||||||
|  |   font-weight: normal; | ||||||
|  |  | ||||||
|   font-family: knowit, Arial; |   font-family: knowit, Arial; | ||||||
|   margin-bottom: 25px; |   margin-bottom: 25px; | ||||||
| } | } | ||||||
|  |  | ||||||
| .wines-container { | .label { | ||||||
|  |   font-weight: 600; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #wines-container { | ||||||
|   display: flex; |   display: flex; | ||||||
|   flex-wrap: wrap; |   flex-wrap: wrap; | ||||||
|   justify-content: space-evenly; |   justify-content: space-evenly; | ||||||
|   align-items: center; |   align-items: flex-start; | ||||||
|   width: 100%; |  | ||||||
|   margin: 0 auto; |  | ||||||
|  |  | ||||||
|   @include desktop { |   @include desktop { | ||||||
|     margin: 0 2rem; |     margin: 0 2rem; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   > div { |   > div { | ||||||
|       max-width: max-content; |     justify-content: flex-start; | ||||||
|     } |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| .winners-container { | .winners-container { | ||||||
|   display: flex; |   display: flex; | ||||||
|   flex-direction: row; |   flex-direction: column; | ||||||
|   margin-top: 2rem; |   margin-top: 1rem; | ||||||
|  |  | ||||||
|   @include mobile { |   > div:not(:last-of-type) { | ||||||
|     flex-direction: row; |     margin-bottom: 1rem; | ||||||
|     width: max-content; |  | ||||||
|     margin: 0.75rem; |  | ||||||
|  |  | ||||||
|     &:not(&:first-child) { |  | ||||||
|       margin-top: 0.5rem; |  | ||||||
|   } |   } | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .label { |  | ||||||
|   margin-bottom: 0.25rem; |  | ||||||
|   font-weight: 600; |  | ||||||
|   width: 100%; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| .name-wins { | .name-wins { | ||||||
|   display: flex; |   display: flex; | ||||||
|   flex-direction: column; |   flex-direction: column; | ||||||
|   width: max-content; |  | ||||||
|  |  | ||||||
|   .names { |   a { | ||||||
|     margin-left: 0.5rem; |     font-weight: normal; | ||||||
|  |     &:not(:hover) { | ||||||
|  |       border-color: transparent; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ul { | ||||||
|  |     padding-left: 0; | ||||||
|  |  | ||||||
|  |     li { | ||||||
|  |       padding-left: 1.5rem; | ||||||
|  |       list-style: none; | ||||||
|  |  | ||||||
|  |       &:before { | ||||||
|  |         content: "- "; | ||||||
|  |         margin-left: -0.5rem; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| .color-wins { | .raffle-element { | ||||||
|   display: flex; |   padding: 1rem; | ||||||
|   flex-direction: row; |  | ||||||
|   flex-wrap: wrap; |  | ||||||
|   align-items: flex-end; |  | ||||||
|  |  | ||||||
|   margin-left: -3px;   // offset span.color-win margin |  | ||||||
|  |  | ||||||
|   @include mobile { |  | ||||||
|     width: 25vw; |  | ||||||
|     margin-left: -2px; // offset span.color-win margin |  | ||||||
|   } |  | ||||||
|   @include desktop { |  | ||||||
|     width: 30%; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .color-wins.big { |  | ||||||
|   width: unset; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| span.color-win { |  | ||||||
|   border: 2px solid transparent; |  | ||||||
|   color: #333; |  | ||||||
|   display: block; |  | ||||||
|   padding: 25px; |  | ||||||
|   font-size: 1.3rem; |   font-size: 1.3rem; | ||||||
|   display: inline-flex; |  | ||||||
|   flex-wrap: wrap; |  | ||||||
|   flex-direction: row; |  | ||||||
|   /* max-height: calc(3rem + 18px); */ |  | ||||||
|   /* max-width: calc(3rem + 18px); */ |  | ||||||
|   width: 1rem; |  | ||||||
|   margin: 3px; |   margin: 3px; | ||||||
|   touch-action: manipulation; |  | ||||||
|   height: 1rem; |  | ||||||
|   display: flex; |  | ||||||
|   justify-content: center; |  | ||||||
|   align-items: center; |  | ||||||
|   font-weight: 900; |  | ||||||
|  |  | ||||||
|   @include mobile { |  | ||||||
|     margin: 2px; |  | ||||||
|     padding: 10px; |  | ||||||
|     font-size: 1rem; |  | ||||||
|     flex-direction: row; |  | ||||||
|     flex-wrap: wrap; |  | ||||||
|     grow: 0.5; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   &.green { |  | ||||||
|     background: #c8f9df; |  | ||||||
|   } |  | ||||||
|   &.blue { |  | ||||||
|     background: #d4f2fe; |  | ||||||
|   } |  | ||||||
|   &.red { |  | ||||||
|     background: #fbd7de; |  | ||||||
|   } |  | ||||||
|   &.yellow { |  | ||||||
|     background: #fff6d6; |  | ||||||
|   } |  | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user