This commit is contained in:
Kasper Rynning-Tønnesen
2020-02-12 14:04:14 +01:00
parent 9e6d352934
commit 7677eea9cb
5 changed files with 192 additions and 153 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -4,27 +4,7 @@
<h1 class="title">Alle viner</h1>
<div class="wines-container">
<a :href="wine.vivinoLink" v-for="wine in wines">
<div class="inner-wine-container">
<div class="left">
<img :src="wine.image" class="wine-image" />
</div>
<div class="right">
<h2>{{ wine.name }}</h2>
<span v-if="wine.rating">{{ wine.rating }} rating</span>
<a :herf="wine.vivinoLink" class="wine-link">Les mer</a>
<span class="name-wins">
Vunnet av:
{{wine.winners.join(", ")}}
</span>
<div class="color-wins">
<span class="color-win blue">{{wine.blue == undefined ? 0 : wine.blue}}</span>
<span class="color-win red">{{wine.red == undefined ? 0 : wine.red}}</span>
<span class="color-win green">{{wine.green == undefined ? 0 : wine.green}}</span>
<span class="color-win yellow">{{wine.yellow == undefined ? 0 : wine.yellow}}</span>
</div>
</div>
</div>
<Wine :wine="wine" />
</a>
</div>
</div>
@@ -34,10 +14,12 @@
<script>
import { page, event } from "vue-analytics";
import Banner from "@/ui/Banner";
import Wine from "@/ui/Wine";
export default {
components: {
Banner
Banner,
Wine
},
data() {
return {
@@ -56,10 +38,6 @@ export default {
<style lang="scss" scoped>
@import "./src/styles/media-queries";
.wine-image {
height: 250px;
}
h1 {
font-family: knowit, Arial;
margin-bottom: 25px;
@@ -80,106 +58,4 @@ h1 {
flex-direction: column;
}
}
.name-wins,
.color-wins {
display: flex;
width: 60%;
flex-wrap: wrap;
}
span.color-win {
border: 2px solid transparent;
color: #333;
display: block;
padding: 30px;
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: 10px;
touch-action: manipulation;
height: 1rem;
display: flex;
justify-content: center;
align-items: center;
@include mobile {
margin: 2px;
padding: 10px;
font-size: 1rem;
}
&.green {
background: #c8f9df;
}
&.blue {
background: #d4f2fe;
}
&.red {
background: #fbd7de;
}
&.yellow {
background: #fff6d6;
}
}
h3 {
max-width: 30vw;
@include mobile {
max-width: 50vw;
}
}
.inner-wine-container {
display: flex;
flex-direction: row;
margin: auto;
width: 500px;
font-family: Arial;
margin-bottom: 30px;
@include desktop {
justify-content: center;
}
@include mobile {
width: auto;
}
}
.right {
display: flex;
flex-direction: column;
margin-bottom: 150px;
margin-left: 50px;
@include mobile {
margin-left: 2rem;
margin-bottom: 50px;
}
}
a,
a:focus,
a:hover,
a:visited {
color: #333333;
font-family: Arial;
text-decoration: none;
font-weight: bold;
}
.wine-link {
color: #333333;
font-family: Arial;
text-decoration: none;
font-weight: bold;
border-bottom: 1px solid #ff5fff;
width: fit-content;
}
</style>

142
src/ui/Wine.vue Normal file
View File

@@ -0,0 +1,142 @@
<template>
<div class="inner-wine-container">
<div class="left">
<img :src="wine.image" class="wine-image" />
</div>
<div class="right">
<h2>{{ wine.name }}</h2>
<span v-if="wine.rating">{{ wine.rating }} rating</span>
<a :herf="wine.vivinoLink" class="wine-link">Les mer</a>
<span class="name-wins">
Vunnet av:
{{wine.winners.join(", ")}}
</span>
<div class="color-wins">
<span class="color-win blue">{{wine.blue == undefined ? 0 : wine.blue}}</span>
<span class="color-win red">{{wine.red == undefined ? 0 : wine.red}}</span>
<span class="color-win green">{{wine.green == undefined ? 0 : wine.green}}</span>
<span class="color-win yellow">{{wine.yellow == undefined ? 0 : wine.yellow}}</span>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
wine: {
type: Object,
required: true
}
}
};
</script>
<style lang="scss" scoped>
@import "./src/styles/media-queries";
.wine-image {
height: 250px;
}
.name-wins,
.color-wins {
display: flex;
width: 60%;
flex-wrap: wrap;
}
span.color-win {
border: 2px solid transparent;
color: #333;
display: block;
padding: 30px;
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: 10px;
touch-action: manipulation;
height: 1rem;
display: flex;
justify-content: center;
align-items: center;
@include mobile {
margin: 2px;
padding: 10px;
font-size: 1rem;
}
&.green {
background: #c8f9df;
}
&.blue {
background: #d4f2fe;
}
&.red {
background: #fbd7de;
}
&.yellow {
background: #fff6d6;
}
}
h3 {
max-width: 30vw;
@include mobile {
max-width: 50vw;
}
}
.inner-wine-container {
display: flex;
flex-direction: row;
width: 500px;
font-family: Arial;
margin-bottom: 30px;
@include desktop {
justify-content: center;
}
@include mobile {
width: auto;
}
}
.right {
display: flex;
flex-direction: column;
margin-bottom: 150px;
margin-left: 50px;
@include mobile {
margin-left: 2rem;
margin-bottom: 50px;
}
}
a,
a:focus,
a:hover,
a:visited {
color: #333333;
font-family: Arial;
text-decoration: none;
font-weight: bold;
}
.wine-link {
color: #333333;
font-family: Arial;
text-decoration: none;
font-weight: bold;
border-bottom: 1px solid #ff5fff;
width: fit-content;
}
</style>

View File

@@ -16,22 +16,30 @@
<a
class="wine-link"
:href="wine.vivinoLink"
v-if="wine.vivinoLink != '' && wine.vivinoLink != null"
@click="wineClick(wine)"
@click="wineClick(wine, $event)"
>Les mer</a>
</li>
</ol>
<div class="wine-window" v-if="wineOpen">
<div class="close-modal" @click="closeWine">X</div>
<Wine :wine="clickedWine" />
</div>
</div>
</template>
<script>
import { event } from "vue-analytics";
import Wine from "@/ui/Wine";
export default {
components: {
Wine
},
data() {
return { wines: [] };
return { wines: [], clickedWine: null, wineOpen: false };
},
async mounted() {
let _response = await fetch("/api/wines/statistics");
let _response = await fetch("/api/wines/statistics/overall");
let response = await _response.json();
response.sort();
@@ -52,7 +60,11 @@ export default {
this.wines = response.slice(0, 5);
},
methods: {
wineClick: function(wine) {
wineClick: function(wine, event) {
event.preventDefault();
this.clickedWine = wine;
this.wineOpen = true;
if (window.location.hostname == "localhost") {
return;
}
@@ -62,6 +74,10 @@ export default {
eventValue: `${wine.name} - ${wine.vivinoLink}`
});
},
closeWine: function() {
this.clickedWine = null;
this.wineOpen = false;
},
predicate: function() {
var fields = [],
@@ -129,6 +145,30 @@ export default {
<style lang="scss" scoped>
@import "../styles/media-queries.scss";
.wine-window {
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
position: fixed;
width: 95vw;
height: 95vh;
background: white;
border: 1px solid #3333333a;
display: flex;
justify-content: center;
align-items: center;
}
.close-modal {
position: absolute;
top: 10px;
right: 20px;
font-size: 2rem;
cursor: pointer;
}
h3 {
text-align: left;
@@ -185,6 +225,7 @@ ol {
color: #333333;
text-decoration: none;
font-weight: bold;
cursor: pointer;
border-bottom: 1px solid #ff5fff;
}
@@ -194,25 +235,5 @@ ol {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
&:hover {
line-break: unset;
word-break: break-word;
white-space: normal;
overflow: auto;
text-overflow: unset;
}
@include mobile {
max-width: calc(75vw - 177px);
&:focus {
line-break: unset;
word-break: break-word;
white-space: normal;
overflow: auto;
text-overflow: unset;
}
}
}
</style>