Pulled feature branch up-stream.

This commit is contained in:
2020-09-08 09:19:56 +02:00
20 changed files with 909 additions and 63 deletions

View File

@@ -1,18 +1,36 @@
<template>
<router-link to="/" class="link">
<div class="top-banner">
<img src="/public/assets/images/knowit.svg" alt="knowit logo" />
<div class="clock">
<h2 v-if="!fiveMinutesLeft || !tenMinutesOver">
<span v-if="days > 0">{{ pad(days) }}:</span>
<span>{{ pad(hours) }}</span>:
<span>{{ pad(minutes) }}</span>:
<span>{{ pad(seconds) }}</span>
</h2>
<h2 v-if="twoMinutesLeft || tenMinutesOver">Lotteriet er i gang!</h2>
</div>
<div class="top-banner">
<!-- Mobile -->
<div id="menuToggle" >
<input type="checkbox" />
<span></span>
<span></span>
<span></span>
<ul id="menu">
<router-link v-for="(route, index) in routes" :key="index" :to="route.route">
<li>{{route.name}}</li>
</router-link>
</ul>
</div>
</router-link>
<router-link to="/">
<img src="/public/assets/images/knowit.svg" alt="knowit logo" />
</router-link>
<div v-for="(route, index) in routes" :key="index" class="desktop">
<router-link :to="route.route" class="routes">
{{route.name}}
</router-link>
</div>
<div class="clock">
<h2 v-if="!fiveMinutesLeft || !tenMinutesOver">
<span v-if="days > 0">{{ pad(days) }}:</span>
<span>{{ pad(hours) }}</span>:
<span>{{ pad(minutes) }}</span>:
<span>{{ pad(seconds) }}</span>
</h2>
<h2 v-if="twoMinutesLeft || tenMinutesOver">Lotteriet er i gang!</h2>
</div>
</div>
</template>
<script>
@@ -25,12 +43,15 @@ export default {
minutes: 0,
seconds: 0,
distance: 0,
enabled: false,
code: "38384040373937396665",
codeDone: "",
interval: null
interval: null,
};
},
props: {
routes: {
required: true,
type: Array
}
},
mounted() {
this.initialize(), this.countdown();
},
@@ -55,19 +76,6 @@ export default {
}
return num;
},
listenerFunction: function(event) {
this.codeDone += event.keyCode;
if (this.code.substring(0, this.codeDone.length) == this.codeDone) {
if (this.code == this.codeDone && !this.enabled) {
this.enabled = true;
this.initialize();
this.countdown();
this.codeDone = "";
}
} else {
this.codeDone = "";
}
},
initialize: function() {
let d = new Date();
let dayOfLottery = __DATE__;
@@ -115,7 +123,7 @@ export default {
this.initialize();
}
this.interval = setTimeout(this.countdown, 500);
}
},
}
};
</script>
@@ -123,41 +131,56 @@ export default {
<style lang="scss" scoped>
@import "../styles/media-queries.scss";
@import "../styles/variables.scss";
@import "../styles/banner.scss";
.link {
text-decoration: none;
@include mobile {
.desktop {
display: none;
}
}
@include desktop {
.top-banner{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: calc(100% - 20px);
.routes {
text-decoration: none;
color: #333333;
}
}
}
.top-banner {
text-align: center;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
width: calc(100% - 80px);
margin-top: 0px;
padding: 0px 40px;
width: calc(100% - 20px);
padding: 5px 10px;
background-color: $primary;
-webkit-box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
-moz-box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
box-shadow: 0px 0px 22px -8px rgba(0, 0, 0, 0.65);
@include mobile {
padding: 0px 40px;
> img {
height: 23px;
.clock {
text-decoration: none;
color: #333333;
display: flex;
font-family: Arial;
margin-right: 2rem;
@include mobile {
font-size: 0.8em;
margin-right: 1rem;
}
h2 {
display: flex;
}
}
}
.clock {
text-decoration: none;
color: #333333;
display: flex;
font-family: Arial;
h2 {
display: flex;
}
}
</style>

101
src/ui/Modal.vue Normal file
View File

@@ -0,0 +1,101 @@
<template>
<transition name="modal-fade">
<main class="modal-backdrop">
<section class="modal">
<header class="modal-header" v-if="headerText">
{{headerText}}
</header>
<section class="modal-body">
<p>
{{modalText}}
</p>
<section class="button-container">
<button v-for="(button, index) in buttons" :key="index" @click="modalButtonClicked(button.action)" class="vin-button">
{{button.text}}
</button>
</section>
</section>
</section>
</main>
</transition>
</template>
<script>
export default {
props: {
headerText: {
type: String,
required: false
},
modalText: {
type: String,
required: true
},
buttons: {
type: Array,
required: true
},
},
methods:{
modalButtonClicked(action){
this.$emit('click', action)
}
}
}
</script>
<style lang="scss" scoped>
@import "../styles/global.scss";
.modal-fade-enter,
.modal-fade-leave-active {
opacity: 0;
}
.modal-fade-enter-active,
.modal-fade-leave-active {
transition: opacity .5s ease
}
.modal-backdrop {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
width: 100vw;
height: 100vh;
}
.modal {
background: #FFFFFF;
-webkit-box-shadow: 0px 0px 22px 1px rgba(0, 0, 0, 0.65);
-moz-box-shadow: 0px 0px 22px 1px rgba(0, 0, 0, 0.65);
box-shadow: 0px 0px 22px 1px rgba(0, 0, 0, 0.65);
overflow-x: auto;
display: flex;
flex-direction: column;
}
.modal-header {
padding: 15px;
display: flex;
}
.modal-header {
border-bottom: 1px solid #eeeeee;
color: #4AAE9B;
justify-content: space-between;
}
.modal-body {
position: relative;
padding: 20px 10px;
}
</style>

View File

@@ -0,0 +1,80 @@
<template>
<div class="requested-wine">
<img
v-if="wine.image"
:src="wine.image"
class="wine-image"
:class="{ 'fullscreen': fullscreen }"
/>
<img v-else class="wine-placeholder" alt="Wine image" />
<section class="wine-info">
<h3 v-if="wine.name">{{ wine.name }}</h3>
<h3 v-else>(no name)</h3>
<p>Antall ganger denne har blitt foreslått: {{requestedElement.count}}</p>
<section class="buttons">
<button class="vin-button" @click="request(wine)" v-if="!locallyRequested">Foreslå denne</button>
<a
v-if="wine.vivinoLink"
:href="wine.vivinoLink"
class="wine-link"
>Les mer polet</a>
</section>
<button @click="deleteWine(wine)" v-if="showDeleteButton == true">
Slett vinen
</button>
</section>
</div>
</template>
<script>
import { deleteRequestedWine, requestNewWine } from "@/api";
export default {
data(){
return {
wine: this.requestedElement.wine,
locallyRequested: false
}
},
props: {
requestedElement: {
required: true,
type: Object
},
showDeleteButton: {
required: false,
type: Boolean,
default: false
}
},
methods: {
request(wine){
this.locallyRequested = true
this.requestedElement.count = this.requestedElement.count +1
requestNewWine(wine)
},
async deleteWine(wine) {
if (window.confirm("Er du sikker på at du vil slette vinen?")) {
let response = await deleteRequestedWine(wine);
if (response['success'] == true) {
this.$emit('wineDeleted', wine);
} else {
alert("Klarte ikke slette vinen");
}
}
},
},
}
</script>
<style lang="scss" scoped>
.requested-wine{
padding: 20px;
border-radius: 1px;
margin: 1rem 0;
-webkit-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65);
-moz-box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65);
box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.65);
}
</style>